harperdb 4.7.27 → 4.7.28
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.
- package/README.md +1 -1
- package/bin/harperdb.js +1 -1
- package/bin/lite.js +1 -1
- package/launchServiceScripts/launchNatsIngestService.js +1 -1
- package/launchServiceScripts/launchNatsReplyService.js +1 -1
- package/launchServiceScripts/launchUpdateNodes4-0-0.js +1 -1
- package/npm-shrinkwrap.json +246 -246
- package/package.json +2 -2
- package/server/jobs/jobProcess.js +1 -1
- package/server/threads/threadServer.js +1 -1
- package/studio/web/assets/{index-BKH0o6vZ.js → index-BLrHW_4X.js} +5 -5
- package/studio/web/assets/{index-BKH0o6vZ.js.map → index-BLrHW_4X.js.map} +1 -1
- package/studio/web/assets/{index.lazy-D5vviOl1.js → index.lazy-B3bMWbNh.js} +2 -2
- package/studio/web/assets/{index.lazy-D5vviOl1.js.map → index.lazy-B3bMWbNh.js.map} +1 -1
- package/studio/web/assets/{profile-V6JtmyCF.js → profile-BLeDamUk.js} +2 -2
- package/studio/web/assets/{profile-V6JtmyCF.js.map → profile-BLeDamUk.js.map} +1 -1
- package/studio/web/assets/{status-9_1gEAyL.js → status-CdZyfe1S.js} +2 -2
- package/studio/web/assets/{status-9_1gEAyL.js.map → status-CdZyfe1S.js.map} +1 -1
- package/studio/web/index.html +1 -1
- package/utility/scripts/restartHdb.js +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index.lazy-
|
|
2
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.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}from"./cn-CCIpMBd-.js";import{$t as y,Qt as b,Zt as x,an as S,cn as ee,en as te,gn as C,hn as ne,in as re,ln as w,nn as ie,on as ae,rn as oe,sn as T,tn as E,un as se}from"./vendor-core-eR3ZofrV.js";import{$i as D,$n as ce,$r as le,$t as ue,Ai as de,An as O,Ar as fe,At as pe,Bi as me,Bn as he,Br as ge,Bt as _e,Ci as ve,Cn as ye,Cr as be,Ct as xe,Di as Se,Dn as Ce,Dr as we,Dt as Te,Ei as Ee,En as De,Er as Oe,Et as ke,Fi as Ae,Fn as k,Fr as je,Ft as Me,Gi as Ne,Gn as Pe,Gr as Fe,Gt as Ie,Hi as A,Hn as Le,Hr as Re,Ht as ze,Ii as Be,In as Ve,Ir as He,It as Ue,Ji as We,Jn as Ge,Jr as Ke,Jt as qe,Ki as j,Kn as Je,Kr as Ye,Kt as Xe,Li as Ze,Ln as Qe,Lr as $e,Lt as et,Mi as tt,Mn as nt,Mr as rt,Mt as it,Ni as at,Nn as ot,Nr as st,Nt as ct,Oi as lt,On as ut,Or as dt,Ot as ft,Pi as pt,Pn as mt,Pr as ht,Pt as gt,Qi as M,Qn as N,Qr as _t,Qt as vt,Ri as yt,Rn as bt,Rr as xt,Rt as St,Si as Ct,Sn as wt,Sr as Tt,St as Et,Ti as Dt,Tn as Ot,Tr as kt,Tt as At,Ui as jt,Un as Mt,Ur as Nt,Ut as Pt,Vi as P,Vn as Ft,Vr as It,Vt as Lt,Wi as F,Wn as Rt,Wr as zt,Wt as Bt,Xi as Vt,Xn as Ht,Xr as Ut,Xt as Wt,Yi as Gt,Yn as Kt,Yr as qt,Yt as Jt,Zi as I,Zn as Yt,Zr as Xt,Zt,_i as Qt,_n as $t,_r as en,ai as tn,an as nn,ar as rn,bn as an,br as on,bt as sn,ci as cn,cn as ln,cr as un,di as dn,dn as fn,dr as pn,ea as L,ei as mn,en as hn,er as gn,fi as _n,fn as vn,fr as yn,gi as bn,gn as xn,gr as Sn,hi as Cn,hn as wn,hr as Tn,ia as En,ii as Dn,in as On,ir as kn,ji as An,jn,jr as Mn,jt as Nn,ki as Pn,kn as Fn,kr as In,kt as Ln,li as Rn,ln as zn,lr as Bn,mi as Vn,mn as Hn,mr as Un,na as Wn,ni as Gn,nn as Kn,nr as qn,oi as Jn,on as Yn,or as Xn,pi as Zn,pn as Qn,pr as $n,qi as er,qn as tr,qr as nr,qt as rr,ra as ir,ri as ar,rn as or,rr as sr,si as cr,sn as lr,sr as ur,ta as dr,ti as fr,tn as pr,ui as mr,un as hr,ur as gr,vi as _r,vn as vr,vr as yr,wi as br,wn as xr,wr as Sr,wt as Cr,xi as wr,xn as Tr,xr as Er,xt as Dr,yi as Or,yn as kr,yr as Ar,yt as jr,zn as Mr,zt as Nr}from"./vendor-react-BMHj_SFM.js";import{c as Pr,l as Fr,s as Ir}from"./vendor-tanstack-Ls8ti0nO.js";import{a as Lr,i as Rr,n as zr,o as Br,r as Vr,t as R}from"./button-D7FHU9xr.js";import{i as Hr,r as Ur}from"./vendor-datadog-CFwwQ6-a.js";import"./vendor-stripe-B2SHoXve.js";import{t as Wr}from"./vendor-markdown-CZ125_GG.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)}})();var z=e(En(),1),B=ir();function Gr({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card`,className:g(`bg-card text-card-foreground flex flex-col gap-6 rounded-xl py-4 shadow-deep`,e),...t})}function Kr({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-header`,className:g(`flex flex-col gap-1.5 px-6`,e),...t})}function qr({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-title`,className:g(`leading-none text-lg`,e),...t})}function Jr({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-description`,className:g(`text-muted-foreground text-xs`,e),...t})}function Yr({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-content`,className:g(`px-6`,e),...t})}function Xr(e){return e!==null&&!!e.username}function Zr(e){if(e&&!Xr(e)){let t=Object.keys(e.roles);if(t.length===1)return`/${t[0]}`}return`/`}function Qr({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=Lr();return Zr(a),(0,B.jsxs)(Gr,{className:g(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,B.jsxs)(Kr,{children:[(0,B.jsx)(qr,{className:`text-2xl`,children:(0,B.jsx)(`h2`,{children:n??`Component Error`})}),(0,B.jsx)(Jr,{children:t.message})]}),(0,B.jsxs)(Yr,{children:[i,r!==!1&&(a&&!o?(0,B.jsx)(A,{to:`/`,children:(0,B.jsxs)(R,{children:[` `,(0,B.jsx)(Pn,{}),` Return to Home`]})}):(0,B.jsx)(A,{to:`/sign-in`,children:(0,B.jsxs)(R,{children:[` `,(0,B.jsx)(Pn,{}),` Go to Sign In Page`]})}))]})]})}function $r(){let{user:e,isLoading:t}=Lr();return Zr(e),(0,B.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,B.jsxs)(Gr,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,B.jsx)(Kr,{children:(0,B.jsx)(qr,{className:`text-2xl`,children:(0,B.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,B.jsx)(Yr,{children:e&&!t?(0,B.jsx)(A,{to:`/`,children:(0,B.jsxs)(R,{children:[` `,(0,B.jsx)(Pn,{}),` Return to Home`]})}):(0,B.jsx)(A,{to:`/sign-in`,children:(0,B.jsxs)(R,{children:[` `,(0,B.jsx)(Pn,{}),` Go Sign In Page`]})})})]})})}function ei(){return`ontouchstart`in window||navigator.maxTouchPoints>0}function ti(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(`:`)}N.error(t,{description:n,action:{label:`Dismiss`,onClick:()=>N.dismiss()}})}var ni=new Ir({queryCache:new Pr({onError:ti}),mutationCache:new Fr({onError:ti})});function ri(e){return!!e}var ii=!1,ai=!1;function oi(){(0,z.useEffect)(()=>{ii||(ii=!0,ai&&(Ur.init({applicationId:`f590deee-4bac-49b4-a202-3b6963d9721d`,clientToken:`pub27aa29cea521492f4fef73032f86a023`,site:`datadoghq.com`,service:`studio`,env:void 0,version:`v4.7.27`,trackViewsManually:!0,trackUserInteractions:!0,sessionSampleRate:100,sessionReplaySampleRate:0,defaultPrivacyLevel:`mask`,plugins:[Ht()]}),Ur.onReady(()=>{Ur.startView({service:`studio`,version:`v4.7.27`,name:window.location.pathname||`initial`})})))},[])}function si(e){if(!ai)return;Ur.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)?Ur.addAction(`return_login`):(Ur.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&&Ur.addAction(`login_time_gap`,{value:e})}localStorage.setItem(n,String(i)),Ur.addAction(`login_success`,{userId:e.id})}function ci(){return(0,B.jsx)(B.Fragment,{children:(0,B.jsx)(Ze,{})})}var li=me()({component:ci});function ui(){return(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,B.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 di(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`img`,{src:`/harper-studio_white.png`,alt:`Harper Studio`,className:`w-64 hidden md:inline-block`}),(0,B.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}function fi({className:e,...t}){return(0,B.jsx)(`div`,{className:g(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,B.jsx)(Ge,{"data-slot":`navigation-menu-viewport`,className:g(`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 pi({className:e,children:t,viewport:n=!0,...r}){return(0,B.jsxs)(tr,{"data-slot":`navigation-menu`,"data-viewport":n,className:g(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,B.jsx)(fi,{})]})}function mi({className:e,...t}){return(0,B.jsx)(Rt,{"data-slot":`navigation-menu-item`,className:g(`relative`,e),...t})}function hi({className:e,...t}){return(0,B.jsx)(Pe,{"data-slot":`navigation-menu-link`,className:g(`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 gi({className:e,...t}){return(0,B.jsx)(Je,{"data-slot":`navigation-menu-list`,className:g(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}var _i=ne(`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 vi(){return(0,B.jsx)(`a`,{href:`https://github.com/HarperFast/studio/releases`,target:`_blank`,rel:`noopener noreferrer`,children:(0,B.jsxs)(`span`,{className:g(_i({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[`v4.7.27`,` BETA`]})})}function yi(e={}){let{instanceId:t,clusterId:n}=j({strict:!1});return i({id:d,...e})}function bi(e={}){let{instanceId:t,clusterId:n}=j({strict:!1});return{instanceClient:i({id:d,...e}),entityType:`instance`}}function V(e={}){let{instanceId:t,clusterId:n}=j({strict:!1});return(0,z.useMemo)(()=>xi({instanceId:t,clusterId:n,...e}),[e.instanceId??t,e.clusterId??n,e.operationsUrl,e.port,e.secure,e.disableFabricConnect,e.forceFabricConnect])}function xi({instanceId:e,clusterId:t,...n}){let r=d;if(!r)throw Error(`id could not be automatically calculated in useInstanceClientIdParams`);return{instanceClient:i({id:r,...n}),entityId:r,entityType:`instance`}}function Si(){localStorage.clear()}function Ci(){sessionStorage.clear()}async function wi(){m.setUserForEntity(d,null),ni.getQueryCache().clear(),Si(),Ci(),await ni.invalidateQueries({refetchType:`none`})}async function Ti(e){await m.signOutFromPotentiallyAuthenticatedInstances(),await h({...e,entityId:d})}function Ei(){let e=yi();return I({mutationFn:()=>Ti({instanceClient:e}),onSuccess:wi})}function Di(e){let{user:t}=Vr(),{organizationId:n}=j({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 Oi(e){let{user:t}=Vr(),{organizationId:n}=j({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 ki(e,t){let{user:n}=Vr(),{organizationId:r,clusterId:i}=j({strict:!1});return Ai(n,e??r,t??i)}function Ai(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 ji(e,t){let{user:n}=Vr(),{organizationId:r,clusterId:i}=j({strict:!1});return Mi(n,e??r,t??i)}function Mi(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 Ni(e){let{clusterId:t,instanceId:n}=j({strict:!1}),{user:r}=Rr(e??n??t),i=r?.role?.permission;return i?i.super_user===!0:!1}function Pi(e){let{clusterId:t,instanceId:n}=j({strict:!1}),{user:r}=Rr(e??n??t),i=r?.role?.permission;return i?i.super_user===!0||i.structure_user===!0:!1}function Fi(e,t,n,r){let{clusterId:i,instanceId:a}=j({strict:!1}),{user:o}=Rr(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 Ii={className:`text-white`};function Li(){let{mutate:e}=Ei(),t=F(),{user:n}=Lr(),r=We(),{organizationId:i}=j({strict:!1}),{update:a}=Di(i),{view:o}=Oi(i),s=a,c=(0,z.useCallback)(()=>{e(void 0,{onSuccess:async()=>{N.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>N.dismiss()}}),t({to:`/sign-in`}),r.invalidate()}})},[e,r,t]),l=(0,z.useMemo)(()=>[!1,!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,B.jsx)(br,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,B.jsx)(wr,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,B.jsx)(ui,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:c,icon:(0,B.jsx)(In,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(ri),[i,s,o,c]);return n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Hi,{menuItems:l}),(0,B.jsx)(Bi,{menuItems:l})]}):(0,B.jsx)(zi,{})}function Ri(e){return e.items!==void 0}function zi(){return(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`inline-block`,children:[(0,B.jsx)(A,{to:`/sign-in`,children:(0,B.jsx)(di,{})}),(0,B.jsx)(vi,{})]}),(0,B.jsx)(pi,{children:(0,B.jsxs)(gi,{className:`text-grey-400`,children:[(0,B.jsx)(mi,{children:(0,B.jsx)(hi,{asChild:!0,children:(0,B.jsxs)(A,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,B.jsx)(br,{}),` `,(0,B.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,B.jsx)(mi,{children:(0,B.jsx)(hi,{asChild:!0,children:(0,B.jsxs)(A,{to:`/sign-in`,className:`flex-row items-center`,activeProps:Ii,children:[(0,B.jsx)(fe,{}),` Sign In`]})})})]})})]})}function Bi({menuItems:e}){let{user:t}=Lr();return Zr(t),(0,B.jsx)(`div`,{className:`hidden md:block`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`inline-block`,children:[(0,B.jsx)(A,{to:`/`,children:(0,B.jsx)(di,{})}),(0,B.jsx)(vi,{})]}),(0,B.jsx)(pi,{children:(0,B.jsx)(gi,{className:`text-grey-400`,children:e.map(e=>Ri(e)?!!e.items.length&&(0,B.jsx)(`div`,{className:`bg-black rounded-2xl flex`,children:e.items.map(e=>(0,B.jsx)(Vi,{menuItem:e},e.text))},e.text):(0,B.jsx)(Vi,{menuItem:e},e.text))})})]})})}function Vi({menuItem:e}){return(0,B.jsx)(mi,{className:`text-gray-400 hover:text-white`,children:(0,B.jsx)(hi,{asChild:!0,children:(0,B.jsxs)(A,{to:e.to,onClick:e.onClick,className:`flex-row items-center`,target:e.target,activeProps:e.to?Ii:void 0,children:[e.icon,(0,B.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,B.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})})}function Hi({menuItems:e}){let{user:t}=Lr();Zr(t);let[n,r]=(0,z.useState)(!1),i=(0,z.useCallback)(()=>r(e=>!e),[]),a=(0,z.useCallback)(()=>r(!1),[]);return(0,B.jsxs)(`div`,{className:`md:hidden`,id:`mobile-menu`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(A,{to:`/`,children:(0,B.jsx)(di,{})}),(0,B.jsx)(vi,{}),(0,B.jsxs)(`button`,{type:`button`,className:`shadow-xs text-grey-400 hover:text-white hover:bg-black-dark`,onClick:i,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,B.jsx)(ce,{}):(0,B.jsx)(we,{})]})]}),(0,B.jsx)(`div`,{className:`${n?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-black-dark opacity-70`,onClick:a}),(0,B.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=>Ri(e)?!!e.items.length&&(0,B.jsx)(`div`,{className:`bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,B.jsx)(Ui,{menuItem:e,onClick:a},e.text))},e.text):(0,B.jsx)(Ui,{menuItem:e,onClick:a},e.text))})]})}function Ui({menuItem:e,onClick:t}){let n=(0,z.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,B.jsxs)(A,{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?Ii:void 0,children:[e.icon,(0,B.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function Wi(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.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,B.jsx)(Li,{})}),(0,B.jsxs)(`div`,{className:`pt-20 grid h-screen grid-cols-1 md:grid-cols-2`,children:[(0,B.jsx)(`section`,{className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,B.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,B.jsx)(`section`,{className:`flex items-center justify-center px-6 bg-linear-(--purple-gradient) dark:bg-linear-(--black-dark-gradient)`,children:(0,B.jsx)(Ze,{})})]})]})}var Gi;function Ki(){(0,z.useEffect)(()=>{},[])}var qi=[`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 Ji(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of qi)if(t===e||t.endsWith(`.`+e))return null;return t}var Yi=null;function Xi(){let e=F(),t=We(),n=Wn(),{redirect:i}=Ne({strict:!1});return(0,z.useEffect)(()=>{Yi||=(async function(){let a=await l().catch(()=>null);if(!a)N.error(`We were not able to verify your sign-in. Please try signing in again.`,{duration:1e4}),await e({to:`/sign-in`});else{m.setUserForEntity(d,a);let o=Zr(a);si(a);let s=Ji(a.email);Gi?.identify?.({username:a.email,type:`email`,...s?{company:s}:{}}),await n.invalidateQueries({queryKey:r,refetchType:`none`}),await t.invalidate(),await e({to:i?.startsWith(`/`)?i:o})}Yi=null})()},[]),(0,B.jsxs)(`div`,{className:`text-white w-lg flex flex-col gap-4`,children:[(0,B.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,B.jsx)(`div`,{className:`underline flex gap-4`,children:(0,B.jsx)(A,{className:`text-sm opacity-50 hover:text-blue-300`,to:`/sign-in`,children:`Try signing in again`})})]})}function Zi({delayDuration:e=0,...t}){return(0,B.jsx)(Ft,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Qi({...e}){return(0,B.jsx)(Zi,{children:(0,B.jsx)(Le,{"data-slot":`tooltip`,...e})})}function $i({...e}){return(0,B.jsx)(Mt,{"data-slot":`tooltip-trigger`,...e})}function ea({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,B.jsx)(he,{children:(0,B.jsxs)(Mr,{"data-slot":`tooltip-content`,sideOffset:t,className:g(`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,B.jsx)(bt,{className:g(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}var ta=new Map;function na(e){if(!e)return``;if(ta.has(e))return ta.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return ta.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return ta.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(ra).join(` `);return ta.set(e,i),i}function ra(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function ia({restartRequired:e}){let t=at(),{organization:n,instance:r,cluster:i}=pt({strict:!1});return(0,B.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,z.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,B.jsxs)(A,{to:`/`,children:[(0,B.jsx)(He,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,B.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=na(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,B.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,B.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,B.jsx)(A,{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,B.jsxs)(Qi,{children:[(0,B.jsx)($i,{asChild:!0,children:(0,B.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,B.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,B.jsxs)(ea,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,B.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var H=ot,aa=(0,z.createContext)({}),oa=(0,z.createContext)({});function sa(){let e=(0,z.useContext)(aa),t=(0,z.useContext)(oa),{getFieldState:n}=Ve(),r=Qe({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 U({...e}){let{error:t,formItemId:n,formDescriptionId:r,formMessageId:i}=sa();return(0,B.jsx)(tt,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function W({...e}){return(0,B.jsx)(aa,{value:{name:e.name},children:(0,B.jsx)(nt,{...e})})}function G({className:e,...t}){return(0,B.jsx)(oa,{value:{id:(0,z.useId)()},children:(0,B.jsx)(`div`,{"data-slot":`form-item`,className:g(`grid gap-2`,e),...t})})}function ca({className:e,...t}){return(0,B.jsx)(jn,{"data-slot":`label`,className:g(`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 K({className:e,...t}){let{error:n,formItemId:r}=sa();return(0,B.jsx)(ca,{"data-slot":`form-label`,"data-error":!!n,className:g(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function q({className:e,...t}){let{error:n,formMessageId:r}=sa(),i=n?String(n?.message):t.children;return i?(0,B.jsx)(`p`,{"data-slot":`form-message`,id:r,className:g(`text-destructive text-sm`,e),...t,children:i}):null}function J({className:e,type:t,...n}){return(0,B.jsx)(`input`,{type:t,"data-slot":`input`,className:g(`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-B3bMWbNh.js","assets/rolldown-runtime-FhOqtrmT.js","assets/vendor-datadog-CFwwQ6-a.js","assets/vendor-react-BMHj_SFM.js","assets/vendor-misc-COZdCpxH.js","assets/vendor-markdown-CZ125_GG.js","assets/vendor-html-C0BzV7Np.js","assets/vendor-core-eR3ZofrV.js","assets/vendor-monaco-kOw-FVJn.js","assets/vendor-charts-BUlf-q3q.js","assets/vendor-react-CH1CJXTy.css","assets/button-D7FHU9xr.js","assets/cn-CCIpMBd-.js","assets/index-DZem5S77.css","assets/mermaid.core-ClMyP1L0.js","assets/vendor-viz-BrWvdZwR.js","assets/status-CdZyfe1S.js","assets/profile-BLeDamUk.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.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}from"./cn-CCIpMBd-.js";import{$t as y,Qt as b,Zt as x,an as S,cn as ee,en as te,gn as C,hn as ne,in as re,ln as w,nn as ie,on as ae,rn as oe,sn as T,tn as E,un as se}from"./vendor-core-eR3ZofrV.js";import{$i as D,$n as ce,$r as le,$t as ue,Ai as de,An as O,Ar as fe,At as pe,Bi as me,Bn as he,Br as ge,Bt as _e,Ci as ve,Cn as ye,Cr as be,Ct as xe,Di as Se,Dn as Ce,Dr as we,Dt as Te,Ei as Ee,En as De,Er as Oe,Et as ke,Fi as Ae,Fn as k,Fr as je,Ft as Me,Gi as Ne,Gn as Pe,Gr as Fe,Gt as Ie,Hi as A,Hn as Le,Hr as Re,Ht as ze,Ii as Be,In as Ve,Ir as He,It as Ue,Ji as We,Jn as Ge,Jr as Ke,Jt as qe,Ki as j,Kn as Je,Kr as Ye,Kt as Xe,Li as Ze,Ln as Qe,Lr as $e,Lt as et,Mi as tt,Mn as nt,Mr as rt,Mt as it,Ni as at,Nn as ot,Nr as st,Nt as ct,Oi as lt,On as ut,Or as dt,Ot as ft,Pi as pt,Pn as mt,Pr as ht,Pt as gt,Qi as M,Qn as N,Qr as _t,Qt as vt,Ri as yt,Rn as bt,Rr as xt,Rt as St,Si as Ct,Sn as wt,Sr as Tt,St as Et,Ti as Dt,Tn as Ot,Tr as kt,Tt as At,Ui as jt,Un as Mt,Ur as Nt,Ut as Pt,Vi as P,Vn as Ft,Vr as It,Vt as Lt,Wi as F,Wn as Rt,Wr as zt,Wt as Bt,Xi as Vt,Xn as Ht,Xr as Ut,Xt as Wt,Yi as Gt,Yn as Kt,Yr as qt,Yt as Jt,Zi as I,Zn as Yt,Zr as Xt,Zt,_i as Qt,_n as $t,_r as en,ai as tn,an as nn,ar as rn,bn as an,br as on,bt as sn,ci as cn,cn as ln,cr as un,di as dn,dn as fn,dr as pn,ea as L,ei as mn,en as hn,er as gn,fi as _n,fn as vn,fr as yn,gi as bn,gn as xn,gr as Sn,hi as Cn,hn as wn,hr as Tn,ia as En,ii as Dn,in as On,ir as kn,ji as An,jn,jr as Mn,jt as Nn,ki as Pn,kn as Fn,kr as In,kt as Ln,li as Rn,ln as zn,lr as Bn,mi as Vn,mn as Hn,mr as Un,na as Wn,ni as Gn,nn as Kn,nr as qn,oi as Jn,on as Yn,or as Xn,pi as Zn,pn as Qn,pr as $n,qi as er,qn as tr,qr as nr,qt as rr,ra as ir,ri as ar,rn as or,rr as sr,si as cr,sn as lr,sr as ur,ta as dr,ti as fr,tn as pr,ui as mr,un as hr,ur as gr,vi as _r,vn as vr,vr as yr,wi as br,wn as xr,wr as Sr,wt as Cr,xi as wr,xn as Tr,xr as Er,xt as Dr,yi as Or,yn as kr,yr as Ar,yt as jr,zn as Mr,zt as Nr}from"./vendor-react-BMHj_SFM.js";import{c as Pr,l as Fr,s as Ir}from"./vendor-tanstack-Ls8ti0nO.js";import{a as Lr,i as Rr,n as zr,o as Br,r as Vr,t as R}from"./button-D7FHU9xr.js";import{i as Hr,r as Ur}from"./vendor-datadog-CFwwQ6-a.js";import"./vendor-stripe-B2SHoXve.js";import{t as Wr}from"./vendor-markdown-CZ125_GG.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)}})();var z=e(En(),1),B=ir();function Gr({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card`,className:g(`bg-card text-card-foreground flex flex-col gap-6 rounded-xl py-4 shadow-deep`,e),...t})}function Kr({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-header`,className:g(`flex flex-col gap-1.5 px-6`,e),...t})}function qr({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-title`,className:g(`leading-none text-lg`,e),...t})}function Jr({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-description`,className:g(`text-muted-foreground text-xs`,e),...t})}function Yr({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-content`,className:g(`px-6`,e),...t})}function Xr(e){return e!==null&&!!e.username}function Zr(e){if(e&&!Xr(e)){let t=Object.keys(e.roles);if(t.length===1)return`/${t[0]}`}return`/`}function Qr({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=Lr();return Zr(a),(0,B.jsxs)(Gr,{className:g(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,B.jsxs)(Kr,{children:[(0,B.jsx)(qr,{className:`text-2xl`,children:(0,B.jsx)(`h2`,{children:n??`Component Error`})}),(0,B.jsx)(Jr,{children:t.message})]}),(0,B.jsxs)(Yr,{children:[i,r!==!1&&(a&&!o?(0,B.jsx)(A,{to:`/`,children:(0,B.jsxs)(R,{children:[` `,(0,B.jsx)(Pn,{}),` Return to Home`]})}):(0,B.jsx)(A,{to:`/sign-in`,children:(0,B.jsxs)(R,{children:[` `,(0,B.jsx)(Pn,{}),` Go to Sign In Page`]})}))]})]})}function $r(){let{user:e,isLoading:t}=Lr();return Zr(e),(0,B.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,B.jsxs)(Gr,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,B.jsx)(Kr,{children:(0,B.jsx)(qr,{className:`text-2xl`,children:(0,B.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,B.jsx)(Yr,{children:e&&!t?(0,B.jsx)(A,{to:`/`,children:(0,B.jsxs)(R,{children:[` `,(0,B.jsx)(Pn,{}),` Return to Home`]})}):(0,B.jsx)(A,{to:`/sign-in`,children:(0,B.jsxs)(R,{children:[` `,(0,B.jsx)(Pn,{}),` Go Sign In Page`]})})})]})})}function ei(){return`ontouchstart`in window||navigator.maxTouchPoints>0}function ti(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(`:`)}N.error(t,{description:n,action:{label:`Dismiss`,onClick:()=>N.dismiss()}})}var ni=new Ir({queryCache:new Pr({onError:ti}),mutationCache:new Fr({onError:ti})});function ri(e){return!!e}var ii=!1,ai=!1;function oi(){(0,z.useEffect)(()=>{ii||(ii=!0,ai&&(Ur.init({applicationId:`f590deee-4bac-49b4-a202-3b6963d9721d`,clientToken:`pub27aa29cea521492f4fef73032f86a023`,site:`datadoghq.com`,service:`studio`,env:void 0,version:`v4.7.28`,trackViewsManually:!0,trackUserInteractions:!0,sessionSampleRate:100,sessionReplaySampleRate:0,defaultPrivacyLevel:`mask`,plugins:[Ht()]}),Ur.onReady(()=>{Ur.startView({service:`studio`,version:`v4.7.28`,name:window.location.pathname||`initial`})})))},[])}function si(e){if(!ai)return;Ur.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)?Ur.addAction(`return_login`):(Ur.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&&Ur.addAction(`login_time_gap`,{value:e})}localStorage.setItem(n,String(i)),Ur.addAction(`login_success`,{userId:e.id})}function ci(){return(0,B.jsx)(B.Fragment,{children:(0,B.jsx)(Ze,{})})}var li=me()({component:ci});function ui(){return(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,B.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 di(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`img`,{src:`/harper-studio_white.png`,alt:`Harper Studio`,className:`w-64 hidden md:inline-block`}),(0,B.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}function fi({className:e,...t}){return(0,B.jsx)(`div`,{className:g(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,B.jsx)(Ge,{"data-slot":`navigation-menu-viewport`,className:g(`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 pi({className:e,children:t,viewport:n=!0,...r}){return(0,B.jsxs)(tr,{"data-slot":`navigation-menu`,"data-viewport":n,className:g(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,B.jsx)(fi,{})]})}function mi({className:e,...t}){return(0,B.jsx)(Rt,{"data-slot":`navigation-menu-item`,className:g(`relative`,e),...t})}function hi({className:e,...t}){return(0,B.jsx)(Pe,{"data-slot":`navigation-menu-link`,className:g(`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 gi({className:e,...t}){return(0,B.jsx)(Je,{"data-slot":`navigation-menu-list`,className:g(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}var _i=ne(`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 vi(){return(0,B.jsx)(`a`,{href:`https://github.com/HarperFast/studio/releases`,target:`_blank`,rel:`noopener noreferrer`,children:(0,B.jsxs)(`span`,{className:g(_i({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[`v4.7.28`,` BETA`]})})}function yi(e={}){let{instanceId:t,clusterId:n}=j({strict:!1});return i({id:d,...e})}function bi(e={}){let{instanceId:t,clusterId:n}=j({strict:!1});return{instanceClient:i({id:d,...e}),entityType:`instance`}}function V(e={}){let{instanceId:t,clusterId:n}=j({strict:!1});return(0,z.useMemo)(()=>xi({instanceId:t,clusterId:n,...e}),[e.instanceId??t,e.clusterId??n,e.operationsUrl,e.port,e.secure,e.disableFabricConnect,e.forceFabricConnect])}function xi({instanceId:e,clusterId:t,...n}){let r=d;if(!r)throw Error(`id could not be automatically calculated in useInstanceClientIdParams`);return{instanceClient:i({id:r,...n}),entityId:r,entityType:`instance`}}function Si(){localStorage.clear()}function Ci(){sessionStorage.clear()}async function wi(){m.setUserForEntity(d,null),ni.getQueryCache().clear(),Si(),Ci(),await ni.invalidateQueries({refetchType:`none`})}async function Ti(e){await m.signOutFromPotentiallyAuthenticatedInstances(),await h({...e,entityId:d})}function Ei(){let e=yi();return I({mutationFn:()=>Ti({instanceClient:e}),onSuccess:wi})}function Di(e){let{user:t}=Vr(),{organizationId:n}=j({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 Oi(e){let{user:t}=Vr(),{organizationId:n}=j({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 ki(e,t){let{user:n}=Vr(),{organizationId:r,clusterId:i}=j({strict:!1});return Ai(n,e??r,t??i)}function Ai(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 ji(e,t){let{user:n}=Vr(),{organizationId:r,clusterId:i}=j({strict:!1});return Mi(n,e??r,t??i)}function Mi(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 Ni(e){let{clusterId:t,instanceId:n}=j({strict:!1}),{user:r}=Rr(e??n??t),i=r?.role?.permission;return i?i.super_user===!0:!1}function Pi(e){let{clusterId:t,instanceId:n}=j({strict:!1}),{user:r}=Rr(e??n??t),i=r?.role?.permission;return i?i.super_user===!0||i.structure_user===!0:!1}function Fi(e,t,n,r){let{clusterId:i,instanceId:a}=j({strict:!1}),{user:o}=Rr(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 Ii={className:`text-white`};function Li(){let{mutate:e}=Ei(),t=F(),{user:n}=Lr(),r=We(),{organizationId:i}=j({strict:!1}),{update:a}=Di(i),{view:o}=Oi(i),s=a,c=(0,z.useCallback)(()=>{e(void 0,{onSuccess:async()=>{N.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>N.dismiss()}}),t({to:`/sign-in`}),r.invalidate()}})},[e,r,t]),l=(0,z.useMemo)(()=>[!1,!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,B.jsx)(br,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,B.jsx)(wr,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,B.jsx)(ui,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:c,icon:(0,B.jsx)(In,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(ri),[i,s,o,c]);return n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Hi,{menuItems:l}),(0,B.jsx)(Bi,{menuItems:l})]}):(0,B.jsx)(zi,{})}function Ri(e){return e.items!==void 0}function zi(){return(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`inline-block`,children:[(0,B.jsx)(A,{to:`/sign-in`,children:(0,B.jsx)(di,{})}),(0,B.jsx)(vi,{})]}),(0,B.jsx)(pi,{children:(0,B.jsxs)(gi,{className:`text-grey-400`,children:[(0,B.jsx)(mi,{children:(0,B.jsx)(hi,{asChild:!0,children:(0,B.jsxs)(A,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,B.jsx)(br,{}),` `,(0,B.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,B.jsx)(mi,{children:(0,B.jsx)(hi,{asChild:!0,children:(0,B.jsxs)(A,{to:`/sign-in`,className:`flex-row items-center`,activeProps:Ii,children:[(0,B.jsx)(fe,{}),` Sign In`]})})})]})})]})}function Bi({menuItems:e}){let{user:t}=Lr();return Zr(t),(0,B.jsx)(`div`,{className:`hidden md:block`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`inline-block`,children:[(0,B.jsx)(A,{to:`/`,children:(0,B.jsx)(di,{})}),(0,B.jsx)(vi,{})]}),(0,B.jsx)(pi,{children:(0,B.jsx)(gi,{className:`text-grey-400`,children:e.map(e=>Ri(e)?!!e.items.length&&(0,B.jsx)(`div`,{className:`bg-black rounded-2xl flex`,children:e.items.map(e=>(0,B.jsx)(Vi,{menuItem:e},e.text))},e.text):(0,B.jsx)(Vi,{menuItem:e},e.text))})})]})})}function Vi({menuItem:e}){return(0,B.jsx)(mi,{className:`text-gray-400 hover:text-white`,children:(0,B.jsx)(hi,{asChild:!0,children:(0,B.jsxs)(A,{to:e.to,onClick:e.onClick,className:`flex-row items-center`,target:e.target,activeProps:e.to?Ii:void 0,children:[e.icon,(0,B.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,B.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})})}function Hi({menuItems:e}){let{user:t}=Lr();Zr(t);let[n,r]=(0,z.useState)(!1),i=(0,z.useCallback)(()=>r(e=>!e),[]),a=(0,z.useCallback)(()=>r(!1),[]);return(0,B.jsxs)(`div`,{className:`md:hidden`,id:`mobile-menu`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(A,{to:`/`,children:(0,B.jsx)(di,{})}),(0,B.jsx)(vi,{}),(0,B.jsxs)(`button`,{type:`button`,className:`shadow-xs text-grey-400 hover:text-white hover:bg-black-dark`,onClick:i,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,B.jsx)(ce,{}):(0,B.jsx)(we,{})]})]}),(0,B.jsx)(`div`,{className:`${n?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-black-dark opacity-70`,onClick:a}),(0,B.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=>Ri(e)?!!e.items.length&&(0,B.jsx)(`div`,{className:`bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,B.jsx)(Ui,{menuItem:e,onClick:a},e.text))},e.text):(0,B.jsx)(Ui,{menuItem:e,onClick:a},e.text))})]})}function Ui({menuItem:e,onClick:t}){let n=(0,z.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,B.jsxs)(A,{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?Ii:void 0,children:[e.icon,(0,B.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function Wi(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.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,B.jsx)(Li,{})}),(0,B.jsxs)(`div`,{className:`pt-20 grid h-screen grid-cols-1 md:grid-cols-2`,children:[(0,B.jsx)(`section`,{className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,B.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,B.jsx)(`section`,{className:`flex items-center justify-center px-6 bg-linear-(--purple-gradient) dark:bg-linear-(--black-dark-gradient)`,children:(0,B.jsx)(Ze,{})})]})]})}var Gi;function Ki(){(0,z.useEffect)(()=>{},[])}var qi=[`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 Ji(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of qi)if(t===e||t.endsWith(`.`+e))return null;return t}var Yi=null;function Xi(){let e=F(),t=We(),n=Wn(),{redirect:i}=Ne({strict:!1});return(0,z.useEffect)(()=>{Yi||=(async function(){let a=await l().catch(()=>null);if(!a)N.error(`We were not able to verify your sign-in. Please try signing in again.`,{duration:1e4}),await e({to:`/sign-in`});else{m.setUserForEntity(d,a);let o=Zr(a);si(a);let s=Ji(a.email);Gi?.identify?.({username:a.email,type:`email`,...s?{company:s}:{}}),await n.invalidateQueries({queryKey:r,refetchType:`none`}),await t.invalidate(),await e({to:i?.startsWith(`/`)?i:o})}Yi=null})()},[]),(0,B.jsxs)(`div`,{className:`text-white w-lg flex flex-col gap-4`,children:[(0,B.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,B.jsx)(`div`,{className:`underline flex gap-4`,children:(0,B.jsx)(A,{className:`text-sm opacity-50 hover:text-blue-300`,to:`/sign-in`,children:`Try signing in again`})})]})}function Zi({delayDuration:e=0,...t}){return(0,B.jsx)(Ft,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Qi({...e}){return(0,B.jsx)(Zi,{children:(0,B.jsx)(Le,{"data-slot":`tooltip`,...e})})}function $i({...e}){return(0,B.jsx)(Mt,{"data-slot":`tooltip-trigger`,...e})}function ea({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,B.jsx)(he,{children:(0,B.jsxs)(Mr,{"data-slot":`tooltip-content`,sideOffset:t,className:g(`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,B.jsx)(bt,{className:g(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}var ta=new Map;function na(e){if(!e)return``;if(ta.has(e))return ta.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return ta.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return ta.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(ra).join(` `);return ta.set(e,i),i}function ra(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function ia({restartRequired:e}){let t=at(),{organization:n,instance:r,cluster:i}=pt({strict:!1});return(0,B.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,z.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,B.jsxs)(A,{to:`/`,children:[(0,B.jsx)(He,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,B.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=na(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,B.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,B.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,B.jsx)(A,{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,B.jsxs)(Qi,{children:[(0,B.jsx)($i,{asChild:!0,children:(0,B.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,B.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,B.jsxs)(ea,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,B.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var H=ot,aa=(0,z.createContext)({}),oa=(0,z.createContext)({});function sa(){let e=(0,z.useContext)(aa),t=(0,z.useContext)(oa),{getFieldState:n}=Ve(),r=Qe({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 U({...e}){let{error:t,formItemId:n,formDescriptionId:r,formMessageId:i}=sa();return(0,B.jsx)(tt,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function W({...e}){return(0,B.jsx)(aa,{value:{name:e.name},children:(0,B.jsx)(nt,{...e})})}function G({className:e,...t}){return(0,B.jsx)(oa,{value:{id:(0,z.useId)()},children:(0,B.jsx)(`div`,{"data-slot":`form-item`,className:g(`grid gap-2`,e),...t})})}function ca({className:e,...t}){return(0,B.jsx)(jn,{"data-slot":`label`,className:g(`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 K({className:e,...t}){let{error:n,formItemId:r}=sa();return(0,B.jsx)(ca,{"data-slot":`form-label`,"data-error":!!n,className:g(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function q({className:e,...t}){let{error:n,formMessageId:r}=sa(),i=n?String(n?.message):t.children;return i?(0,B.jsx)(`p`,{"data-slot":`form-message`,id:r,className:g(`text-destructive text-sm`,e),...t,children:i}):null}function J({className:e,type:t,...n}){return(0,B.jsx)(`input`,{type:t,"data-slot":`input`,className:g(`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{o as e}from"./rolldown-runtime-FhOqtrmT.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 la=[`RUNNING`],ua=[`TERMINATING`,`TERMINATED`,`REMOVED`];function da(){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 fa({username:e,password:t,instanceClient:n,entityId:r}){let a={username:e,password:t};m.checkForBasicAuth(r)&&(n.defaults.auth=a,n.defaults.withCredentials=!1);let{data:{message:o}}=await n.post(`/`,{operation:`login`,username:e,password:t});if(!m.checkForBasicAuth(r))try{return{message:o,user:await f({instanceClient:n})}}catch(e){console.error(`Failed to get user after login, trying basic auth`,e)}try{n.defaults.auth=a,n.defaults.withCredentials=!1;let e=await f({instanceClient:n,auth:a});return m.flagForBasicAuth(r,a),{message:o,user:e}}catch(e){throw n.defaults.auth=void 0,n.defaults.withCredentials=!0,e}let s=i({id:r,forceFabricConnect:!0}),c=await f({instanceClient:s});return m.flagForFabricConnect(r,!0),{message:o,user:c,instanceClient:s}}function pa(){return I({mutationFn:fa})}function ma({cluster:e,instance:t,instanceParams:n}){let r=F(),i=We(),{redirect:a}=Ne({strict:!1}),{mutate:o,isPending:s}=pa();return{isPending:s,submitForm:(0,z.useCallback)(async s=>{o({...s,...n},{onSuccess:async({message:n,user:o})=>{if(N.success(n),e?.instances?.length&&!t)for(let t of e.instances)m.setUserForEntity(t,o);let s=d;if(!s)throw Error(`Sign in failed due to missing cluster or instance.`);m.setUserForEntity(s,o),i.invalidate(),await r({to:a?.startsWith(`/`)?a:`/`})}})},[e,t,n,r,a,i,o])}}async function ha(e){let{data:t}=await u.get(`/Cluster/${e}`);return t}function ga(e,t){return M({queryKey:[e],queryFn:()=>ha(e),retry:!1,staleTime:1900,enabled:!!e,refetchInterval:t?t===!0?1e4:t:void 0})}var _a=oe({error:`Please enter a valid email address.`}).toLowerCase().trim(),va=w().nonempty({error:`Please enter your password.`}),ya=w().nonempty({error:`Please enter a username.`}),ba=T({username:ya,password:va}),xa=T({email:_a,password:va});function Sa({entityId:e,instanceClient:t}){return M({queryKey:[e,`health`],queryFn:async()=>{try{return await t.get(`/health`),!0}catch{return!1}},retry:2,refetchInterval:5e3})}var Ca=[`localhost`,`127.0.0.1`],wa=function(e){return e.MixedLoopback=`MixedLoopback`,e.InsecureCookieOutsideChromeAndFirefox=`InsecureCookieOutsideChromeAndFirefox`,e}({});function Ta(e,t,n){if(!n||!t||!e)return null;let r=new URL(n).hostname,i=Ca.includes(t),a=Ca.includes(r);if(i&&a&&r!==t)return wa.MixedLoopback;if(!i&&a){let t=e.indexOf(`Chrome`)>=0,n=e.indexOf(`Firefox`)>=0;if(!t&&!n)return wa.InsecureCookieOutsideChromeAndFirefox}return null}function Ea(){let{clusterId:e,instanceId:t}=j({strict:!1}),{data:r}=L(ga(e,!0)),i=(0,z.useMemo)(()=>t&&r&&r?.instances?.find(e=>e.id===t)||void 0,[r,t]),a=(0,z.useMemo)(()=>r?.status&&la.includes(r.status),[r?.status]),o=`instance`,s=(0,z.useMemo)(()=>r?i?(m.flagForFabricConnect(i.id,!1),c(i)):(m.flagForFabricConnect(r.id,!1),n(r)):null,[r,i]),l=V({operationsUrl:s}),u=(0,z.useMemo)(()=>s?.includes(`localhost`)||s?.includes(`127.0.0.1`),[s]),d=(0,z.useMemo)(()=>Ta(navigator.userAgent,location.hostname,s),[s]),{data:f}=L(Sa(l)),p=k({resolver:O(ba),defaultValues:{username:``,password:``}}),{control:h,handleSubmit:g}=p,{submitForm:_,isPending:v}=ma({cluster:r,instance:i,instanceParams:l});return!t&&r&&!r?.fqdn?(0,B.jsx)(jt,{to:`../instances`,replace:!0}):a&&r?.resetPassword?(0,B.jsx)(jt,{to:`/${r.organizationId}/${r.id}/finish-setup`,replace:!0}):!a&&r?.resetPassword?(0,B.jsx)(jt,{to:`/${r.organizationId}/${r.id}/starting-up`,replace:!0}):(0,B.jsxs)(B.Fragment,{children:[!1,(0,B.jsx)(`div`,{className:`h-screen items-center justify-center flex`,children:(0,B.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,B.jsxs)(`h2`,{className:`text-2xl font-light`,children:[`Sign in to Harper `,`Local`]}),(0,B.jsx)(H,{...p,children:(0,B.jsxs)(`form`,{id:`auth-${o}-signin-form`,name:`auth-${o}-signin-form`,onSubmit:g(_),className:`my-4`,children:[(0,B.jsx)(W,{control:h,name:`username`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Username`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{autoComplete:`username`,autoFocus:!0,type:`text`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:h,name:`password`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(R,{disabled:v,type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,children:`Sign In`}),f===!1&&(0,B.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,B.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` This `,o,` is not responding to GET`,` `,(0,B.jsxs)(`a`,{href:`${s}health`,className:`underline`,target:`_blank`,children:[s,`health`]}),` `,`checks.`,(0,B.jsxs)(`ol`,{className:`list-decimal ml-8 mt-2`,children:[(0,B.jsx)(`li`,{children:`Is the server running?`}),(0,B.jsxs)(`li`,{children:[`Have you`,` `,(0,B.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,B.jsxs)(`li`,{children:[`Have you allowed`,` `,(0,B.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===wa.MixedLoopback&&(0,B.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,B.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===wa.InsecureCookieOutsideChromeAndFirefox&&(0,B.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,B.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,B.jsxs)(`div`,{className:`p-4 mt-4 text-sm rounded-lg bg-purple-950`,role:`alert`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:`Did you know?`}),` `,`You can add this instance to your Harper account to manage it remotely.`,(0,B.jsx)(`div`,{className:`text-center pt-2`,children:(0,B.jsx)(A,{to:da(),target:`_blank`,children:(0,B.jsx)(R,{type:`button`,variant:`positive`,children:`Connect to Harper Fabric`})})})]})]})})]})})]})}async function Da({email:e}){let{data:t}=await u.post(`/ForgotPassword/`,{email:e});if(t)return t;throw Error(`Something went wrong`)}function Oa(){return I({mutationFn:e=>Da(e)})}var ka=T({email:_a});function Aa(){let e=F(),{me:t}=Ne({strict:!1}),n=k({resolver:O(ka),defaultValues:{email:t||``}}),r=n.watch(`email`),{setFocus:i,control:a,handleSubmit:o}=n;(0,z.useEffect)(()=>{i(`email`)},[i]);let{mutate:s,isPending:c}=Oa(),l=async t=>{s(t,{onSuccess:t=>{N.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>N.dismiss()}}),e({to:`/sign-in`,search:{me:r}})}})};return(0,B.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,B.jsx)(`h2`,{className:`text-2xl font-light`,children:`Enter your account email`}),(0,B.jsx)(`p`,{className:`text-sm pt-1`,children:`If a matching account exists, we'll send you a password reset link.`}),(0,B.jsx)(H,{...n,children:(0,B.jsxs)(`form`,{id:`auth-forgot-password-form`,name:`auth-forgot-password-form`,onSubmit:o(l),className:`my-4`,children:[(0,B.jsx)(W,{control:a,name:`email`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-2`,children:[(0,B.jsx)(K,{children:`Email`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{disabled:c,type:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(R,{type:`submit`,variant:`submit`,disabled:c,className:`w-full my-2 rounded-full`,children:`Send Password Reset Email`})]})}),(0,B.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,B.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:r},children:`Sign in to your account`}),(0,B.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:r},children:`Sign up for free`})]})]})}var ja=async({token:e,password:t})=>{let{data:n}=await u.put(`/ResetPassword/`,{token:e,newPassword:t});return n};function Ma(){return I({mutationFn:e=>ja(e)})}var Na=T({password:va.min(8,{error:`Password must be at least 8 characters long.`}).max(50,{error:`Password cannot be longer than 50 characters.`}),confirmPassword:w()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});function Pa(){let{token:e}=Ne({strict:!1}),t=F();(0,z.useEffect)(()=>{e||t({to:`/sign-in`})},[e,t]);let n=k({resolver:O(Na),defaultValues:{password:``,confirmPassword:``}}),{setFocus:r,control:i,handleSubmit:a}=n;(0,z.useEffect)(()=>{r(`password`)},[r]);let{mutate:o,isPending:s}=Ma(),c=(0,z.useCallback)(async n=>{o({token:e,password:n.password},{onSuccess:()=>{N.success(`Success`,{description:`Your password has been reset successfully.`,action:{label:`Dismiss`,onClick:()=>N.dismiss()}}),t({to:`/sign-in`})}})},[t,o,e]);return(0,B.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,B.jsx)(`h2`,{className:`text-2xl font-light`,children:`Reset Password`}),(0,B.jsx)(H,{...n,children:(0,B.jsxs)(`form`,{id:`auth-reset-password-form`,name:`auth-reset-password-form`,className:`my-4`,onSubmit:a(c),children:[(0,B.jsx)(W,{control:i,name:`password`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-2`,children:[(0,B.jsx)(K,{children:`New Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{disabled:s,type:`password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:i,name:`confirmPassword`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-2`,children:[(0,B.jsx)(K,{children:`Confirm Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{disabled:s,type:`password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(R,{variant:`submit`,type:`submit`,disabled:s,className:`w-full my-2 rounded-full`,children:`Submit New Password`})]})})]})}function Fa({text:e,disabled:t,onClick:n}){return(0,B.jsx)(`a`,{href:`/oauth/github/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,children:(0,B.jsxs)(`button`,{className:C(`github-signin-btn`,t&&`opacity-50`),type:`button`,children:[(0,B.jsx)(`img`,{src:`/github/GitHub_Invertocat_White.svg`,alt:`GitHub Logo`,className:`github-icon`}),e]})})}function Ia({text:e,disabled:t,onClick:n}){return(0,B.jsx)(`a`,{href:`/oauth/google/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,children:(0,B.jsxs)(`button`,{className:C(`gsi-material-button`,t&&`opacity-50`),type:`button`,children:[(0,B.jsx)(`div`,{className:`gsi-material-button-state`}),(0,B.jsxs)(`div`,{className:`gsi-material-button-content-wrapper`,children:[(0,B.jsx)(`div`,{className:`gsi-material-button-icon`,children:(0,B.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,B.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,B.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,B.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,B.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,B.jsx)(`path`,{fill:`none`,d:`M0 0h48v48H0z`})]})}),(0,B.jsx)(`span`,{className:`gsi-material-button-contents`,children:e}),(0,B.jsx)(`span`,{className:`hidden`,children:e})]})]})})}function La(){let e=F(),t=Wn(),n=We(),{redirect:i}=Ne({strict:!1}),{mutate:a,isPending:o}=Ra();return{isPending:o,submitForm:(0,z.useCallback)(o=>{a(o,{onSuccess:async a=>{m.setUserForEntity(d,a);let o=Zr(a);si(a);let s=Ji(a.email);Gi?.identify?.({username:a.email,type:`email`,...s?{company:s}:{}}),await t.invalidateQueries({queryKey:r,refetchType:`none`}),n.invalidate(),await e({to:i?.startsWith(`/`)?i:o})}})},[e,t,i,n,a])}}function Ra(){return I({mutationFn:e=>za(e)})}async function za({email:e,password:t}){let{data:n}=await u.post(`/Login/`,{email:e,password:t});if(n)return n;throw Error(`Something went wrong`)}function Ba(){let{me:e}=Ne({strict:!1}),t=k({resolver:O(xa),defaultValues:{email:e||``,password:``}}),{handleSubmit:n,control:r}=t,i=t.watch(`email`),{submitForm:a,isPending:o}=La();return(0,B.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,B.jsx)(`h2`,{className:`text-2xl font-light`,children:`Sign in to Harper Fabric`}),(0,B.jsx)(H,{...t,children:(0,B.jsxs)(`form`,{id:`auth-signin-form`,name:`auth-signin-form`,onSubmit:n(a),className:`my-4`,children:[(0,B.jsx)(W,{control:r,name:`email`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Email`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`email`,autoFocus:!0,autoComplete:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:r,name:`password`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,autoComplete:`current-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(R,{type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,disabled:o,children:`Sign In`}),(0,B.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,B.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:i},children:`Sign up for free`}),(0,B.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/forgot-password`,search:{me:i},children:`Forgot password?`})]})]})}),(0,B.jsx)(`hr`,{className:`border-gray-600 my-6`}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(Ia,{text:`Sign in with Google`}),(0,B.jsx)(Fa,{text:`Sign in with GitHub`})]})]})}var Va=/^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžæÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,'-]+$/u;async function Ha(e){let{data:t}=await u.post(`/User/`,e);if(t)return t;throw Error(`Something went wrong`)}function Ua(){return I({mutationFn:e=>Ha(e)})}var Wa=T({email:_a.max(80,{error:`Email cannot be longer than 80 characters.`}),firstname:w().trim().min(2,{error:`Please enter your first name.`}).regex(Va,{error:`First name can only contain letters, spaces, and hyphens.`}).max(40,{error:`First name cannot be longer than 40 characters.`}),lastname:w().trim().min(2,{error:`Please enter your last name.`}).regex(Va,{error:`Last name can only contain letters, spaces, and hyphens.`}).max(80,{error:`Last name cannot be longer than 80 characters.`}),password:va.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:w(),acceptTerms:E().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 Ga(){let e=F(),{email:t,me:n}=Ne({strict:!1}),[r,i]=(0,z.useState)(!1),a=k({resolver:O(Wa),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,z.useEffect)(()=>{c(`firstname`)},[c]);let{mutate:d}=Ua(),f=(0,z.useCallback)(async t=>{let{confirmPassword:n,acceptTerms:r,...i}=t;d(i,{onSuccess:()=>{let t=Ji(i.email);Gi?.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,z.useCallback)(e=>{if(!s)return i(!0),setTimeout(()=>i(!1),1e3),e.preventDefault(),!1},[s]),m=(0,B.jsx)(W,{control:l,name:`acceptTerms`,render:({field:e})=>(0,B.jsxs)(G,{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,B.jsx)(U,{children:(0,B.jsx)(J,{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,B.jsxs)(`div`,{className:`space-y-1 leading-none`,children:[(0,B.jsxs)(K,{className:`text-xs font-normal`,children:[`I accept the`,` `,(0,B.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,B.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,B.jsx)(q,{})]})]})});return(0,B.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,B.jsx)(`h2`,{className:`text-2xl font-light`,children:`Sign up for Harper Fabric`}),(0,B.jsxs)(H,{...a,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-2 my-6`,children:[m,(0,B.jsx)(Ia,{text:`Sign up with Google`,disabled:!s,onClick:p}),(0,B.jsx)(Fa,{text:`Sign up with GitHub`,disabled:!s,onClick:p})]}),(0,B.jsx)(`hr`,{className:`border-gray-600`}),(0,B.jsxs)(`form`,{id:`auth-signup-form`,name:`auth-signup-form`,onSubmit:u(f),className:`grid gap-4 my-4`,children:[(0,B.jsx)(W,{control:l,name:`firstname`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`First Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:l,name:`lastname`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Last Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:l,name:`email`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Email`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{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,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:l,name:`password`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,autoComplete:`new-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:l,name:`confirmPassword`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Confirm Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,autoComplete:`new-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),m,(0,B.jsx)(R,{type:`submit`,variant:`submit`,className:`w-full rounded-full my-4`,children:`Sign Up For Free`})]})]}),(0,B.jsx)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:(0,B.jsx)(A,{className:`m-auto text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:o},children:`Already have an account? Sign in instead.`})})]})}var Ka=async({email:e})=>{let{data:t}=await u.post(`/ResendVerificationEmail/`,{email:e});return t};function qa(){return I({mutationFn:e=>Ka(e)})}var Ja=async e=>{let{data:t}=await u.put(`/VerifyEmail/`,{token:e.toString()});return t};function Ya(){return I({mutationFn:e=>Ja(e)})}var Xa=T({email:_a});function Za(){let e=F(),{mutate:t,isPending:n}=qa(),r=k({resolver:O(Xa),defaultValues:{email:``}}),i=r.watch(`email`),{setFocus:a,control:o,handleSubmit:s}=r;(0,z.useEffect)(()=>{a(`email`)},[a]);let c=(0,z.useCallback)(async n=>{t(n,{onSuccess:t=>{N.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>N.dismiss()}}),e({to:`/sign-in`,search:{me:i}})}})},[i,e,t]);return(0,B.jsxs)(H,{...r,children:[(0,B.jsx)(`p`,{className:`text-sm py-2`,children:`Please Enter an Email`}),(0,B.jsxs)(`form`,{id:`auth-verify-email-form`,name:`auth-verify-email-form`,onSubmit:s(c),className:`my-4`,children:[(0,B.jsx)(W,{control:o,name:`email`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-2`,children:[(0,B.jsx)(K,{children:`Email`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{disabled:n,type:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(R,{type:`submit`,variant:`submit`,disabled:n,className:`w-full my-2 rounded-full`,children:`Send Verification Email`})]})]})}function Qa(){let{token:e}=Ne({strict:!1}),t=F(),{mutate:n,isPending:r}=Ya(),i=(0,z.useCallback)(e=>{n(e,{onSuccess:()=>{N.success(`Success`,{description:`Email verified successfully`,action:{label:`Dismiss`,onClick:()=>N.dismiss()}}),t({to:`/sign-in`})}})},[n,t]);return(0,z.useEffect)(()=>{e&&i(e)},[i,e]),(0,B.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,B.jsx)(`h1`,{className:`text-3xl font-light`,children:`Verify Email`}),r?(0,B.jsx)(`p`,{className:`text-sm pt-1`,children:`Verifying email...`}):(0,B.jsx)(Za,{})]})}function $a(){let{email:e}=Ne({strict:!1}),{mutate:t,isPending:n}=qa(),r=(0,z.useCallback)(n=>(n.preventDefault(),e&&t({email:e},{onSuccess:e=>{N.success(`Code Sent`,{description:`${e}`,action:{label:`Dismiss`,onClick:()=>N.dismiss()}})}}),!1),[e,t]);return(0,B.jsxs)(`div`,{className:`text-white w-lg flex flex-col gap-4`,children:[(0,B.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Check your email!`]}),(0,B.jsxs)(`p`,{children:[`Your account has been created! You should receive an email with a link to `,(0,B.jsx)(`strong`,{children:`[Verify My Email]`}),`!`]}),(0,B.jsxs)(`p`,{children:[`From: `,(0,B.jsx)(`strong`,{children:`harper@notifications.harperfabric.com`})]}),(0,B.jsxs)(`p`,{children:[`To: `,(0,B.jsx)(`strong`,{children:e||`your email`})]}),(0,B.jsx)(`p`,{children:`Can you click it? Then we can carry on to more fun things!`}),(0,B.jsxs)(`div`,{className:`underline flex gap-4`,children:[(0,B.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:e},children:`I did it, let me sign in!`}),(0,B.jsx)(A,{className:`text-sm opacity-50 hover:text-blue-300`,to:void 0,onClick:r,disabled:n,children:`Send me another code, please.`})]})]})}var eo=P({getParentRoute:()=>li,id:`_authLayout`,component:Wi}),to=P({getParentRoute:()=>eo,path:`sign-in`,component:Ba,beforeLoad:({context:e,location:t})=>{let n=e.authentication[d]?.user;if(n){let e=t?.search,r=Zr(n);throw Gt({to:e?.redirect?.startsWith(`/`)?e.redirect:r})}}}),no=P({getParentRoute:()=>li,path:`sign-in`,component:Ea,beforeLoad:({context:e,location:t})=>{if(e.authentication.OverallAppSignIn?.user){let e=t?.search;throw Gt({to:e?.redirect?.startsWith(`/`)?e.redirect:`/`})}}}),ro=P({getParentRoute:()=>eo,path:`sign-up`,component:Ga}),io=P({getParentRoute:()=>eo,path:`forgot-password`,component:Aa}),ao=P({getParentRoute:()=>eo,path:`verify-email`,component:Qa}),oo=P({getParentRoute:()=>eo,path:`verifying`,component:$a}),so=P({getParentRoute:()=>eo,path:`check-oauth`,component:Xi}),co=P({getParentRoute:()=>eo,path:`reset-password`,component:Pa});eo.addChildren([to,ro,so,io,ao,oo,co]);var lo=[no];function uo({children:e}){return(0,B.jsx)(`nav`,{className:`fixed top-20 w-full h-12 z-39 py-2 px-4 md:px-12 bg-grey-700`,children:(0,B.jsxs)(`div`,{className:`flex items-center h-full space-x-2`,children:[(0,B.jsx)(ia,{}),e]})})}function fo(e){if(go(e)||_o(e))return`warning`;if(po(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 po(e){switch(e){case`RUNNING`:case`UPDATED`:return!0;default:return!1}}function mo(e){switch(e){case`FAILED`:return!0;default:return!1}}function ho(e){switch(e){case`TERMINATED`:return!0;default:return!1}}function go(e){switch(e){case`CLONE_PENDING`:return!0;default:return!1}}function _o(e){switch(e){case`PROVISIONING`:case`CLONING`:case`CLONE_READY`:case`UPDATING_HDB_NODES`:case`UPDATING`:return!0;default:return!1}}function Y({...e}){return(0,B.jsx)(Ce,{"data-slot":`dialog`,...e})}function vo({...e}){return(0,B.jsx)(Fn,{"data-slot":`dialog-trigger`,...e})}function yo({...e}){return(0,B.jsx)(De,{"data-slot":`dialog-portal`,...e})}function bo({className:e,...t}){return(0,B.jsx)(Ot,{"data-slot":`dialog-overlay`,className:g(`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 X({className:e,children:t,...n}){return(0,B.jsxs)(yo,{"data-slot":`dialog-portal`,children:[(0,B.jsx)(bo,{}),(0,B.jsxs)(ye,{"data-slot":`dialog-content`,className:g(`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,B.jsxs)(wt,{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,B.jsx)(ce,{className:`text-white`}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function xo({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`dialog-header`,className:g(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function Z({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`dialog-footer`,className:g(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function Q({className:e,...t}){return(0,B.jsx)(ut,{"data-slot":`dialog-title`,className:g(`text-lg leading-none text-white font-semibold`,e),...t})}function So({className:e,...t}){return(0,B.jsx)(xr,{"data-slot":`dialog-description`,className:g(`text-muted-foreground text-sm`,e),...t})}function Co({typeOfThingBeingDeleted:e,nameOfThingBeingDeleted:t,isModalOpen:n,hideDataLossWarning:r,setIsModalOpen:i,deletionConfirmed:a,deletionPending:o,trigger:s,presentParticiple:c=`Deleting`,transitiveVerb:l=`Delete`}){return(0,B.jsxs)(Y,{open:n,onOpenChange:i,children:[s&&(0,B.jsx)(vo,{asChild:!0,children:s}),(0,B.jsxs)(X,{className:`sm:max-w-[750px]`,children:[(0,B.jsxs)(xo,{children:[(0,B.jsxs)(Q,{children:[`Are you sure you want to `,l.toLowerCase(),` this `,e,`?`]}),(0,B.jsx)(So,{children:`This action cannot be undone.`})]}),!r&&(0,B.jsxs)(`div`,{className:`p-3 my-5 text-white rounded-md bg-amber-600`,children:[(0,B.jsxs)(`p`,{className:`flex space-x-1 font-semibold align-baseline`,children:[(0,B.jsx)(sr,{className:`inline-block size-5`}),` `,(0,B.jsx)(`span`,{children:`Warning`})]}),(0,B.jsxs)(`p`,{className:`pt-2 text-base`,children:[`By `,c.toLowerCase(),` `,e,` `,(0,B.jsx)(`span`,{className:`font-semibold`,children:t}),` `,`you will lose the data stored in it permanently.`]})]}),(0,B.jsx)(Z,{children:(0,B.jsxs)(`div`,{className:`flex justify-center space-x-5`,children:[(0,B.jsxs)(R,{className:`rounded-full`,onClick:()=>i(!1),children:[(0,B.jsx)(Pn,{}),` Cancel`]}),(0,B.jsxs)(R,{variant:`destructive`,className:`rounded-full`,onClick:a,disabled:o,children:[(0,B.jsx)(kn,{}),` `,l]})]})})]})]})}function wo({className:e,variant:t,asChild:n=!1,...r}){return(0,B.jsx)(n?tt:`span`,{"data-slot":`badge`,className:g(_i({variant:t}),e),...r})}function To({...e}){return(0,B.jsx)(kr,{"data-slot":`dropdown-menu`,...e})}function Eo({...e}){return(0,B.jsx)(Tr,{"data-slot":`dropdown-menu-trigger`,...e})}function Do({className:e,sideOffset:t=4,...n}){return(0,B.jsx)(vr,{children:(0,B.jsx)(Hn,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:g(`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 Oo({className:e,inset:t,variant:n=`default`,...r}){return(0,B.jsx)(wn,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:g(`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 ko({className:e,children:t,checked:n,...r}){return(0,B.jsxs)(Qn,{"data-slot":`dropdown-menu-checkbox-item`,className:g(`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,B.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,B.jsx)(xn,{children:(0,B.jsx)(_r,{className:`size-4`})})}),t]})}function Ao({className:e,inset:t,...n}){return(0,B.jsx)($t,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:g(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function jo({className:e,...t}){return(0,B.jsx)(an,{"data-slot":`dropdown-menu-separator`,className:g(`bg-grey-700 -mx-1 my-1 h-px`,e),...t})}function Mo(e){return!!e?.plans?.[0]?.planId?.startsWith(`self-hosted`)}function No({cluster:e}){let t=Rr(e.id),{view:n,update:r}=ki(e.organizationId,e.id),i=!m.checkForFabricConnect(e.id)&&!!t.user;if(n){if(!e.fqdn)return(0,B.jsx)(A,{to:`/${e.organizationId}/${e.id}/instances`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,B.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Instances `,(0,B.jsx)(lt,{className:`inline-block`})]})});if(e.resetPassword)return r?(0,B.jsx)(A,{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,B.jsxs)(R,{variant:`positive`,className:`py-2 hover:border-b-2 animate-glow-pulse`,children:[`Finish Setup `,(0,B.jsx)(lt,{className:`inline-block`})]})}):(0,B.jsx)(`span`,{className:`py-2 text-nowrap`,children:`Pending Owner Setup`});if(!t.isLoading)return i?(0,B.jsx)(A,{to:`/${e.organizationId}/${e.id}/`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,B.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Direct Connect `,(0,B.jsx)(lt,{className:`inline-block`})]})}):r&&!Mo(e)?(0,B.jsx)(A,{to:`/${e.organizationId}/${e.id}/`,className:`text-sm text-nowrap`,"aria-label":`Connect to ${e.name}`,title:`Connect to ${e.name}`,children:(0,B.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Fabric Connect `,(0,B.jsx)(lt,{className:`inline-block`})]})}):(0,B.jsx)(A,{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,B.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Direct Sign In `,(0,B.jsx)(lt,{className:`inline-block`})]})})}}function Po(e,t){let n=[];if(e)for(let r of e)n.push(r[t]);return n}function Fo({cluster:e,forceProgressBarVisible:t}){let[n,r]=(0,z.useState)(t||!1),{data:i}=L(ga(n&&e.id,2e3));(0,z.useEffect)(function(){(go(e.status)||_o(e.status))&&r(!0)},[n,e.status,i?.instances]);let a=(0,z.useMemo)(()=>{let e=Po(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||ho(t)||(go(t)?(n+=1,r[t]=`${n} ${na(t)}`):_o(t)?(a+=1,o[t]=`${a} ${na(t)}`):mo(t)?(l+=1,u[t]=`${l} ${na(t)}`):!i.planId||!e.includes(i.planId)?(a+=1,o.DRAINING_TRAFFIC=`${a} ${na(`Draining Traffic`)}`):po(t)&&(s+=1,c[t]=`${s} ${na(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,B.jsxs)(`div`,{className:`w-full text-center`,children:[(0,B.jsxs)(`div`,{className:`w-full h-2.5 rounded-full overflow-clip flex shadow`,children:[(0,B.jsx)(`div`,{style:{width:a.runningWidth},className:`grow bg-green/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,B.jsx)(`div`,{style:{width:a.failedWidth},className:`grow bg-red/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,B.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,B.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,B.jsx)(`div`,{className:`text-xs text-muted-foreground font-light mt-2`,children:a.text})]}):null}async function Io(e){let{data:t}=await u.delete(`/Cluster/${e}`,{timeout:0});return t}function Lo(){return I({mutationFn:e=>Io(e)})}function Ro(...e){return(0,z.useMemo)(()=>e.map(e=>(()=>{navigator.clipboard.writeText(e),N.info(`Copied to clipboard!`,{icon:(0,B.jsx)(_n,{}),duration:1e3})})),e)}function zo(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 Bo(e,t){return zo(localStorage.getItem(e))??t}function Vo(e,t){t==null?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}function Ho(e,t){let n=(0,z.useState)(Bo(e,t)),[r]=n;return(0,z.useEffect)(()=>Vo(e,r),[e,r]),n}var Uo=function(e){return e.SavedClusterState=`SavedClusterState`,e}({});function Wo({cluster:e}){let t=We(),r=Wn(),i=(0,z.useMemo)(()=>n(e),[e]),a=yi({operationsUrl:i}),o=Rr(e.id),[,s]=Ho(Uo.SavedClusterState,null),{view:c,update:l,remove:u,create:d}=ki(e.organizationId,e.id),{mutate:f,isPending:p}=Lo(),[g,_]=(0,z.useState)(!1),[v,y]=(0,z.useState)(!1),b=(0,z.useMemo)(()=>e.status&&la.includes(e.status),[e.status]),x=Mo(e),S=m.checkForFabricConnect(e.id),ee=!S&&!!o.user,te=(0,z.useMemo)(()=>e.status&&ua.includes(e.status),[e.status]),C=(0,z.useMemo)(()=>e.status&&mo(e.status),[e.status]),ne=(0,z.useCallback)(async()=>{_(!0);let t=await ha(e.id).catch(e=>(console.error(`Failed to lookup cluster details, proceeding without checking instances.`,e),null));if(await h({entityId:e.id,instanceClient:a}),t?.instances?.length)for(let e of t.instances)m.setUserForEntity(e,null);m.setUserForEntity(e,null)},[e,a]),re=(0,z.useCallback)(()=>{s(e),t.navigate({to:`/${e.organizationId}/new-cluster`})},[e,t,s]),w=(0,z.useCallback)(()=>y(!0),[]),ie=(0,z.useCallback)(()=>{let n=e.organizationId;f(e.id,{onSuccess:async()=>{await r.invalidateQueries({queryKey:[n],refetchType:`active`}),await t.invalidate(),N.success(`Success`,{description:x?`Cluster successfully removed.`:`Cluster successfully terminated.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>N.dismiss()}}),y(!1)},onError:()=>{N.error(`Error`,{description:x?`Failed to remove cluster: ${e.name}`:`Failed to terminate cluster: ${e.name}.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>N.dismiss()}}),y(!1)}})},[t,e.organizationId,e.id,e.name,f,x,r]),ae=e.domains?.[0]?.domain||e.fqdn,[oe,T]=Ro(`${ae}`,`https://${ae}`),E=[b&&l&&!o.isLoading&&(!ee||S)&&(0,B.jsx)(A,{to:`${e.id}/sign-in`,disabled:g,children:(0,B.jsxs)(Oo,{children:[(0,B.jsx)(je,{className:`text-green`}),` Direct Sign In`]})},`sign-in`),b&&l&&(0,B.jsx)(A,{to:`${e.id}/edit`,disabled:g,children:(0,B.jsxs)(Oo,{children:[(0,B.jsx)($n,{className:`text-purple-600`}),` Edit Scaling`]})},`edit`),b&&l&&(0,B.jsx)(A,{to:`${e.id}/edit/version`,disabled:g,children:(0,B.jsxs)(Oo,{children:[(0,B.jsx)(It,{className:`text-fuchsia-300`}),` Edit Version`]})},`edit`),b&&l&&!1,b&&c&&(0,B.jsx)(A,{to:`${e.id}/instances`,disabled:g,children:(0,B.jsxs)(Oo,{children:[(0,B.jsx)(yn,{className:`text-orange-300`}),` Instances`]})},`instances`),b&&c&&e.fqdn&&(0,B.jsx)(jo,{},`copy-separator`),b&&c&&e.fqdn&&(0,B.jsxs)(Oo,{onClick:oe,disabled:g,children:[(0,B.jsx)(dn,{}),` Copy Host Name`]},`copy-host-name`),b&&c&&e.fqdn&&(0,B.jsxs)(Oo,{onClick:T,disabled:g,children:[(0,B.jsx)(dn,{}),` Copy API URL`]},`copy-api-url`),b&&c&&!!i&&!o.isLoading&&ee&&(0,B.jsx)(Oo,{onClick:ne,disabled:g,children:`Direct Sign Out`},`direct-sign-out`),C&&d&&(0,B.jsx)(Oo,{className:`focus:bg-green/70 focus:text-white`,onClick:re,children:`Try Again`},`try-again`),!te&&u&&b&&(0,B.jsx)(jo,{},`remove-separator`),!te&&u&&(0,B.jsxs)(Oo,{className:`focus:bg-red/70 focus:text-white`,onClick:w,children:[(0,B.jsx)(kn,{className:`text-red-300`}),` `,x?`Remove`:`Terminate`]},`remove`)].filter(ri);return(0,B.jsxs)(Gr,{className:`relative h-full justify-between`,children:[(0,B.jsxs)(Kr,{children:[(0,B.jsxs)(Jr,{className:`flex items-center justify-between`,children:[ae?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`truncate max-w-48`,children:ae}),(0,B.jsx)(tn,{onClick:oe,size:16,className:`cursor-pointer`}),(0,B.jsx)(`span`,{className:`grow`})]}):(0,B.jsx)(`span`,{children:`Self-Hosted`}),!te&&(0,B.jsxs)(To,{children:[(0,B.jsx)(Eo,{children:(0,B.jsx)(fr,{"aria-label":`Cluster options`})}),(0,B.jsx)(Do,{children:[...E]})]})]}),(0,B.jsx)(qr,{children:(0,B.jsx)(`h2`,{children:e.name})})]}),(0,B.jsxs)(Yr,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(Fo,{cluster:e}),b&&c&&(0,B.jsx)(No,{cluster:e}),C&&e.status&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(wo,{variant:fo(e.status),children:na(e.status)}),(0,B.jsx)(`span`,{className:`text-xs`,children:`Click "..." to choose how to proceed.`})]})]}),(0,B.jsx)(Co,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:x?`Remove`:`Terminate`,presentParticiple:x?`Removing`:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:v,hideDataLossWarning:x,setIsModalOpen:e=>y(e),deletionConfirmed:ie,deletionPending:p})]})}function Go({overEmail:e}){return(0,B.jsx)(`a`,{href:e?`mailto:support@harperdb.io`:`https://discord.com/channels/1415002037439041710/1415002038286286994`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Contact us`})}function Ko({className:e,text:t,centered:n,...r}){return(0,B.jsxs)(`div`,{className:`text-white h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,B.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,B.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function qo({children:e,className:t}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] relative ${t??``}`,children:e})]})}async function Jo(e){let{data:t}=await u.get(`/Plan/`,{params:{organizationId:e}});return t}function Yo(e){return M({queryKey:[e,`instancePlan`],queryFn:()=>Jo(e),retry:!1})}async function Xo(){let{data:e}=await u.get(`/HarperVersions/`);return e}function Zo(){return M({queryKey:[`HarperVersions`],queryFn:Xo,staleTime:6e4,retry:!1})}async function Qo({organizationId:e,availableHosts:t}={}){let{data:n}=await u.get(`/Region/`,{params:{availableHosts:t,organizationId:e}});return n}function $o({organizationId:e,availableHosts:t}={}){return M({queryKey:[e,`regionLocations`,t],queryFn:()=>Qo({organizationId:e,availableHosts:t}),retry:!1})}function es(e){return(t,n)=>t[e]===n[e]?0:t[e]>n[e]?1:-1}function ts(e){let t=e.split(`.`).map(Number);return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0}function ns(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 rs(e,t){return e.instanceFqdn===t.instanceFqdn?e.operationsApiPort-t.operationsApiPort:ns(e.instanceFqdn)&&ns(t.instanceFqdn)?ts(e.instanceFqdn)-ts(t.instanceFqdn):e.instanceFqdn>t.instanceFqdn?1:-1}function is(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 as(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=is(e,t),i={};for(let e in r)i[e]=as(r[e],n);return i}function ss(e,t){let n=ls(e),r=ls(t);return!n||!r?!1:fs(r,n)>=0}function cs(e,t){let n=ls(e),r=ls(t);return!n&&!r?0:n?r?fs(n,r):1:-1}function ls(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=us(a[0]),s=us(a[1]??`0`),c=us(a[2]??`0`);return o==null||s==null||c==null?null:{major:o,minor:s,patch:c,pre:i?i.split(`.`).map(e=>ds(e)?Number(e):e):[]}}function us(e){return e==null||e===``||!/^\d+$/.test(e)?null:Number(e)}function ds(e){return/^\d+$/.test(e)}function fs(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 ps({width:e,className:t,animated:n,placeholder:r}){return(0,B.jsxs)(`div`,{className:C(`w-full bg-gray-200 rounded-full relative`,r?`h-6`:`h-2.5`),children:[r&&(0,B.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,B.jsx)(`div`,{className:C(`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 ms({duration:e,message:t,lateMessage:n}){let r=(0,z.useRef)(0),i=(0,z.useRef)(0),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(`5%`),l=(0,z.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,z.useEffect)(()=>(r.current=requestAnimationFrame(l),()=>cancelAnimationFrame(r.current)),[l]),(0,B.jsxs)(B.Fragment,{children:[a?n:t,(0,B.jsx)(ps,{width:s,animated:!1})]})}async function hs(e){let{data:t}=await u.post(`/Cluster/`,e,{timeout:0});return t}function gs(){return I({mutationFn:e=>hs(e)})}async function _s(e){let{id:t,...n}=e,{data:r}=await u.put(`/Cluster/${t}`,n,{timeout:0});return r}function vs(){return I({mutationFn:e=>_s(e)})}async function ys(e){let{data:t}=await u.get(`/Organization/${e}`);return t}function bs(e){return M({queryKey:[e],queryFn:()=>ys(e),retry:!1,refetchInterval:1e4})}var xs=`ENTERPRISE`;function Ss(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 Cs(e,t,n=`-`){let r=t.split(n)[0];return e.findIndex(e=>e.startsWith(r))!==-1}function ws(e){return e.replace(/[^a-zA-Z0-9]/g,`-`).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase().replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}async function Ts(e){await u.put(`/Payment/`,e)}function Es(){return I({mutationFn:e=>Ts(e)})}function Ds(e){let{mutate:t}=Es();return(0,z.useCallback)((n,r)=>{t({paymentMethodId:typeof n==`string`?n:n.id,organizationId:e},{onSuccess:()=>{N.success(`Success! Your payment method has been saved.`),r(!0)},onError:()=>{N.error(`Failed to process payment method details. Please try another payment method.`),r(!1)}})},[t,e])}var Os=(0,z.createContext)(null);function ks(){return(0,z.useContext)(Os)}function As({hasExistingBilling:e,onPaymentAdded:t,onSaveStateForBillingRedirect:n}){let{organizationId:r}=j({strict:!1}),i=vn(),a=ks(),o=fn(),[s,c]=(0,z.useState)(!1),l=Ds(r),u=(0,z.useCallback)(()=>{t(!1)},[t]);return(0,B.jsxs)(`form`,{id:`billing-add-payment-method-form`,name:`billing-add-payment-method-form`,onSubmit:(0,z.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),N.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,B.jsx)(hr,{}),(0,B.jsx)(zn,{options:{mode:`billing`}}),(0,B.jsxs)(`div`,{className:`mt-4 flex gap-8 items-center`,children:[(0,B.jsxs)(R,{disabled:!i||!o||s,variant:`submit`,className:`rounded-full`,children:[(0,B.jsx)(Un,{}),` Add Payment Method`]}),e&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`text-xs text-gray-600`,children:`Your existing payment method will be overwritten.`}),(0,B.jsx)(R,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Cancel`})]})]})]})}async function js(e){let{data:t}=await u.post(`/StripeAccount/`,e);return t}function Ms(){return I({mutationFn:e=>js(e)})}async function Ns(e){let{data:t}=await u.post(`/Payment/`,{organizationId:e.organizationId});return t}function Ps(){return I({mutationFn:e=>Ns(e)})}function Fs(e){let{enabled:t,existingStripeId:n,organizationId:r}=e,{mutate:i}=Ms(),{mutate:a}=Ps(),[o,s]=(0,z.useState)(void 0);return(0,z.useEffect)(()=>{},[i,t,n,a,(0,z.useCallback)(e=>{s(e.clientSecret)},[]),r]),o}function Is({children:e}){let{organizationId:t}=j({strict:!1}),{data:n}=L(bs(t)),r=Fs({organizationId:t,enabled:!!n,existingStripeId:n?.stripeId});return(0,z.useMemo)(()=>({clientSecret:r||``,appearance:{theme:`night`}}),[r]),console.error(`No VITE_PUBLIC_STRIPE_KEY is configured for this environment.`),(0,B.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 Ls({onPaymentAdded:e,onSaveStateForBillingRedirect:t}){let{organizationId:n}=j({strict:!1}),{data:r}=L(bs(n)),i=r?.billing,a=i?.paymentMethod;return(0,B.jsxs)(Is,{children:[(0,B.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,B.jsx)(As,{hasExistingBilling:!!i,onSaveStateForBillingRedirect:t,onPaymentAdded:e})]})}var Rs=function(e){return e.PASS=`pass`,e.FAIL=`fail`,e.PENDING=`pending`,e.ERROR=`error`,e}({});function zs(e){switch(e){case Rs.PASS:return`success`;case Rs.FAIL:case Rs.ERROR:return`destructive`;case Rs.PENDING:default:return`default`}}function Bs(e){switch(e){case Rs.PASS:return`READY`;case Rs.FAIL:case Rs.ERROR:case Rs.PENDING:default:return e.toUpperCase()}}function Vs(e,t){return`${String(e).padStart(2,`0`)}/${String(t%100).padStart(2,`0`)}`}function Hs(e){let{onSaveStateForBillingRedirect:t,onReplacingPaymentMethod:n}=e??{},{organizationId:r}=j({strict:!1}),{update:i}=Di(r),{data:a,refetch:o}=L(bs(r)),s=a?.billing?.paymentMethod,[c,l]=(0,z.useState)(!1),u=(0,z.useCallback)(()=>{l(!c),n?.(!c)},[n,c]),d=(0,z.useCallback)(e=>{l(!1),n?.(!1),e&&o()},[n,o]);return a?.type===`ENTERPRISE`?(0,B.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,B.jsx)(Go,{}),`, we would love to talk!`]}):s&&!c?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`mt-2`,children:[s.brand?.toUpperCase()??`Card`,` ending in `,s.last4??`••••`,s.expMonth&&s.expYear?(0,B.jsxs)(B.Fragment,{children:[`(exp `,Vs(s.expMonth,s.expYear),`)`]}):null,s.status?(0,B.jsxs)(B.Fragment,{children:[`—`,` `,(0,B.jsx)(wo,{variant:zs(s.status),children:Bs(s.status)})]}):null]}),i&&(0,B.jsx)(`div`,{className:`mt-2 mb-6`,children:(0,B.jsx)(R,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Replace Payment Method`})})]}):i?(0,B.jsx)(Ls,{onSaveStateForBillingRedirect:t,onPaymentAdded:d}):(0,B.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 Us(e){return e!==void 0&&e>0}function Ws({clusterId:e,isPending:t,onGoBackToDetails:n,onSaveStateForBillingRedirect:r,onSubmit:i,organizationId:a,selectedPlan:o}){let{data:s}=L(bs(a)),c=s?.billing,l=s?.type===xs,u=l||c?.paymentMethod?.status===Rs.PASS,[d,f]=(0,z.useState)(!1),m=Us(o?.planLimits?.expirationMonths)&&o.planLimits.expirationMonths<1e3&&o.planLimits.expirationMonths,h=(0,B.jsx)(B.Fragment,{children:(0,B.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end mt-3 max-w-xl`,children:[(0,B.jsxs)(R,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,disabled:t,onClick:n,children:[(0,B.jsx)(Pn,{}),` Back to Details`]}),(0,B.jsxs)(R,{disabled:t||!u||d,type:`submit`,variant:`submit`,className:`rounded-full`,onClick:i,children:[e?`Edit Cluster`:`Create New Cluster`,` `,(0,B.jsx)(lt,{})]})]})});if(l)return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`ul`,{className:`list-disc ml-6 max-w-lg`,children:[(0,B.jsx)(`li`,{children:`Reminder: you will be billed at your contracted rate for any additional infrastructure.`}),(0,B.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,B.jsx)(Go,{overEmail:!0}),`, we are here to help.`]})]}),h]});let g=m&&`, or ${p(m,`month`,`months`)} elapse`;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`ul`,{className:`list-disc ml-6 mb-6`,children:[(0,B.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,B.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,B.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,B.jsxs)(`li`,{children:[`When that block is used up`,g,`, you will be automatically renewed.`]}),(0,B.jsx)(`li`,{children:`While refunds are not available, we’d be happy to assist you with troubleshooting.`}),(0,B.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,B.jsx)(Go,{overEmail:!0}),`, we are here to help.`]})]}),(0,B.jsx)(`p`,{className:`text-muted-foreground text-sm mb-6`,children:`Payment method:`}),(0,B.jsx)(Hs,{onSaveStateForBillingRedirect:r,onReplacingPaymentMethod:f}),h]})}var Gs=/(^$|^(?: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,Ks=65535,qs=w().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.`),Js=T({clusterName:w().nonempty(`Please enter a cluster name.`).max(255,`Cluster name cannot be longer than 255 characters long.`),abbreviatedName:se([S(``),y(),qs]),fqdn:w().regex(Gs,`Please enter a valid host name without the port or any path.`).optional(),version:w().optional(),deploymentDescription:w().nonempty(`Please select a deployment tier.`),performanceDescription:w().nonempty(`Please select a performance tier.`),regionPlans:te(T({regionName:w().nonempty(`Please select a region.`),latencyDescription:w().nonempty(`Please select a latency tier.`)})).max(50,{error:`A maximum of 50 regions can be selected for each cluster. `}),instances:te(T({secure:b([`true`,`false`]),fqdn:w().nonempty(`Please enter the host name of your instance.`).regex(Gs,`Please enter a valid host name without the port or any path.`),port:ae().min(0,`Positive thinking only, please.`).max(Ks,`That port number is too high.`).optional()})).max(100,{error:`A maximum of 100 instances can be added to each cluster.`}),skipToBilling:E().optional(),skipGtmWait:E().optional(),sourceClusterId:w().optional()});function Ys({calculatedNames:e,disabled:t,form:n}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(W,{control:n.control,name:`abbreviatedName`,render:({field:n})=>(0,B.jsxs)(G,{className:`col-span-3`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Host Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{...n,type:`text`,maxLength:qs.maxLength,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:e.suggestedAbbreviatedName,disabled:t})}),(0,B.jsx)(q,{})]})}),(0,B.jsxs)(G,{className:`col-span-3 `,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Full Host Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(`span`,{children:e.fullHostName})}),(0,B.jsx)(q,{})]})]})}function Xs({className:e}={}){return(0,B.jsx)(`div`,{className:(0,z.useMemo)(()=>C(`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 Zs({...e}){return(0,B.jsx)(or,{"data-slot":`select`,...e})}function Qs({...e}){return(0,B.jsx)(Wt,{"data-slot":`select-group`,...e})}function $s({...e}){return(0,B.jsx)(lr,{"data-slot":`select-value`,...e})}function ec({className:e,children:t,...n}){return(0,B.jsxs)(Yn,{"data-slot":`select-trigger`,className:g(`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,B.jsx)(Zt,{asChild:!0,children:(0,B.jsx)(Qt,{className:`opacity-50 size-4`})})]})}function tc({className:e,children:t,position:n=`popper`,...r}){return(0,B.jsx)(Kn,{children:(0,B.jsxs)(Jt,{"data-slot":`select-content`,className:g(`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,B.jsx)(rc,{}),(0,B.jsx)(ln,{className:g(`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,B.jsx)(ic,{})]})})}function nc({className:e,...t}){return(0,B.jsx)(pr,{"data-slot":`select-label`,className:g(`px-2 py-1.5 text-sm font-medium`,e),...t})}function $({className:e,children:t,...n}){return(0,B.jsxs)(vt,{"data-slot":`select-item`,className:g(`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,B.jsx)(hn,{children:t}),(0,B.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,B.jsx)(ue,{children:(0,B.jsx)(_r,{className:`size-4`})})})]})}function rc({className:e,...t}){return(0,B.jsx)(nn,{"data-slot":`select-scroll-up-button`,className:g(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,B.jsx)(bn,{className:`size-4`})})}function ic({className:e,...t}){return(0,B.jsx)(On,{"data-slot":`select-scroll-down-button`,className:g(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,B.jsx)(Qt,{className:`size-4`})})}var ac={Colocated:`Shared infrastructure for optimized value`,Dedicated:`Dedicated infrastructure for consistent performance`,"Self-Hosted":`Your own infrastructure`};function oc({availableDeploymentTypes:e,disabled:t,form:n}){return(0,B.jsx)(W,{control:n.control,name:`deploymentDescription`,render:({field:r})=>(0,B.jsxs)(G,{className:`col-span-3`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Harper Deployment`}),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(Xs,{}),children:(0,B.jsx)(U,{children:(0,B.jsxs)(Zs,{...r,disabled:t,onValueChange:e=>{r.onChange(e),n.trigger()},children:[(0,B.jsx)(ec,{className:`w-full h-auto`,children:(0,B.jsx)($s,{placeholder:`Choose Tier`})}),(0,B.jsx)(tc,{children:(0,B.jsx)(Qs,{children:e.map(e=>(0,B.jsxs)($,{value:e,children:[(0,B.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e}),ac[e]&&(0,B.jsx)(`dd`,{className:`font-light`,children:ac[e]})]},e))})})]})})}),(0,B.jsx)(q,{})]})})}function sc({disabled:e,form:t}){return(0,B.jsx)(W,{control:t.control,name:`fqdn`,render:({field:t})=>(0,B.jsxs)(G,{className:`md:col-span-6 col-span-3`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Optional Cluster Load Balancer Host Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{...t,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:`example.your-company.com`,disabled:e})}),(0,B.jsx)(q,{})]})})}function cc({className:e,disabled:t,form:n}){return(0,B.jsx)(W,{control:n.control,name:`clusterName`,render:({field:n})=>(0,B.jsxs)(G,{className:e,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Cluster Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{autoFocus:!0,type:`text`,maxLength:Js.shape.clusterName.maxLength,autoCapitalize:`words`,disabled:t,...n})}),(0,B.jsx)(q,{})]})})}function lc({availablePerformanceDescriptions:e,form:t,selectedDeployment:n}){return(0,B.jsx)(W,{control:t.control,name:`performanceDescription`,render:({field:r})=>(0,B.jsxs)(G,{className:`col-span-3`,children:[(0,B.jsxs)(K,{className:`pb-1`,children:[n.startsWith(`Self`)?`Support`:`Performance`,` & Usage`]}),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(Xs,{}),children:(0,B.jsx)(U,{children:(0,B.jsxs)(Zs,{...r,onValueChange:e=>{r.onChange(e),t.trigger()},disabled:!e?.length,children:[(0,B.jsx)(ec,{className:`w-full h-auto`,children:(0,B.jsx)($s,{placeholder:`Choose Tier`})}),(0,B.jsx)(tc,{children:(0,B.jsx)(Qs,{children:e.map(e=>(0,B.jsxs)($,{value:e.performanceTier,children:[(0,B.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e.name}),e.description&&(0,B.jsx)(`dd`,{className:`font-light`,children:e.description})]},e.name))})})]})})}),(0,B.jsx)(q,{})]})})}function uc({className:e,...t}){let{formDescriptionId:n}=sa();return(0,B.jsx)(`p`,{"data-slot":`form-description`,id:n,className:g(`text-muted-foreground text-sm`,e),...t})}function dc({className:e,form:t}){return(0,B.jsx)(W,{control:t.control,name:`skipGtmWait`,render:({field:t})=>(0,B.jsxs)(G,{className:e,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(U,{children:(0,B.jsx)(J,{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,B.jsx)(K,{className:`cursor-pointer`,children:`Immediate upgrade and restart`})]}),(0,B.jsx)(uc,{children:`Apply changes immediately without waiting for each instance to be taken out of the load balancer (faster, but potentially less safe).`})]})})}function fc({className:e,disabled:t,form:n,harperVersions:r}){return r?.value?.length?(0,B.jsx)(W,{control:n.control,name:`version`,render:({field:i})=>(0,B.jsxs)(G,{className:e,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Harper Version`}),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(Xs,{}),children:(0,B.jsx)(U,{children:(0,B.jsxs)(Zs,{...i,disabled:t,onValueChange:e=>{i.onChange(e),n.trigger()},children:[(0,B.jsx)(ec,{className:`w-full h-auto`,children:(0,B.jsx)($s,{placeholder:`Choose Version`})}),(0,B.jsx)(tc,{children:(0,B.jsx)(Qs,{children:r?.value.map(e=>(0,B.jsxs)($,{value:e.version,children:[e.version,` `,(0,B.jsx)(`span`,{className:`font-light opacity-50`,children:e.name})]},e.version))})})]})})}),(0,B.jsx)(q,{})]})}):null}var pc=new RegExp(/^\d+/);function mc(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 hc=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],gc=[`secs`,`mins`,`hrs`],_c={bytes:1e3,secs:60};function vc(e,t,n){let r,i;switch(t){case`bytes`:r=hc,i=_c.bytes;break;case`secs`:r=gc,i=_c.secs;break;default:return e}let a=r.indexOf(n);return a===-1?e:e/i**a}function yc(e,t){let n,r;switch(e){case`bytes`:n=hc,r=_c.bytes;break;case`secs`:n=gc,r=_c.secs;break;default:return e}let i=0;for(;t>=r&&i<n.length-1;)t/=r,i++;return n[i]}function bc(e,t=1){let n=e*t,r=yc(`bytes`,n),i=vc(n,`bytes`,r);return`${new Intl.NumberFormat().format(Math.round(i))} ${r}`}function xc(e){return new Intl.NumberFormat().format(e)}var Sc=[`K`,`M`,`B`,`T`,`Qa`,`Qi`,`Sx`,`Sp`,`Oc`,`No`,`Dc`];function Cc(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<Sc.length-1);return`${xc(Math.round(n))} ${Sc[r]}`}function wc({selectedPlan:e,selectedRegion:t,isEnterprise:n}){let[r,i]=(0,z.useState)(!1),a=(0,z.useCallback)(()=>{i(!r)},[r,i]),o=e?.planLimits,s=e?.resourcesPerInstance,c=Us(o?.expirationMonths)&&o.expirationMonths<1e3&&o.expirationMonths,l=t?.purchasedBlockMultiplier??1,u=(0,z.useMemo)(()=>o?[Us(o.totalReadCount)&&{label:`Total Reads`,value:`${Cc(o.totalReadCount*l)} reads`},Us(o.totalReadsBytes)&&{label:`Total Read Transfer`,value:`${bc(o.totalReadsBytes*l)}`},Us(o.readsPerMinuteCount)&&{label:`Read Rate`,value:`${Cc(o.readsPerMinuteCount*60*l)}/min`},Us(o.readsPerMinuteBytes)&&{label:`Read Bandwidth`,value:`${bc(o.readsPerMinuteBytes*60*l)}/min`},Us(o.totalWriteCount)&&{label:`Total Writes`,value:`${Cc(o.totalWriteCount)} reads`},Us(o.totalWritesBytes)&&{label:`Total Write Transfer`,value:`${bc(o.totalWritesBytes)}`},Us(o.writesPerMinuteCount)&&{label:`Write Rate`,value:`${Cc(o.writesPerMinuteCount*60)}/min`},Us(o.writesPerMinuteBytes)&&{label:`Write Bandwidth`,value:`${bc(o.writesPerMinuteBytes*60)}/min`},Us(o.totalRealTimeMessageDeliveries)&&{label:`Total Real-Time Messages`,value:`${Cc(o.totalRealTimeMessageDeliveries*l)} messages`},Us(o.totalRealTimeMessageDeliveryBytes)&&{label:`Total Real-Time Message Transfer`,value:`${bc(o.totalRealTimeMessageDeliveryBytes*l)}`},Us(o.realTimeMessageDeliveriesPerMinute)&&{label:`Real-Time Message Rate`,value:`${Cc(o.realTimeMessageDeliveriesPerMinute*60*l)}/min`},Us(o.realTimeMessageDeliveryBytesPerMinute)&&{label:`Real-Time Message Bandwidth`,value:`${bc(o.realTimeMessageDeliveryBytesPerMinute*60*l)}/min`},Us(o.tlsHandshakes)&&{label:`TLS Handshakes`,value:`${Cc(o.tlsHandshakes*60*l)}`},Us(o.applicationComputeHours)&&{label:`Application Compute Hours`,value:`${Cc(o.applicationComputeHours*l)}`},!!s&&Us(s.storageGb)&&{label:`Storage`,value:`${bc(s.storageGb*1e9)}`},!!c&&{label:`Expiration`,value:p(c,`month`,`months`)},!!t?.id&&{label:`Region ID`,value:t.id},!!e?.id&&{label:`Plan ID`,value:e.id}].filter(ri):[],[c,t,e,l]);if(!o)return``;if(!Us(o.totalReadCount))return`This plan has no usage limits.`;let d=n?` Pricing subject to contracted rate.`:` Beta pricing subject to change.`,f=Us(o.readsPerMinuteCount)?`${Cc(o.readsPerMinuteCount*l)} reads/min & `:``,m=Us(o.writesPerMinuteCount)?` ${Cc(o.writesPerMinuteCount)} writes/min & `:` `,h=Us(o.readsPerMinuteCount)?`in ${t?.region??``} region${t?` (${t?.id})`:``}`:`per server`,_=c?`, for ${p(c,`month`,`months`)}`:``,v=n?`for the contracted rate`:`for the price listed above`,y=c?` in ${p(c,`month`,`months`)} or`:``;return(0,B.jsxs)(G,{className:`basis-full`,children:[(0,B.jsxs)(K,{onClick:a,children:[(0,B.jsx)(`em`,{className:`text-muted-foreground`,children:e?.id}),` Purchasing usage block for `,f,Cc(o.totalReadCount*l),` total reads `,h,`,`,(0,B.jsx)(`br`,{className:`hidden sm:block`}),m,` `,Cc(o.totalWriteCount),` total writes`,_,`.`,d,(0,B.jsx)(`br`,{className:`block sm:hidden`}),(0,B.jsxs)(R,{type:`button`,variant:`link`,className:`text-white`,children:[`Learn More `,r?(0,B.jsx)(de,{}):(0,B.jsx)(lt,{})]})]}),(0,B.jsx)(U,{children:(0,B.jsxs)(`dl`,{className:g(`divide-y divide-black overflow-hidden transition-[max-height] duration-200 ease-in`,r?`max-h-fit`:`max-h-0`),children:[(0,B.jsxs)(`div`,{className:`text-sm mb-3 max-w-lg`,children:[`This plan licenses Harper for the usage limits below, `,v,`. The usage license expires`,y,` `,`when any usage limit is reached. New usage blocks are automatically purchased/billed as blocks are consumed.`]}),u.map((e,t)=>(0,B.jsxs)(`div`,{className:g(`px-4 py-1 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-3`,t%2==0&&`bg-gray-700`),children:[(0,B.jsx)(`dt`,{className:`text-sm/6 font-medium text-gray-300`,children:e.label}),(0,B.jsx)(`dd`,{className:`mt-1 text-sm/6 sm:col-span-2 sm:mt-0`,children:e.value})]},e.label))]})}),(0,B.jsx)(q,{})]})}function Tc({control:e,fieldArray:t,form:n,index:r,regionNameToLatencyToRegion:i,selectedPlan:a,isEnterprise:o}){let s=(0,z.useMemo)(()=>Object.keys(i).sort(),[i]),c=n.watch(`deploymentDescription`)?.startsWith(`Dedicated`),l=n.watch(`regionPlans.${r}.regionName`),u=n.watch(`regionPlans.${r}.latencyDescription`),d=(0,z.useMemo)(()=>Object.keys(i[l]||{}).sort(mc).reverse(),[i,l]);(0,z.useEffect)(function(){if(l&&d?.length&&!d?.includes(u)){let e=u?.split(` `)[0].toLowerCase(),t=d.find(t=>e?t.split(` `)[0].toLowerCase()===e:!0)||d[0];n.setValue(`regionPlans.${r}.latencyDescription`,t),n.trigger()}},[d,n,r,u,l]);let f=(0,z.useCallback)(()=>{t?.remove(r),n.trigger()},[t,n,r]);return(0,B.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,B.jsx)(W,{control:e,name:`regionPlans.${r}.regionName`,render:({field:e})=>(0,B.jsxs)(G,{className:`flex-1`,children:[(0,B.jsxs)(K,{children:[`Region `,t.fields.length>1?r+1:``]}),(0,B.jsx)(U,{children:(0,B.jsxs)(Zs,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,children:[(0,B.jsx)(ec,{className:`w-full`,children:(0,B.jsx)($s,{placeholder:`Choose Region`})}),(0,B.jsx)(tc,{children:(0,B.jsx)(Qs,{children:s.map(e=>(0,B.jsx)($,{value:e,children:e},e))})})]})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e,name:`regionPlans.${r}.latencyDescription`,render:({field:e})=>(0,B.jsxs)(G,{className:`flex-1`,children:[(0,B.jsxs)(K,{children:[`Estimated `,c?`P95`:`P90`,` Latency, Distribution`]}),(0,B.jsx)(U,{children:(0,B.jsxs)(Zs,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,disabled:!d?.length,children:[(0,B.jsx)(ec,{className:`w-full`,children:(0,B.jsx)($s,{placeholder:`Choose Latency Tier`})}),(0,B.jsx)(tc,{children:(0,B.jsx)(Qs,{children:d.map(e=>(0,B.jsx)($,{value:e,children:e},e))})})]})}),(0,B.jsx)(q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,B.jsx)(`div`,{className:`flex-none mt-6`,children:(0,B.jsxs)(R,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:f,children:[(0,B.jsx)(kn,{}),` `,(0,B.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})}),(0,B.jsx)(wc,{selectedPlan:a,selectedRegion:i[l]?.[u],isEnterprise:o})]})}function Ec({form:e,regionLocations:t,regionNameToLatencyToRegion:n,selectedPlan:r,totalPrice:i,isEnterprise:a}){let o=e.watch(`regionPlans`),s=mt({control:e.control,name:`regionPlans`}),c=(0,z.useMemo)(()=>{let e=o.map(e=>n?.[e.regionName]?.[e.latencyDescription]?.region);return i?t?.find(t=>!e.includes(t.region)):null},[t,n,o,i]),l=(0,z.useCallback)(()=>{c&&(s.append({regionName:c.region,latencyDescription:c.latencyDescription}),e.trigger())},[e,c,s]);return t?.length?(0,B.jsxs)(B.Fragment,{children:[s.fields.map((t,i)=>(0,B.jsx)(Tc,{control:e.control,fieldArray:s,form:e,index:i,regionNameToLatencyToRegion:n,selectedPlan:r,isEnterprise:a},t.id)),c&&(0,B.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,B.jsxs)(R,{type:`button`,variant:`positiveOutline`,className:`rounded-full`,onClick:l,children:[(0,B.jsx)(on,{}),`Add Additional Region Usage`]})})]}):(0,B.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,B.jsx)(Qr,{className:`mt-0 m-0`,title:`No Regions Available`,showReturnToHome:!1,error:{message:(0,B.jsxs)(B.Fragment,{children:[`The deployment type you selected currently has no available regions. Please try a different deployment type, try again later, or `,(0,B.jsx)(Go,{}),`.`]})}})})}function Dc({control:e,fieldArray:t,form:n,index:r}){let i=(0,z.useCallback)(()=>{t?.remove(r)},[t,r]);return(0,B.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,B.jsx)(W,{control:e,name:`instances.${r}.secure`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsxs)(K,{children:[`Instance `,t.fields.length>1?r+1:``]}),(0,B.jsx)(U,{children:(0,B.jsxs)(Zs,{...e,onValueChange:t=>{e.onChange(t),n.trigger()},children:[(0,B.jsx)(ec,{className:`w-full`,children:(0,B.jsx)($s,{placeholder:`https://`})}),(0,B.jsx)(tc,{children:(0,B.jsxs)(Qs,{children:[(0,B.jsx)($,{value:`true`,children:`https://`}),(0,B.jsx)($,{value:`false`,children:`http://`})]})})]})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e,name:`instances.${r}.fqdn`,render:({field:e})=>(0,B.jsxs)(G,{className:`flex-3`,children:[(0,B.jsx)(K,{children:`Host Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{...e,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e,name:`instances.${r}.port`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Operations API Port`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{...e,type:`number`,min:0,max:Ks,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:String(o),onChange:t=>{e.onChange(t.target.value?parseInt(t.target.value,10):void 0),n.trigger()}})}),(0,B.jsx)(q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,B.jsx)(`div`,{className:`flex-none mt-6`,children:(0,B.jsxs)(R,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:i,children:[(0,B.jsx)(kn,{}),` `,(0,B.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})})]})}function Oc({form:e}){let t=mt({control:e.control,name:`instances`}),n=(0,z.useCallback)(()=>{t.append({secure:`true`,fqdn:``,port:o})},[t]);return(0,B.jsxs)(B.Fragment,{children:[t.fields.map((n,r)=>(0,B.jsx)(Dc,{control:e.control,fieldArray:t,form:e,index:r},n.id)),(0,B.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,B.jsxs)(R,{type:`button`,variant:`positiveOutline`,className:`rounded-full`,onClick:n,children:[(0,B.jsx)(on,{}),`Add Instance`]})})]})}function kc({calculatedNames:e,clusterId:t,deploymentToPerformanceToPlan:n,form:r,harperVersions:i,isEnterprise:a,isPending:o,mode:s,regionLocations:c,regionNameToLatencyToRegion:l,selectedDeployment:u,selectedPerformance:d,selectedPlan:f,totalPrice:p}){let{isDirty:m,isValid:h}=Qe(),g=(0,z.useMemo)(()=>Object.keys(n[u]||{}).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,u]),_=(0,z.useMemo)(()=>Object.keys(n).sort(),[n]);(0,z.useEffect)(function(){g?.length&&!g.find(e=>e.performanceTier===d)&&(r.setValue(`performanceDescription`,g[0].performanceTier),r.trigger())},[u,d,g,r]);let v=u===`Self-Hosted`,y=(0,B.jsx)(Z,{className:`mt-3 mb-12`,children:(0,B.jsxs)(R,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:o||t&&!m||!h,children:[s!==`version`&&p>0?`Confirm Payment Details`:t?`Edit Cluster`:`Create New Cluster`,(0,B.jsx)(lt,{})]})});return s===`version`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-6 text-white md:grid-cols-6`,children:[(0,B.jsx)(cc,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!0,form:r}),(0,B.jsx)(fc,{className:`col-span-3`,form:r,harperVersions:i}),(0,B.jsx)(dc,{className:`col-span-3 md:col-span-6`,form:r})]}),y]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-6 text-white md:grid-cols-6`,children:[(0,B.jsx)(cc,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!!t,form:r}),(0,B.jsx)(fc,{className:`col-span-3`,disabled:!!t,form:r,harperVersions:i}),v?(0,B.jsx)(sc,{form:r,disabled:!!t}):(0,B.jsx)(Ys,{form:r,calculatedNames:e,disabled:!!t}),(0,B.jsx)(oc,{form:r,availableDeploymentTypes:_}),(0,B.jsx)(lc,{availablePerformanceDescriptions:g,form:r,selectedDeployment:u}),v?(0,B.jsx)(Oc,{form:r}):(0,B.jsx)(Ec,{form:r,regionLocations:c,regionNameToLatencyToRegion:l,selectedPlan:f,totalPrice:p,isEnterprise:a}),t&&(0,B.jsx)(dc,{className:`col-span-3 md:col-span-6`,form:r})]}),y]})}function Ac(e){let{fqdn:t}=e,{secure:n,port:r}=e;return r||=o,r===443&&n===`false`&&(n=`true`),r===80&&n===`true`&&(n=`false`),`${n===`true`?`https`:`http`}://${t}${r===443||r===80?``:`:`+r}`.toLowerCase()}function jc(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 Mc(e,t,n){if(t&&n){let r=e.getValues();if(!r.deploymentDescription||!r.performanceDescription||!r.regionPlans.length){let i=jc(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 Nc({price:e}){return(0,B.jsx)(`span`,{className:`text-4xl`,children:new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).formatToParts(e||0).map((e,t)=>(0,B.jsx)(Pc,{type:e.type,value:e.value},t))})}function Pc({type:e,value:t}){switch(e){case`currency`:case`decimal`:case`fraction`:return(0,B.jsx)(`sup`,{className:`font-light text-xl`,children:t});default:return t}}function Fc({alreadyUsingFree:e,clusterId:t,defaultValues:n,deploymentToPerformanceToPlan:r,harperVersions:i,mode:a,organization:s,organizationId:c,planTypes:l,regionLocationsColocated:u,regionLocationsDedicated:d,setSavedClusterState:f,startOffOnBilling:p}){let m=F(),h=We(),g=s?.type===xs,_=Wn(),{mutate:v,isPending:y}=gs(),{mutate:b,isPending:x}=vs(),[S,ee]=(0,z.useState)(p),te=(0,z.useMemo)(()=>os(u?.sort(es(`latencyDescription`))||[],`region`,`latencyDescription`),[u]),ne=(0,z.useMemo)(()=>os(d?.sort(es(`latencyDescription`))||[],`region`,`latencyDescription`),[d]),re=(0,z.useCallback)((t,n)=>{let i=new Set,a=r?.[t.deploymentDescription]?.[t.performanceDescription];if(t.deploymentDescription===`Self-Hosted`)for(let e=0;e<t.instances.length;e++){let r=Ac(t.instances[e]);i.has(r)?n.addIssue({code:`custom`,path:[`instances.${e}.fqdn`],message:`Every instance url must be unique!`}):i.add(r)}else{a?.priceUsd===0&&e&&n.addIssue({code:`custom`,path:[`performanceDescription`],message:`Only one free cluster is allowed per organization.`});let r=a?.deploymentDescription===`Dedicated`?ne:te;for(let e=0;e<t.regionPlans.length;e++){let o=t.regionPlans[e],s=r[o.regionName]?.[o.latencyDescription];i.has(o.regionName)?n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`You can only select a region once!`}):i.add(o.regionName),a?.allowedRegionIds?.length&&s?.id&&(a.allowedRegionIds.includes(s.id)?e>=1&&n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`You can only select one region with this performance tier!`}):Cs(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,te,ne,r]),w=k({mode:`onChange`,resolver:O(Js.superRefine(re)),defaultValues:n}),[ie,ae]=(0,z.useState)(!0);(0,z.useEffect)(()=>{ie&&n&&(f(null),ae(!1))},[n,ie,f]);let oe=w.watch(`clusterName`),T=w.watch(`abbreviatedName`),E=w.watch(`deploymentDescription`),se=w.watch(`performanceDescription`),D=w.watch(`regionPlans`),ce=w.watch(`instances`),le=E===`Dedicated`?ne:te,ue=E===`Dedicated`?d:u;(0,z.useEffect)(function(){let e=w.getValues();E&&(E===`Self-Hosted`?(e.abbreviatedName&&w.setValue(`abbreviatedName`,``),e.regionPlans.length&&w.setValue(`regionPlans`,[]),e.instances.length||w.setValue(`instances`,[{secure:`true`,fqdn:``,port:o}])):(e.fqdn&&w.setValue(`fqdn`,``),e.instances.length&&w.setValue(`instances`,[]),e.regionPlans.length||Mc(w,l,ue)))},[w,l,ue,E]);let de=(0,z.useMemo)(()=>{let e=Ss(ws(oe),qs.maxLength);return{suggestedAbbreviatedName:e,fullHostName:`${T||e}.${s.subdomain||`your-org`}.harperfabric.com`}},[oe,T,s]),fe=(0,z.useMemo)(()=>r?.[E]?.[se],[r,E,se]);(0,z.useEffect)(function(){let e=fe?.allowedRegionIds;if(e?.length&&D?.length===1){let t=D[0],n=le?.[t.regionName]?.[t.latencyDescription];if(!e.includes(n?.id)){let t=ue?.filter(t=>e.includes(t.id)),n=t?.find(e=>e.region===`US`)||t?.[0];n&&(w.setValue(`regionPlans.0.regionName`,n.region),w.setValue(`regionPlans.0.latencyDescription`,n.latencyDescription),w.trigger())}}},[fe,D,w,le,ue]),(0,z.useEffect)(function(){if(E!==`Self-Hosted`&&Object.keys(le).length&&D.length)for(let e=0;e<D.length;e++)le[D[e].regionName]||w.setValue(`regionPlans.${e}.regionName`,``)},[w,le,E,D]);let pe=fe?.priceUsd?E===`Self-Hosted`?ce.length*fe.priceUsd:D.reduce((e,t)=>{let n=le?.[t.regionName]?.[t.latencyDescription];return e+(n?fe.priceUsd*n.instanceCount/2:0)},0):0,me=(0,z.useCallback)(({creating:e,deploymentDescription:t})=>N.message(e?`Creating Cluster`:`Updating Cluster`,{description:(0,B.jsx)(ms,{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,z.useCallback)(async({clusterId:e,sourceClusterId:t,creating:n,toastId:r,isSelfManaged:i})=>{if(t){let e=(await ys(c)).clusters?.find(e=>e.id===t);mo(e?.status)&&await Io(t)}_.invalidateQueries({queryKey:[c],refetchType:`active`}),n||_.invalidateQueries({queryKey:[e],refetchType:`active`}),h.invalidate(),m(i?{to:`/${c}/${e}/instances`}:n?{to:`/${c}/${e}/starting-up`}:{to:`/${c}/${e}/scaling`}),w.reset(),N.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})},[_,h,m,c,w]),ge=(0,z.useCallback)(async()=>{let e=w.getValues(),n=[],i=r[e.deploymentDescription][e.performanceDescription],o=e.deploymentDescription===`Self-Hosted`;if(o)for(let t of e.instances)n.push({autoRenew:!0,instanceFqdn:t.fqdn,operationsApiPort:t.port||9925,operationsApiSecure:t.secure===`true`,planId:i.id});else for(let t of e.regionPlans){let e=le[t.regionName][t.latencyDescription];n.push({autoRenew:!0,planId:i.id,regionId:e.id})}f(null);let s=me({creating:!t,deploymentDescription:e.deploymentDescription}),l=()=>N.dismiss(s);t?b(a===`version`?{id:t,version:e.version,skipGtmWait:e.skipGtmWait}:{id:t,regionPlans:n,skipGtmWait:e.skipGtmWait},{onSuccess:t=>he({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:o,creating:!1,toastId:s}),onError:l}):v({abbreviatedName:o?void 0:e.abbreviatedName||de.suggestedAbbreviatedName,autoRenew:!0,fqdn:o&&e.fqdn||void 0,name:e.clusterName,version:e.version,organizationId:c,regionPlans:n},{onSuccess:t=>he({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:o,creating:!0,toastId:s}),onError:l})},[de.suggestedAbbreviatedName,t,r,w,he,me,c,le,f,b,v]),_e=(0,z.useCallback)(()=>{if(a!==`version`&&pe>0){ee(!0);return}return ge()},[a,ge,pe]),ve=(0,z.useCallback)(e=>{f(e?{clusterId:t,...w.getValues(),skipToBilling:!0}:null)},[t,w,f]),ye=(0,z.useCallback)(()=>{ee(!1)},[]),be=!g&&`mr-37.5`;return(0,B.jsxs)(B.Fragment,{children:[!g&&a!==`version`&&(0,B.jsxs)(`div`,{className:`absolute top-3 right-4 md:right-12 text-right`,children:[(0,B.jsx)(`dt`,{className:`font-light`,children:`Total Price`}),(0,B.jsx)(`dd`,{className:`font-bold`,children:(0,B.jsx)(Nc,{price:pe})})]}),(0,B.jsx)(H,{...w,children:S?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`h1`,{className:C(`text-lg leading-none text-white font-semibold mb-4`,be),children:`Cluster Billing`}),(0,B.jsx)(`p`,{className:C(`text-muted-foreground text-sm mb-2`,be),children:`Please confirm the following billing details:`}),(0,B.jsx)(Ws,{clusterId:t,isPending:y||x,onGoBackToDetails:ye,onSaveStateForBillingRedirect:ve,onSubmit:ge,organizationId:c,selectedPlan:fe})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`h1`,{className:C(`text-lg leading-none text-white font-semibold mb-4`,be),children:`Cluster Configuration`}),(0,B.jsx)(`p`,{className:C(`text-muted-foreground text-sm mb-6`,be),children:`Configure your Harper cluster and define deployment plans.`}),(0,B.jsx)(`form`,{id:`cluster-upsert-form`,name:`cluster-upsert-form`,onSubmit:w.handleSubmit(_e),children:(0,B.jsx)(kc,{calculatedNames:de,clusterId:t,deploymentToPerformanceToPlan:r,form:w,isPending:y||x,harperVersions:i,mode:a,regionLocations:ue,regionNameToLatencyToRegion:le,selectedDeployment:E,selectedPerformance:se,selectedPlan:fe,totalPrice:pe,isEnterprise:g})})]})})]})}function Ic(e){return e?.clusterName!==void 0}function Lc(){let{organizationId:e,clusterId:t,mode:n}=j({strict:!1}),{create:r,update:i}=ki(e),{organization:a,cluster:o}=pt({strict:!1}),[s,c]=Ho(Uo.SavedClusterState,null),{data:l}=L(Yo(e)),{data:u}=L($o({availableHosts:!0,organizationId:e})),{data:d}=L($o({organizationId:e})),{data:f}=L(Zo()),p=(0,z.useMemo)(()=>{if(o){let e=o.instances?.map(e=>e.version).filter(ri);if(f&&e){let t=e.sort(cs).pop();return{...f,value:[!!t&&{name:`current`,version:t},...(f?.value||[]).filter(e=>t!==e.version&&(!t||ss(t,e.version)))].filter(ri)}}}return f},[f,o]),m=(0,z.useMemo)(()=>{for(let e of a?.clusters??[])if(e.id!==o?.id&&l&&!ho(e.status)&&!mo(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,z.useMemo)(()=>os(l?.sort(es(`priceUsd`))||[],`deploymentDescription`,`performanceDescription`),[l]),g=(0,z.useMemo)(()=>{if(!l||!p||!u||!d||t&&!o)return null;let e=o;if(s){if(Ic(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=jc(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&&!ua.includes(e.status)).sort(rs);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,B.jsx)(qo,{children:(0,B.jsx)(Ko,{centered:!0,text:`Loading...`})}):(o?.id?!i:!r)?(0,B.jsx)(qo,{children:(0,B.jsx)(Qr,{title:`Not Allowed`,error:{message:(0,B.jsxs)(B.Fragment,{children:[`You do not have permission to `,o?.id?`update`:`create`,` clusters in this org.`]})}})}):l.length===0?(0,B.jsx)(qo,{children:(0,B.jsx)(Qr,{title:`Cluster ${t?`Modification`:`Creation`} Not Currently Allowed`,error:{message:(0,B.jsxs)(B.Fragment,{children:[`There are no available deployment types right now! Please try again later, or `,(0,B.jsx)(Go,{}),`.`]})}})}):(0,B.jsx)(qo,{className:`max-w-4xl mx-auto`,children:(0,B.jsx)(Fc,{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:Ic(s)&&s.skipToBilling===!0})})}var Rc={FAILED:0,UPDATING:1,PROVISIONING:2,RUNNING:3,TERMINATED:4},zc=Rc.RUNNING;function Bc(e,t){return e.status===t.status?e.name.localeCompare(t.name):(e.status?Rc[e.status]??zc:zc)-(t.status?Rc[t.status]??zc:zc)}function Vc(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 Hc(){let{organizationId:e}=j({strict:!1}),{create:t}=ki(e),{data:n,isSuccess:r}=D(bs(e)),[i]=Ho(Uo.SavedClusterState,null),[a,o]=(0,z.useState)(``),s=(0,z.useCallback)(()=>o(``),[]),c=(0,z.useCallback)(e=>{o(e.currentTarget.value?.toLowerCase()||``)},[]),l=(0,z.useMemo)(()=>n?.clusters?.slice().filter(e=>!ho(e.status)).sort(Bc)||[],[n?.clusters]),u=(0,z.useMemo)(()=>l.filter(Vc([`id`,`name`],a))||[],[a,l]);return n&&l.length===0&&t?(0,B.jsx)(Lc,{}):i?(0,B.jsx)(jt,{to:`/${e}/new-cluster`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{children:r?(0,B.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,B.jsx)(J,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:a,onChange:c}),t&&(0,B.jsx)(A,{to:`new-cluster`,children:(0,B.jsxs)(R,{variant:`positive`,accessKey:`n`,children:[(0,B.jsx)(on,{}),` `,(0,B.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,B.jsx)(`u`,{children:`N`}),`ew `,(0,B.jsx)(`span`,{className:`hidden md:inline-block`,children:`Cluster`})]})]})})]}):null}),(0,B.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12 mb-4`,children:[u.map(e=>(0,B.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,B.jsx)(Wo,{cluster:e})},e.id)),!u.length&&(0,B.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,B.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,B.jsx)(R,{variant:`outline`,onClick:s,children:`Clear Filters`})]})]})})]})}function Uc(){let e=URL.parse(location.href);return e?.hash?e.hash.startsWith(`#/`)?e.hash.slice(1):e.hash:`/`}function Wc(){return`/#`+Uc()}function Gc(){let{organizationId:e}=j({strict:!1}),t=F(),n=new URLSearchParams(window.location.search).get(`setup_intent_client_secret`),{setup_intent_client_secret:r}=Ne({strict:!1}),[i]=Ho(Uo.SavedClusterState,null),a=n||r,o=vn(),s=Ds(e),c=(0,z.useCallback)(()=>{let e=i?i.clusterId?`../../${i.clusterId}/edit`:`../../new-cluster`:`../`;window.history.replaceState(null,``,Wc()),t({search:void 0,to:e})},[t,i]);return(0,z.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?(N.error(`Failed to process payment method details. Please try another payment method.`),c()):s(e.payment_method,c);break;case`processing`:N.warning(`Processing payment method. Please check back later.`),c();break;case`requires_payment_method`:N.error(`Failed to process payment method details. Please try another payment method.`),c();break;default:N.error(`Failed to process payment method details. Please try another payment method.`),c();break}}catch(e){console.error(e),N.error(`Failed to process payment method details. Please try another payment method.`),c()}})()},[a,c,e,s,o]),(0,B.jsx)(Ko,{centered:!0})}function Kc(){return(0,B.jsx)(Is,{children:(0,B.jsx)(Gc,{})})}function qc({clusterId:e,instanceId:t,organizationId:n},r){return`/`+[n,e,t&&`instance`,t,r].filter(ri).join(`/`)}var Jc=`flex items-center p-2 rounded-lg group`,Yc={className:`text-white hover:bg-gray-700`},Xc={className:`text-black bg-white pointer-events-none cursor-default`};function Zc(){let{organizationId:e}=j({strict:!1}),{update:t}=Di(e);return t?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,B.jsxs)(`div`,{className:`md:grid gap-4 md:grid-cols-12 min-h-[calc(100vh-theme(spacing.36))] mb-12`,children:[(0,B.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,B.jsx)(Qc,{}),(0,B.jsx)($c,{})]}),(0,B.jsx)(`section`,{className:`col-span-1 text-white md:col-span-8 lg:col-span-9`,children:(0,B.jsx)(Ze,{})})]})})]}):(0,B.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 Qc(){let e=j({strict:!1});return(0,B.jsxs)(`div`,{className:`hidden md:block`,children:[(0,B.jsxs)(`span`,{className:Jc,children:[(0,B.jsx)(yr,{className:`inline-block`}),(0,B.jsx)(`h3`,{className:`ms-3 text-2xl font-extrabold dark:text-white`,children:`Billing`})]}),(0,B.jsxs)(`ul`,{className:`border-t border-gray-700 pt-4 mt-4 space-y-2`,children:[(0,B.jsx)(`li`,{children:(0,B.jsxs)(A,{to:qc(e,`billing`),className:Jc,activeOptions:{exact:!0},inactiveProps:Yc,activeProps:Xc,children:[(0,B.jsx)(Dn,{className:`inline-block`}),` `,(0,B.jsx)(`span`,{className:`ms-3`,children:`Payment Method`})]})}),(0,B.jsx)(`li`,{children:(0,B.jsxs)(A,{to:qc(e,`billing/invoices`),className:Jc,inactiveProps:Yc,activeProps:Xc,children:[(0,B.jsx)(Ar,{className:`inline-block`}),(0,B.jsx)(`span`,{className:`ms-3`,children:`Invoices & Payments`})]})})]})]})}function $c(){let e=j({strict:!1});return(0,B.jsxs)(`ul`,{className:`flex space-x-4 md:hidden py-2`,children:[(0,B.jsx)(`li`,{children:(0,B.jsxs)(A,{to:qc(e,`billing`),className:Jc,activeOptions:{exact:!0},inactiveProps:Yc,activeProps:Xc,children:[(0,B.jsx)(Dn,{className:`inline-block`}),` `,(0,B.jsx)(`span`,{className:`ms-3`,children:`Payment Method`})]})}),(0,B.jsx)(`li`,{children:(0,B.jsxs)(A,{to:qc(e,`billing/invoices`),className:Jc,inactiveProps:Yc,activeProps:Xc,children:[(0,B.jsx)(Ar,{className:`inline-block`}),` `,(0,B.jsx)(`span`,{className:`ms-3`,children:`Invoices & Payments`})]})})]})}function el({className:e,containerClassName:t,...n}){return(0,B.jsx)(`div`,{"data-slot":`table-container`,className:g(`relative w-full overflow-x-auto`,t),children:(0,B.jsx)(`table`,{"data-slot":`table`,className:g(`w-full caption-bottom text-sm`,e),...n})})}function tl({className:e,...t}){return(0,B.jsx)(`thead`,{"data-slot":`table-header`,className:g(`[&_tr]:border-b`,e),...t})}function nl({className:e,...t}){return(0,B.jsx)(`tbody`,{"data-slot":`table-body`,className:g(`[&_tr:last-child]:border-0`,e),...t})}function rl({className:e,...t}){return(0,B.jsx)(`tr`,{"data-slot":`table-row`,className:g(`border-b border-grey-700 transition-colors`,e),...t})}function il({className:e,...t}){return(0,B.jsx)(`th`,{"data-slot":`table-head`,className:g(`h-10 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function al({header:e,onColumnClick:t,...n}){let r=(0,z.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:Pt(e.column.columnDef.header,e.getContext()),s=(0,z.useCallback)(()=>{e.column.resetSize()},[e]);return(0,B.jsx)(il,{...n,style:{width:`${e.getSize()}px`},className:i?`px-0`:`px-2`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[i?(0,B.jsxs)(R,{type:`button`,variant:`ghost`,className:g(`rounded-none`,!e.column.getIsSorted()||e.column.getIsSorted()===`asc`?`cursor-n-resize`:`cursor-s-resize`),onClick:r,children:[o,e.column.getIsSorted()===`asc`?(0,B.jsx)(Ee,{}):e.column.getIsSorted()===`desc`?(0,B.jsx)(de,{}):(0,B.jsx)(Se,{className:`text-gray-600`})]}):o,a&&(0,B.jsx)(R,{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,B.jsx)(xt,{})})]})})}function ol({className:e,...t}){return(0,B.jsx)(`td`,{"data-slot":`table-cell`,className:g(`align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function sl({columns:e,data:t,isFetching:n,onRowClick:r,onColumnClick:i,sortingState:a,children:o}){let s=Bt({data:t,columns:e,getCoreRowModel:Xe(),getSortedRowModel:qe(),initialState:{sorting:a}});return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-end space-x-2 pb-4`,children:[(0,B.jsx)(`div`,{className:`grow lg:hidden`}),o,(0,B.jsx)(`div`,{className:`grow hidden lg:visible`})]}),(0,B.jsxs)(el,{containerClassName:`rounded-md bg-black-dark`,children:[(0,B.jsx)(tl,{children:s.getHeaderGroups().map(e=>(0,B.jsx)(rl,{className:`border-none`,children:e.headers.map(e=>(0,B.jsx)(al,{header:e,onColumnClick:i},e.id))},e.id))}),(0,B.jsx)(nl,{className:`bg-black border border-grey-700`,children:s.getRowModel().rows?.length?s.getRowModel().rows.map(e=>(0,B.jsx)(rl,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>r?.(e),className:g(`hover:bg-muted/10 data-[state=selected]:bg-muted`,r&&`cursor-pointer`),children:e.getVisibleCells().map(e=>(0,B.jsx)(ol,{className:`py-2 px-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,style:{width:`${e.column.getSize()}px`},children:Pt(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,B.jsx)(rl,{children:(0,B.jsx)(ol,{colSpan:e.length,className:`h-24 text-center`,children:n?(0,B.jsx)(`div`,{children:(0,B.jsx)(Ko,{className:`p-12`})}):(0,B.jsx)(`span`,{children:`No results.`})})})})]})]})}function cl(e){switch(e){case`paid`:return`success`;case`void`:case`uncollectible`:return`destructive`;default:return`default`}}function ll(e){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e)}function ul(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 dl=[{header:`Invoice Id`,accessorKey:`id`,enableSorting:!1},{header:`Status`,accessorKey:`status`,enableSorting:!1,cell:({cell:e})=>(0,B.jsx)(wo,{variant:cl(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?ul(r,t):[t?ul(r,t):`-`,n?ul(i,n):`-`].join(` to `)}},{header:`Amount Due`,accessorKey:`amountDue`,enableSorting:!1,cell:({cell:e})=>ll(e.getValue()?e.getValue()/100:0)},{header:`Amount Paid`,accessorKey:`amountPaid`,enableSorting:!1,cell:({cell:e})=>ll(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} @ ${ll(e.amount/100)}`);return n.join(`
|
|
11
|
-
`)}}];function fl(e){return(0,z.useCallback)(async()=>{N.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await a(500),N.success(`Refreshed!`,{id:`refreshing`})},[e])}async function pl(e){let{data:t}=await u.get(`/Invoice/${e}`);return t}function ml(e,t){return M({queryKey:[e,`invoices`],queryFn:()=>pl(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function hl(){let{organizationId:e}=j({strict:!1}),{data:t}=L(bs(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=L(ml(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=fl(r);return t?.type===`ENTERPRISE`?(0,B.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,B.jsx)(Go,{}),`, we would love to talk!`]}):i?(0,B.jsx)(Ko,{centered:!0}):!n||!n.length?(0,B.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,B.jsx)(Go,{overEmail:!0}),`, we would love to talk!`]}):(0,B.jsx)(sl,{data:n,columns:dl,children:(0,B.jsxs)(R,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,B.jsx)(en,{}),(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function gl(e){let t=P({getParentRoute:()=>e,path:`billing`,component:Zc}),n=P({getParentRoute:()=>t,path:`/`,component:Hs}),r=P({getParentRoute:()=>t,path:`invoices`,component:hl}),i=P({getParentRoute:()=>t,path:`confirm`,component:Kc});return t.addChildren([n,r,i])}async function _l(e){let{data:t}=await u.get(`/OrganizationRole/${e}`);return t}function vl(e){return M({queryKey:[e,`roles`],queryFn:()=>_l(e),retry:!1,refetchInterval:10*1e3})}var yl=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},Ie().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 bl(e){let{data:t}=await u.post(`/Role/`,e);return t}function xl(){return I({mutationFn:bl})}var Sl=T({name:w().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:E(),delete:E()});T({roles:T({create:E(),delete:E(),update:E(),view:E()}),clusters:T({create:E(),delete:E(),update:E(),view:E(),resources:te(T({id:w(),delete:E(),update:E(),view:E(),instances:T({create:E(),delete:E(),update:E(),view:E()})}))})});var Cl={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function wl({isModalOpen:e,setIsModalOpen:t}){let n=Wn(),{organizationId:r}=j({strict:!1}),[i,a]=(0,z.useState)(!0),[o,s]=(0,z.useState)(JSON.stringify(Cl,null,2)),{mutate:c,isPending:l}=xl(),u=k({resolver:O(Sl),defaultValues:{name:``,update:!1,delete:!1}}),d=(0,z.useCallback)(e=>{a(e.length===0)},[a]),f=(0,z.useCallback)(async e=>{let a=zo(o);if(!a)return;let s={...e,...a,organizationId:r};e&&i&&c(s,{onSuccess:()=>{N.success(`Organization role added successfully!`),t(!1),n.invalidateQueries({queryKey:[r,`roles`],refetchType:`active`}),u.reset()},onError:e=>{N.error(`Failed to add organization role: ${e.message}`)}})},[i,o,c,u,n,t,r]);return(0,B.jsx)(Y,{onOpenChange:t,open:e,children:(0,B.jsxs)(X,{children:[(0,B.jsx)(Q,{children:`Add New Organization Role`}),(0,B.jsx)(So,{children:`Set the new organization role permissions.`}),(0,B.jsx)(H,{...u,children:(0,B.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,B.jsx)(W,{control:u.control,name:`name`,render:({field:e})=>(0,B.jsxs)(G,{className:`col-span-2`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Role Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,className:``,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:u.control,name:`update`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Update Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:u.control,name:`delete`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Delete Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(`div`,{className:`col-span-2`,children:(0,B.jsx)(ze,{theme:`vs-dark`,height:`300px`,defaultLanguage:`json`,onValidate:d,onChange:e=>{e&&s(e)},defaultValue:JSON.stringify(Cl,null,2)})}),(0,B.jsx)(Z,{className:`col-span-2`,children:(0,B.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,B.jsx)(R,{variant:`destructiveOutline`,className:`rounded-full`,type:`button`,onClick:()=>t(!1),disabled:l,children:`Cancel`}),(0,B.jsx)(R,{variant:`submit`,className:`rounded-full`,disabled:l||!i||!u.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function Tl({roleId:e}){let{data:t}=await u.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function El(){return I({mutationFn:({roleId:e})=>Tl({roleId:e})})}async function Dl({roleId:e,updatedRoleInfo:t}){let{data:n}=await u.put(`/Role/${e}`,t);return n}function Ol(){return I({mutationFn:({roleId:e,updatedRoleInfo:t})=>Dl({roleId:e,updatedRoleInfo:t})})}function kl({organizationId:e,roleId:t}){return M({queryKey:[e,`roles`,t],queryFn:()=>Al(t),refetchInterval:10*1e3})}async function Al(e){let{data:t}=await u.get(`/Role/${e}`);return t}function jl({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Q,{children:`Confirm Role Deletion`}),(0,B.jsx)(So,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,B.jsxs)(Z,{children:[(0,B.jsx)(R,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,onClick:()=>t(!1),children:`Cancel`}),(0,B.jsx)(R,{variant:`destructiveOutline`,className:`rounded-full`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function Ml({data:e,isModalOpen:t,closeModal:n}){let r=Wn(),{data:i}=D(kl({roleId:e.id,organizationId:e.organizationId})),a=Vr(),o=a.user&&a.user?.roles?.[e.organizationId]?.role===e.roleName,{update:s,remove:c}=Oi(e.organizationId),{mutate:l,isPending:u}=Ol(),{mutate:d,isPending:f}=El(),[p,m]=(0,z.useState)(!1),h=k({resolver:O(Sl),defaultValues:{name:e.roleName,update:i.organization.update||!1,delete:i.organization.delete||!1}}),g=(0,z.useCallback)(()=>{d({roleId:e.id},{onSuccess:()=>{N.success(`Role deleted successfully!`),n(!0),h.reset()},onError:e=>{N.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>N.dismiss()}})}})},[e.id,d,h,n]),[_,v]=(0,z.useState)(!0),[y,b]=(0,z.useState)(JSON.stringify({roles:{...i.organization.roles},clusters:{...i.organization.clusters}},null,2)),x=(0,z.useCallback)(e=>{v(e.length===0)},[v]),S=(0,z.useCallback)(async t=>{if(!s)return;let i=zo(y);if(!i)return;let a={...t,...i,organizationId:e.organizationId};y&&_&&l({roleId:e.id,updatedRoleInfo:a},{onSuccess:async()=>{N.success(`Role updated successfully!`),await r.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),n(!1),h.reset()},onError:e=>{N.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>N.dismiss()}})}})},[n,e.id,e.organizationId,h,_,r,i,s,y,l]);return(0,B.jsx)(Y,{onOpenChange:(0,z.useCallback)(()=>n(!1),[n]),open:t,children:(0,B.jsx)(X,{children:p?(0,B.jsx)(jl,{onRoleDeleteClick:g,setIsConfirmingRoleDeletion:m,isRoleDeletionPending:f}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(Q,{children:[o||!s?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,B.jsx)(H,{...h,children:(0,B.jsxs)(`form`,{id:`org-edit-role-form`,name:`org-edit-role-form`,className:`grid grid-cols-2 gap-4 my-4`,onSubmit:h.handleSubmit(S),children:[(0,B.jsx)(W,{control:h.control,name:`name`,render:({field:e})=>(0,B.jsxs)(G,{className:`col-span-2`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Role Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:h.control,name:`update`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Update Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:h.control,name:`delete`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Delete Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(`div`,{className:`col-span-2`,children:(0,B.jsx)(ze,{theme:`vs-dark`,height:`300px`,defaultLanguage:`json`,onValidate:x,onChange:e=>{e&&b(e)},options:o||!s?{readOnly:!0}:void 0,defaultValue:y})}),!o&&(c||s)&&(0,B.jsx)(Z,{className:`col-span-2`,children:(0,B.jsxs)(`div`,{className:`flex justify-between w-full`,children:[c&&(0,B.jsx)(R,{type:`button`,variant:`destructiveOutline`,className:`rounded-full`,onClick:()=>m(!0),disabled:u,children:`Delete Role`}),s&&(0,B.jsx)(R,{variant:`submit`,className:`rounded-full`,disabled:!_||u||!h.formState.isValid||!h.formState.isDirty,children:`Save Changes`})]})})]})})]})})})}function Nl(){let e=F(),t=Wn(),{organizationId:n,orgRoleId:r}=j({strict:!1}),{create:i}=Oi(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=D(vl(n)),l=(0,z.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,z.useState)(!1),p=(0,z.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,z.useCallback)(()=>{f(!0)},[f]),h=(0,z.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,z.useCallback)(e=>p(void 0,e),[p]),_=fl(o);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,B.jsxs)(z.Suspense,{fallback:(0,B.jsx)(Ko,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,B.jsxs)(sl,{data:a,columns:yl,onRowClick:h,children:[(0,B.jsxs)(R,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,B.jsx)(en,{}),(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,B.jsxs)(R,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,B.jsx)(on,{}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,B.jsx)(wl,{isModalOpen:d,setIsModalOpen:f}),u&&(0,B.jsx)(Ml,{data:l,isModalOpen:u,closeModal:g})]})})]})}var Pl=[{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},Ie().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}],Fl=x.object({email:_a.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:x.string().nonempty({error:`Please select a role.`})});async function Il(e){let{data:t}=await u.post(`/OrganizationRole/`,e);return t}function Ll(){return I({mutationFn:e=>Il(e)})}x.object({email:_a.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:x.string().nonempty({error:`Please select a role.`})});async function Rl(e){let{data:t}=await u.post(`/UserInvite/`,e);return t}function zl(){return I({mutationFn:e=>Rl(e)})}function Bl({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=j({strict:!1}),{data:i}=D(vl(r)),[a,o]=(0,z.useState)(!1),s=k({resolver:O(Fl),defaultValues:{email:``,roleId:``}}),{mutate:c,isPending:l}=Ll(),{mutate:u,isPending:d}=zl(),f=(0,z.useCallback)(async e=>{e&&(a?u:c)(e,{onSuccess:()=>{let r=e.roleId;s.reset(),s.setValue(`roleId`,r),t(),N.success(`User invited successfully!`),n(!1),o(!1)},onError:e=>{e?.status===404&&o(!0)}})},[c,s,u,t,n,a]);return(0,B.jsx)(Y,{onOpenChange:()=>{n(!1),o(!1),s.reset()},open:e,children:(0,B.jsx)(X,{"aria-describedby":void 0,children:(0,B.jsx)(H,{...s,children:(0,B.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:s.handleSubmit(f),className:`grid gap-4 my-4`,children:[(0,B.jsx)(xo,{children:(0,B.jsx)(Q,{children:a?`Invite User`:`Add User`})}),(0,B.jsx)(W,{control:s.control,name:`email`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Email`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:s.control,name:`roleId`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Roles`}),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(Xs,{}),children:(0,B.jsx)(U,{children:(0,B.jsxs)(Zs,{...e,onValueChange:t=>e.onChange(t),children:[(0,B.jsx)(ec,{className:`w-full`,children:(0,B.jsx)($s,{placeholder:`Choose Role`})}),(0,B.jsx)(tc,{children:(0,B.jsxs)(Qs,{children:[(0,B.jsx)(nc,{children:`Role`}),i?.map(e=>(0,B.jsx)($,{value:e.id,children:e.roleName},e.id))]})})]})})}),(0,B.jsx)(q,{})]})}),a&&(0,B.jsxs)(So,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,B.jsx)(dt,{className:`inline-block size-12 pr-2`}),(0,B.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,B.jsx)(Z,{children:(0,B.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,B.jsxs)(R,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:l||d,children:[(0,B.jsx)(Un,{}),` `,a?`Invite User`:`Add User`]})})})]})})})})}async function Vl({roleId:e,userId:t}){let{data:n}=await u.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function Hl(){return I({mutationFn:({roleId:e,userId:t})=>Vl({roleId:e,userId:t})})}function Ul(e){let[t,n]=(0,z.useState)(e||!1);return[t,(0,z.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function Wl({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=Ll(),{mutate:c,isPending:l}=Hl(),u=!!i[r.roleName],[d,f]=(0,z.useState)(u),[p,m]=Ul(u);return(0,z.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),N.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),N.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,B.jsxs)(ca,{className:`flex`,children:[(0,B.jsx)(J,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,B.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function Gl({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r}){let{organizationId:i}=j({strict:!1}),a=Vr(),{update:o,remove:s}=Oi(i),c=a.user?.email===t.email,{data:l}=D(vl(i)),u=(0,z.useMemo)(()=>t.roles?as(t.roles,`roleName`):{},[t]),[d,f]=(0,z.useState)(!1);return(0,B.jsx)(Y,{onOpenChange:d?r:e,open:n,children:(0,B.jsxs)(X,{className:`sm:max-w-[750px]`,children:[(0,B.jsx)(xo,{children:(0,B.jsxs)(Q,{children:[o?`Edit `:`View `,` `,t.email,` `,c?`(yourself)`:``]})}),o&&(0,B.jsxs)(So,{children:[`To remove `,c?`your self`:`this user`,` from the organization, uncheck all of the boxes below.`]}),l.map(e=>(0,B.jsx)(Wl,{readOnly:!o,canRemove:s,data:t,orgRole:e,selectedRoles:u,setChangesMade:f},e.id))]})})}function Kl(e,t){return e.email>t.email?1:-1}function ql(){let e=F(),{organizationId:t,orgUserId:n}=j({strict:!1}),{update:r}=Oi(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=D(vl(t)),c=(0,z.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(Kl)},[i]),l=(0,z.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),u=(0,z.useCallback)(t=>{e({to:[n?`..`:``,t].filter(Boolean).join(`/`)})},[n,e]),d=!!n&&!!l,[f,p]=(0,z.useState)(!1),[m]=(0,z.useState)({attribute:`email`,descending:!1}),h=(0,z.useMemo)(()=>[{desc:m.descending,id:m.attribute}],[m]),g=(0,z.useCallback)(()=>{p(!0)},[p]),_=(0,z.useCallback)(()=>{a(),p(!1)},[a,p]),v=(0,z.useCallback)(e=>{u(e.original.id)},[u]),y=(0,z.useCallback)(()=>{u(void 0)},[u]),b=(0,z.useCallback)(()=>{a(),u(void 0)},[u,a]),x=fl(a);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,B.jsxs)(z.Suspense,{fallback:(0,B.jsx)(Ko,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,B.jsxs)(sl,{data:c,isFetching:o||s,columns:Pl,onRowClick:v,sortingState:h,children:[(0,B.jsxs)(R,{variant:`defaultOutline`,onClick:x,accessKey:`r`,disabled:o||s,children:[(0,B.jsx)(en,{}),` `,(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,B.jsxs)(R,{variant:`positiveOutline`,onClick:g,accessKey:`a`,disabled:f,children:[(0,B.jsx)(on,{}),` `,(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,B.jsx)(Bl,{isModalOpen:f,onChangesSaved:_,setIsModalOpen:p}),d&&(0,B.jsx)(Gl,{closeModal:y,data:l,isModalOpen:d,onUserUpdated:b})]})})]})}function Jl({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=Di(n),s=o,{view:c}=Oi(n),l=(0,z.useCallback)(()=>{t(e)},[t,e]);return(0,B.jsxs)(Gr,{className:`relative h-full justify-between`,children:[(0,B.jsxs)(Kr,{children:[(0,B.jsxs)(Jr,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`truncate`,children:n}),a&&(0,B.jsxs)(To,{children:[(0,B.jsx)(Eo,{className:`p-4 -m-4 -mr-6 hover:text-white`,children:(0,B.jsx)(fr,{"aria-label":`Options`})}),(0,B.jsxs)(Do,{children:[(0,B.jsx)(Ao,{className:`text-gray-600 text-xs`,children:`Options`}),(0,B.jsx)(jo,{}),(0,B.jsx)(A,{to:`${n}`,children:(0,B.jsx)(Oo,{children:`Clusters`})}),c&&(0,B.jsx)(A,{to:`${n}/roles`,children:(0,B.jsx)(Oo,{children:`Roles`})}),c&&(0,B.jsx)(A,{to:`${n}/users`,children:(0,B.jsx)(Oo,{children:`Users`})}),s&&(0,B.jsx)(A,{to:`${n}/billing`,children:(0,B.jsx)(Oo,{children:`Billing`})}),(0,B.jsx)(jo,{}),a&&(0,B.jsx)(Oo,{className:`focus:bg-red/70 focus:text-white`,onClick:l,children:`Delete`})]})]})]}),(0,B.jsx)(qr,{children:(0,B.jsx)(`h2`,{children:r})})]}),(0,B.jsxs)(Yr,{className:`flex justify-between`,children:[(0,B.jsx)(wo,{children:na(i)}),(0,B.jsx)(A,{to:n,className:`text-sm`,"aria-label":`View ${r}`,title:`View ${r}`,children:(0,B.jsxs)(`span`,{className:`py-2 transition-all duration-100 ease-in-out border-0 hover:border-b-2`,children:[`View `,(0,B.jsx)(lt,{className:`inline-block`})]})})]})]})}async function Yl(e){let{data:t}=await u.delete(`/Organization/${e}`);return t}function Xl(){return I({mutationFn:e=>Yl(e)})}async function Zl(e){let{data:t}=await u.post(`/Organization/`,{...e});return t}function Ql(){return I({mutationFn:e=>Zl(e)})}var $l=w().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.`}),eu=T({name:w().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:se([S(``),y(),$l])});function tu(){let{user:e}=Vr(),t=F(),n=k({resolver:O(eu),defaultValues:{name:``,subdomain:``}}),{setFocus:i,watch:a}=n;(0,z.useEffect)(()=>{i(`name`)},[i]);let o=`${e?.firstname} ${e?.lastname} Org`,s=a(`name`)||o,c=a(`subdomain`),l=(0,z.useMemo)(()=>{let e=Ss(ws(s),$l.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${c||e}.harperfabric.com`}},[s,c]),{mutate:u,isPending:f}=Ql(),p=Wn(),h=(0,z.useCallback)(async e=>{u({name:e.name||o,subdomain:e.subdomain||l.suggestedSubdomain},{onSuccess:e=>{p.invalidateQueries({queryKey:r,refetchType:`active`}),m.reloadUser(d),t({to:`/${e.id}`})}})},[l.suggestedSubdomain,p,u,o,t]);return(0,B.jsx)(B.Fragment,{children:(0,B.jsx)(H,{...n,children:(0,B.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,B.jsx)(W,{control:n.control,name:`name`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,maxLength:eu.shape.name.maxLength,autoCapitalize:`words`,placeholder:o,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:n.control,name:`subdomain`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Subdomain`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,maxLength:$l.maxLength,autoCapitalize:`none`,placeholder:l.suggestedSubdomain,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Full Host Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(`span`,{children:l.fullHostName})}),(0,B.jsx)(q,{})]}),(0,B.jsx)(Z,{children:(0,B.jsxs)(R,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:f,children:[`Create New Organization `,(0,B.jsx)(lt,{})]})})]})})})}function nu(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{}),(0,B.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,B.jsx)(tu,{})})]})}function ru(){let e=Wn(),{data:t}=D(_()),{mutate:n,isPending:r}=Xl(),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(``),u=(0,z.useCallback)(()=>l(``),[]),d=(0,z.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(Vc([`organizationId`,`organizationName`],c)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1)||[]},[c,t?.roles]),f=(0,z.useCallback)(e=>{l(e.currentTarget.value?.toLowerCase()||``)},[]),p=(0,z.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{N.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>N.dismiss()}}),e.invalidateQueries({queryKey:[]}),a(!1)},onError:()=>a(!1)})},[n,e,a]),m=(0,z.useCallback)(e=>{s(e),a(!0)},[]),{createCluster:h}=Ne({strict:!1});return d.length===1&&!c.length&&h?(0,B.jsx)(jt,{to:`/${d[0].organizationId}/new-cluster`,replace:!0}):!d.length&&!c.length?(0,B.jsx)(nu,{}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{children:(0,B.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,B.jsx)(J,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:c,onChange:f}),(0,B.jsx)(A,{to:`/new-org`,children:(0,B.jsxs)(R,{variant:`positive`,accessKey:`n`,children:[(0,B.jsx)(on,{}),(0,B.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,B.jsx)(`u`,{children:`N`}),`ew `,(0,B.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,B.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[d.map(e=>(0,B.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,B.jsx)(Jl,{organizationRole:e,onDeleteOrgModal:m})},e.organizationId)),!d.length&&(0,B.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,B.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,B.jsx)(R,{variant:`outline`,onClick:u,children:`Clear Filters`})]})]})}),o&&(0,B.jsx)(Co,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:o.organizationName,isModalOpen:i,setIsModalOpen:()=>a(!1),deletionConfirmed:()=>p(o),deletionPending:r})]})}function iu(){let{isLoading:e}=Lr(),{createCluster:t}=Ne({strict:!1}),[,n]=Ho(Uo.SavedClusterState,null);return(0,z.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,B.jsx)(Ko,{className:`fixed z-50 translate-1/2`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.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,B.jsx)(Li,{})}),(0,B.jsx)(`main`,{children:(0,B.jsx)(Ze,{})})]})}var au=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function ou(){let e=Uc();return!au.includes(e)&&{redirect:e}}var su=P({getParentRoute:()=>li,id:`_dashboardLayout`,component:iu,beforeLoad:({context:e})=>{let t=e.authentication[d];if(t&&!t.isLoading&&!t.user)throw Gt({to:`/sign-in`,search:ou()})}}),cu=P({getParentRoute:()=>su,id:`_orgsLayout`});P({getParentRoute:()=>cu,path:`/`,component:ru}),P({getParentRoute:()=>cu,path:`/new-org`,component:nu});var lu=P({getParentRoute:()=>cu,path:`$organizationId`,beforeLoad:async e=>({organization:await e.context.queryClient.ensureQueryData(bs(e.params.organizationId))})});P({getParentRoute:()=>lu,path:`/roles`,component:Nl}),P({getParentRoute:()=>lu,path:`/roles/$orgRoleId`,component:Nl}),P({getParentRoute:()=>lu,path:`/users`,component:ql}),P({getParentRoute:()=>lu,path:`/users/$orgUserId`,component:ql}),gl(lu);var uu=P({getParentRoute:()=>lu,id:`_clusterLayout`});P({getParentRoute:()=>uu,path:`/`,component:Hc}),P({getParentRoute:()=>lu,path:`/new-cluster`,component:Lc}),P({getParentRoute:()=>fu,path:`/edit`,component:Lc}),P({getParentRoute:()=>fu,path:`/edit/$mode`,component:Lc});function du(){return(0,B.jsx)(Ze,{})}var fu=P({getParentRoute:()=>uu,path:`$clusterId`,component:du,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(ga(t.clusterId))})});function pu({children:e,className:t}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{}),(0,B.jsx)(`div`,{className:C(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}var mu=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function hu(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&&mu.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function gu({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=hu(t),[i,a,o]=Ro(r,e||``,n);return(0,B.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,B.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,B.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.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,B.jsx)(R,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,B.jsx)(tn,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.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,B.jsx)(R,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,B.jsx)(tn,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.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,B.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,B.jsx)(R,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,B.jsx)(tn,{className:`w-3 h-3`})})]})}),(0,B.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 _u({certificate:e,domain:t,cluster:n}){let r=hu(t.domain),[i,a,o]=Ro(r,n.fqdn||``,t.id),s=(0,z.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,B.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,B.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,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,B.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,B.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,B.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 px-2 py-0.5 rounded text-xs`,children:[(0,B.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,B.jsx)(R,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,B.jsx)(tn,{className:`w-3 h-3`})})]}),(0,B.jsx)(vu,{}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 px-2 py-0.5 rounded text-xs`,children:[(0,B.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,B.jsx)(R,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,B.jsx)(tn,{className:`w-3 h-3`})})]})]}),(0,B.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.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,B.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,B.jsx)(R,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,B.jsx)(tn,{className:`w-2.5 h-2.5`})})]})})]})]})}function vu(){return(0,B.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,B.jsx)(`path`,{d:`M5 12h14`}),(0,B.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function yu(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l}=e;return M({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:()=>bu(e)})}async function bu({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 xu(e){return M({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await bu({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},enabled:!0,instanceClient:i({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:5e3})}function Su(e){return L(xu(e))}function Cu({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=hu(n),[o,s,c,l,u]=Ro(t,e,a,i||``,r);return(0,B.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,B.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,B.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.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,B.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,B.jsx)(tn,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.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,B.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,B.jsx)(tn,{className:`w-3.5 h-3.5`})})]})}),(0,B.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,B.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.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,B.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,B.jsx)(tn,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.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,B.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,B.jsx)(tn,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.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,B.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,B.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,B.jsx)(tn,{className:`w-3 h-3`})})]})}),(0,B.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 wu({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await u.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function Tu(){return I({mutationFn:e=>wu(e)})}x.object({domainId:x.string()});async function Eu(e){let{data:t}=await u.delete(`/Domain/${e.domainId}`);return t}function Du(){return I({mutationFn:e=>Eu(e)})}function Ou(e){return[...new Set(e)]}var ku=Ie();function Au(e,t,n){let{data:r}=Su(e.id),i=(0,z.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=Tu(),{mutate:s,isPending:c}=Du(),l=o||c,u=(0,z.useCallback)((t,n)=>{if(!po(e.status)){N.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:Ou((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{ni.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),N.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,z.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{ni.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),N.success(`Domain removed!`)}})},[s]),f=(0,z.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{ni.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),N.success(`Domain unbound!`)}})},[s]);return(0,z.useMemo)(()=>[ku.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!Mo(e)?(0,B.jsx)(`label`,{className:`p-10 -m-10`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),ku.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,B.jsxs)(Qi,{children:[(0,B.jsx)($i,{asChild:!0,children:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{children:t.domain}),(0,B.jsx)(R,{variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,B.jsx)(ea,{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!`})]})}}),ku.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,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,B.jsx)(`div`,{className:`py-2`,children:(0,B.jsx)(_u,{certificate:i,domain:n,cluster:e})}),(0,B.jsx)(R,{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,B.jsx)(Cu,{domain:n,cluster:e}):Mo(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,B.jsx)(gu,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var ju=x.object({domain:x.string(),organizationId:x.string()});async function Mu(e){let{data:t}=await u.post(`/Domain/`,e);return t}function Nu(){return I({mutationFn:e=>Mu(e)})}async function Pu(e){let{data:t}=await u.post(`/Domain/${e}/validate`);return t}async function Fu(e){let{data:t}=await u.get(`/Domain/?organizationId=${e}`);return t}function Iu(e){return M({queryKey:[e,`domains`],queryFn:()=>Fu(e)})}function Lu(){let{organizationId:e,clusterId:t}=j({strict:!1}),{data:n}=D(ga(t,!0)),{update:r}=Oi(e),{data:i,refetch:a,isFetching:o,isRefetching:s}=L(Iu(e)),c=(0,z.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[l]=(0,z.useState)({attribute:`domain`,descending:!1}),u=(0,z.useMemo)(()=>[{desc:l.descending,id:l.attribute}],[l]),d=fl(a),[f,m]=(0,z.useState)([]),h=(0,z.useCallback)(e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:g,isPending:_}=Tu(),v=(0,z.useCallback)(()=>{if(!po(n.status)){N.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}g({clusterId:n.id,domainIds:Ou((n.domainIds?.slice()||[]).concat(f)),generateDomainCerts:!0},{onSuccess:()=>{ni.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),N.success(`Domain(s) bound! Certificates are being generated in the background now.`),m([])}})},[n,f,g]),{mutateAsync:y,isPending:b}=Nu(),x=k({resolver:O(ju),defaultValues:{domain:``,organizationId:e}}),S=(0,z.useCallback)(async e=>{if(e){let t=e.domain.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean);for(let n of t)await y({...e,domain:n});x.reset(),await a(),N.success(`${p(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[y,x,a]),ee=(0,z.useCallback)(async()=>{let e=`Validating ${p(c.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of c)try{N.loading(e,{description:`${n++} of ${c.length} checked`,id:t}),await Pu(i.id)}catch{r+=1}r>0?N.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(),N.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[c]),te=Au(n,f,h),C=x.watch(`domain`),ne=(0,z.useMemo)(()=>typeof C==`string`?C.trim().split(`.`).length===2:!1,[C]),re=(0,z.useCallback)(()=>{typeof C==`string`&&x.setValue(`domain`,`${C.trim()}, www.${C.trim()}`)},[C,x]);return(0,B.jsx)(sl,{data:i||[],isFetching:o||s,columns:te,sortingState:u,children:(0,B.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,B.jsx)(H,{...x,children:(0,B.jsxs)(`form`,{id:`cluster-add-domain-form`,name:`cluster-add-domain-form`,onSubmit:x.handleSubmit(S),className:`flex gap-1 flex-col md:flex-row`,children:[(0,B.jsx)(W,{control:x.control,name:`domain`,render:({field:e})=>(0,B.jsxs)(G,{className:`flex-1`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`New Domain Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),ne&&(0,B.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,B.jsx)(R,{variant:`positiveOutline`,type:`button`,onClick:re,children:`Add www as well`})]}),(0,B.jsx)(q,{children:(0,B.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,B.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,B.jsxs)(R,{type:`submit`,variant:`submit`,disabled:b,children:[(0,B.jsx)(on,{}),` Add`]}),c.length>0&&(0,B.jsxs)(R,{variant:`positiveOutline`,onClick:ee,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,B.jsx)(st,{}),` `,(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,B.jsxs)(R,{variant:`defaultOutline`,onClick:d,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,B.jsx)(en,{}),` `,(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),f.length>0&&(0,B.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,B.jsxs)(R,{variant:`submit`,onClick:v,disabled:_,children:[(0,B.jsx)(Un,{}),` Bind `,p(f.length,`Domain`,`Domains`)]})})]})})}function Ru(){return(0,B.jsx)(pu,{className:`flex flex-col justify-start max-w-4xl`,children:(0,B.jsx)(Lu,{})})}var zu=T({username:ya,role:w().nonempty({error:`Please select a role.`}),password:va.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:w()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function Bu(e){await u.patch(`/ResetPasswordUpdater/${e}`)}async function Vu(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function Hu(){return I({mutationFn:Vu})}async function Uu({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 Wu(){return I({mutationFn:Uu})}async function Gu({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function Ku(){return I({mutationFn:Gu})}async function qu({clusterId:e,initialUsername:t,desiredUsername:n,newPassword:r,tempPassword:i,instanceClient:a}){if(!i)throw Error(`You may not have permission to set the password on this cluster.`);let o=a;try{let a=await fa({username:t,password:i,instanceClient:o,entityId:e});return a.instanceClient&&(o=a.instanceClient),n===`HDB_ADMIN`?await Uu({username:n,password:r,instanceClient:o}):(await Vu({username:n,password:r,role:`super_user`,active:!0,instanceClient:o}),await fa({username:n,password:r,instanceClient:o,entityId:e}),await Gu({username:s,instanceClient:o})),await Bu(e),a}catch(t){throw await h({entityId:e,instanceClient:o}),t}}function Ju(){return I({mutationFn:qu})}function Yu(){let{user:e}=Vr(),{clusterId:t}=j({strict:!1}),{data:r}=L(ga(t,!0)),i=F(),a=(0,z.useMemo)(()=>n(r),[r]),o=yi({operationsUrl:a}),{redirect:c}=Ne({strict:!1}),l=We(),u=k({resolver:O(zu),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:d,control:f,handleSubmit:p}=u;(0,z.useEffect)(()=>{d(`password`)},[d]);let h=r?.instances?.find(e=>e.tempPassword)?.tempPassword,{mutate:g,isPending:_}=Ju(),v=(0,z.useCallback)(async e=>{if(!a){N.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}g({instanceClient:o,clusterId:t,newPassword:e.password,tempPassword:h,initialUsername:s,desiredUsername:e.username},{onSuccess:async({message:e,user:t})=>{N.success(e),m.setUserForEntity(r,t),l.invalidate(),await i({to:c?.startsWith(`/`)?c:`../`})}})},[r,t,o,i,a,c,l,g,h]);return r&&!r.resetPassword?(0,B.jsx)(jt,{to:`../sign-in`,replace:!0}):(0,B.jsxs)(B.Fragment,{children:[(0,B.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,B.jsx)(ia,{})}),(0,B.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,B.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,B.jsx)(`h2`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,B.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,B.jsx)(H,{...u,children:(0,B.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:p(v),className:`my-4`,children:[(0,B.jsx)(W,{control:f,name:`username`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Username`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{autoComplete:`username`,type:`text`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:f,name:`password`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:f,name:`confirmPassword`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Confirm Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(R,{disabled:_,type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,children:`Create Admin User`})]})}),(0,B.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,B.jsx)(An,{size:36,className:`flex-none`}),(0,B.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 Xu({columns:e,data:t}){let n=Bt({data:t,columns:e,getCoreRowModel:Xe()});return(0,B.jsx)(`div`,{className:`bg-black-dark rounded-md`,children:(0,B.jsxs)(el,{children:[(0,B.jsx)(tl,{children:n.getHeaderGroups().map(e=>(0,B.jsx)(rl,{className:`border-none`,children:e.headers.map(e=>(0,B.jsx)(il,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:Pt(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,B.jsx)(nl,{className:`bg-black`,children:n.getRowModel().rows?.length?n.getRowModel().rows.map(e=>(0,B.jsx)(rl,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,B.jsx)(ol,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:Pt(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,B.jsx)(rl,{children:(0,B.jsx)(ol,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function Zu(){return(0,B.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,B.jsx)(`p`,{children:`No instances found.`})})}function Qu({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=Rr(t.id),i=yi({operationsUrl:(0,z.useMemo)(()=>c(t),[t])}),{update:a}=ji(),o=m.checkForFabricConnect(t.id),s=(0,z.useCallback)(async()=>{await h({instanceClient:i,entityId:t.id}),m.setUserForEntity(t,null)},[t,i]);return r||![`CLONE_READY`,`RUNNING`,`UPDATED`].includes(t.status)?(0,B.jsx)(rt,{className:`animate-spin`,color:`gray`}):!n||o?(0,B.jsxs)(`span`,{className:`flex gap-4`,children:[a&&!e&&(0,B.jsx)(A,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,B.jsx)(R,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,B.jsx)(A,{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,B.jsx)(R,{variant:a?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,B.jsxs)(`span`,{className:`flex gap-4`,children:[(0,B.jsx)(A,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,B.jsx)(R,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,B.jsx)(R,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:s,children:`Direct Sign Out`})]})}function $u({entityId:e,instanceClient:t},n){return M({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 ed(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function td({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function nd(){return I({mutationFn:td,onSuccess:(e,t)=>ni.invalidateQueries({queryKey:[t.entityId,`get_status`]})})}function rd({instance:e,index:t}){let{update:n}=ji(),r=V({operationsUrl:(0,z.useMemo)(()=>c(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:i,isPending:a}=nd(),[o,s]=(0,z.useState)(!1);(0,z.useEffect)(()=>{let e=setTimeout(()=>s(!0),t*500);return()=>clearTimeout(e)},[t]);let{data:l,isLoading:u,isFetching:d}=L($u(r,o&&n)),f=ed(l,`availability`)||`Unknown`,p=f===`Available`,m=f===`Unavailable`;return n?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsxs)(Qi,{children:[(0,B.jsx)($i,{asChild:!0,children:(0,B.jsx)(`div`,{className:`flex items-center`,children:u||!o||d&&!l?(0,B.jsx)(rt,{className:`animate-spin size-5 text-muted-foreground`}):(0,B.jsx)(wo,{variant:p?`success`:m?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,B.jsx)(`span`,{className:`sr-only`,children:p?`Online`:`Offline`})})})}),(0,B.jsxs)(ea,{children:[d&&l?`Refreshing... `:``,f]})]}),n&&(0,B.jsxs)(`div`,{className:`flex gap-1`,children:[p&&(0,B.jsxs)(Qi,{children:[(0,B.jsx)($i,{asChild:!0,children:(0,B.jsx)(R,{variant:`destructiveGhost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Unavailable`}),disabled:a,children:a?(0,B.jsx)(rt,{className:`animate-spin size-4`}):(0,B.jsx)(Bn,{className:`size-4`})})}),(0,B.jsx)(ea,{children:`Bring out of rotation`})]}),m&&(0,B.jsxs)(Qi,{children:[(0,B.jsx)($i,{asChild:!0,children:(0,B.jsx)(R,{variant:`ghost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Available`}),disabled:a,children:a?(0,B.jsx)(rt,{className:`animate-spin size-4`}):(0,B.jsx)(gr,{className:`size-4`})})}),(0,B.jsx)(ea,{children:`Bring back into rotation`})]})]})]}):null}function id(){let{clusterId:e}=j({strict:!1}),{data:t,isLoading:n}=L(ga(e,!0)),r=Mo(t),i=(0,z.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,B.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,B.jsx)(Qu,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>Ac({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,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(rd,{instance:e.row.original,index:e.row.index}),t?(0,B.jsx)(wo,{variant:fo(t),children:na(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,B.jsxs)(B.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(ri),[r]),a=(0,z.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!ua.includes(e.status)).sort(rs):[],[t]);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,B.jsx)(Gr,{className:`p-0 mt-4 min-h-96`,children:(0,B.jsx)(Yr,{className:`p-0 min-h-96`,children:n?(0,B.jsx)(Xs,{}):a.length?(0,B.jsx)(Xu,{data:a,columns:i}):(0,B.jsx)(Zu,{})})})})]})}function ad(){let{clusterId:e}=j({strict:!1}),{data:t,isLoading:n}=L(ga(e,2e3)),r=t?.status,i=(0,z.useMemo)(()=>r&&la.includes(r),[r]);return n||!t?(0,B.jsx)(pu,{className:`flex justify-center`,children:(0,B.jsx)(Xs,{})}):i?(0,B.jsx)(pu,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,B.jsx)(Fo,{cluster:t,forceProgressBarVisible:!0}),(0,B.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,B.jsx)(`div`,{className:`text-center`,children:(0,B.jsx)(No,{cluster:t})})]})}):(0,B.jsx)(pu,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,B.jsx)(Fo,{cluster:t,forceProgressBarVisible:!0}),(0,B.jsxs)(`p`,{children:[`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,B.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,B.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 od(){let e=We(),{clusterId:t}=j({strict:!1}),{data:n,isLoading:r}=L(ga(t,2e3)),i=n?.status,a=(0,z.useMemo)(()=>i&&la.includes(i),[i]),o=mo(i),[,s]=Ho(Uo.SavedClusterState,null),c=(0,z.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,B.jsx)(pu,{className:`flex justify-center`,children:(0,B.jsx)(Xs,{})}):o?(0,B.jsx)(pu,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,B.jsx)(mr,{className:`w-24 h-24`}),(0,B.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,B.jsx)(Go,{}),` if you want more help.`]}),(0,B.jsx)(R,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,B.jsx)(pu,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,B.jsx)(Fo,{cluster:n,forceProgressBarVisible:!0}),(0,B.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,B.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,B.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,B.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,B.jsx)(`div`,{className:`text-center`,children:(0,B.jsx)(No,{cluster:n})})]})}):(0,B.jsx)(pu,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,B.jsx)(Fo,{cluster:n,forceProgressBarVisible:!0}),(0,B.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,B.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,B.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.`]})]})]})})}P({getParentRoute:()=>fu,path:`instances`,component:id}),P({getParentRoute:()=>fu,path:`starting-up`,component:od}),P({getParentRoute:()=>fu,path:`scaling`,component:ad}),P({getParentRoute:()=>fu,path:`domains`,component:Ru}),P({getParentRoute:()=>fu,path:`sign-in`,component:Ea,beforeLoad:({context:e,location:t,params:n})=>{let r=m.checkForFabricConnect(n.clusterId);if(e.authentication[n.clusterId]?.user&&!r){let e=t?.search;throw Gt({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),P({getParentRoute:()=>fu,path:`instance/$instanceId/sign-in`,component:Ea,beforeLoad:({context:e,location:t,params:n})=>{if(!(m.checkForFabricConnect(n.clusterId)||m.checkForFabricConnect(n.instanceId))&&e.authentication[n.instanceId]?.user){let e=t?.search;throw Gt({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),P({getParentRoute:()=>fu,path:`finish-setup`,component:Yu});function sd(e){return P({getParentRoute:()=>e,path:`apis`}).lazy(()=>Hr(()=>import(`./index.lazy-D5vviOl1.js`).then(e=>e.route),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])))}function cd(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 ld(e,t){let[n,r]=(0,z.useState)(t),[i,a]=(0,z.useState)(e);return(0,z.useEffect)(()=>{cd(n,t)||(r(t),a(e))},[n,t,e]),cd(n,t)?[i,a]:[e,a]}var ud={};function dd(e,t,n){let r=(0,z.useCallback)((e,n)=>t(e,n),[n]);(0,z.useEffect)(()=>(ud[e]||(ud[e]=[]),ud[e].push(r),function(){let t=ud[e].indexOf(r);t>=0&&ud[e].splice(t,1)}),[e,t,r])}function fd(e,t,n){let r=ud[e];if(r)for(let e of r)e(t,n)}function pd(e,t,n){return r=>fd(e,t,n??r)}function md(e,t,n){return(0,z.useCallback)(r=>fd(e,t,n??r),[e,t,n])}function hd(e,t){return zo(sessionStorage.getItem(String(e)))??t}function gd(e,t){t==null?sessionStorage.removeItem(String(e)):sessionStorage.setItem(String(e),JSON.stringify(t))}function _d(e,t){let n=ld(hd(e,t),[e]),[r,i]=n;return(0,z.useEffect)(()=>{gd(e,r),fd(`Session:${e}`,r)},[e,r]),dd(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,z.useEffect)(function(){let n=n=>{n.key===e&&i(hd(e,t))};return window.addEventListener(`storage`,n),()=>{window.removeEventListener(`storage`,n)}},[e,i,t]),n}function vd(e,t=!1){let[n,r]=_d(e,t),i=(0,z.useCallback)(e=>{e?.preventDefault?.(),r(e=>!e)},[r]),a=(0,z.useCallback)(e=>{e?.preventDefault?.(),r(!0)},[r]),o=(0,z.useCallback)(e=>{e?.preventDefault?.(),r(!1)},[r]);return(0,z.useMemo)(()=>({toggled:n,setToggled:r,toggle:i,toggleOn:a,toggleOff:o}),[i,r,o,a,n])}var yd=(0,z.createContext)(null);function bd(){return(0,z.useContext)(yd)}async function xd({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 Sd(e){let t=(e||``)?.split(`.`);return t.length>1?t.slice(-1)[0]:``}function Cd(e){switch(Sd(e).toLowerCase()){case`jpg`:case`jpeg`:case`gif`:case`png`:case`pneg`:case`webp`:return!0;default:return!1}}async function wd({instanceClient:e,file:t,project:n,encoding:r}){let{data:i}=await e.post(`/`,{operation:`get_component_file`,file:t,project:n,encoding:r??(Cd(t)?`base64`:`utf8`)});return{file:t,project:n,...i}}function Td(e){return M({queryKey:Ed(e),queryFn:()=>wd(e),enabled:!!e.file&&!!e.project,retry:!1})}function Ed(e){return[e.entityId,`get_component_file`,e.file,e.project,e.encoding]}async function Dd({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 Od(){return I({mutationFn:Dd})}function kd(){let{reloadRootEntries:e,setFocusedItem:t,setSelectedItems:n}=bd(),r=V();return(0,z.useCallback)(async i=>{let a=!1,o=i.filter(e=>e.from!==e.to);if(o.length===0)return;let s=`Renaming ${p(o.length,`File`,`Files`)}`,c={duration:6e4,action:{label:`Cancel`,onClick:()=>{a=!0}}};c.id=N.loading(s,{...c,description:(0,B.jsx)(ps,{animated:!0,width:`0%`})});let l=o.length*3,u=0;function d(){u+=1,N.loading(s,{...c,description:(0,B.jsx)(ps,{animated:!0,width:(u===0?0:u/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 wd({...r,file:i,project:n,encoding:`base64`});if(a||(d(),await Dd({...r,file:c,project:s,encoding:`base64`,payload:l.message}),a)||(d(),await xd({...r,file:i,project:n}),a))break;d()}u>=l?N.success(`Renamed ${p(o.length,`File`,`Files`)}`,{id:c.id,description:`All done!`,duration:3e3,action:{label:`OK`,onClick:()=>{}}}):N.warning(`Rename Cancelled`,{id:c.id,description:`${u} 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 Ad(e,t){return e[t]!==void 0}function jd(e){return t=>Ad(t,e)}function Md(e,t){let[n,r]=(0,z.useState)({value:t});return dd(e,(e,t)=>r({value:e,trigger:t}),[r]),n}function Nd(e,t,n){fd(e,t,n)}function Pd(e,t,n){return r=>Nd(e,t,n??r)}function Fd(e,t,n){return(0,z.useCallback)(r=>{Nd(e,t,n??r)},[e,t,n])}var Id=[{handleGlobal(e,t){if((t.cmd||t.ctrl)&&e===`Delete`)return Nd(`ShowDeleteDirectoryOrFileModal`,!0),!0},addEditorAction(e){return{id:`delete-file`,label:`Delete File`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.Delete],run:Pd(`ShowDeleteDirectoryOrFileModal`,!0)}}},{handleGlobal(e,t){if(t.ctrl&&t.alt&&t.shift&&e===`˜`)return Nd(`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:Pd(`ShowAddDirectoryOrFileModalType`,`directory`)}}},{handleGlobal(e,t){if(t.ctrl&&e===`n`)return Nd(`ShowAddDirectoryOrFileModalType`,`file`),!0},addEditorAction(e){return{id:`new-file`,label:`New File`,keybindings:[e.KeyMod.WinCtrl|e.KeyCode.KeyN],run:Pd(`ShowAddDirectoryOrFileModalType`,`file`)}}},{handleGlobal(e){if(e===`F2`)return Nd(`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:Pd(`ShowRenameFileModal`,!0)}}},{addEditorAction(){return{id:`revert-file`,label:`Revert File`,run:pd(`RevertChanges`,!0)}}},{handleGlobal(e,t){if(t.cmd&&e===`s`)return fd(`SaveFile`,!0),!0},addEditorAction(e){return{id:`save-file`,label:`Save Changes`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.KeyS],run:pd(`SaveFile`,!0)}}}],Ld=Id.filter(jd(`addEditorAction`)),Rd=Id.filter(jd(`handleGlobal`));function zd(e){let[t,n]=e,r=Ld.map(e=>t.addAction(e.addEditorAction(n)));return()=>{for(let e of r)e?.dispose()}}function Bd(){(0,z.useEffect)(()=>(document.addEventListener(`keydown`,Vd),()=>{document.removeEventListener(`keydown`,Vd)}),[])}function Vd(e){let t={cmd:e.getModifierState(`Meta`),alt:e.getModifierState(`Alt`),shift:e.getModifierState(`Shift`),ctrl:e.getModifierState(`Control`)};for(let n of Rd)if(n.handleGlobal(e.key,t)){e.preventDefault();return}}function Hd(e){return e.split(`/`).pop()}function Ud(...e){return e.flat(1).join(`/`)}function Wd(e){return!!e?.entries}var Gd=`__root__`,Kd=`importedApplications`,qd=`newApplication`;function Jd(e){let t={},n=[],r=[],i=[];for(let a of e)Wd(a)?a.package?r.push(a.path):n.push(a.path):i.push(a.path),Yd(t,a);return t[Gd]={index:Gd,isFolder:!0,children:[qd,Kd,...n,...i],data:void 0,canMove:!1,canRename:!1},t[Kd]={index:Kd,isFolder:!0,children:r,data:{name:`Imported Applications`,path:Kd,package:Kd,project:``,entries:[]},canMove:!1,canRename:!1},t[qd]={index:qd,isFolder:!1,data:{name:`New Application`,path:qd,project:``},canMove:!1,canRename:!1},{items:t,rootId:Gd}}function Yd(e,t){let n=t.path;if(Wd(t)){let r=t,i=[],a=[];for(let e of r.entries)Wd(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)Yd(e,t)}else e[n]={index:n,isFolder:!1,data:t,canMove:!t.package,canRename:!t.package}}function Xd(){let[e,t]=(0,z.useState)(!1),[n,r]=(0,z.useState)(void 0),i=(0,z.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,z.useCallback)(()=>{t(!1),r(e=>{e&&e.classList.remove(`rct-tree-item-title-container-dragging-over`)})},[]),o=(0,z.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,z.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,z.useMemo)(()=>({dragging:e,dragTarget:n}),[e,n])}function Zd(e){return new Promise((t,n)=>{let r=new FileReader;r.onabort=n,r.onerror=n,r.onload=t,r.readAsDataURL(e)})}function Qd(){let[e,n]=(0,z.useState)(``),{clusterId:r}=j({strict:!1}),{openedEntry:i,restrictPackageModification:a,reloadRootEntries:o,entryExists:s}=bd(),c=!!i&&!i.package&&!a,l=V(),{dragging:u,dragTarget:d}=Xd(),f=(d?.getAttribute?.(`data-rct-item-id`))?.split?.(`/`)?.pop?.(),h=i?.project,g=!1,_;if(i?.path){let e=i.path.split(`/`),t=Wd(i);g=c&&(t?e.slice(1):e.slice(1,-1)).join(`/`),_=e[e.length-(t?1:2)]}let y=(0,z.useCallback)(async(e,t)=>{let r=d?.getAttribute?.(`data-rct-item-id`)?.split?.(`/`),i=r?.length?r[0]:c?h:!1,a=r?.length?r.slice(1).join(`/`):c?g:!1;if(i===!1||i===void 0||a===!1||a===void 0)return;let u=[],f=t.slice();for(let t of e){let e=$d(a,t);t.name.startsWith(`.`)||t.relativePath?.includes(`/.`)?f.push({file:t,errors:[{message:`Sensitive files and folders starting with . are skipped.`,code:`dot-ignored`}]}):s(`${i}/${e}`)?f.push({file:t,errors:[{message:`${e} already exists`,code:`duplicate`}]}):u.push(t)}let m=!1,_=`uploading-files`,v={label:`Cancel`,onClick:()=>{m=!0}},y={label:`OK`,onClick:()=>void 0};n(`Uploading ${p(u.length,`file`,`files`)}...`);let b=u.reduce((e,t)=>e+t.size,0),x=0,S=0;for(let e of u){S+=1,N.loading(`Upload in progress...`,{id:_,descriptionClassName:`whitespace-pre`,description:`${S} of ${p(u.length,`file`,`files`)}
|
|
11
|
+
`)}}];function fl(e){return(0,z.useCallback)(async()=>{N.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await a(500),N.success(`Refreshed!`,{id:`refreshing`})},[e])}async function pl(e){let{data:t}=await u.get(`/Invoice/${e}`);return t}function ml(e,t){return M({queryKey:[e,`invoices`],queryFn:()=>pl(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function hl(){let{organizationId:e}=j({strict:!1}),{data:t}=L(bs(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=L(ml(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=fl(r);return t?.type===`ENTERPRISE`?(0,B.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,B.jsx)(Go,{}),`, we would love to talk!`]}):i?(0,B.jsx)(Ko,{centered:!0}):!n||!n.length?(0,B.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,B.jsx)(Go,{overEmail:!0}),`, we would love to talk!`]}):(0,B.jsx)(sl,{data:n,columns:dl,children:(0,B.jsxs)(R,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,B.jsx)(en,{}),(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function gl(e){let t=P({getParentRoute:()=>e,path:`billing`,component:Zc}),n=P({getParentRoute:()=>t,path:`/`,component:Hs}),r=P({getParentRoute:()=>t,path:`invoices`,component:hl}),i=P({getParentRoute:()=>t,path:`confirm`,component:Kc});return t.addChildren([n,r,i])}async function _l(e){let{data:t}=await u.get(`/OrganizationRole/${e}`);return t}function vl(e){return M({queryKey:[e,`roles`],queryFn:()=>_l(e),retry:!1,refetchInterval:10*1e3})}var yl=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},Ie().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 bl(e){let{data:t}=await u.post(`/Role/`,e);return t}function xl(){return I({mutationFn:bl})}var Sl=T({name:w().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:E(),delete:E()});T({roles:T({create:E(),delete:E(),update:E(),view:E()}),clusters:T({create:E(),delete:E(),update:E(),view:E(),resources:te(T({id:w(),delete:E(),update:E(),view:E(),instances:T({create:E(),delete:E(),update:E(),view:E()})}))})});var Cl={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function wl({isModalOpen:e,setIsModalOpen:t}){let n=Wn(),{organizationId:r}=j({strict:!1}),[i,a]=(0,z.useState)(!0),[o,s]=(0,z.useState)(JSON.stringify(Cl,null,2)),{mutate:c,isPending:l}=xl(),u=k({resolver:O(Sl),defaultValues:{name:``,update:!1,delete:!1}}),d=(0,z.useCallback)(e=>{a(e.length===0)},[a]),f=(0,z.useCallback)(async e=>{let a=zo(o);if(!a)return;let s={...e,...a,organizationId:r};e&&i&&c(s,{onSuccess:()=>{N.success(`Organization role added successfully!`),t(!1),n.invalidateQueries({queryKey:[r,`roles`],refetchType:`active`}),u.reset()},onError:e=>{N.error(`Failed to add organization role: ${e.message}`)}})},[i,o,c,u,n,t,r]);return(0,B.jsx)(Y,{onOpenChange:t,open:e,children:(0,B.jsxs)(X,{children:[(0,B.jsx)(Q,{children:`Add New Organization Role`}),(0,B.jsx)(So,{children:`Set the new organization role permissions.`}),(0,B.jsx)(H,{...u,children:(0,B.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,B.jsx)(W,{control:u.control,name:`name`,render:({field:e})=>(0,B.jsxs)(G,{className:`col-span-2`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Role Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,className:``,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:u.control,name:`update`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Update Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:u.control,name:`delete`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Delete Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(`div`,{className:`col-span-2`,children:(0,B.jsx)(ze,{theme:`vs-dark`,height:`300px`,defaultLanguage:`json`,onValidate:d,onChange:e=>{e&&s(e)},defaultValue:JSON.stringify(Cl,null,2)})}),(0,B.jsx)(Z,{className:`col-span-2`,children:(0,B.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,B.jsx)(R,{variant:`destructiveOutline`,className:`rounded-full`,type:`button`,onClick:()=>t(!1),disabled:l,children:`Cancel`}),(0,B.jsx)(R,{variant:`submit`,className:`rounded-full`,disabled:l||!i||!u.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function Tl({roleId:e}){let{data:t}=await u.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function El(){return I({mutationFn:({roleId:e})=>Tl({roleId:e})})}async function Dl({roleId:e,updatedRoleInfo:t}){let{data:n}=await u.put(`/Role/${e}`,t);return n}function Ol(){return I({mutationFn:({roleId:e,updatedRoleInfo:t})=>Dl({roleId:e,updatedRoleInfo:t})})}function kl({organizationId:e,roleId:t}){return M({queryKey:[e,`roles`,t],queryFn:()=>Al(t),refetchInterval:10*1e3})}async function Al(e){let{data:t}=await u.get(`/Role/${e}`);return t}function jl({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Q,{children:`Confirm Role Deletion`}),(0,B.jsx)(So,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,B.jsxs)(Z,{children:[(0,B.jsx)(R,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,onClick:()=>t(!1),children:`Cancel`}),(0,B.jsx)(R,{variant:`destructiveOutline`,className:`rounded-full`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function Ml({data:e,isModalOpen:t,closeModal:n}){let r=Wn(),{data:i}=D(kl({roleId:e.id,organizationId:e.organizationId})),a=Vr(),o=a.user&&a.user?.roles?.[e.organizationId]?.role===e.roleName,{update:s,remove:c}=Oi(e.organizationId),{mutate:l,isPending:u}=Ol(),{mutate:d,isPending:f}=El(),[p,m]=(0,z.useState)(!1),h=k({resolver:O(Sl),defaultValues:{name:e.roleName,update:i.organization.update||!1,delete:i.organization.delete||!1}}),g=(0,z.useCallback)(()=>{d({roleId:e.id},{onSuccess:()=>{N.success(`Role deleted successfully!`),n(!0),h.reset()},onError:e=>{N.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>N.dismiss()}})}})},[e.id,d,h,n]),[_,v]=(0,z.useState)(!0),[y,b]=(0,z.useState)(JSON.stringify({roles:{...i.organization.roles},clusters:{...i.organization.clusters}},null,2)),x=(0,z.useCallback)(e=>{v(e.length===0)},[v]),S=(0,z.useCallback)(async t=>{if(!s)return;let i=zo(y);if(!i)return;let a={...t,...i,organizationId:e.organizationId};y&&_&&l({roleId:e.id,updatedRoleInfo:a},{onSuccess:async()=>{N.success(`Role updated successfully!`),await r.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),n(!1),h.reset()},onError:e=>{N.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>N.dismiss()}})}})},[n,e.id,e.organizationId,h,_,r,i,s,y,l]);return(0,B.jsx)(Y,{onOpenChange:(0,z.useCallback)(()=>n(!1),[n]),open:t,children:(0,B.jsx)(X,{children:p?(0,B.jsx)(jl,{onRoleDeleteClick:g,setIsConfirmingRoleDeletion:m,isRoleDeletionPending:f}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(Q,{children:[o||!s?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,B.jsx)(H,{...h,children:(0,B.jsxs)(`form`,{id:`org-edit-role-form`,name:`org-edit-role-form`,className:`grid grid-cols-2 gap-4 my-4`,onSubmit:h.handleSubmit(S),children:[(0,B.jsx)(W,{control:h.control,name:`name`,render:({field:e})=>(0,B.jsxs)(G,{className:`col-span-2`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Role Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:h.control,name:`update`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Update Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:h.control,name:`delete`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Delete Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(`div`,{className:`col-span-2`,children:(0,B.jsx)(ze,{theme:`vs-dark`,height:`300px`,defaultLanguage:`json`,onValidate:x,onChange:e=>{e&&b(e)},options:o||!s?{readOnly:!0}:void 0,defaultValue:y})}),!o&&(c||s)&&(0,B.jsx)(Z,{className:`col-span-2`,children:(0,B.jsxs)(`div`,{className:`flex justify-between w-full`,children:[c&&(0,B.jsx)(R,{type:`button`,variant:`destructiveOutline`,className:`rounded-full`,onClick:()=>m(!0),disabled:u,children:`Delete Role`}),s&&(0,B.jsx)(R,{variant:`submit`,className:`rounded-full`,disabled:!_||u||!h.formState.isValid||!h.formState.isDirty,children:`Save Changes`})]})})]})})]})})})}function Nl(){let e=F(),t=Wn(),{organizationId:n,orgRoleId:r}=j({strict:!1}),{create:i}=Oi(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=D(vl(n)),l=(0,z.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,z.useState)(!1),p=(0,z.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,z.useCallback)(()=>{f(!0)},[f]),h=(0,z.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,z.useCallback)(e=>p(void 0,e),[p]),_=fl(o);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,B.jsxs)(z.Suspense,{fallback:(0,B.jsx)(Ko,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,B.jsxs)(sl,{data:a,columns:yl,onRowClick:h,children:[(0,B.jsxs)(R,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,B.jsx)(en,{}),(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,B.jsxs)(R,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,B.jsx)(on,{}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,B.jsx)(wl,{isModalOpen:d,setIsModalOpen:f}),u&&(0,B.jsx)(Ml,{data:l,isModalOpen:u,closeModal:g})]})})]})}var Pl=[{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},Ie().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}],Fl=x.object({email:_a.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:x.string().nonempty({error:`Please select a role.`})});async function Il(e){let{data:t}=await u.post(`/OrganizationRole/`,e);return t}function Ll(){return I({mutationFn:e=>Il(e)})}x.object({email:_a.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:x.string().nonempty({error:`Please select a role.`})});async function Rl(e){let{data:t}=await u.post(`/UserInvite/`,e);return t}function zl(){return I({mutationFn:e=>Rl(e)})}function Bl({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=j({strict:!1}),{data:i}=D(vl(r)),[a,o]=(0,z.useState)(!1),s=k({resolver:O(Fl),defaultValues:{email:``,roleId:``}}),{mutate:c,isPending:l}=Ll(),{mutate:u,isPending:d}=zl(),f=(0,z.useCallback)(async e=>{e&&(a?u:c)(e,{onSuccess:()=>{let r=e.roleId;s.reset(),s.setValue(`roleId`,r),t(),N.success(`User invited successfully!`),n(!1),o(!1)},onError:e=>{e?.status===404&&o(!0)}})},[c,s,u,t,n,a]);return(0,B.jsx)(Y,{onOpenChange:()=>{n(!1),o(!1),s.reset()},open:e,children:(0,B.jsx)(X,{"aria-describedby":void 0,children:(0,B.jsx)(H,{...s,children:(0,B.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:s.handleSubmit(f),className:`grid gap-4 my-4`,children:[(0,B.jsx)(xo,{children:(0,B.jsx)(Q,{children:a?`Invite User`:`Add User`})}),(0,B.jsx)(W,{control:s.control,name:`email`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Email`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:s.control,name:`roleId`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Roles`}),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(Xs,{}),children:(0,B.jsx)(U,{children:(0,B.jsxs)(Zs,{...e,onValueChange:t=>e.onChange(t),children:[(0,B.jsx)(ec,{className:`w-full`,children:(0,B.jsx)($s,{placeholder:`Choose Role`})}),(0,B.jsx)(tc,{children:(0,B.jsxs)(Qs,{children:[(0,B.jsx)(nc,{children:`Role`}),i?.map(e=>(0,B.jsx)($,{value:e.id,children:e.roleName},e.id))]})})]})})}),(0,B.jsx)(q,{})]})}),a&&(0,B.jsxs)(So,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,B.jsx)(dt,{className:`inline-block size-12 pr-2`}),(0,B.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,B.jsx)(Z,{children:(0,B.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,B.jsxs)(R,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:l||d,children:[(0,B.jsx)(Un,{}),` `,a?`Invite User`:`Add User`]})})})]})})})})}async function Vl({roleId:e,userId:t}){let{data:n}=await u.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function Hl(){return I({mutationFn:({roleId:e,userId:t})=>Vl({roleId:e,userId:t})})}function Ul(e){let[t,n]=(0,z.useState)(e||!1);return[t,(0,z.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function Wl({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=Ll(),{mutate:c,isPending:l}=Hl(),u=!!i[r.roleName],[d,f]=(0,z.useState)(u),[p,m]=Ul(u);return(0,z.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),N.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),N.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,B.jsxs)(ca,{className:`flex`,children:[(0,B.jsx)(J,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,B.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function Gl({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r}){let{organizationId:i}=j({strict:!1}),a=Vr(),{update:o,remove:s}=Oi(i),c=a.user?.email===t.email,{data:l}=D(vl(i)),u=(0,z.useMemo)(()=>t.roles?as(t.roles,`roleName`):{},[t]),[d,f]=(0,z.useState)(!1);return(0,B.jsx)(Y,{onOpenChange:d?r:e,open:n,children:(0,B.jsxs)(X,{className:`sm:max-w-[750px]`,children:[(0,B.jsx)(xo,{children:(0,B.jsxs)(Q,{children:[o?`Edit `:`View `,` `,t.email,` `,c?`(yourself)`:``]})}),o&&(0,B.jsxs)(So,{children:[`To remove `,c?`your self`:`this user`,` from the organization, uncheck all of the boxes below.`]}),l.map(e=>(0,B.jsx)(Wl,{readOnly:!o,canRemove:s,data:t,orgRole:e,selectedRoles:u,setChangesMade:f},e.id))]})})}function Kl(e,t){return e.email>t.email?1:-1}function ql(){let e=F(),{organizationId:t,orgUserId:n}=j({strict:!1}),{update:r}=Oi(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=D(vl(t)),c=(0,z.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(Kl)},[i]),l=(0,z.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),u=(0,z.useCallback)(t=>{e({to:[n?`..`:``,t].filter(Boolean).join(`/`)})},[n,e]),d=!!n&&!!l,[f,p]=(0,z.useState)(!1),[m]=(0,z.useState)({attribute:`email`,descending:!1}),h=(0,z.useMemo)(()=>[{desc:m.descending,id:m.attribute}],[m]),g=(0,z.useCallback)(()=>{p(!0)},[p]),_=(0,z.useCallback)(()=>{a(),p(!1)},[a,p]),v=(0,z.useCallback)(e=>{u(e.original.id)},[u]),y=(0,z.useCallback)(()=>{u(void 0)},[u]),b=(0,z.useCallback)(()=>{a(),u(void 0)},[u,a]),x=fl(a);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,B.jsxs)(z.Suspense,{fallback:(0,B.jsx)(Ko,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,B.jsxs)(sl,{data:c,isFetching:o||s,columns:Pl,onRowClick:v,sortingState:h,children:[(0,B.jsxs)(R,{variant:`defaultOutline`,onClick:x,accessKey:`r`,disabled:o||s,children:[(0,B.jsx)(en,{}),` `,(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,B.jsxs)(R,{variant:`positiveOutline`,onClick:g,accessKey:`a`,disabled:f,children:[(0,B.jsx)(on,{}),` `,(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,B.jsx)(Bl,{isModalOpen:f,onChangesSaved:_,setIsModalOpen:p}),d&&(0,B.jsx)(Gl,{closeModal:y,data:l,isModalOpen:d,onUserUpdated:b})]})})]})}function Jl({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=Di(n),s=o,{view:c}=Oi(n),l=(0,z.useCallback)(()=>{t(e)},[t,e]);return(0,B.jsxs)(Gr,{className:`relative h-full justify-between`,children:[(0,B.jsxs)(Kr,{children:[(0,B.jsxs)(Jr,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`truncate`,children:n}),a&&(0,B.jsxs)(To,{children:[(0,B.jsx)(Eo,{className:`p-4 -m-4 -mr-6 hover:text-white`,children:(0,B.jsx)(fr,{"aria-label":`Options`})}),(0,B.jsxs)(Do,{children:[(0,B.jsx)(Ao,{className:`text-gray-600 text-xs`,children:`Options`}),(0,B.jsx)(jo,{}),(0,B.jsx)(A,{to:`${n}`,children:(0,B.jsx)(Oo,{children:`Clusters`})}),c&&(0,B.jsx)(A,{to:`${n}/roles`,children:(0,B.jsx)(Oo,{children:`Roles`})}),c&&(0,B.jsx)(A,{to:`${n}/users`,children:(0,B.jsx)(Oo,{children:`Users`})}),s&&(0,B.jsx)(A,{to:`${n}/billing`,children:(0,B.jsx)(Oo,{children:`Billing`})}),(0,B.jsx)(jo,{}),a&&(0,B.jsx)(Oo,{className:`focus:bg-red/70 focus:text-white`,onClick:l,children:`Delete`})]})]})]}),(0,B.jsx)(qr,{children:(0,B.jsx)(`h2`,{children:r})})]}),(0,B.jsxs)(Yr,{className:`flex justify-between`,children:[(0,B.jsx)(wo,{children:na(i)}),(0,B.jsx)(A,{to:n,className:`text-sm`,"aria-label":`View ${r}`,title:`View ${r}`,children:(0,B.jsxs)(`span`,{className:`py-2 transition-all duration-100 ease-in-out border-0 hover:border-b-2`,children:[`View `,(0,B.jsx)(lt,{className:`inline-block`})]})})]})]})}async function Yl(e){let{data:t}=await u.delete(`/Organization/${e}`);return t}function Xl(){return I({mutationFn:e=>Yl(e)})}async function Zl(e){let{data:t}=await u.post(`/Organization/`,{...e});return t}function Ql(){return I({mutationFn:e=>Zl(e)})}var $l=w().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.`}),eu=T({name:w().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:se([S(``),y(),$l])});function tu(){let{user:e}=Vr(),t=F(),n=k({resolver:O(eu),defaultValues:{name:``,subdomain:``}}),{setFocus:i,watch:a}=n;(0,z.useEffect)(()=>{i(`name`)},[i]);let o=`${e?.firstname} ${e?.lastname} Org`,s=a(`name`)||o,c=a(`subdomain`),l=(0,z.useMemo)(()=>{let e=Ss(ws(s),$l.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${c||e}.harperfabric.com`}},[s,c]),{mutate:u,isPending:f}=Ql(),p=Wn(),h=(0,z.useCallback)(async e=>{u({name:e.name||o,subdomain:e.subdomain||l.suggestedSubdomain},{onSuccess:e=>{p.invalidateQueries({queryKey:r,refetchType:`active`}),m.reloadUser(d),t({to:`/${e.id}`})}})},[l.suggestedSubdomain,p,u,o,t]);return(0,B.jsx)(B.Fragment,{children:(0,B.jsx)(H,{...n,children:(0,B.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,B.jsx)(W,{control:n.control,name:`name`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,maxLength:eu.shape.name.maxLength,autoCapitalize:`words`,placeholder:o,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:n.control,name:`subdomain`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Subdomain`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,maxLength:$l.maxLength,autoCapitalize:`none`,placeholder:l.suggestedSubdomain,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Full Host Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(`span`,{children:l.fullHostName})}),(0,B.jsx)(q,{})]}),(0,B.jsx)(Z,{children:(0,B.jsxs)(R,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:f,children:[`Create New Organization `,(0,B.jsx)(lt,{})]})})]})})})}function nu(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{}),(0,B.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,B.jsx)(tu,{})})]})}function ru(){let e=Wn(),{data:t}=D(_()),{mutate:n,isPending:r}=Xl(),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(``),u=(0,z.useCallback)(()=>l(``),[]),d=(0,z.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(Vc([`organizationId`,`organizationName`],c)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1)||[]},[c,t?.roles]),f=(0,z.useCallback)(e=>{l(e.currentTarget.value?.toLowerCase()||``)},[]),p=(0,z.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{N.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>N.dismiss()}}),e.invalidateQueries({queryKey:[]}),a(!1)},onError:()=>a(!1)})},[n,e,a]),m=(0,z.useCallback)(e=>{s(e),a(!0)},[]),{createCluster:h}=Ne({strict:!1});return d.length===1&&!c.length&&h?(0,B.jsx)(jt,{to:`/${d[0].organizationId}/new-cluster`,replace:!0}):!d.length&&!c.length?(0,B.jsx)(nu,{}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{children:(0,B.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,B.jsx)(J,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:c,onChange:f}),(0,B.jsx)(A,{to:`/new-org`,children:(0,B.jsxs)(R,{variant:`positive`,accessKey:`n`,children:[(0,B.jsx)(on,{}),(0,B.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,B.jsx)(`u`,{children:`N`}),`ew `,(0,B.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,B.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[d.map(e=>(0,B.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,B.jsx)(Jl,{organizationRole:e,onDeleteOrgModal:m})},e.organizationId)),!d.length&&(0,B.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,B.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,B.jsx)(R,{variant:`outline`,onClick:u,children:`Clear Filters`})]})]})}),o&&(0,B.jsx)(Co,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:o.organizationName,isModalOpen:i,setIsModalOpen:()=>a(!1),deletionConfirmed:()=>p(o),deletionPending:r})]})}function iu(){let{isLoading:e}=Lr(),{createCluster:t}=Ne({strict:!1}),[,n]=Ho(Uo.SavedClusterState,null);return(0,z.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,B.jsx)(Ko,{className:`fixed z-50 translate-1/2`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.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,B.jsx)(Li,{})}),(0,B.jsx)(`main`,{children:(0,B.jsx)(Ze,{})})]})}var au=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function ou(){let e=Uc();return!au.includes(e)&&{redirect:e}}var su=P({getParentRoute:()=>li,id:`_dashboardLayout`,component:iu,beforeLoad:({context:e})=>{let t=e.authentication[d];if(t&&!t.isLoading&&!t.user)throw Gt({to:`/sign-in`,search:ou()})}}),cu=P({getParentRoute:()=>su,id:`_orgsLayout`});P({getParentRoute:()=>cu,path:`/`,component:ru}),P({getParentRoute:()=>cu,path:`/new-org`,component:nu});var lu=P({getParentRoute:()=>cu,path:`$organizationId`,beforeLoad:async e=>({organization:await e.context.queryClient.ensureQueryData(bs(e.params.organizationId))})});P({getParentRoute:()=>lu,path:`/roles`,component:Nl}),P({getParentRoute:()=>lu,path:`/roles/$orgRoleId`,component:Nl}),P({getParentRoute:()=>lu,path:`/users`,component:ql}),P({getParentRoute:()=>lu,path:`/users/$orgUserId`,component:ql}),gl(lu);var uu=P({getParentRoute:()=>lu,id:`_clusterLayout`});P({getParentRoute:()=>uu,path:`/`,component:Hc}),P({getParentRoute:()=>lu,path:`/new-cluster`,component:Lc}),P({getParentRoute:()=>fu,path:`/edit`,component:Lc}),P({getParentRoute:()=>fu,path:`/edit/$mode`,component:Lc});function du(){return(0,B.jsx)(Ze,{})}var fu=P({getParentRoute:()=>uu,path:`$clusterId`,component:du,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(ga(t.clusterId))})});function pu({children:e,className:t}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{}),(0,B.jsx)(`div`,{className:C(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}var mu=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function hu(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&&mu.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function gu({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=hu(t),[i,a,o]=Ro(r,e||``,n);return(0,B.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,B.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,B.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.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,B.jsx)(R,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,B.jsx)(tn,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.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,B.jsx)(R,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,B.jsx)(tn,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.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,B.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,B.jsx)(R,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,B.jsx)(tn,{className:`w-3 h-3`})})]})}),(0,B.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 _u({certificate:e,domain:t,cluster:n}){let r=hu(t.domain),[i,a,o]=Ro(r,n.fqdn||``,t.id),s=(0,z.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,B.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,B.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,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,B.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,B.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,B.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 px-2 py-0.5 rounded text-xs`,children:[(0,B.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,B.jsx)(R,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,B.jsx)(tn,{className:`w-3 h-3`})})]}),(0,B.jsx)(vu,{}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 px-2 py-0.5 rounded text-xs`,children:[(0,B.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,B.jsx)(R,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,B.jsx)(tn,{className:`w-3 h-3`})})]})]}),(0,B.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.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,B.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,B.jsx)(R,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,B.jsx)(tn,{className:`w-2.5 h-2.5`})})]})})]})]})}function vu(){return(0,B.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,B.jsx)(`path`,{d:`M5 12h14`}),(0,B.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function yu(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l}=e;return M({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:()=>bu(e)})}async function bu({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 xu(e){return M({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await bu({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},enabled:!0,instanceClient:i({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:5e3})}function Su(e){return L(xu(e))}function Cu({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=hu(n),[o,s,c,l,u]=Ro(t,e,a,i||``,r);return(0,B.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,B.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,B.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.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,B.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,B.jsx)(tn,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.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,B.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,B.jsx)(tn,{className:`w-3.5 h-3.5`})})]})}),(0,B.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,B.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.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,B.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,B.jsx)(tn,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.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,B.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,B.jsx)(tn,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.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,B.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,B.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,B.jsx)(tn,{className:`w-3 h-3`})})]})}),(0,B.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 wu({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await u.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function Tu(){return I({mutationFn:e=>wu(e)})}x.object({domainId:x.string()});async function Eu(e){let{data:t}=await u.delete(`/Domain/${e.domainId}`);return t}function Du(){return I({mutationFn:e=>Eu(e)})}function Ou(e){return[...new Set(e)]}var ku=Ie();function Au(e,t,n){let{data:r}=Su(e.id),i=(0,z.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=Tu(),{mutate:s,isPending:c}=Du(),l=o||c,u=(0,z.useCallback)((t,n)=>{if(!po(e.status)){N.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:Ou((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{ni.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),N.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,z.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{ni.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),N.success(`Domain removed!`)}})},[s]),f=(0,z.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{ni.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),N.success(`Domain unbound!`)}})},[s]);return(0,z.useMemo)(()=>[ku.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!Mo(e)?(0,B.jsx)(`label`,{className:`p-10 -m-10`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),ku.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,B.jsxs)(Qi,{children:[(0,B.jsx)($i,{asChild:!0,children:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{children:t.domain}),(0,B.jsx)(R,{variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,B.jsx)(ea,{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!`})]})}}),ku.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,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,B.jsx)(`div`,{className:`py-2`,children:(0,B.jsx)(_u,{certificate:i,domain:n,cluster:e})}),(0,B.jsx)(R,{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,B.jsx)(Cu,{domain:n,cluster:e}):Mo(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,B.jsx)(gu,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var ju=x.object({domain:x.string(),organizationId:x.string()});async function Mu(e){let{data:t}=await u.post(`/Domain/`,e);return t}function Nu(){return I({mutationFn:e=>Mu(e)})}async function Pu(e){let{data:t}=await u.post(`/Domain/${e}/validate`);return t}async function Fu(e){let{data:t}=await u.get(`/Domain/?organizationId=${e}`);return t}function Iu(e){return M({queryKey:[e,`domains`],queryFn:()=>Fu(e)})}function Lu(){let{organizationId:e,clusterId:t}=j({strict:!1}),{data:n}=D(ga(t,!0)),{update:r}=Oi(e),{data:i,refetch:a,isFetching:o,isRefetching:s}=L(Iu(e)),c=(0,z.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[l]=(0,z.useState)({attribute:`domain`,descending:!1}),u=(0,z.useMemo)(()=>[{desc:l.descending,id:l.attribute}],[l]),d=fl(a),[f,m]=(0,z.useState)([]),h=(0,z.useCallback)(e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:g,isPending:_}=Tu(),v=(0,z.useCallback)(()=>{if(!po(n.status)){N.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}g({clusterId:n.id,domainIds:Ou((n.domainIds?.slice()||[]).concat(f)),generateDomainCerts:!0},{onSuccess:()=>{ni.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),N.success(`Domain(s) bound! Certificates are being generated in the background now.`),m([])}})},[n,f,g]),{mutateAsync:y,isPending:b}=Nu(),x=k({resolver:O(ju),defaultValues:{domain:``,organizationId:e}}),S=(0,z.useCallback)(async e=>{if(e){let t=e.domain.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean);for(let n of t)await y({...e,domain:n});x.reset(),await a(),N.success(`${p(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[y,x,a]),ee=(0,z.useCallback)(async()=>{let e=`Validating ${p(c.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of c)try{N.loading(e,{description:`${n++} of ${c.length} checked`,id:t}),await Pu(i.id)}catch{r+=1}r>0?N.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(),N.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[c]),te=Au(n,f,h),C=x.watch(`domain`),ne=(0,z.useMemo)(()=>typeof C==`string`?C.trim().split(`.`).length===2:!1,[C]),re=(0,z.useCallback)(()=>{typeof C==`string`&&x.setValue(`domain`,`${C.trim()}, www.${C.trim()}`)},[C,x]);return(0,B.jsx)(sl,{data:i||[],isFetching:o||s,columns:te,sortingState:u,children:(0,B.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,B.jsx)(H,{...x,children:(0,B.jsxs)(`form`,{id:`cluster-add-domain-form`,name:`cluster-add-domain-form`,onSubmit:x.handleSubmit(S),className:`flex gap-1 flex-col md:flex-row`,children:[(0,B.jsx)(W,{control:x.control,name:`domain`,render:({field:e})=>(0,B.jsxs)(G,{className:`flex-1`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`New Domain Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),ne&&(0,B.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,B.jsx)(R,{variant:`positiveOutline`,type:`button`,onClick:re,children:`Add www as well`})]}),(0,B.jsx)(q,{children:(0,B.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,B.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,B.jsxs)(R,{type:`submit`,variant:`submit`,disabled:b,children:[(0,B.jsx)(on,{}),` Add`]}),c.length>0&&(0,B.jsxs)(R,{variant:`positiveOutline`,onClick:ee,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,B.jsx)(st,{}),` `,(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,B.jsxs)(R,{variant:`defaultOutline`,onClick:d,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,B.jsx)(en,{}),` `,(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),f.length>0&&(0,B.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,B.jsxs)(R,{variant:`submit`,onClick:v,disabled:_,children:[(0,B.jsx)(Un,{}),` Bind `,p(f.length,`Domain`,`Domains`)]})})]})})}function Ru(){return(0,B.jsx)(pu,{className:`flex flex-col justify-start max-w-4xl`,children:(0,B.jsx)(Lu,{})})}var zu=T({username:ya,role:w().nonempty({error:`Please select a role.`}),password:va.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:w()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function Bu(e){await u.patch(`/ResetPasswordUpdater/${e}`)}async function Vu(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function Hu(){return I({mutationFn:Vu})}async function Uu({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 Wu(){return I({mutationFn:Uu})}async function Gu({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function Ku(){return I({mutationFn:Gu})}async function qu({clusterId:e,initialUsername:t,desiredUsername:n,newPassword:r,tempPassword:i,instanceClient:a}){if(!i)throw Error(`You may not have permission to set the password on this cluster.`);let o=a;try{let a=await fa({username:t,password:i,instanceClient:o,entityId:e});return a.instanceClient&&(o=a.instanceClient),n===`HDB_ADMIN`?await Uu({username:n,password:r,instanceClient:o}):(await Vu({username:n,password:r,role:`super_user`,active:!0,instanceClient:o}),await fa({username:n,password:r,instanceClient:o,entityId:e}),await Gu({username:s,instanceClient:o})),await Bu(e),a}catch(t){throw await h({entityId:e,instanceClient:o}),t}}function Ju(){return I({mutationFn:qu})}function Yu(){let{user:e}=Vr(),{clusterId:t}=j({strict:!1}),{data:r}=L(ga(t,!0)),i=F(),a=(0,z.useMemo)(()=>n(r),[r]),o=yi({operationsUrl:a}),{redirect:c}=Ne({strict:!1}),l=We(),u=k({resolver:O(zu),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:d,control:f,handleSubmit:p}=u;(0,z.useEffect)(()=>{d(`password`)},[d]);let h=r?.instances?.find(e=>e.tempPassword)?.tempPassword,{mutate:g,isPending:_}=Ju(),v=(0,z.useCallback)(async e=>{if(!a){N.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}g({instanceClient:o,clusterId:t,newPassword:e.password,tempPassword:h,initialUsername:s,desiredUsername:e.username},{onSuccess:async({message:e,user:t})=>{N.success(e),m.setUserForEntity(r,t),l.invalidate(),await i({to:c?.startsWith(`/`)?c:`../`})}})},[r,t,o,i,a,c,l,g,h]);return r&&!r.resetPassword?(0,B.jsx)(jt,{to:`../sign-in`,replace:!0}):(0,B.jsxs)(B.Fragment,{children:[(0,B.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,B.jsx)(ia,{})}),(0,B.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,B.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,B.jsx)(`h2`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,B.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,B.jsx)(H,{...u,children:(0,B.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:p(v),className:`my-4`,children:[(0,B.jsx)(W,{control:f,name:`username`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Username`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{autoComplete:`username`,type:`text`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:f,name:`password`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:f,name:`confirmPassword`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Confirm Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(R,{disabled:_,type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,children:`Create Admin User`})]})}),(0,B.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,B.jsx)(An,{size:36,className:`flex-none`}),(0,B.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 Xu({columns:e,data:t}){let n=Bt({data:t,columns:e,getCoreRowModel:Xe()});return(0,B.jsx)(`div`,{className:`bg-black-dark rounded-md`,children:(0,B.jsxs)(el,{children:[(0,B.jsx)(tl,{children:n.getHeaderGroups().map(e=>(0,B.jsx)(rl,{className:`border-none`,children:e.headers.map(e=>(0,B.jsx)(il,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:Pt(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,B.jsx)(nl,{className:`bg-black`,children:n.getRowModel().rows?.length?n.getRowModel().rows.map(e=>(0,B.jsx)(rl,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,B.jsx)(ol,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:Pt(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,B.jsx)(rl,{children:(0,B.jsx)(ol,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function Zu(){return(0,B.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,B.jsx)(`p`,{children:`No instances found.`})})}function Qu({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=Rr(t.id),i=yi({operationsUrl:(0,z.useMemo)(()=>c(t),[t])}),{update:a}=ji(),o=m.checkForFabricConnect(t.id),s=(0,z.useCallback)(async()=>{await h({instanceClient:i,entityId:t.id}),m.setUserForEntity(t,null)},[t,i]);return r||![`CLONE_READY`,`RUNNING`,`UPDATED`].includes(t.status)?(0,B.jsx)(rt,{className:`animate-spin`,color:`gray`}):!n||o?(0,B.jsxs)(`span`,{className:`flex gap-4`,children:[a&&!e&&(0,B.jsx)(A,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,B.jsx)(R,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,B.jsx)(A,{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,B.jsx)(R,{variant:a?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,B.jsxs)(`span`,{className:`flex gap-4`,children:[(0,B.jsx)(A,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,B.jsx)(R,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,B.jsx)(R,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:s,children:`Direct Sign Out`})]})}function $u({entityId:e,instanceClient:t},n){return M({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 ed(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function td({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function nd(){return I({mutationFn:td,onSuccess:(e,t)=>ni.invalidateQueries({queryKey:[t.entityId,`get_status`]})})}function rd({instance:e,index:t}){let{update:n}=ji(),r=V({operationsUrl:(0,z.useMemo)(()=>c(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:i,isPending:a}=nd(),[o,s]=(0,z.useState)(!1);(0,z.useEffect)(()=>{let e=setTimeout(()=>s(!0),t*500);return()=>clearTimeout(e)},[t]);let{data:l,isLoading:u,isFetching:d}=L($u(r,o&&n)),f=ed(l,`availability`)||`Unknown`,p=f===`Available`,m=f===`Unavailable`;return n?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsxs)(Qi,{children:[(0,B.jsx)($i,{asChild:!0,children:(0,B.jsx)(`div`,{className:`flex items-center`,children:u||!o||d&&!l?(0,B.jsx)(rt,{className:`animate-spin size-5 text-muted-foreground`}):(0,B.jsx)(wo,{variant:p?`success`:m?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,B.jsx)(`span`,{className:`sr-only`,children:p?`Online`:`Offline`})})})}),(0,B.jsxs)(ea,{children:[d&&l?`Refreshing... `:``,f]})]}),n&&(0,B.jsxs)(`div`,{className:`flex gap-1`,children:[p&&(0,B.jsxs)(Qi,{children:[(0,B.jsx)($i,{asChild:!0,children:(0,B.jsx)(R,{variant:`destructiveGhost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Unavailable`}),disabled:a,children:a?(0,B.jsx)(rt,{className:`animate-spin size-4`}):(0,B.jsx)(Bn,{className:`size-4`})})}),(0,B.jsx)(ea,{children:`Bring out of rotation`})]}),m&&(0,B.jsxs)(Qi,{children:[(0,B.jsx)($i,{asChild:!0,children:(0,B.jsx)(R,{variant:`ghost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Available`}),disabled:a,children:a?(0,B.jsx)(rt,{className:`animate-spin size-4`}):(0,B.jsx)(gr,{className:`size-4`})})}),(0,B.jsx)(ea,{children:`Bring back into rotation`})]})]})]}):null}function id(){let{clusterId:e}=j({strict:!1}),{data:t,isLoading:n}=L(ga(e,!0)),r=Mo(t),i=(0,z.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,B.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,B.jsx)(Qu,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>Ac({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,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(rd,{instance:e.row.original,index:e.row.index}),t?(0,B.jsx)(wo,{variant:fo(t),children:na(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,B.jsxs)(B.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(ri),[r]),a=(0,z.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!ua.includes(e.status)).sort(rs):[],[t]);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uo,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,B.jsx)(Gr,{className:`p-0 mt-4 min-h-96`,children:(0,B.jsx)(Yr,{className:`p-0 min-h-96`,children:n?(0,B.jsx)(Xs,{}):a.length?(0,B.jsx)(Xu,{data:a,columns:i}):(0,B.jsx)(Zu,{})})})})]})}function ad(){let{clusterId:e}=j({strict:!1}),{data:t,isLoading:n}=L(ga(e,2e3)),r=t?.status,i=(0,z.useMemo)(()=>r&&la.includes(r),[r]);return n||!t?(0,B.jsx)(pu,{className:`flex justify-center`,children:(0,B.jsx)(Xs,{})}):i?(0,B.jsx)(pu,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,B.jsx)(Fo,{cluster:t,forceProgressBarVisible:!0}),(0,B.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,B.jsx)(`div`,{className:`text-center`,children:(0,B.jsx)(No,{cluster:t})})]})}):(0,B.jsx)(pu,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,B.jsx)(Fo,{cluster:t,forceProgressBarVisible:!0}),(0,B.jsxs)(`p`,{children:[`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,B.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,B.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 od(){let e=We(),{clusterId:t}=j({strict:!1}),{data:n,isLoading:r}=L(ga(t,2e3)),i=n?.status,a=(0,z.useMemo)(()=>i&&la.includes(i),[i]),o=mo(i),[,s]=Ho(Uo.SavedClusterState,null),c=(0,z.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,B.jsx)(pu,{className:`flex justify-center`,children:(0,B.jsx)(Xs,{})}):o?(0,B.jsx)(pu,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,B.jsx)(mr,{className:`w-24 h-24`}),(0,B.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,B.jsx)(Go,{}),` if you want more help.`]}),(0,B.jsx)(R,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,B.jsx)(pu,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,B.jsx)(Fo,{cluster:n,forceProgressBarVisible:!0}),(0,B.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,B.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,B.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,B.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,B.jsx)(`div`,{className:`text-center`,children:(0,B.jsx)(No,{cluster:n})})]})}):(0,B.jsx)(pu,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,B.jsx)(Fo,{cluster:n,forceProgressBarVisible:!0}),(0,B.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,B.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,B.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.`]})]})]})})}P({getParentRoute:()=>fu,path:`instances`,component:id}),P({getParentRoute:()=>fu,path:`starting-up`,component:od}),P({getParentRoute:()=>fu,path:`scaling`,component:ad}),P({getParentRoute:()=>fu,path:`domains`,component:Ru}),P({getParentRoute:()=>fu,path:`sign-in`,component:Ea,beforeLoad:({context:e,location:t,params:n})=>{let r=m.checkForFabricConnect(n.clusterId);if(e.authentication[n.clusterId]?.user&&!r){let e=t?.search;throw Gt({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),P({getParentRoute:()=>fu,path:`instance/$instanceId/sign-in`,component:Ea,beforeLoad:({context:e,location:t,params:n})=>{if(!(m.checkForFabricConnect(n.clusterId)||m.checkForFabricConnect(n.instanceId))&&e.authentication[n.instanceId]?.user){let e=t?.search;throw Gt({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),P({getParentRoute:()=>fu,path:`finish-setup`,component:Yu});function sd(e){return P({getParentRoute:()=>e,path:`apis`}).lazy(()=>Hr(()=>import(`./index.lazy-B3bMWbNh.js`).then(e=>e.route),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])))}function cd(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 ld(e,t){let[n,r]=(0,z.useState)(t),[i,a]=(0,z.useState)(e);return(0,z.useEffect)(()=>{cd(n,t)||(r(t),a(e))},[n,t,e]),cd(n,t)?[i,a]:[e,a]}var ud={};function dd(e,t,n){let r=(0,z.useCallback)((e,n)=>t(e,n),[n]);(0,z.useEffect)(()=>(ud[e]||(ud[e]=[]),ud[e].push(r),function(){let t=ud[e].indexOf(r);t>=0&&ud[e].splice(t,1)}),[e,t,r])}function fd(e,t,n){let r=ud[e];if(r)for(let e of r)e(t,n)}function pd(e,t,n){return r=>fd(e,t,n??r)}function md(e,t,n){return(0,z.useCallback)(r=>fd(e,t,n??r),[e,t,n])}function hd(e,t){return zo(sessionStorage.getItem(String(e)))??t}function gd(e,t){t==null?sessionStorage.removeItem(String(e)):sessionStorage.setItem(String(e),JSON.stringify(t))}function _d(e,t){let n=ld(hd(e,t),[e]),[r,i]=n;return(0,z.useEffect)(()=>{gd(e,r),fd(`Session:${e}`,r)},[e,r]),dd(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,z.useEffect)(function(){let n=n=>{n.key===e&&i(hd(e,t))};return window.addEventListener(`storage`,n),()=>{window.removeEventListener(`storage`,n)}},[e,i,t]),n}function vd(e,t=!1){let[n,r]=_d(e,t),i=(0,z.useCallback)(e=>{e?.preventDefault?.(),r(e=>!e)},[r]),a=(0,z.useCallback)(e=>{e?.preventDefault?.(),r(!0)},[r]),o=(0,z.useCallback)(e=>{e?.preventDefault?.(),r(!1)},[r]);return(0,z.useMemo)(()=>({toggled:n,setToggled:r,toggle:i,toggleOn:a,toggleOff:o}),[i,r,o,a,n])}var yd=(0,z.createContext)(null);function bd(){return(0,z.useContext)(yd)}async function xd({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 Sd(e){let t=(e||``)?.split(`.`);return t.length>1?t.slice(-1)[0]:``}function Cd(e){switch(Sd(e).toLowerCase()){case`jpg`:case`jpeg`:case`gif`:case`png`:case`pneg`:case`webp`:return!0;default:return!1}}async function wd({instanceClient:e,file:t,project:n,encoding:r}){let{data:i}=await e.post(`/`,{operation:`get_component_file`,file:t,project:n,encoding:r??(Cd(t)?`base64`:`utf8`)});return{file:t,project:n,...i}}function Td(e){return M({queryKey:Ed(e),queryFn:()=>wd(e),enabled:!!e.file&&!!e.project,retry:!1})}function Ed(e){return[e.entityId,`get_component_file`,e.file,e.project,e.encoding]}async function Dd({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 Od(){return I({mutationFn:Dd})}function kd(){let{reloadRootEntries:e,setFocusedItem:t,setSelectedItems:n}=bd(),r=V();return(0,z.useCallback)(async i=>{let a=!1,o=i.filter(e=>e.from!==e.to);if(o.length===0)return;let s=`Renaming ${p(o.length,`File`,`Files`)}`,c={duration:6e4,action:{label:`Cancel`,onClick:()=>{a=!0}}};c.id=N.loading(s,{...c,description:(0,B.jsx)(ps,{animated:!0,width:`0%`})});let l=o.length*3,u=0;function d(){u+=1,N.loading(s,{...c,description:(0,B.jsx)(ps,{animated:!0,width:(u===0?0:u/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 wd({...r,file:i,project:n,encoding:`base64`});if(a||(d(),await Dd({...r,file:c,project:s,encoding:`base64`,payload:l.message}),a)||(d(),await xd({...r,file:i,project:n}),a))break;d()}u>=l?N.success(`Renamed ${p(o.length,`File`,`Files`)}`,{id:c.id,description:`All done!`,duration:3e3,action:{label:`OK`,onClick:()=>{}}}):N.warning(`Rename Cancelled`,{id:c.id,description:`${u} 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 Ad(e,t){return e[t]!==void 0}function jd(e){return t=>Ad(t,e)}function Md(e,t){let[n,r]=(0,z.useState)({value:t});return dd(e,(e,t)=>r({value:e,trigger:t}),[r]),n}function Nd(e,t,n){fd(e,t,n)}function Pd(e,t,n){return r=>Nd(e,t,n??r)}function Fd(e,t,n){return(0,z.useCallback)(r=>{Nd(e,t,n??r)},[e,t,n])}var Id=[{handleGlobal(e,t){if((t.cmd||t.ctrl)&&e===`Delete`)return Nd(`ShowDeleteDirectoryOrFileModal`,!0),!0},addEditorAction(e){return{id:`delete-file`,label:`Delete File`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.Delete],run:Pd(`ShowDeleteDirectoryOrFileModal`,!0)}}},{handleGlobal(e,t){if(t.ctrl&&t.alt&&t.shift&&e===`˜`)return Nd(`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:Pd(`ShowAddDirectoryOrFileModalType`,`directory`)}}},{handleGlobal(e,t){if(t.ctrl&&e===`n`)return Nd(`ShowAddDirectoryOrFileModalType`,`file`),!0},addEditorAction(e){return{id:`new-file`,label:`New File`,keybindings:[e.KeyMod.WinCtrl|e.KeyCode.KeyN],run:Pd(`ShowAddDirectoryOrFileModalType`,`file`)}}},{handleGlobal(e){if(e===`F2`)return Nd(`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:Pd(`ShowRenameFileModal`,!0)}}},{addEditorAction(){return{id:`revert-file`,label:`Revert File`,run:pd(`RevertChanges`,!0)}}},{handleGlobal(e,t){if(t.cmd&&e===`s`)return fd(`SaveFile`,!0),!0},addEditorAction(e){return{id:`save-file`,label:`Save Changes`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.KeyS],run:pd(`SaveFile`,!0)}}}],Ld=Id.filter(jd(`addEditorAction`)),Rd=Id.filter(jd(`handleGlobal`));function zd(e){let[t,n]=e,r=Ld.map(e=>t.addAction(e.addEditorAction(n)));return()=>{for(let e of r)e?.dispose()}}function Bd(){(0,z.useEffect)(()=>(document.addEventListener(`keydown`,Vd),()=>{document.removeEventListener(`keydown`,Vd)}),[])}function Vd(e){let t={cmd:e.getModifierState(`Meta`),alt:e.getModifierState(`Alt`),shift:e.getModifierState(`Shift`),ctrl:e.getModifierState(`Control`)};for(let n of Rd)if(n.handleGlobal(e.key,t)){e.preventDefault();return}}function Hd(e){return e.split(`/`).pop()}function Ud(...e){return e.flat(1).join(`/`)}function Wd(e){return!!e?.entries}var Gd=`__root__`,Kd=`importedApplications`,qd=`newApplication`;function Jd(e){let t={},n=[],r=[],i=[];for(let a of e)Wd(a)?a.package?r.push(a.path):n.push(a.path):i.push(a.path),Yd(t,a);return t[Gd]={index:Gd,isFolder:!0,children:[qd,Kd,...n,...i],data:void 0,canMove:!1,canRename:!1},t[Kd]={index:Kd,isFolder:!0,children:r,data:{name:`Imported Applications`,path:Kd,package:Kd,project:``,entries:[]},canMove:!1,canRename:!1},t[qd]={index:qd,isFolder:!1,data:{name:`New Application`,path:qd,project:``},canMove:!1,canRename:!1},{items:t,rootId:Gd}}function Yd(e,t){let n=t.path;if(Wd(t)){let r=t,i=[],a=[];for(let e of r.entries)Wd(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)Yd(e,t)}else e[n]={index:n,isFolder:!1,data:t,canMove:!t.package,canRename:!t.package}}function Xd(){let[e,t]=(0,z.useState)(!1),[n,r]=(0,z.useState)(void 0),i=(0,z.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,z.useCallback)(()=>{t(!1),r(e=>{e&&e.classList.remove(`rct-tree-item-title-container-dragging-over`)})},[]),o=(0,z.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,z.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,z.useMemo)(()=>({dragging:e,dragTarget:n}),[e,n])}function Zd(e){return new Promise((t,n)=>{let r=new FileReader;r.onabort=n,r.onerror=n,r.onload=t,r.readAsDataURL(e)})}function Qd(){let[e,n]=(0,z.useState)(``),{clusterId:r}=j({strict:!1}),{openedEntry:i,restrictPackageModification:a,reloadRootEntries:o,entryExists:s}=bd(),c=!!i&&!i.package&&!a,l=V(),{dragging:u,dragTarget:d}=Xd(),f=(d?.getAttribute?.(`data-rct-item-id`))?.split?.(`/`)?.pop?.(),h=i?.project,g=!1,_;if(i?.path){let e=i.path.split(`/`),t=Wd(i);g=c&&(t?e.slice(1):e.slice(1,-1)).join(`/`),_=e[e.length-(t?1:2)]}let y=(0,z.useCallback)(async(e,t)=>{let r=d?.getAttribute?.(`data-rct-item-id`)?.split?.(`/`),i=r?.length?r[0]:c?h:!1,a=r?.length?r.slice(1).join(`/`):c?g:!1;if(i===!1||i===void 0||a===!1||a===void 0)return;let u=[],f=t.slice();for(let t of e){let e=$d(a,t);t.name.startsWith(`.`)||t.relativePath?.includes(`/.`)?f.push({file:t,errors:[{message:`Sensitive files and folders starting with . are skipped.`,code:`dot-ignored`}]}):s(`${i}/${e}`)?f.push({file:t,errors:[{message:`${e} already exists`,code:`duplicate`}]}):u.push(t)}let m=!1,_=`uploading-files`,v={label:`Cancel`,onClick:()=>{m=!0}},y={label:`OK`,onClick:()=>void 0};n(`Uploading ${p(u.length,`file`,`files`)}...`);let b=u.reduce((e,t)=>e+t.size,0),x=0,S=0;for(let e of u){S+=1,N.loading(`Upload in progress...`,{id:_,descriptionClassName:`whitespace-pre`,description:`${S} of ${p(u.length,`file`,`files`)}
|
|
12
12
|
${e.name}
|
|
13
13
|
${bc(x)} of ${bc(b)}`,action:v});let t=$d(a,e),n=(await Zd(e)).target.result,r=n.indexOf(`base64,`);m?f.push({file:e,errors:[{message:`${t} cancelled`,code:`cancelled`}]}):(await Dd({...l,file:t,project:i,encoding:`base64`,payload:n.slice(r+7)}),x+=e.size)}N.loading(`Reloading sidebar...`,{id:m?void 0:_,action:y,description:``}),await o(),f.length===0?e.length>0&&N.success(`Uploaded ${p(u.length,`file`,`files`)}!`,{id:_,action:y,description:``}):(console.log(f),N.error(m?`Cancelled uploads`:`Rejected uploads`,{id:m?void 0:_,action:y,descriptionClassName:`whitespace-pre overflow-y-auto`,description:f.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.`:``)})),n(``)},[d,c,h,g,s,l,o]),{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 wg({className:e,variant:t,size:n,...r}){return(0,B.jsx)(Dr,{"data-slot":`toggle`,className:g(Cg({variant:t,size:n,className:e})),...r})}function Tg(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 Eg=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],Dg=0,Og=new Map,kg=e=>{if(Og.has(e))return Og.get(e);Dg++;let t=Eg[Dg%Eg.length];return Og.set(e,t),t};function Ag({columns:e,data:t,onRowClick:n}){let r=Bt({data:t,columns:e,getCoreRowModel:Xe()});return(0,B.jsx)(`div`,{className:`rounded-md bg-black-dark logsTable`,children:(0,B.jsxs)(el,{className:`text-xs`,children:[(0,B.jsx)(tl,{children:r.getHeaderGroups().map(e=>(0,B.jsx)(rl,{className:`border-none`,children:e.headers.map(e=>(0,B.jsx)(il,{className:`p-4 max-w-96`,children:e.isPlaceholder?null:Pt(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,B.jsx)(nl,{className:`bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>(0,B.jsx)(rl,{"data-state":e.getIsSelected()&&`selected`,className:g(`hover:bg-muted/10 data-[state=selected]:bg-muted max-w-full`,n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,B.jsx)(ol,{className:`p-1`,children:Pt(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,B.jsx)(rl,{children:(0,B.jsx)(ol,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function jg(e){try{JSON.parse(e)}catch{return!1}return!0}function Mg({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?kg(n.node):`default`;return(0,B.jsx)(Y,{onOpenChange:e,open:t,children:(0,B.jsxs)(X,{"aria-describedby":void 0,children:[(0,B.jsx)(xo,{children:(0,B.jsx)(Q,{children:`Edit Row`})}),n?(0,B.jsxs)(`div`,{className:`flex flex-col gap-3 text-white`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`inline-block pr-2`,children:`Level:`}),(0,B.jsx)(wo,{variant:Tg(n.level),children:na(n.level)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{children:`Timestamp:`}),(0,B.jsx)(`p`,{className:`text-sm`,children:n.timestamp})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{children:`Thread:`}),(0,B.jsx)(`p`,{className:`text-sm`,children:n.thread})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{children:`Node:`}),(0,B.jsx)(wo,{variant:r,children:n.node})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{children:`Tags:`}),(0,B.jsx)(`p`,{className:`text-sm`,children:n.tags&&n.tags.length>0?(0,B.jsx)(`span`,{children:n.tags}):`N/A`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-lg font-bold`,children:`Message`}),(0,B.jsx)(Lt,{className:`w-full h-72`,language:jg(n.message)?`json`:`text`,theme:`vs-dark`,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1}})]})]}):(0,B.jsx)(Ko,{}),(0,B.jsx)(Z,{children:(0,B.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,B.jsxs)(R,{type:`button`,variant:`destructive`,className:`rounded-full`,children:[(0,B.jsx)(kn,{}),` Delete Row`]}),(0,B.jsxs)(R,{variant:`submit`,className:`rounded-full`,children:[(0,B.jsx)(Un,{}),` Save Changes`]})]})})]})})}function Ng({entityId:e,instanceClient:t,logFilters:n,replicated:r,isAutoRefreshEnabled:i}){return M({queryKey:[e,`read_log`,n.limit,n.level,n.from,n.until,r],queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`read_log`,start:0,replicated:r,limit:n.limit?parseInt(n.limit,10):void 0,level:n.level===`undefined`?void 0:n.level,from:n.from?new Date(n.from).toISOString():void 0,until:n.until?new Date(n.until).toISOString():void 0,order:`desc`});return e},retry:!1,refetchInterval:i?5e3:!1})}var Pg=T({limit:w().optional(),level:b([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).optional(),from:w().or(y()).optional(),until:w().or(y()).optional()});function Fg({form:e,resetFilters:t,submitFilters:n}){return(0,B.jsx)(`div`,{children:(0,B.jsx)(H,{...e,children:(0,B.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:[(0,B.jsx)(W,{control:e.control,name:`limit`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Log Limit:`}),(0,B.jsxs)(Zs,{onValueChange:e.onChange,value:e.value,children:[(0,B.jsx)(ec,{className:`w-full`,children:(0,B.jsx)($s,{placeholder:`Select log limit`})}),(0,B.jsx)(tc,{children:(0,B.jsxs)(Qs,{children:[(0,B.jsx)($,{value:`1000`,children:`1000`}),(0,B.jsx)($,{value:`500`,children:`500`}),(0,B.jsx)($,{value:`250`,children:`250`}),(0,B.jsx)($,{value:`100`,children:`100`}),(0,B.jsx)($,{value:`10`,children:`10`})]})})]}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e.control,name:`level`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Log Level:`}),(0,B.jsxs)(Zs,{onValueChange:e.onChange,value:e.value,children:[(0,B.jsx)(ec,{className:`w-full`,children:(0,B.jsx)($s,{placeholder:`Select log level`})}),(0,B.jsx)(tc,{children:(0,B.jsxs)(Qs,{children:[(0,B.jsx)($,{value:`undefined`,children:`All`}),(0,B.jsx)($,{value:`notify`,children:`Notify`}),(0,B.jsx)($,{value:`error`,children:`Error`}),(0,B.jsx)($,{value:`warn`,children:`Warn`}),(0,B.jsx)($,{value:`info`,children:`Info`}),(0,B.jsx)($,{value:`debug`,children:`Debug`}),(0,B.jsx)($,{value:`trace`,children:`Trace`})]})})]}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e.control,name:`from`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Start Date:`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`datetime-local`,value:e.value,onChange:e.onChange})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e.control,name:`until`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`End Date:`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`datetime-local`,value:e.value,onChange:e.onChange})}),(0,B.jsx)(q,{})]})}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between space-x-2 mt-2`,children:[(0,B.jsx)(R,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,B.jsx)(R,{type:`reset`,variant:`destructiveOutline`,onClick:()=>t(),children:`Clear Filters`})]})]})})})}var Ig={limit:`100`,level:`undefined`,from:``,until:``},Lg=[{accessorKey:`level`,header:`Status`,cell:({row:e})=>{let{level:t}=e.original;return(0,B.jsx)(wo,{variant:Tg(t),children:na(t)})}},{accessorKey:`timestamp`,header:`Date`,cell:({row:e})=>{let{timestamp:t}=e.original;return(0,B.jsx)(`span`,{children:new Date(t).toLocaleDateString()})}},{accessorKey:`time`,header:`Time`,cell:({row:e})=>{let{timestamp:t}=e.original;return(0,B.jsx)(`span`,{children:new Date(t).toLocaleTimeString()})}},{accessorKey:`thread`,header:`Thread`},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=kg(t);return(0,B.jsx)(B.Fragment,{children:t?(0,B.jsxs)(Qi,{children:[(0,B.jsx)($i,{asChild:!0,children:(0,B.jsxs)(wo,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,B.jsx)(ea,{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,B.jsx)(`pre`,{children:(0,B.jsx)(`code`,{children:t})})}}],Rg=(e,t)=>!e&&!t||!e||!t?!0:new Date(e)<=new Date(t);function zg(){let[e,t]=(0,z.useState)(Ig),[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)(),[o,s]=(0,z.useState)(!1),c=V(),{data:l,isLoading:u,refetch:d,isFetching:f}=L(Ng({logFilters:e,...c,replicated:c.entityType===`cluster`,isAutoRefreshEnabled:o})),p=k({resolver:O(Pg),defaultValues:Ig,mode:`onChange`}),m=e=>{a(e.original),r(!0)},h=async e=>{if(!Rg(e.from,e.until)){p.setError(`from`,{type:`onChange`,message:`Start date must be before end date`}),p.setError(`until`,{type:`onChange`,message:`End date must be after start date`});return}t(e)},g=async()=>{p.reset(),t(Ig)},_=fl(d);return(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 text-white md:grid-cols-12`,children:[(0,B.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pt-4 md:pt-12`,children:[(0,B.jsx)(Fg,{form:p,resetFilters:g,submitFilters:h}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between space-x-2 mt-2`,children:[(0,B.jsxs)(R,{variant:`defaultOutline`,onClick:_,disabled:f||u||o,className:`grow`,children:[(0,B.jsx)(en,{}),`Refresh`]}),(0,B.jsxs)(wg,{variant:`outline`,"aria-label":`Toggle Auto Refresh`,onPressedChange:s,children:[(0,B.jsx)(en,{}),`Auto Refresh `,o?`On`:`Off`]})]})]}),(0,B.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:u?(0,B.jsx)(`div`,{children:`Loading...`}):(0,B.jsx)(`div`,{children:(0,B.jsx)(Ag,{columns:Lg,data:l||[],onRowClick:m})})}),(0,B.jsx)(Mg,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function Bg(e){return P({getParentRoute:()=>e,path:`logs`,component:zg})}function Vg(e){return P({getParentRoute:()=>e,path:`status`,component:yt(async()=>Hr(()=>import(`./status-9_1gEAyL.js`),__vite__mapDeps([16,1,3,2,4,5,6,7,8,9,10,12])),`StatusIndex`)})}function Hg(e){let t=xg(e),n=[Bg(t),...Np(t),sd(t),Vg(t),ph(t),hg(t)];return t.addChildren(n)}P({getParentRoute:()=>su,path:`profile`,component:yt(async()=>Hr(()=>import(`./profile-V6JtmyCF.js`),__vite__mapDeps([17,1,3,2,4,5,6,7,8,9,10,11,12])),`ProfileIndex`)});var Ug=li.addChildren([...lo,su.addChildren([Hg(`local`)])]);function Wg({routeTree:e=Ug,authentication:t}){return Be({routeTree:e,history:Vt(),defaultNotFoundComponent:$r,defaultErrorComponent:Qr,defaultPreload:ei()?!1:`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:ni,authentication:t||{}}})}function Gg(){let e=Br();return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Ae,{router:Wg({authentication:e}),context:{authentication:e}}),!1]})}var Kg=({...e})=>(0,B.jsx)(Yt,{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}),qg=!1,Jg=!1;function Yg(){(0,z.useEffect)(()=>{qg||(qg=!0,Jg&&(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 Xg(){return Ki(),oi(),Yg(),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(dr,{client:ni,children:[(0,B.jsx)(Gg,{}),(0,B.jsx)(sn,{buttonPosition:`bottom-right`})]}),(0,B.jsx)(Kg,{richColors:!0})]})}(0,jr().createRoot)(document.getElementById(`root`),{onUncaughtError:(e,t)=>{Kt(e,t),console.error(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{Kt(e,t),console.error(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{Kt(e,t),console.warn(`Recoverable error:`,e,t)}}).render((0,B.jsx)(z.StrictMode,{children:(0,B.jsx)(Xg,{})}));export{Qr as A,G as C,wi as D,H as E,V as O,ca as S,U as T,ss as _,$u as a,q as b,yc as c,tc as d,Qs as f,Xs as g,$s as h,ap as i,ri as k,vc as l,ec as m,am as n,ul as o,$ as p,im as r,bc as s,om as t,Zs as u,Ko as v,W as w,K as x,J as y};
|
|
52
|
-
//# sourceMappingURL=index-
|
|
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 wg({className:e,variant:t,size:n,...r}){return(0,B.jsx)(Dr,{"data-slot":`toggle`,className:g(Cg({variant:t,size:n,className:e})),...r})}function Tg(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 Eg=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],Dg=0,Og=new Map,kg=e=>{if(Og.has(e))return Og.get(e);Dg++;let t=Eg[Dg%Eg.length];return Og.set(e,t),t};function Ag({columns:e,data:t,onRowClick:n}){let r=Bt({data:t,columns:e,getCoreRowModel:Xe()});return(0,B.jsx)(`div`,{className:`rounded-md bg-black-dark logsTable`,children:(0,B.jsxs)(el,{className:`text-xs`,children:[(0,B.jsx)(tl,{children:r.getHeaderGroups().map(e=>(0,B.jsx)(rl,{className:`border-none`,children:e.headers.map(e=>(0,B.jsx)(il,{className:`p-4 max-w-96`,children:e.isPlaceholder?null:Pt(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,B.jsx)(nl,{className:`bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>(0,B.jsx)(rl,{"data-state":e.getIsSelected()&&`selected`,className:g(`hover:bg-muted/10 data-[state=selected]:bg-muted max-w-full`,n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,B.jsx)(ol,{className:`p-1`,children:Pt(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,B.jsx)(rl,{children:(0,B.jsx)(ol,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function jg(e){try{JSON.parse(e)}catch{return!1}return!0}function Mg({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?kg(n.node):`default`;return(0,B.jsx)(Y,{onOpenChange:e,open:t,children:(0,B.jsxs)(X,{"aria-describedby":void 0,children:[(0,B.jsx)(xo,{children:(0,B.jsx)(Q,{children:`Edit Row`})}),n?(0,B.jsxs)(`div`,{className:`flex flex-col gap-3 text-white`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`inline-block pr-2`,children:`Level:`}),(0,B.jsx)(wo,{variant:Tg(n.level),children:na(n.level)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{children:`Timestamp:`}),(0,B.jsx)(`p`,{className:`text-sm`,children:n.timestamp})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{children:`Thread:`}),(0,B.jsx)(`p`,{className:`text-sm`,children:n.thread})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{children:`Node:`}),(0,B.jsx)(wo,{variant:r,children:n.node})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{children:`Tags:`}),(0,B.jsx)(`p`,{className:`text-sm`,children:n.tags&&n.tags.length>0?(0,B.jsx)(`span`,{children:n.tags}):`N/A`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-lg font-bold`,children:`Message`}),(0,B.jsx)(Lt,{className:`w-full h-72`,language:jg(n.message)?`json`:`text`,theme:`vs-dark`,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1}})]})]}):(0,B.jsx)(Ko,{}),(0,B.jsx)(Z,{children:(0,B.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,B.jsxs)(R,{type:`button`,variant:`destructive`,className:`rounded-full`,children:[(0,B.jsx)(kn,{}),` Delete Row`]}),(0,B.jsxs)(R,{variant:`submit`,className:`rounded-full`,children:[(0,B.jsx)(Un,{}),` Save Changes`]})]})})]})})}function Ng({entityId:e,instanceClient:t,logFilters:n,replicated:r,isAutoRefreshEnabled:i}){return M({queryKey:[e,`read_log`,n.limit,n.level,n.from,n.until,r],queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`read_log`,start:0,replicated:r,limit:n.limit?parseInt(n.limit,10):void 0,level:n.level===`undefined`?void 0:n.level,from:n.from?new Date(n.from).toISOString():void 0,until:n.until?new Date(n.until).toISOString():void 0,order:`desc`});return e},retry:!1,refetchInterval:i?5e3:!1})}var Pg=T({limit:w().optional(),level:b([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).optional(),from:w().or(y()).optional(),until:w().or(y()).optional()});function Fg({form:e,resetFilters:t,submitFilters:n}){return(0,B.jsx)(`div`,{children:(0,B.jsx)(H,{...e,children:(0,B.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:[(0,B.jsx)(W,{control:e.control,name:`limit`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Log Limit:`}),(0,B.jsxs)(Zs,{onValueChange:e.onChange,value:e.value,children:[(0,B.jsx)(ec,{className:`w-full`,children:(0,B.jsx)($s,{placeholder:`Select log limit`})}),(0,B.jsx)(tc,{children:(0,B.jsxs)(Qs,{children:[(0,B.jsx)($,{value:`1000`,children:`1000`}),(0,B.jsx)($,{value:`500`,children:`500`}),(0,B.jsx)($,{value:`250`,children:`250`}),(0,B.jsx)($,{value:`100`,children:`100`}),(0,B.jsx)($,{value:`10`,children:`10`})]})})]}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e.control,name:`level`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Log Level:`}),(0,B.jsxs)(Zs,{onValueChange:e.onChange,value:e.value,children:[(0,B.jsx)(ec,{className:`w-full`,children:(0,B.jsx)($s,{placeholder:`Select log level`})}),(0,B.jsx)(tc,{children:(0,B.jsxs)(Qs,{children:[(0,B.jsx)($,{value:`undefined`,children:`All`}),(0,B.jsx)($,{value:`notify`,children:`Notify`}),(0,B.jsx)($,{value:`error`,children:`Error`}),(0,B.jsx)($,{value:`warn`,children:`Warn`}),(0,B.jsx)($,{value:`info`,children:`Info`}),(0,B.jsx)($,{value:`debug`,children:`Debug`}),(0,B.jsx)($,{value:`trace`,children:`Trace`})]})})]}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e.control,name:`from`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Start Date:`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`datetime-local`,value:e.value,onChange:e.onChange})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e.control,name:`until`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`End Date:`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`datetime-local`,value:e.value,onChange:e.onChange})}),(0,B.jsx)(q,{})]})}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between space-x-2 mt-2`,children:[(0,B.jsx)(R,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,B.jsx)(R,{type:`reset`,variant:`destructiveOutline`,onClick:()=>t(),children:`Clear Filters`})]})]})})})}var Ig={limit:`100`,level:`undefined`,from:``,until:``},Lg=[{accessorKey:`level`,header:`Status`,cell:({row:e})=>{let{level:t}=e.original;return(0,B.jsx)(wo,{variant:Tg(t),children:na(t)})}},{accessorKey:`timestamp`,header:`Date`,cell:({row:e})=>{let{timestamp:t}=e.original;return(0,B.jsx)(`span`,{children:new Date(t).toLocaleDateString()})}},{accessorKey:`time`,header:`Time`,cell:({row:e})=>{let{timestamp:t}=e.original;return(0,B.jsx)(`span`,{children:new Date(t).toLocaleTimeString()})}},{accessorKey:`thread`,header:`Thread`},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=kg(t);return(0,B.jsx)(B.Fragment,{children:t?(0,B.jsxs)(Qi,{children:[(0,B.jsx)($i,{asChild:!0,children:(0,B.jsxs)(wo,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,B.jsx)(ea,{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,B.jsx)(`pre`,{children:(0,B.jsx)(`code`,{children:t})})}}],Rg=(e,t)=>!e&&!t||!e||!t?!0:new Date(e)<=new Date(t);function zg(){let[e,t]=(0,z.useState)(Ig),[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)(),[o,s]=(0,z.useState)(!1),c=V(),{data:l,isLoading:u,refetch:d,isFetching:f}=L(Ng({logFilters:e,...c,replicated:c.entityType===`cluster`,isAutoRefreshEnabled:o})),p=k({resolver:O(Pg),defaultValues:Ig,mode:`onChange`}),m=e=>{a(e.original),r(!0)},h=async e=>{if(!Rg(e.from,e.until)){p.setError(`from`,{type:`onChange`,message:`Start date must be before end date`}),p.setError(`until`,{type:`onChange`,message:`End date must be after start date`});return}t(e)},g=async()=>{p.reset(),t(Ig)},_=fl(d);return(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 text-white md:grid-cols-12`,children:[(0,B.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pt-4 md:pt-12`,children:[(0,B.jsx)(Fg,{form:p,resetFilters:g,submitFilters:h}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between space-x-2 mt-2`,children:[(0,B.jsxs)(R,{variant:`defaultOutline`,onClick:_,disabled:f||u||o,className:`grow`,children:[(0,B.jsx)(en,{}),`Refresh`]}),(0,B.jsxs)(wg,{variant:`outline`,"aria-label":`Toggle Auto Refresh`,onPressedChange:s,children:[(0,B.jsx)(en,{}),`Auto Refresh `,o?`On`:`Off`]})]})]}),(0,B.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:u?(0,B.jsx)(`div`,{children:`Loading...`}):(0,B.jsx)(`div`,{children:(0,B.jsx)(Ag,{columns:Lg,data:l||[],onRowClick:m})})}),(0,B.jsx)(Mg,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function Bg(e){return P({getParentRoute:()=>e,path:`logs`,component:zg})}function Vg(e){return P({getParentRoute:()=>e,path:`status`,component:yt(async()=>Hr(()=>import(`./status-CdZyfe1S.js`),__vite__mapDeps([16,1,3,2,4,5,6,7,8,9,10,12])),`StatusIndex`)})}function Hg(e){let t=xg(e),n=[Bg(t),...Np(t),sd(t),Vg(t),ph(t),hg(t)];return t.addChildren(n)}P({getParentRoute:()=>su,path:`profile`,component:yt(async()=>Hr(()=>import(`./profile-BLeDamUk.js`),__vite__mapDeps([17,1,3,2,4,5,6,7,8,9,10,11,12])),`ProfileIndex`)});var Ug=li.addChildren([...lo,su.addChildren([Hg(`local`)])]);function Wg({routeTree:e=Ug,authentication:t}){return Be({routeTree:e,history:Vt(),defaultNotFoundComponent:$r,defaultErrorComponent:Qr,defaultPreload:ei()?!1:`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:ni,authentication:t||{}}})}function Gg(){let e=Br();return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Ae,{router:Wg({authentication:e}),context:{authentication:e}}),!1]})}var Kg=({...e})=>(0,B.jsx)(Yt,{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}),qg=!1,Jg=!1;function Yg(){(0,z.useEffect)(()=>{qg||(qg=!0,Jg&&(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 Xg(){return Ki(),oi(),Yg(),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(dr,{client:ni,children:[(0,B.jsx)(Gg,{}),(0,B.jsx)(sn,{buttonPosition:`bottom-right`})]}),(0,B.jsx)(Kg,{richColors:!0})]})}(0,jr().createRoot)(document.getElementById(`root`),{onUncaughtError:(e,t)=>{Kt(e,t),console.error(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{Kt(e,t),console.error(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{Kt(e,t),console.warn(`Recoverable error:`,e,t)}}).render((0,B.jsx)(z.StrictMode,{children:(0,B.jsx)(Xg,{})}));export{Qr as A,G as C,wi as D,H as E,V as O,ca as S,U as T,ss as _,$u as a,q as b,yc as c,tc as d,Qs as f,Xs as g,$s as h,ap as i,ri as k,vc as l,ec as m,am as n,ul as o,$ as p,im as r,bc as s,om as t,Zs as u,Ko as v,W as w,K as x,J as y};
|
|
52
|
+
//# sourceMappingURL=index-BLrHW_4X.js.map
|