@harperfast/harper 5.0.5 → 5.0.7
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/dist/security/jsLoader.js +13 -7
- package/dist/security/jsLoader.js.map +1 -1
- package/package.json +2 -2
- package/security/jsLoader.ts +13 -7
- package/studio/web/assets/{index-D07pIqJt.js → index-C0And10y.js} +2 -2
- package/studio/web/assets/{index-D07pIqJt.js.map → index-C0And10y.js.map} +1 -1
- package/studio/web/index.html +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index.lazy-JvCzgHOj.js","assets/rolldown-runtime-FhOqtrmT.js","assets/vendor-datadog-DVU9bdcc.js","assets/vendor-react-Vbe32VU9.js","assets/vendor-misc-D7UZlQZq.js","assets/vendor-markdown-C_pbQ5C-.js","assets/vendor-html-VZf1YLCF.js","assets/vendor-core-CvqwRnws.js","assets/vendor-monaco-B3gKcUcU.js","assets/vendor-charts-B7HJAEn1.js","assets/vendor-react-Bh0DbzfM.css","assets/getRegistrationInfo-LbRH9o_1.js","assets/button-BxVMmVxn.js","assets/cn-BOQea7EA.js","assets/useInstanceClient-B-0rgxDK.js","assets/index-DZem5S77.css","assets/mermaid.core-B_GYoaFg.js","assets/vendor-viz-BJ3KPk2F.js","assets/status-BpQLcjsg.js","assets/getStatus-D2vddYdp.js","assets/label-DTuYaIbU.js","assets/profile-BuZ1ni1t.js","assets/input-Kn9SJu2o.js","assets/vendor-tanstack-B8xOiRT8.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-BOQea7EA.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-CvqwRnws.js";import{$i as D,$n as ce,$r as le,Ai as ue,An as O,Ar as de,At as fe,Bi as pe,Bn as me,Br as he,Bt as ge,Ci as _e,Cn as ve,Cr as ye,Ct as be,Di as xe,Dn as Se,Dr as Ce,Dt as we,Ei as Te,En as Ee,Er as De,Et as Oe,Fi as ke,Fn as k,Fr as Ae,Ft as je,Gi as Me,Gn as Ne,Gr as Pe,Gt as Fe,Hi as A,Hn as Ie,Hr as Le,Ht as Re,Ii as ze,Ir as Be,It as Ve,Ji as He,Jn as Ue,Jr as We,Jt as Ge,Ki as j,Kn as Ke,Kr as qe,Kt as Je,Li as Ye,Ln as Xe,Lr as Ze,Lt as Qe,Mi as $e,Mr as et,Mt as tt,Ni as nt,Nr as rt,Nt as it,Oi as at,On as ot,Or as st,Ot as ct,Pi as lt,Pn as ut,Pr as dt,Pt as ft,Qi as M,Qn as N,Qr as pt,Ri as mt,Rn as ht,Rr as gt,Rt as _t,Si as vt,Sn as yt,Sr as bt,St as xt,Ti as St,Tn as Ct,Tr as wt,Tt,Ui as Et,Un as Dt,Ur as Ot,Ut as kt,Vi as P,Vn as At,Vr as jt,Vt as Mt,Wi as F,Wn as Nt,Wr as Pt,Wt as Ft,Xi as It,Xn as Lt,Xr as Rt,Yi as zt,Yn as Bt,Yr as Vt,Zi as I,Zn as Ht,Zr as Ut,_n as Wt,_r as Gt,ai as Kt,ar as qt,bn as Jt,br as Yt,bt as Xt,ci as Zt,cr as Qt,di as $t,dn as en,dr as tn,ea as L,ei as nn,er as rn,fi as an,fn as on,fr as sn,gn as cn,gr as ln,hi as un,hn as dn,hr as fn,ia as pn,ii as mn,ir as hn,ji as gn,jr as _n,jt as vn,ki as yn,kn as bn,kr as xn,kt as Sn,li as Cn,ln as wn,lr as Tn,mi as En,mn as Dn,mr as On,na as kn,ni as An,nr as jn,oi as Mn,or as Nn,pi as Pn,pn as Fn,pr as In,qi as Ln,qn as Rn,qr as zn,qt as Bn,ra as Vn,ri as Hn,rr as Un,si as Wn,sr as Gn,ta as Kn,ti as qn,ui as Jn,un as Yn,ur as Xn,vi as Zn,vn as Qn,vr as $n,wi as er,wn as tr,wr as nr,wt as rr,xi as ir,xn as ar,xr as or,xt as sr,yi as cr,yn as lr,yr as ur,yt as dr,zn as fr,zt as pr}from"./vendor-react-Vbe32VU9.js";import{a as mr,i as hr,n as gr,o as _r,r as vr,t as R}from"./button-BxVMmVxn.js";import{_ as yr,a as br,b as xr,c as Sr,d as Cr,f as wr,g as Tr,i as Er,l as Dr,m as Or,n as kr,o as Ar,p as jr,r as Mr,s as Nr,t as Pr,u as Fr,v as Ir,y as Lr}from"./getRegistrationInfo-LbRH9o_1.js";import{a as z,c as B,i as V,l as Rr,n as H,o as U,r as W,s as zr,t as G,u as Br}from"./input-Kn9SJu2o.js";import{a as Vr,i as Hr,n as Ur,r as K,t as Wr}from"./useInstanceClient-B-0rgxDK.js";import{i as Gr,r as Kr}from"./vendor-datadog-DVU9bdcc.js";import{t as qr}from"./label-DTuYaIbU.js";import"./vendor-stripe-RArI0wEC.js";import{c as Jr,d as Yr,f as Xr,i as Zr,l as Qr,m as $r,n as ei,p as ti,r as ni,s as ri,t as ii,u as q}from"./getStatus-D2vddYdp.js";import{t as ai}from"./vendor-markdown-C_pbQ5C-.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 J=Vn();function oi(){let{user:e,isLoading:t}=mr();return Or(e),(0,J.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,J.jsxs)(Tr,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,J.jsx)(Lr,{children:(0,J.jsx)(xr,{className:`text-2xl`,children:(0,J.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,J.jsx)(yr,{children:e&&!t?(0,J.jsx)(A,{to:`/`,children:(0,J.jsxs)(R,{children:[` `,(0,J.jsx)(yn,{}),` Return to Home`]})}):(0,J.jsx)(A,{to:`/sign-in`,children:(0,J.jsxs)(R,{children:[` `,(0,J.jsx)(yn,{}),` Go Sign In Page`]})})})]})})}function si(){return`ontouchstart`in window||navigator.maxTouchPoints>0}var Y=e(pn(),1),ci=!1,li=!1;function ui(){(0,Y.useEffect)(()=>{ci||(ci=!0,li&&(Kr.init({applicationId:`f590deee-4bac-49b4-a202-3b6963d9721d`,clientToken:`pub27aa29cea521492f4fef73032f86a023`,site:`datadoghq.com`,service:`studio`,env:void 0,version:`v5.0.5`,trackViewsManually:!0,trackUserInteractions:!0,sessionSampleRate:100,sessionReplaySampleRate:0,defaultPrivacyLevel:`mask`,plugins:[Lt()]}),Kr.onReady(()=>{Kr.startView({service:`studio`,version:`v5.0.5`,name:window.location.pathname||`initial`})})))},[])}function di(e){if(!li)return;Kr.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)?Kr.addAction(`return_login`):(Kr.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&&Kr.addAction(`login_time_gap`,{value:e})}localStorage.setItem(n,String(i)),Kr.addAction(`login_success`,{userId:e.id})}function fi(){return(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(Ye,{})})}var pi=pe()({component:fi});function mi(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,J.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 hi(){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`img`,{src:`/harper-studio_white.png`,alt:`Harper Studio`,className:`w-64 hidden md:inline-block`}),(0,J.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}function gi({className:e,...t}){return(0,J.jsx)(`div`,{className:g(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,J.jsx)(Ue,{"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 _i({className:e,children:t,viewport:n=!0,...r}){return(0,J.jsxs)(Rn,{"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,J.jsx)(gi,{})]})}function vi({className:e,...t}){return(0,J.jsx)(Nt,{"data-slot":`navigation-menu-item`,className:g(`relative`,e),...t})}function yi({className:e,...t}){return(0,J.jsx)(Ne,{"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 bi({className:e,...t}){return(0,J.jsx)(Ke,{"data-slot":`navigation-menu-list`,className:g(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}var xi=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 Si(){let e=`v5.0.5`;return(0,J.jsx)(`a`,{href:e?.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`,target:`_blank`,rel:`noopener noreferrer`,children:(0,J.jsxs)(`span`,{className:g(xi({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}async function Ci(e){await m.signOutFromPotentiallyAuthenticatedInstances(),await h({...e,entityId:d})}function wi(){let e=Ur();return I({mutationFn:()=>Ci({instanceClient:e}),onSuccess:Rr})}function Ti(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 Ei(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 Di(e,t){let{user:n}=vr(),{organizationId:r,clusterId:i}=j({strict:!1});return Oi(n,e??r,t??i)}function Oi(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 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)?.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 ji(e){let{clusterId:t,instanceId:n}=j({strict:!1}),{user:r}=hr(e??n??t),i=r?.role?.permission;return i?i.super_user===!0:!1}function Mi(e){let{clusterId:t,instanceId:n}=j({strict:!1}),{user:r}=hr(e??n??t),i=r?.role?.permission;return i?i.super_user===!0||i.structure_user===!0:!1}function Ni(e,t,n,r){let{clusterId:i,instanceId:a}=j({strict:!1}),{user:o}=hr(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 Pi={className:`text-white`};function Fi(){let{mutate:e}=wi(),t=F(),{user:n}=mr(),r=He(),{organizationId:i}=j({strict:!1}),{update:a}=Ti(i),{view:o}=Ei(i),s=a,c=(0,Y.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,Y.useMemo)(()=>[!1,!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,J.jsx)(er,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,J.jsx)(ir,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,J.jsx)(mi,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:c,icon:(0,J.jsx)(xn,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(Vr),[i,s,o,c]);return n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Bi,{menuItems:l}),(0,J.jsx)(Ri,{menuItems:l})]}):(0,J.jsx)(Li,{})}function Ii(e){return e.items!==void 0}function Li(){return(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`inline-block`,children:[(0,J.jsx)(A,{to:`/sign-in`,children:(0,J.jsx)(hi,{})}),(0,J.jsx)(Si,{})]}),(0,J.jsx)(_i,{children:(0,J.jsxs)(bi,{className:`text-grey-400`,children:[(0,J.jsx)(vi,{children:(0,J.jsx)(yi,{asChild:!0,children:(0,J.jsxs)(A,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,J.jsx)(er,{}),` `,(0,J.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,J.jsx)(vi,{children:(0,J.jsx)(yi,{asChild:!0,children:(0,J.jsxs)(A,{to:`/sign-in`,className:`flex-row items-center`,activeProps:Pi,children:[(0,J.jsx)(de,{}),` Sign In`]})})})]})})]})}function Ri({menuItems:e}){let{user:t}=mr();return Or(t),(0,J.jsx)(`div`,{className:`hidden md:block`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`inline-block`,children:[(0,J.jsx)(A,{to:`/`,children:(0,J.jsx)(hi,{})}),(0,J.jsx)(Si,{})]}),(0,J.jsx)(_i,{children:(0,J.jsx)(bi,{className:`text-grey-400`,children:e.map(e=>Ii(e)?!!e.items.length&&(0,J.jsx)(`div`,{className:`bg-black rounded-2xl flex`,children:e.items.map(e=>(0,J.jsx)(zi,{menuItem:e},e.text))},e.text):(0,J.jsx)(zi,{menuItem:e},e.text))})})]})})}function zi({menuItem:e}){return(0,J.jsx)(vi,{className:`text-gray-400 hover:text-white`,children:(0,J.jsx)(yi,{asChild:!0,children:(0,J.jsxs)(A,{to:e.to,onClick:e.onClick,className:`flex-row items-center`,target:e.target,activeProps:e.to?Pi:void 0,children:[e.icon,(0,J.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,J.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})})}function Bi({menuItems:e}){let{user:t}=mr();Or(t);let[n,r]=(0,Y.useState)(!1),i=(0,Y.useCallback)(()=>r(e=>!e),[]),a=(0,Y.useCallback)(()=>r(!1),[]);return(0,J.jsxs)(`div`,{className:`md:hidden`,id:`mobile-menu`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(A,{to:`/`,children:(0,J.jsx)(hi,{})}),(0,J.jsx)(Si,{}),(0,J.jsxs)(`button`,{type:`button`,className:`shadow-xs text-grey-400 hover:text-white hover:bg-black-dark`,onClick:i,children:[(0,J.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,J.jsx)(ce,{}):(0,J.jsx)(Ce,{})]})]}),(0,J.jsx)(`div`,{className:`${n?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-black-dark opacity-70`,onClick:a}),(0,J.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=>Ii(e)?!!e.items.length&&(0,J.jsx)(`div`,{className:`bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,J.jsx)(Vi,{menuItem:e,onClick:a},e.text))},e.text):(0,J.jsx)(Vi,{menuItem:e,onClick:a},e.text))})]})}function Vi({menuItem:e,onClick:t}){let n=(0,Y.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,J.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?Pi:void 0,children:[e.icon,(0,J.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function Hi(){return(0,J.jsxs)(J.Fragment,{children:[(0,J.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,J.jsx)(Fi,{})}),(0,J.jsxs)(`div`,{className:`pt-20 grid h-screen grid-cols-1 md:grid-cols-2`,children:[(0,J.jsx)(`section`,{className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,J.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,J.jsx)(`section`,{className:`flex items-center justify-center px-6 bg-linear-(--purple-gradient) dark:bg-linear-(--black-dark-gradient)`,children:(0,J.jsx)(Ye,{})})]})]})}var Ui;function Wi(){(0,Y.useEffect)(()=>{},[])}var Gi=[`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 Ki(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of Gi)if(t===e||t.endsWith(`.`+e))return null;return t}var qi=null;function Ji(){let e=F(),t=He(),n=kn(),{redirect:i}=Me({strict:!1});return(0,Y.useEffect)(()=>{qi||=(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=Or(a);di(a);let s=Ki(a.email);Ui?.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})}qi=null})()},[]),(0,J.jsxs)(`div`,{className:`text-white w-lg flex flex-col gap-4`,children:[(0,J.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,J.jsx)(`div`,{className:`underline flex gap-4`,children:(0,J.jsx)(A,{className:`text-sm opacity-50 hover:text-blue-300`,to:`/sign-in`,children:`Try signing in again`})})]})}function Yi({delayDuration:e=0,...t}){return(0,J.jsx)(At,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Xi({...e}){return(0,J.jsx)(Yi,{children:(0,J.jsx)(Ie,{"data-slot":`tooltip`,...e})})}function Zi({...e}){return(0,J.jsx)(Dt,{"data-slot":`tooltip-trigger`,...e})}function Qi({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,J.jsx)(me,{children:(0,J.jsxs)(fr,{"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,J.jsx)(ht,{className:g(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}var $i=new Map;function ea(e){if(!e)return``;if($i.has(e))return $i.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return $i.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return $i.set(e,``),``;let r=[];for(let e=0;e<n.length;e++){let t=n[e],i=e+1<n.length?n[e+1]:void 0;/^[A-Z]{2,}$/.test(t)&&i&&/[A-Z]*s$/.test(i)||/^[A-Z]$/.test(t)&&i!==void 0&&/^[A-Z]s$/.test(i)?(r.push(t+i),e++):r.push(t)}let i=r.map(ta).join(` `);return $i.set(e,i),i}function ta(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function na({restartRequired:e}){let t=nt(),{organization:n,instance:r,cluster:i}=lt({strict:!1});return(0,J.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,Y.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,J.jsxs)(A,{to:`/`,children:[(0,J.jsx)(Be,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,J.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=ea(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,J.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,J.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,J.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,J.jsxs)(Xi,{children:[(0,J.jsx)(Zi,{asChild:!0,children:(0,J.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,J.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,J.jsxs)(Qi,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,J.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var ra=[`RUNNING`],ia=[`TERMINATING`,`TERMINATED`,`REMOVED`];function aa(){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 oa({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 sa(){return I({mutationFn:oa})}function ca({cluster:e,instance:t,instanceParams:n}){let r=F(),i=He(),{redirect:a}=Me({strict:!1}),{mutate:o,isPending:s}=sa();return{isPending:s,submitForm:(0,Y.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])}}var la=oe({error:`Please enter a valid email address.`}).toLowerCase().trim(),ua=w().nonempty({error:`Please enter your password.`}),da=w().nonempty({error:`Please enter a username.`}),fa=T({username:da,password:ua}),pa=T({email:la,password:ua});function ma({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 ha=[`localhost`,`127.0.0.1`],ga=function(e){return e.MixedLoopback=`MixedLoopback`,e.InsecureCookieOutsideChromeAndFirefox=`InsecureCookieOutsideChromeAndFirefox`,e}({});function _a(e,t,n){if(!n||!t||!e)return null;let r=new URL(n).hostname,i=ha.includes(t),a=ha.includes(r);if(i&&a&&r!==t)return ga.MixedLoopback;if(!i&&a){let t=e.indexOf(`Chrome`)>=0,n=e.indexOf(`Firefox`)>=0;if(!t&&!n)return ga.InsecureCookieOutsideChromeAndFirefox}return null}function va(){let{clusterId:e,instanceId:t}=j({strict:!1}),{data:r}=L(wr(e,!0)),i=(0,Y.useMemo)(()=>t&&r&&r?.instances?.find(e=>e.id===t)||void 0,[r,t]),a=(0,Y.useMemo)(()=>r?.status&&ra.includes(r.status),[r?.status]),o=`instance`,s=(0,Y.useMemo)(()=>r?i?(m.flagForFabricConnect(i.id,!1),c(i)):(m.flagForFabricConnect(r.id,!1),n(r)):null,[r,i]),l=K({operationsUrl:s}),u=(0,Y.useMemo)(()=>s?.includes(`localhost`)||s?.includes(`127.0.0.1`),[s]),d=(0,Y.useMemo)(()=>_a(navigator.userAgent,location.hostname,s),[s]),{data:f}=L(ma(l)),p=k({resolver:O(fa),defaultValues:{username:``,password:``}}),{control:h,handleSubmit:g}=p,{submitForm:_,isPending:v}=ca({cluster:r,instance:i,instanceParams:l});return!t&&r&&!r?.fqdn?(0,J.jsx)(Et,{to:`../instances`,replace:!0}):a&&r?.resetPassword?(0,J.jsx)(Et,{to:`/${r.organizationId}/${r.id}/finish-setup`,replace:!0}):!a&&r?.resetPassword?(0,J.jsx)(Et,{to:`/${r.organizationId}/${r.id}/starting-up`,replace:!0}):(0,J.jsxs)(J.Fragment,{children:[!1,(0,J.jsx)(`div`,{className:`h-screen items-center justify-center flex`,children:(0,J.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,J.jsxs)(`h2`,{className:`text-2xl font-light`,children:[`Sign in to Harper `,`Local`]}),(0,J.jsx)(B,{...p,children:(0,J.jsxs)(`form`,{id:`auth-${o}-signin-form`,name:`auth-${o}-signin-form`,onSubmit:g(_),className:`my-4`,children:[(0,J.jsx)(z,{control:h,name:`username`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-4`,children:[(0,J.jsx)(W,{children:`Username`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{autoComplete:`username`,autoFocus:!0,type:`text`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:h,name:`password`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-4`,children:[(0,J.jsx)(W,{children:`Password`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`password`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(R,{disabled:v,type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,children:`Sign In`}),f===!1&&(0,J.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,J.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` This `,o,` is not responding to GET`,` `,(0,J.jsxs)(`a`,{href:`${s}health`,className:`underline`,target:`_blank`,children:[s,`health`]}),` `,`checks.`,(0,J.jsxs)(`ol`,{className:`list-decimal ml-8 mt-2`,children:[(0,J.jsx)(`li`,{children:`Is the server running?`}),(0,J.jsxs)(`li`,{children:[`Have you`,` `,(0,J.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,J.jsxs)(`li`,{children:[`Have you allowed`,` `,(0,J.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===ga.MixedLoopback&&(0,J.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,J.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===ga.InsecureCookieOutsideChromeAndFirefox&&(0,J.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,J.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,J.jsxs)(`div`,{className:`p-4 mt-4 text-sm rounded-lg bg-purple-950`,role:`alert`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`Did you know?`}),` `,`You can add this instance to your Harper account to manage it remotely.`,(0,J.jsx)(`div`,{className:`text-center pt-2`,children:(0,J.jsx)(A,{to:aa(),target:`_blank`,children:(0,J.jsx)(R,{type:`button`,variant:`positive`,children:`Connect to Harper Fabric`})})})]})]})})]})})]})}async function ya({email:e}){let{data:t}=await u.post(`/ForgotPassword/`,{email:e});if(t)return t;throw Error(`Something went wrong`)}function ba(){return I({mutationFn:e=>ya(e)})}var xa=T({email:la});function Sa(){let e=F(),{me:t}=Me({strict:!1}),n=k({resolver:O(xa),defaultValues:{email:t||``}}),r=n.watch(`email`),{setFocus:i,control:a,handleSubmit:o}=n;(0,Y.useEffect)(()=>{i(`email`)},[i]);let{mutate:s,isPending:c}=ba(),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,J.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,J.jsx)(`h2`,{className:`text-2xl font-light`,children:`Enter your account email`}),(0,J.jsx)(`p`,{className:`text-sm pt-1`,children:`If a matching account exists, we'll send you a password reset link.`}),(0,J.jsx)(B,{...n,children:(0,J.jsxs)(`form`,{id:`auth-forgot-password-form`,name:`auth-forgot-password-form`,onSubmit:o(l),className:`my-4`,children:[(0,J.jsx)(z,{control:a,name:`email`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-2`,children:[(0,J.jsx)(W,{children:`Email`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{disabled:c,type:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(R,{type:`submit`,variant:`submit`,disabled:c,className:`w-full my-2 rounded-full`,children:`Send Password Reset Email`})]})}),(0,J.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,J.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:r},children:`Sign in to your account`}),(0,J.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:r},children:`Sign up for free`})]})]})}var Ca=async({token:e,password:t})=>{let{data:n}=await u.put(`/ResetPassword/`,{token:e,newPassword:t});return n};function wa(){return I({mutationFn:e=>Ca(e)})}var Ta=T({password:ua.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 Ea(){let{token:e}=Me({strict:!1}),t=F();(0,Y.useEffect)(()=>{e||t({to:`/sign-in`})},[e,t]);let n=k({resolver:O(Ta),defaultValues:{password:``,confirmPassword:``}}),{setFocus:r,control:i,handleSubmit:a}=n;(0,Y.useEffect)(()=>{r(`password`)},[r]);let{mutate:o,isPending:s}=wa(),c=(0,Y.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,J.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,J.jsx)(`h2`,{className:`text-2xl font-light`,children:`Reset Password`}),(0,J.jsx)(B,{...n,children:(0,J.jsxs)(`form`,{id:`auth-reset-password-form`,name:`auth-reset-password-form`,className:`my-4`,onSubmit:a(c),children:[(0,J.jsx)(z,{control:i,name:`password`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-2`,children:[(0,J.jsx)(W,{children:`New Password`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{disabled:s,type:`password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:i,name:`confirmPassword`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-2`,children:[(0,J.jsx)(W,{children:`Confirm Password`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{disabled:s,type:`password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(R,{variant:`submit`,type:`submit`,disabled:s,className:`w-full my-2 rounded-full`,children:`Submit New Password`})]})})]})}function Da({text:e,disabled:t,onClick:n}){return(0,J.jsx)(`a`,{href:`/oauth/github/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,children:(0,J.jsxs)(`button`,{className:C(`github-signin-btn`,t&&`opacity-50`),type:`button`,children:[(0,J.jsx)(`img`,{src:`/github/GitHub_Invertocat_White.svg`,alt:`GitHub Logo`,className:`github-icon`}),e]})})}function Oa({text:e,disabled:t,onClick:n}){return(0,J.jsx)(`a`,{href:`/oauth/google/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,children:(0,J.jsxs)(`button`,{className:C(`gsi-material-button`,t&&`opacity-50`),type:`button`,children:[(0,J.jsx)(`div`,{className:`gsi-material-button-state`}),(0,J.jsxs)(`div`,{className:`gsi-material-button-content-wrapper`,children:[(0,J.jsx)(`div`,{className:`gsi-material-button-icon`,children:(0,J.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,J.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,J.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,J.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,J.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,J.jsx)(`path`,{fill:`none`,d:`M0 0h48v48H0z`})]})}),(0,J.jsx)(`span`,{className:`gsi-material-button-contents`,children:e}),(0,J.jsx)(`span`,{className:`hidden`,children:e})]})]})})}function ka(){let e=F(),t=kn(),n=He(),{redirect:i}=Me({strict:!1}),{mutate:a,isPending:o}=Aa();return{isPending:o,submitForm:(0,Y.useCallback)(o=>{a(o,{onSuccess:async a=>{m.setUserForEntity(d,a);let o=Or(a);di(a);let s=Ki(a.email);Ui?.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 Aa(){return I({mutationFn:e=>ja(e)})}async function ja({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 Ma(){let{me:e}=Me({strict:!1}),t=k({resolver:O(pa),defaultValues:{email:e||``,password:``}}),{handleSubmit:n,control:r}=t,i=t.watch(`email`),{submitForm:a,isPending:o}=ka();return(0,J.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,J.jsx)(`h2`,{className:`text-2xl font-light`,children:`Sign in to Harper Fabric`}),(0,J.jsx)(B,{...t,children:(0,J.jsxs)(`form`,{id:`auth-signin-form`,name:`auth-signin-form`,onSubmit:n(a),className:`my-4`,children:[(0,J.jsx)(z,{control:r,name:`email`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-4`,children:[(0,J.jsx)(W,{children:`Email`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`email`,autoFocus:!0,autoComplete:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:r,name:`password`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-4`,children:[(0,J.jsx)(W,{children:`Password`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`password`,autoComplete:`current-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(R,{type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,disabled:o,children:`Sign In`}),(0,J.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,J.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:i},children:`Sign up for free`}),(0,J.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/forgot-password`,search:{me:i},children:`Forgot password?`})]})]})}),(0,J.jsx)(`hr`,{className:`border-gray-600 my-6`}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(Oa,{text:`Sign in with Google`}),(0,J.jsx)(Da,{text:`Sign in with GitHub`})]})]})}var Na=/^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžæÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,'-]+$/u;async function Pa(e){let{data:t}=await u.post(`/User/`,e);if(t)return t;throw Error(`Something went wrong`)}function Fa(){return I({mutationFn:e=>Pa(e)})}var Ia=T({email:la.max(80,{error:`Email cannot be longer than 80 characters.`}),firstname:w().trim().min(2,{error:`Please enter your first name.`}).regex(Na,{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(Na,{error:`Last name can only contain letters, spaces, and hyphens.`}).max(80,{error:`Last name cannot be longer than 80 characters.`}),password:ua.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 La(){let e=F(),{email:t,me:n}=Me({strict:!1}),[r,i]=(0,Y.useState)(!1),a=k({resolver:O(Ia),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,Y.useEffect)(()=>{c(`firstname`)},[c]);let{mutate:d}=Fa(),f=(0,Y.useCallback)(async t=>{let{confirmPassword:n,acceptTerms:r,...i}=t;d(i,{onSuccess:()=>{let t=Ki(i.email);Ui?.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,Y.useCallback)(e=>{if(!s)return i(!0),setTimeout(()=>i(!1),1e3),e.preventDefault(),!1},[s]),m=(0,J.jsx)(z,{control:l,name:`acceptTerms`,render:({field:e})=>(0,J.jsxs)(V,{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,J.jsx)(U,{children:(0,J.jsx)(G,{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,J.jsxs)(`div`,{className:`space-y-1 leading-none`,children:[(0,J.jsxs)(W,{className:`text-xs font-normal`,children:[`I accept the`,` `,(0,J.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,J.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,J.jsx)(H,{})]})]})});return(0,J.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,J.jsx)(`h2`,{className:`text-2xl font-light`,children:`Sign up for Harper Fabric`}),(0,J.jsxs)(B,{...a,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 my-6`,children:[m,(0,J.jsx)(Oa,{text:`Sign up with Google`,disabled:!s,onClick:p}),(0,J.jsx)(Da,{text:`Sign up with GitHub`,disabled:!s,onClick:p})]}),(0,J.jsx)(`hr`,{className:`border-gray-600`}),(0,J.jsxs)(`form`,{id:`auth-signup-form`,name:`auth-signup-form`,onSubmit:u(f),className:`grid gap-4 my-4`,children:[(0,J.jsx)(z,{control:l,name:`firstname`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`First Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`text`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:l,name:`lastname`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Last Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`text`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:l,name:`email`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Email`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{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,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:l,name:`password`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Password`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`password`,autoComplete:`new-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:l,name:`confirmPassword`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Confirm Password`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`password`,autoComplete:`new-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),m,(0,J.jsx)(R,{type:`submit`,variant:`submit`,className:`w-full rounded-full my-4`,children:`Sign Up For Free`})]})]}),(0,J.jsx)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:(0,J.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 Ra=async({email:e})=>{let{data:t}=await u.post(`/ResendVerificationEmail/`,{email:e});return t};function za(){return I({mutationFn:e=>Ra(e)})}var Ba=async e=>{let{data:t}=await u.put(`/VerifyEmail/`,{token:e.toString()});return t};function Va(){return I({mutationFn:e=>Ba(e)})}var Ha=T({email:la});function Ua(){let e=F(),{mutate:t,isPending:n}=za(),r=k({resolver:O(Ha),defaultValues:{email:``}}),i=r.watch(`email`),{setFocus:a,control:o,handleSubmit:s}=r;(0,Y.useEffect)(()=>{a(`email`)},[a]);let c=(0,Y.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,J.jsxs)(B,{...r,children:[(0,J.jsx)(`p`,{className:`text-sm py-2`,children:`Please Enter an Email`}),(0,J.jsxs)(`form`,{id:`auth-verify-email-form`,name:`auth-verify-email-form`,onSubmit:s(c),className:`my-4`,children:[(0,J.jsx)(z,{control:o,name:`email`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-2`,children:[(0,J.jsx)(W,{children:`Email`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{disabled:n,type:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(R,{type:`submit`,variant:`submit`,disabled:n,className:`w-full my-2 rounded-full`,children:`Send Verification Email`})]})]})}function Wa(){let{token:e}=Me({strict:!1}),t=F(),{mutate:n,isPending:r}=Va(),i=(0,Y.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,Y.useEffect)(()=>{e&&i(e)},[i,e]),(0,J.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,J.jsx)(`h1`,{className:`text-3xl font-light`,children:`Verify Email`}),r?(0,J.jsx)(`p`,{className:`text-sm pt-1`,children:`Verifying email...`}):(0,J.jsx)(Ua,{})]})}function Ga(){let{email:e}=Me({strict:!1}),{mutate:t,isPending:n}=za(),r=(0,Y.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,J.jsxs)(`div`,{className:`text-white w-lg flex flex-col gap-4`,children:[(0,J.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Check your email!`]}),(0,J.jsxs)(`p`,{children:[`Your account has been created! You should receive an email with a link to `,(0,J.jsx)(`strong`,{children:`[Verify My Email]`}),`!`]}),(0,J.jsxs)(`p`,{children:[`From: `,(0,J.jsx)(`strong`,{children:`harper@notifications.harperfabric.com`})]}),(0,J.jsxs)(`p`,{children:[`To: `,(0,J.jsx)(`strong`,{children:e||`your email`})]}),(0,J.jsx)(`p`,{children:`Can you click it? Then we can carry on to more fun things!`}),(0,J.jsxs)(`div`,{className:`underline flex gap-4`,children:[(0,J.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:e},children:`I did it, let me sign in!`}),(0,J.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 Ka=P({getParentRoute:()=>pi,id:`_authLayout`,component:Hi}),qa=P({getParentRoute:()=>Ka,path:`sign-in`,component:Ma,beforeLoad:({context:e,location:t})=>{let n=e.authentication[d]?.user;if(n){let e=t?.search,r=Or(n);throw zt({to:e?.redirect?.startsWith(`/`)?e.redirect:r})}}}),Ja=P({getParentRoute:()=>pi,path:`sign-in`,component:va,beforeLoad:({context:e,location:t})=>{if(e.authentication.OverallAppSignIn?.user){let e=t?.search;throw zt({to:e?.redirect?.startsWith(`/`)?e.redirect:`/`})}}}),Ya=P({getParentRoute:()=>Ka,path:`sign-up`,component:La}),Xa=P({getParentRoute:()=>Ka,path:`forgot-password`,component:Sa}),Za=P({getParentRoute:()=>Ka,path:`verify-email`,component:Wa}),Qa=P({getParentRoute:()=>Ka,path:`verifying`,component:Ga}),$a=P({getParentRoute:()=>Ka,path:`check-oauth`,component:Ji}),eo=P({getParentRoute:()=>Ka,path:`reset-password`,component:Ea});Ka.addChildren([qa,Ya,$a,Xa,Za,Qa,eo]);var to=[Ja];function no({children:e}){return(0,J.jsx)(`nav`,{className:`fixed top-20 w-full h-12 z-39 py-2 px-4 md:px-12 bg-grey-700`,children:(0,J.jsxs)(`div`,{className:`flex items-center h-full space-x-2`,children:[(0,J.jsx)(na,{}),e]})})}function ro(e){if(so(e)||co(e))return`warning`;if(io(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 io(e){switch(e){case`RUNNING`:case`UPDATED`:return!0;default:return!1}}function ao(e){switch(e){case`FAILED`:return!0;default:return!1}}function oo(e){switch(e){case`TERMINATED`:return!0;default:return!1}}function so(e){switch(e){case`CLONE_PENDING`:return!0;default:return!1}}function co(e){switch(e){case`PROVISIONING`:case`CLONING`:case`CLONE_READY`:case`UPDATING_HDB_NODES`:case`UPDATING`:return!0;default:return!1}}function X({...e}){return(0,J.jsx)(Se,{"data-slot":`dialog`,...e})}function lo({...e}){return(0,J.jsx)(bn,{"data-slot":`dialog-trigger`,...e})}function uo({...e}){return(0,J.jsx)(Ee,{"data-slot":`dialog-portal`,...e})}function fo({className:e,...t}){return(0,J.jsx)(Ct,{"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 Z({className:e,children:t,...n}){return(0,J.jsxs)(uo,{"data-slot":`dialog-portal`,children:[(0,J.jsx)(fo,{}),(0,J.jsxs)(ve,{"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,J.jsxs)(yt,{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,J.jsx)(ce,{className:`text-white`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function po({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`dialog-header`,className:g(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function Q({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`dialog-footer`,className:g(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function $({className:e,...t}){return(0,J.jsx)(ot,{"data-slot":`dialog-title`,className:g(`text-lg leading-none text-white font-semibold`,e),...t})}function mo({className:e,...t}){return(0,J.jsx)(tr,{"data-slot":`dialog-description`,className:g(`text-muted-foreground text-sm`,e),...t})}function ho({typeOfThingBeingDeleted:e,nameOfThingBeingDeleted:t,isModalOpen:n,hideDataLossWarning:r,setIsModalOpen:i,deletionConfirmed:a,deletionPending:o,trigger:s,presentParticiple:c=`Deleting`,transitiveVerb:l=`Delete`}){return(0,J.jsxs)(X,{open:n,onOpenChange:i,children:[s&&(0,J.jsx)(lo,{asChild:!0,children:s}),(0,J.jsxs)(Z,{className:`sm:max-w-[750px]`,children:[(0,J.jsxs)(po,{children:[(0,J.jsxs)($,{children:[`Are you sure you want to `,l.toLowerCase(),` this `,e,`?`]}),(0,J.jsx)(mo,{children:`This action cannot be undone.`})]}),!r&&(0,J.jsxs)(`div`,{className:`p-3 my-5 text-white rounded-md bg-amber-600`,children:[(0,J.jsxs)(`p`,{className:`flex space-x-1 font-semibold align-baseline`,children:[(0,J.jsx)(Un,{className:`inline-block size-5`}),` `,(0,J.jsx)(`span`,{children:`Warning`})]}),(0,J.jsxs)(`p`,{className:`pt-2 text-base`,children:[`By `,c.toLowerCase(),` `,e,` `,(0,J.jsx)(`span`,{className:`font-semibold`,children:t}),` `,`you will lose the data stored in it permanently.`]})]}),(0,J.jsx)(Q,{children:(0,J.jsxs)(`div`,{className:`flex justify-center space-x-5`,children:[(0,J.jsxs)(R,{className:`rounded-full`,onClick:()=>i(!1),children:[(0,J.jsx)(yn,{}),` Cancel`]}),(0,J.jsxs)(R,{variant:`destructive`,className:`rounded-full`,onClick:a,disabled:o,children:[(0,J.jsx)(hn,{}),` `,l]})]})})]})]})}function go({className:e,variant:t,asChild:n=!1,...r}){return(0,J.jsx)(n?$e:`span`,{"data-slot":`badge`,className:g(xi({variant:t}),e),...r})}function _o({...e}){return(0,J.jsx)(lr,{"data-slot":`dropdown-menu`,...e})}function vo({...e}){return(0,J.jsx)(ar,{"data-slot":`dropdown-menu-trigger`,...e})}function yo({className:e,sideOffset:t=4,...n}){return(0,J.jsx)(Qn,{children:(0,J.jsx)(Dn,{"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 bo({className:e,inset:t,variant:n=`default`,...r}){return(0,J.jsx)(dn,{"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 xo({className:e,children:t,checked:n,...r}){return(0,J.jsxs)(Fn,{"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,J.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,J.jsx)(cn,{children:(0,J.jsx)(Zn,{className:`size-4`})})}),t]})}function So({className:e,inset:t,...n}){return(0,J.jsx)(Wt,{"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 Co({className:e,...t}){return(0,J.jsx)(Jt,{"data-slot":`dropdown-menu-separator`,className:g(`bg-grey-700 -mx-1 my-1 h-px`,e),...t})}function wo(e){return!!e?.plans?.[0]?.planId?.startsWith(`self-hosted`)}function To({cluster:e}){let t=hr(e.id),{view:n,update:r}=Di(e.organizationId,e.id),i=!m.checkForFabricConnect(e.id)&&!!t.user;if(n){if(!e.fqdn)return(0,J.jsx)(A,{to:`/${e.organizationId}/${e.id}/instances`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,J.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Instances `,(0,J.jsx)(at,{className:`inline-block`})]})});if(e.resetPassword)return r?(0,J.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,J.jsxs)(R,{variant:`positive`,className:`py-2 hover:border-b-2 animate-glow-pulse`,children:[`Finish Setup `,(0,J.jsx)(at,{className:`inline-block`})]})}):(0,J.jsx)(`span`,{className:`py-2 text-nowrap`,children:`Pending Owner Setup`});if(!t.isLoading)return i?(0,J.jsx)(A,{to:`/${e.organizationId}/${e.id}/`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,J.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Direct Connect `,(0,J.jsx)(at,{className:`inline-block`})]})}):r&&!wo(e)?(0,J.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,J.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Fabric Connect `,(0,J.jsx)(at,{className:`inline-block`})]})}):(0,J.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,J.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Direct Sign In `,(0,J.jsx)(at,{className:`inline-block`})]})})}}function Eo(e,t){let n=[];if(e)for(let r of e)n.push(r[t]);return n}function Do({cluster:e,forceProgressBarVisible:t}){let[n,r]=(0,Y.useState)(t||!1),{data:i}=L(wr(n&&e.id,2e3));(0,Y.useEffect)(function(){(so(e.status)||co(e.status))&&r(!0)},[n,e.status,i?.instances]);let a=(0,Y.useMemo)(()=>{let e=Eo(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||oo(t)||(so(t)?(n+=1,r[t]=`${n} ${ea(t)}`):co(t)?(a+=1,o[t]=`${a} ${ea(t)}`):ao(t)?(l+=1,u[t]=`${l} ${ea(t)}`):!i.planId||!e.includes(i.planId)?(a+=1,o.DRAINING_TRAFFIC=`${a} ${ea(`Draining Traffic`)}`):io(t)&&(s+=1,c[t]=`${s} ${ea(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,J.jsxs)(`div`,{className:`w-full text-center`,children:[(0,J.jsxs)(`div`,{className:`w-full h-2.5 rounded-full overflow-clip flex shadow`,children:[(0,J.jsx)(`div`,{style:{width:a.runningWidth},className:`grow bg-green/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,J.jsx)(`div`,{style:{width:a.failedWidth},className:`grow bg-red/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,J.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,J.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,J.jsx)(`div`,{className:`text-xs text-muted-foreground font-light mt-2`,children:a.text})]}):null}async function Oo(e){let{data:t}=await u.delete(`/Cluster/${e}`,{timeout:0});return t}function ko(){return I({mutationFn:e=>Oo(e)})}function Ao(...e){return(0,Y.useMemo)(()=>e.map(e=>(()=>{navigator.clipboard.writeText(e),N.info(`Copied to clipboard!`,{icon:(0,J.jsx)(an,{}),duration:1e3})})),e)}function jo(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 Mo(e,t){return jo(localStorage.getItem(e))??t}function No(e,t){t==null?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}function Po(e,t){let n=(0,Y.useState)(Mo(e,t)),[r]=n;return(0,Y.useEffect)(()=>No(e,r),[e,r]),n}var Fo=function(e){return e.SavedClusterState=`SavedClusterState`,e}({});function Io({cluster:e}){let t=He(),r=kn(),i=(0,Y.useMemo)(()=>n(e),[e]),a=Ur({operationsUrl:i}),o=hr(e.id),[,s]=Po(Fo.SavedClusterState,null),{view:c,update:l,remove:u,create:d}=Di(e.organizationId,e.id),{mutate:f,isPending:p}=ko(),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(!1),b=(0,Y.useMemo)(()=>e.status&&ra.includes(e.status),[e.status]),x=wo(e),S=m.checkForFabricConnect(e.id),ee=!S&&!!o.user,te=(0,Y.useMemo)(()=>e.status&&ia.includes(e.status),[e.status]),C=(0,Y.useMemo)(()=>e.status&&ao(e.status),[e.status]),ne=(0,Y.useCallback)(async()=>{_(!0);let t=await Cr(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,Y.useCallback)(()=>{s(e),t.navigate({to:`/${e.organizationId}/new-cluster`})},[e,t,s]),w=(0,Y.useCallback)(()=>y(!0),[]),ie=(0,Y.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]=Ao(`${ae}`,`https://${ae}`),E=[b&&l&&!o.isLoading&&(!ee||S)&&(0,J.jsx)(A,{to:`${e.id}/sign-in`,disabled:g,children:(0,J.jsxs)(bo,{children:[(0,J.jsx)(Ae,{className:`text-green`}),` Direct Sign In`]})},`sign-in`),b&&l&&(0,J.jsx)(A,{to:`${e.id}/edit`,disabled:g,children:(0,J.jsxs)(bo,{children:[(0,J.jsx)(In,{className:`text-purple-600`}),` Edit Scaling`]})},`edit`),b&&l&&(0,J.jsx)(A,{to:`${e.id}/edit/version`,disabled:g,children:(0,J.jsxs)(bo,{children:[(0,J.jsx)(jt,{className:`text-fuchsia-300`}),` Edit Version`]})},`edit`),b&&l&&!1,b&&c&&(0,J.jsx)(A,{to:`${e.id}/instances`,disabled:g,children:(0,J.jsxs)(bo,{children:[(0,J.jsx)(sn,{className:`text-orange-300`}),` Instances`]})},`instances`),b&&c&&e.fqdn&&(0,J.jsx)(Co,{},`copy-separator`),b&&c&&e.fqdn&&(0,J.jsxs)(bo,{onClick:oe,disabled:g,children:[(0,J.jsx)($t,{}),` Copy Host Name`]},`copy-host-name`),b&&c&&e.fqdn&&(0,J.jsxs)(bo,{onClick:T,disabled:g,children:[(0,J.jsx)($t,{}),` Copy API URL`]},`copy-api-url`),b&&c&&!!i&&!o.isLoading&&ee&&(0,J.jsx)(bo,{onClick:ne,disabled:g,children:`Direct Sign Out`},`direct-sign-out`),C&&d&&(0,J.jsx)(bo,{className:`focus:bg-green/70 focus:text-white`,onClick:re,children:`Try Again`},`try-again`),!te&&u&&b&&(0,J.jsx)(Co,{},`remove-separator`),!te&&u&&(0,J.jsxs)(bo,{className:`focus:bg-red/70 focus:text-white`,onClick:w,children:[(0,J.jsx)(hn,{className:`text-red-300`}),` `,x?`Remove`:`Terminate`]},`remove`)].filter(Vr);return(0,J.jsxs)(Tr,{className:`relative h-full justify-between`,children:[(0,J.jsxs)(Lr,{children:[(0,J.jsxs)(Ir,{className:`flex items-center justify-between`,children:[ae?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`truncate max-w-48`,children:ae}),(0,J.jsx)(Kt,{onClick:oe,size:16,className:`cursor-pointer`}),(0,J.jsx)(`span`,{className:`grow`})]}):(0,J.jsx)(`span`,{children:`Self-Hosted`}),!te&&(0,J.jsxs)(_o,{children:[(0,J.jsx)(vo,{children:(0,J.jsx)(qn,{"aria-label":`Cluster options`})}),(0,J.jsx)(yo,{children:[...E]})]})]}),(0,J.jsx)(xr,{children:(0,J.jsx)(`h2`,{children:e.name})})]}),(0,J.jsxs)(yr,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsx)(Do,{cluster:e}),b&&c&&(0,J.jsx)(To,{cluster:e}),C&&e.status&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(go,{variant:ro(e.status),children:ea(e.status)}),(0,J.jsx)(`span`,{className:`text-xs`,children:`Click "..." to choose how to proceed.`})]})]}),(0,J.jsx)(ho,{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 Lo({overEmail:e}){return(0,J.jsx)(`a`,{href:e?`mailto:support@harperdb.io`:`https://discord.com/channels/1415002037439041710/1415002038286286994`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Contact us`})}function Ro({children:e,className:t}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(no,{}),(0,J.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] relative ${t??``}`,children:e})]})}async function zo(e){let{data:t}=await u.get(`/Plan/`,{params:{organizationId:e}});return t}function Bo(e){return M({queryKey:[e,`instancePlan`],queryFn:()=>zo(e),retry:!1})}async function Vo(){let{data:e}=await u.get(`/HarperVersions/`);return e}function Ho(){return M({queryKey:[`HarperVersions`],queryFn:Vo,staleTime:6e4,retry:!1})}async function Uo({organizationId:e,availableHosts:t}={}){let{data:n}=await u.get(`/Region/`,{params:{availableHosts:t,organizationId:e}});return n}function Wo({organizationId:e,availableHosts:t}={}){return M({queryKey:[e,`regionLocations`,t],queryFn:()=>Uo({organizationId:e,availableHosts:t}),retry:!1})}function Go(e){return(t,n)=>t[e]===n[e]?0:t[e]>n[e]?1:-1}function Ko(e){let t=e.split(`.`).map(Number);return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0}function qo(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 Jo(e,t){return e.instanceFqdn===t.instanceFqdn?e.operationsApiPort-t.operationsApiPort:qo(e.instanceFqdn)&&qo(t.instanceFqdn)?Ko(e.instanceFqdn)-Ko(t.instanceFqdn):e.instanceFqdn>t.instanceFqdn?1:-1}function Yo(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 Xo(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 Zo(e,t,n){let r=Yo(e,t),i={};for(let e in r)i[e]=Xo(r[e],n);return i}function Qo({duration:e,message:t,lateMessage:n}){let r=(0,Y.useRef)(0),i=(0,Y.useRef)(0),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(`5%`),l=(0,Y.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,Y.useEffect)(()=>(r.current=requestAnimationFrame(l),()=>cancelAnimationFrame(r.current)),[l]),(0,J.jsxs)(J.Fragment,{children:[a?n:t,(0,J.jsx)(Nr,{width:s,animated:!1})]})}async function $o(e){let{data:t}=await u.post(`/Cluster/`,e,{timeout:0});return t}function es(){return I({mutationFn:e=>$o(e)})}async function ts(e){let{id:t,...n}=e,{data:r}=await u.put(`/Cluster/${t}`,n,{timeout:0});return r}function ns(){return I({mutationFn:e=>ts(e)})}async function rs(e){let{data:t}=await u.get(`/Organization/${e}`);return t}function is(e){return M({queryKey:[e],queryFn:()=>rs(e),retry:!1,refetchInterval:1e4})}var as=`ENTERPRISE`;function os(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 ss(e,t,n=`-`){let r=t.split(n)[0];return e.findIndex(e=>e.startsWith(r))!==-1}function cs(e){return e.replace(/[^a-zA-Z0-9]/g,`-`).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase().replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}async function ls(e){await u.put(`/Payment/`,e)}function us(){return I({mutationFn:e=>ls(e)})}function ds(e){let{mutate:t}=us();return(0,Y.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 fs=(0,Y.createContext)(null);function ps(){return(0,Y.useContext)(fs)}function ms({hasExistingBilling:e,onPaymentAdded:t,onSaveStateForBillingRedirect:n}){let{organizationId:r}=j({strict:!1}),i=on(),a=ps(),o=en(),[s,c]=(0,Y.useState)(!1),l=ds(r),u=(0,Y.useCallback)(()=>{t(!1)},[t]);return(0,J.jsxs)(`form`,{id:`billing-add-payment-method-form`,name:`billing-add-payment-method-form`,onSubmit:(0,Y.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,J.jsx)(Yn,{}),(0,J.jsx)(wn,{options:{mode:`billing`}}),(0,J.jsxs)(`div`,{className:`mt-4 flex gap-8 items-center`,children:[(0,J.jsxs)(R,{disabled:!i||!o||s,variant:`submit`,className:`rounded-full`,children:[(0,J.jsx)(On,{}),` Add Payment Method`]}),e&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`text-xs text-gray-600`,children:`Your existing payment method will be overwritten.`}),(0,J.jsx)(R,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Cancel`})]})]})]})}async function hs(e){let{data:t}=await u.post(`/StripeAccount/`,e);return t}function gs(){return I({mutationFn:e=>hs(e)})}async function _s(e){let{data:t}=await u.post(`/Payment/`,{organizationId:e.organizationId});return t}function vs(){return I({mutationFn:e=>_s(e)})}function ys(e){let{enabled:t,existingStripeId:n,organizationId:r}=e,{mutate:i}=gs(),{mutate:a}=vs(),[o,s]=(0,Y.useState)(void 0);return(0,Y.useEffect)(()=>{},[i,t,n,a,(0,Y.useCallback)(e=>{s(e.clientSecret)},[]),r]),o}function bs({children:e}){let{organizationId:t}=j({strict:!1}),{data:n}=L(is(t)),r=ys({organizationId:t,enabled:!!n,existingStripeId:n?.stripeId});return(0,Y.useMemo)(()=>({clientSecret:r||``,appearance:{theme:`night`}}),[r]),console.error(`No VITE_PUBLIC_STRIPE_KEY is configured for this environment.`),(0,J.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 xs({onPaymentAdded:e,onSaveStateForBillingRedirect:t}){let{organizationId:n}=j({strict:!1}),{data:r}=L(is(n)),i=r?.billing,a=i?.paymentMethod;return(0,J.jsxs)(bs,{children:[(0,J.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,J.jsx)(ms,{hasExistingBilling:!!i,onSaveStateForBillingRedirect:t,onPaymentAdded:e})]})}var Ss=function(e){return e.PASS=`pass`,e.FAIL=`fail`,e.PENDING=`pending`,e.ERROR=`error`,e}({});function Cs(e){switch(e){case Ss.PASS:return`success`;case Ss.FAIL:case Ss.ERROR:return`destructive`;case Ss.PENDING:default:return`default`}}function ws(e){switch(e){case Ss.PASS:return`READY`;case Ss.FAIL:case Ss.ERROR:case Ss.PENDING:default:return e.toUpperCase()}}function Ts(e,t){return`${String(e).padStart(2,`0`)}/${String(t%100).padStart(2,`0`)}`}function Es(e){let{onSaveStateForBillingRedirect:t,onReplacingPaymentMethod:n}=e??{},{organizationId:r}=j({strict:!1}),{update:i}=Ti(r),{data:a,refetch:o}=L(is(r)),s=a?.billing?.paymentMethod,[c,l]=(0,Y.useState)(!1),u=(0,Y.useCallback)(()=>{l(!c),n?.(!c)},[n,c]),d=(0,Y.useCallback)(e=>{l(!1),n?.(!1),e&&o()},[n,o]);return a?.type===`ENTERPRISE`?(0,J.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,J.jsx)(Lo,{}),`, we would love to talk!`]}):s&&!c?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mt-2`,children:[s.brand?.toUpperCase()??`Card`,` ending in `,s.last4??`••••`,s.expMonth&&s.expYear?(0,J.jsxs)(J.Fragment,{children:[`(exp `,Ts(s.expMonth,s.expYear),`)`]}):null,s.status?(0,J.jsxs)(J.Fragment,{children:[`—`,` `,(0,J.jsx)(go,{variant:Cs(s.status),children:ws(s.status)})]}):null]}),i&&(0,J.jsx)(`div`,{className:`mt-2 mb-6`,children:(0,J.jsx)(R,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Replace Payment Method`})})]}):i?(0,J.jsx)(xs,{onSaveStateForBillingRedirect:t,onPaymentAdded:d}):(0,J.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 Ds(e){return e!==void 0&&e>0}function Os({clusterId:e,isPending:t,onGoBackToDetails:n,onSaveStateForBillingRedirect:r,onSubmit:i,organizationId:a,selectedPlan:o}){let{data:s}=L(is(a)),c=s?.billing,l=s?.type===as,u=l||c?.paymentMethod?.status===Ss.PASS,[d,f]=(0,Y.useState)(!1),m=Ds(o?.planLimits?.expirationMonths)&&o.planLimits.expirationMonths<1e3&&o.planLimits.expirationMonths,h=(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end mt-3 max-w-xl`,children:[(0,J.jsxs)(R,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,disabled:t,onClick:n,children:[(0,J.jsx)(yn,{}),` Back to Details`]}),(0,J.jsxs)(R,{disabled:t||!u||d,type:`submit`,variant:`submit`,className:`rounded-full`,onClick:i,children:[e?`Edit Cluster`:`Create New Cluster`,` `,(0,J.jsx)(at,{})]})]})});if(l)return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`ul`,{className:`list-disc ml-6 max-w-lg`,children:[(0,J.jsx)(`li`,{children:`Reminder: you will be billed at your contracted rate for any additional infrastructure.`}),(0,J.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,J.jsx)(Lo,{overEmail:!0}),`, we are here to help.`]})]}),h]});let g=m&&`, or ${p(m,`month`,`months`)} elapse`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`ul`,{className:`list-disc ml-6 mb-6`,children:[(0,J.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,J.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,J.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,J.jsxs)(`li`,{children:[`When that block is used up`,g,`, you will be automatically renewed.`]}),(0,J.jsx)(`li`,{children:`While refunds are not available, we’d be happy to assist you with troubleshooting.`}),(0,J.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,J.jsx)(Lo,{overEmail:!0}),`, we are here to help.`]})]}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-sm mb-6`,children:`Payment method:`}),(0,J.jsx)(Es,{onSaveStateForBillingRedirect:r,onReplacingPaymentMethod:f}),h]})}var ks=/(^$|^(?: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,As=65535,js=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.`),Ms=T({clusterName:w().nonempty(`Please enter a cluster name.`).max(255,`Cluster name cannot be longer than 255 characters long.`),abbreviatedName:se([S(``),y(),js]),fqdn:w().regex(ks,`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(ks,`Please enter a valid host name without the port or any path.`),port:ae().min(0,`Positive thinking only, please.`).max(As,`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 Ns({calculatedNames:e,disabled:t,form:n}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(z,{control:n.control,name:`abbreviatedName`,render:({field:n})=>(0,J.jsxs)(V,{className:`col-span-3`,children:[(0,J.jsx)(W,{className:`pb-1`,children:`Host Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{...n,type:`text`,maxLength:js.maxLength,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:e.suggestedAbbreviatedName,disabled:t})}),(0,J.jsx)(H,{})]})}),(0,J.jsxs)(V,{className:`col-span-3 `,children:[(0,J.jsx)(W,{className:`pb-1`,children:`Full Host Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(`span`,{children:e.fullHostName})}),(0,J.jsx)(H,{})]})]})}var Ps={Colocated:`Shared infrastructure for optimized value`,Dedicated:`Dedicated infrastructure for consistent performance`,"Self-Hosted":`Your own infrastructure`};function Fs({availableDeploymentTypes:e,disabled:t,form:n}){return(0,J.jsx)(z,{control:n.control,name:`deploymentDescription`,render:({field:r})=>(0,J.jsxs)(V,{className:`col-span-3`,children:[(0,J.jsx)(W,{className:`pb-1`,children:`Harper Deployment`}),(0,J.jsx)(Y.Suspense,{fallback:(0,J.jsx)($r,{}),children:(0,J.jsx)(U,{children:(0,J.jsxs)(ri,{...r,disabled:t,onValueChange:e=>{r.onChange(e),n.trigger()},children:[(0,J.jsx)(Xr,{className:`w-full h-auto`,children:(0,J.jsx)(ti,{placeholder:`Choose Tier`})}),(0,J.jsx)(Jr,{children:(0,J.jsx)(Qr,{children:e.map(e=>(0,J.jsxs)(q,{value:e,children:[(0,J.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e}),Ps[e]&&(0,J.jsx)(`dd`,{className:`font-light`,children:Ps[e]})]},e))})})]})})}),(0,J.jsx)(H,{})]})})}function Is({disabled:e,form:t}){return(0,J.jsx)(z,{control:t.control,name:`fqdn`,render:({field:t})=>(0,J.jsxs)(V,{className:`md:col-span-6 col-span-3`,children:[(0,J.jsx)(W,{className:`pb-1`,children:`Optional Cluster Load Balancer Host Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{...t,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:`example.your-company.com`,disabled:e})}),(0,J.jsx)(H,{})]})})}function Ls({className:e,disabled:t,form:n}){return(0,J.jsx)(z,{control:n.control,name:`clusterName`,render:({field:n})=>(0,J.jsxs)(V,{className:e,children:[(0,J.jsx)(W,{className:`pb-1`,children:`Cluster Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{autoFocus:!0,type:`text`,maxLength:Ms.shape.clusterName.maxLength,autoCapitalize:`words`,disabled:t,...n})}),(0,J.jsx)(H,{})]})})}function Rs({availablePerformanceDescriptions:e,form:t,selectedDeployment:n}){return(0,J.jsx)(z,{control:t.control,name:`performanceDescription`,render:({field:r})=>(0,J.jsxs)(V,{className:`col-span-3`,children:[(0,J.jsxs)(W,{className:`pb-1`,children:[n.startsWith(`Self`)?`Support`:`Performance`,` & Usage`]}),(0,J.jsx)(Y.Suspense,{fallback:(0,J.jsx)($r,{}),children:(0,J.jsx)(U,{children:(0,J.jsxs)(ri,{...r,onValueChange:e=>{r.onChange(e),t.trigger()},disabled:!e?.length,children:[(0,J.jsx)(Xr,{className:`w-full h-auto`,children:(0,J.jsx)(ti,{placeholder:`Choose Tier`})}),(0,J.jsx)(Jr,{children:(0,J.jsx)(Qr,{children:e.map(e=>(0,J.jsxs)(q,{value:e.performanceTier,children:[(0,J.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e.name}),e.description&&(0,J.jsx)(`dd`,{className:`font-light`,children:e.description})]},e.name))})})]})})}),(0,J.jsx)(H,{})]})})}function zs({className:e,...t}){let{formDescriptionId:n}=zr();return(0,J.jsx)(`p`,{"data-slot":`form-description`,id:n,className:g(`text-muted-foreground text-sm`,e),...t})}function Bs({className:e,form:t}){return(0,J.jsx)(z,{control:t.control,name:`skipGtmWait`,render:({field:t})=>(0,J.jsxs)(V,{className:e,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(U,{children:(0,J.jsx)(G,{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,J.jsx)(W,{className:`cursor-pointer`,children:`Immediate upgrade and restart`})]}),(0,J.jsx)(zs,{children:`Apply changes immediately without waiting for each instance to be taken out of the load balancer (faster, but potentially less safe).`})]})})}function Vs({className:e,disabled:t,form:n,harperVersions:r}){return r?.value?.length?(0,J.jsx)(z,{control:n.control,name:`version`,render:({field:i})=>(0,J.jsxs)(V,{className:e,children:[(0,J.jsx)(W,{className:`pb-1`,children:`Harper Version`}),(0,J.jsx)(Y.Suspense,{fallback:(0,J.jsx)($r,{}),children:(0,J.jsx)(U,{children:(0,J.jsxs)(ri,{...i,disabled:t,onValueChange:e=>{i.onChange(e),n.trigger()},children:[(0,J.jsx)(Xr,{className:`w-full h-auto`,children:(0,J.jsx)(ti,{placeholder:`Choose Version`})}),(0,J.jsx)(Jr,{children:(0,J.jsx)(Qr,{children:r?.value.map(e=>(0,J.jsxs)(q,{value:e.version,children:[e.version,` `,(0,J.jsx)(`span`,{className:`font-light opacity-50`,children:e.name})]},e.version))})})]})})}),(0,J.jsx)(H,{})]})}):null}var Hs=new RegExp(/^\d+/);function Us(e,t){let n=parseInt(e.match(Hs)?.[0]||`0`,10),r=parseInt(t.match(Hs)?.[0]||`0`,10);return n===r?0:n>r?1:-1}function Ws(e){return new Intl.NumberFormat().format(e)}var Gs=[`K`,`M`,`B`,`T`,`Qa`,`Qi`,`Sx`,`Sp`,`Oc`,`No`,`Dc`];function Ks(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<Gs.length-1);return`${Ws(Math.round(n))} ${Gs[r]}`}function qs({selectedPlan:e,selectedRegion:t,isEnterprise:n}){let[r,i]=(0,Y.useState)(!1),a=(0,Y.useCallback)(()=>{i(!r)},[r,i]),o=e?.planLimits,s=e?.resourcesPerInstance,c=Ds(o?.expirationMonths)&&o.expirationMonths<1e3&&o.expirationMonths,l=t?.purchasedBlockMultiplier??1,u=(0,Y.useMemo)(()=>o?[Ds(o.totalReadCount)&&{label:`Total Reads`,value:`${Ks(o.totalReadCount*l)} reads`},Ds(o.totalReadsBytes)&&{label:`Total Read Transfer`,value:`${Zr(o.totalReadsBytes*l)}`},Ds(o.readsPerMinuteCount)&&{label:`Read Rate`,value:`${Ks(o.readsPerMinuteCount*60*l)}/min`},Ds(o.readsPerMinuteBytes)&&{label:`Read Bandwidth`,value:`${Zr(o.readsPerMinuteBytes*60*l)}/min`},Ds(o.totalWriteCount)&&{label:`Total Writes`,value:`${Ks(o.totalWriteCount)} reads`},Ds(o.totalWritesBytes)&&{label:`Total Write Transfer`,value:`${Zr(o.totalWritesBytes)}`},Ds(o.writesPerMinuteCount)&&{label:`Write Rate`,value:`${Ks(o.writesPerMinuteCount*60)}/min`},Ds(o.writesPerMinuteBytes)&&{label:`Write Bandwidth`,value:`${Zr(o.writesPerMinuteBytes*60)}/min`},Ds(o.totalRealTimeMessageDeliveries)&&{label:`Total Real-Time Messages`,value:`${Ks(o.totalRealTimeMessageDeliveries*l)} messages`},Ds(o.totalRealTimeMessageDeliveryBytes)&&{label:`Total Real-Time Message Transfer`,value:`${Zr(o.totalRealTimeMessageDeliveryBytes*l)}`},Ds(o.realTimeMessageDeliveriesPerMinute)&&{label:`Real-Time Message Rate`,value:`${Ks(o.realTimeMessageDeliveriesPerMinute*60*l)}/min`},Ds(o.realTimeMessageDeliveryBytesPerMinute)&&{label:`Real-Time Message Bandwidth`,value:`${Zr(o.realTimeMessageDeliveryBytesPerMinute*60*l)}/min`},Ds(o.tlsHandshakes)&&{label:`TLS Handshakes`,value:`${Ks(o.tlsHandshakes*60*l)}`},Ds(o.applicationComputeHours)&&{label:`Application Compute Hours`,value:`${Ks(o.applicationComputeHours*l)}`},!!s&&Ds(s.storageGb)&&{label:`Storage`,value:`${Zr(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(Vr):[],[c,t,e,l]);if(!o)return``;if(!Ds(o.totalReadCount))return`This plan has no usage limits.`;let d=n?` Pricing subject to contracted rate.`:` Beta pricing subject to change.`,f=Ds(o.readsPerMinuteCount)?`${Ks(o.readsPerMinuteCount*l)} reads/min & `:``,m=Ds(o.writesPerMinuteCount)?` ${Ks(o.writesPerMinuteCount)} writes/min & `:` `,h=Ds(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,J.jsxs)(V,{className:`basis-full`,children:[(0,J.jsxs)(W,{onClick:a,children:[(0,J.jsx)(`em`,{className:`text-muted-foreground`,children:e?.id}),` Purchasing usage block for `,f,Ks(o.totalReadCount*l),` total reads `,h,`,`,(0,J.jsx)(`br`,{className:`hidden sm:block`}),m,` `,Ks(o.totalWriteCount),` total writes`,_,`.`,d,(0,J.jsx)(`br`,{className:`block sm:hidden`}),(0,J.jsxs)(R,{type:`button`,variant:`link`,className:`text-white`,children:[`Learn More `,r?(0,J.jsx)(ue,{}):(0,J.jsx)(at,{})]})]}),(0,J.jsx)(U,{children:(0,J.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,J.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,J.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,J.jsx)(`dt`,{className:`text-sm/6 font-medium text-gray-300`,children:e.label}),(0,J.jsx)(`dd`,{className:`mt-1 text-sm/6 sm:col-span-2 sm:mt-0`,children:e.value})]},e.label))]})}),(0,J.jsx)(H,{})]})}function Js({control:e,fieldArray:t,form:n,index:r,regionNameToLatencyToRegion:i,selectedPlan:a,isEnterprise:o}){let s=(0,Y.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,Y.useMemo)(()=>Object.keys(i[l]||{}).sort(Us).reverse(),[i,l]);(0,Y.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,Y.useCallback)(()=>{t?.remove(r),n.trigger()},[t,n,r]);return(0,J.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,J.jsx)(z,{control:e,name:`regionPlans.${r}.regionName`,render:({field:e})=>(0,J.jsxs)(V,{className:`flex-1`,children:[(0,J.jsxs)(W,{children:[`Region `,t.fields.length>1?r+1:``]}),(0,J.jsx)(U,{children:(0,J.jsxs)(ri,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,children:[(0,J.jsx)(Xr,{className:`w-full`,children:(0,J.jsx)(ti,{placeholder:`Choose Region`})}),(0,J.jsx)(Jr,{children:(0,J.jsx)(Qr,{children:s.map(e=>(0,J.jsx)(q,{value:e,children:e},e))})})]})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:e,name:`regionPlans.${r}.latencyDescription`,render:({field:e})=>(0,J.jsxs)(V,{className:`flex-1`,children:[(0,J.jsxs)(W,{children:[`Estimated `,c?`P95`:`P90`,` Latency, Distribution`]}),(0,J.jsx)(U,{children:(0,J.jsxs)(ri,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,disabled:!d?.length,children:[(0,J.jsx)(Xr,{className:`w-full`,children:(0,J.jsx)(ti,{placeholder:`Choose Latency Tier`})}),(0,J.jsx)(Jr,{children:(0,J.jsx)(Qr,{children:d.map(e=>(0,J.jsx)(q,{value:e,children:e},e))})})]})}),(0,J.jsx)(H,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,J.jsx)(`div`,{className:`flex-none mt-6`,children:(0,J.jsxs)(R,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:f,children:[(0,J.jsx)(hn,{}),` `,(0,J.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})}),(0,J.jsx)(qs,{selectedPlan:a,selectedRegion:i[l]?.[u],isEnterprise:o})]})}function Ys({form:e,regionLocations:t,regionNameToLatencyToRegion:n,selectedPlan:r,totalPrice:i,isEnterprise:a}){let o=e.watch(`regionPlans`),s=ut({control:e.control,name:`regionPlans`}),c=(0,Y.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,Y.useCallback)(()=>{c&&(s.append({regionName:c.region,latencyDescription:c.latencyDescription}),e.trigger())},[e,c,s]);return t?.length?(0,J.jsxs)(J.Fragment,{children:[s.fields.map((t,i)=>(0,J.jsx)(Js,{control:e.control,fieldArray:s,form:e,index:i,regionNameToLatencyToRegion:n,selectedPlan:r,isEnterprise:a},t.id)),c&&(0,J.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,J.jsxs)(R,{type:`button`,variant:`positiveOutline`,className:`rounded-full`,onClick:l,children:[(0,J.jsx)(Yt,{}),`Add Additional Region Usage`]})})]}):(0,J.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,J.jsx)(jr,{className:`mt-0 m-0`,title:`No Regions Available`,showReturnToHome:!1,error:{message:(0,J.jsxs)(J.Fragment,{children:[`The deployment type you selected currently has no available regions. Please try a different deployment type, try again later, or `,(0,J.jsx)(Lo,{}),`.`]})}})})}function Xs({control:e,fieldArray:t,form:n,index:r}){let i=(0,Y.useCallback)(()=>{t?.remove(r)},[t,r]);return(0,J.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,J.jsx)(z,{control:e,name:`instances.${r}.secure`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsxs)(W,{children:[`Instance `,t.fields.length>1?r+1:``]}),(0,J.jsx)(U,{children:(0,J.jsxs)(ri,{...e,onValueChange:t=>{e.onChange(t),n.trigger()},children:[(0,J.jsx)(Xr,{className:`w-full`,children:(0,J.jsx)(ti,{placeholder:`https://`})}),(0,J.jsx)(Jr,{children:(0,J.jsxs)(Qr,{children:[(0,J.jsx)(q,{value:`true`,children:`https://`}),(0,J.jsx)(q,{value:`false`,children:`http://`})]})})]})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:e,name:`instances.${r}.fqdn`,render:({field:e})=>(0,J.jsxs)(V,{className:`flex-3`,children:[(0,J.jsx)(W,{children:`Host Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{...e,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:e,name:`instances.${r}.port`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{children:`Operations API Port`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{...e,type:`number`,min:0,max:As,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,J.jsx)(H,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,J.jsx)(`div`,{className:`flex-none mt-6`,children:(0,J.jsxs)(R,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:i,children:[(0,J.jsx)(hn,{}),` `,(0,J.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})})]})}function Zs({form:e}){let t=ut({control:e.control,name:`instances`}),n=(0,Y.useCallback)(()=>{t.append({secure:`true`,fqdn:``,port:o})},[t]);return(0,J.jsxs)(J.Fragment,{children:[t.fields.map((n,r)=>(0,J.jsx)(Xs,{control:e.control,fieldArray:t,form:e,index:r},n.id)),(0,J.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,J.jsxs)(R,{type:`button`,variant:`positiveOutline`,className:`rounded-full`,onClick:n,children:[(0,J.jsx)(Yt,{}),`Add Instance`]})})]})}function Qs({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}=Xe(),g=(0,Y.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,Y.useMemo)(()=>Object.keys(n).sort(),[n]);(0,Y.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,J.jsx)(Q,{className:`mt-3 mb-12`,children:(0,J.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,J.jsx)(at,{})]})});return s===`version`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-3 gap-6 text-white md:grid-cols-6`,children:[(0,J.jsx)(Ls,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!0,form:r}),(0,J.jsx)(Vs,{className:`col-span-3`,form:r,harperVersions:i}),(0,J.jsx)(Bs,{className:`col-span-3 md:col-span-6`,form:r})]}),y]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-3 gap-6 text-white md:grid-cols-6`,children:[(0,J.jsx)(Ls,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!!t,form:r}),(0,J.jsx)(Vs,{className:`col-span-3`,disabled:!!t,form:r,harperVersions:i}),v?(0,J.jsx)(Is,{form:r,disabled:!!t}):(0,J.jsx)(Ns,{form:r,calculatedNames:e,disabled:!!t}),(0,J.jsx)(Fs,{form:r,availableDeploymentTypes:_}),(0,J.jsx)(Rs,{availablePerformanceDescriptions:g,form:r,selectedDeployment:u}),v?(0,J.jsx)(Zs,{form:r}):(0,J.jsx)(Ys,{form:r,regionLocations:c,regionNameToLatencyToRegion:l,selectedPlan:f,totalPrice:p,isEnterprise:a}),t&&(0,J.jsx)(Bs,{className:`col-span-3 md:col-span-6`,form:r})]}),y]})}function $s(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 ec(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 tc(e,t,n){if(t&&n){let r=e.getValues();if(!r.deploymentDescription||!r.performanceDescription||!r.regionPlans.length){let i=ec(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,J.jsx)(`span`,{className:`text-4xl`,children:new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).formatToParts(e||0).map((e,t)=>(0,J.jsx)(rc,{type:e.type,value:e.value},t))})}function rc({type:e,value:t}){switch(e){case`currency`:case`decimal`:case`fraction`:return(0,J.jsx)(`sup`,{className:`font-light text-xl`,children:t});default:return t}}function ic({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=He(),g=s?.type===as,_=kn(),{mutate:v,isPending:y}=es(),{mutate:b,isPending:x}=ns(),[S,ee]=(0,Y.useState)(p),te=(0,Y.useMemo)(()=>Zo(u?.sort(Go(`latencyDescription`))||[],`region`,`latencyDescription`),[u]),ne=(0,Y.useMemo)(()=>Zo(d?.sort(Go(`latencyDescription`))||[],`region`,`latencyDescription`),[d]),re=(0,Y.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=$s(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!`}):ss(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(Ms.superRefine(re)),defaultValues:n}),[ie,ae]=(0,Y.useState)(!0);(0,Y.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,Y.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||tc(w,l,ue)))},[w,l,ue,E]);let de=(0,Y.useMemo)(()=>{let e=os(cs(oe),js.maxLength);return{suggestedAbbreviatedName:e,fullHostName:`${T||e}.${s.subdomain||`your-org`}.harperfabric.com`}},[oe,T,s]),fe=(0,Y.useMemo)(()=>r?.[E]?.[se],[r,E,se]);(0,Y.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,Y.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,Y.useCallback)(({creating:e,deploymentDescription:t})=>N.message(e?`Creating Cluster`:`Updating Cluster`,{description:(0,J.jsx)(Qo,{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,Y.useCallback)(async({clusterId:e,sourceClusterId:t,creating:n,toastId:r,isSelfManaged:i})=>{if(t){let e=(await rs(c)).clusters?.find(e=>e.id===t);ao(e?.status)&&await Oo(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,Y.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,Y.useCallback)(()=>{if(a!==`version`&&pe>0){ee(!0);return}return ge()},[a,ge,pe]),ve=(0,Y.useCallback)(e=>{f(e?{clusterId:t,...w.getValues(),skipToBilling:!0}:null)},[t,w,f]),ye=(0,Y.useCallback)(()=>{ee(!1)},[]),be=!g&&`mr-37.5`;return(0,J.jsxs)(J.Fragment,{children:[!g&&a!==`version`&&(0,J.jsxs)(`div`,{className:`absolute top-3 right-4 md:right-12 text-right`,children:[(0,J.jsx)(`dt`,{className:`font-light`,children:`Total Price`}),(0,J.jsx)(`dd`,{className:`font-bold`,children:(0,J.jsx)(nc,{price:pe})})]}),(0,J.jsx)(B,{...w,children:S?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h1`,{className:C(`text-lg leading-none text-white font-semibold mb-4`,be),children:`Cluster Billing`}),(0,J.jsx)(`p`,{className:C(`text-muted-foreground text-sm mb-2`,be),children:`Please confirm the following billing details:`}),(0,J.jsx)(Os,{clusterId:t,isPending:y||x,onGoBackToDetails:ye,onSaveStateForBillingRedirect:ve,onSubmit:ge,organizationId:c,selectedPlan:fe})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h1`,{className:C(`text-lg leading-none text-white font-semibold mb-4`,be),children:`Cluster Configuration`}),(0,J.jsx)(`p`,{className:C(`text-muted-foreground text-sm mb-6`,be),children:`Configure your Harper cluster and define deployment plans.`}),(0,J.jsx)(`form`,{id:`cluster-upsert-form`,name:`cluster-upsert-form`,onSubmit:w.handleSubmit(_e),children:(0,J.jsx)(Qs,{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 ac(e){return e?.clusterName!==void 0}function oc(){let{organizationId:e,clusterId:t,mode:n}=j({strict:!1}),{create:r,update:i}=Di(e),{organization:a,cluster:o}=lt({strict:!1}),[s,c]=Po(Fo.SavedClusterState,null),{data:l}=L(Bo(e)),{data:u}=L(Wo({availableHosts:!0,organizationId:e})),{data:d}=L(Wo({organizationId:e})),{data:f}=L(Ho()),p=(0,Y.useMemo)(()=>{if(o){let e=o.instances?.map(e=>e.version).filter(Vr);if(f&&e){let t=e.sort(Sr).pop();return{...f,value:[!!t&&{name:`current`,version:t},...(f?.value||[]).filter(e=>t!==e.version&&(!t||Dr(t,e.version)))].filter(Vr)}}}return f},[f,o]),m=(0,Y.useMemo)(()=>{for(let e of a?.clusters??[])if(e.id!==o?.id&&l&&!oo(e.status)&&!ao(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,Y.useMemo)(()=>Zo(l?.sort(Go(`priceUsd`))||[],`deploymentDescription`,`performanceDescription`),[l]),g=(0,Y.useMemo)(()=>{if(!l||!p||!u||!d||t&&!o)return null;let e=o;if(s){if(ac(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=ec(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&&!ia.includes(e.status)).sort(Jo);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,J.jsx)(Ro,{children:(0,J.jsx)(Fr,{centered:!0,text:`Loading...`})}):(o?.id?!i:!r)?(0,J.jsx)(Ro,{children:(0,J.jsx)(jr,{title:`Not Allowed`,error:{message:(0,J.jsxs)(J.Fragment,{children:[`You do not have permission to `,o?.id?`update`:`create`,` clusters in this org.`]})}})}):l.length===0?(0,J.jsx)(Ro,{children:(0,J.jsx)(jr,{title:`Cluster ${t?`Modification`:`Creation`} Not Currently Allowed`,error:{message:(0,J.jsxs)(J.Fragment,{children:[`There are no available deployment types right now! Please try again later, or `,(0,J.jsx)(Lo,{}),`.`]})}})}):(0,J.jsx)(Ro,{className:`max-w-4xl mx-auto`,children:(0,J.jsx)(ic,{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:ac(s)&&s.skipToBilling===!0})})}var sc={FAILED:0,UPDATING:1,PROVISIONING:2,RUNNING:3,TERMINATED:4},cc=sc.RUNNING;function lc(e,t){return e.status===t.status?e.name.localeCompare(t.name):(e.status?sc[e.status]??cc:cc)-(t.status?sc[t.status]??cc:cc)}function uc(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 dc(){let{organizationId:e}=j({strict:!1}),{create:t}=Di(e),{data:n,isSuccess:r}=D(is(e)),[i]=Po(Fo.SavedClusterState,null),[a,o]=(0,Y.useState)(``),s=(0,Y.useCallback)(()=>o(``),[]),c=(0,Y.useCallback)(e=>{o(e.currentTarget.value?.toLowerCase()||``)},[]),l=(0,Y.useMemo)(()=>n?.clusters?.slice().filter(e=>!oo(e.status)).sort(lc)||[],[n?.clusters]),u=(0,Y.useMemo)(()=>l.filter(uc([`id`,`name`],a))||[],[a,l]);return n&&l.length===0&&t?(0,J.jsx)(oc,{}):i?(0,J.jsx)(Et,{to:`/${e}/new-cluster`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(no,{children:r?(0,J.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,J.jsx)(G,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:a,onChange:c}),t&&(0,J.jsx)(A,{to:`new-cluster`,children:(0,J.jsxs)(R,{variant:`positive`,accessKey:`n`,children:[(0,J.jsx)(Yt,{}),` `,(0,J.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,J.jsx)(`u`,{children:`N`}),`ew `,(0,J.jsx)(`span`,{className:`hidden md:inline-block`,children:`Cluster`})]})]})})]}):null}),(0,J.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12 mb-4`,children:[u.map(e=>(0,J.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,J.jsx)(Io,{cluster:e})},e.id)),!u.length&&(0,J.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,J.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,J.jsx)(R,{variant:`outline`,onClick:s,children:`Clear Filters`})]})]})})]})}function fc(){let e=URL.parse(location.href);return e?.hash?e.hash.startsWith(`#/`)?e.hash.slice(1):e.hash:`/`}function pc(){return`/#`+fc()}function mc(){let{organizationId:e}=j({strict:!1}),t=F(),n=new URLSearchParams(window.location.search).get(`setup_intent_client_secret`),{setup_intent_client_secret:r}=Me({strict:!1}),[i]=Po(Fo.SavedClusterState,null),a=n||r,o=on(),s=ds(e),c=(0,Y.useCallback)(()=>{let e=i?i.clusterId?`../../${i.clusterId}/edit`:`../../new-cluster`:`../`;window.history.replaceState(null,``,pc()),t({search:void 0,to:e})},[t,i]);return(0,Y.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,J.jsx)(Fr,{centered:!0})}function hc(){return(0,J.jsx)(bs,{children:(0,J.jsx)(mc,{})})}function gc({clusterId:e,instanceId:t,organizationId:n},r){return`/`+[n,e,t&&`instance`,t,r].filter(Vr).join(`/`)}var _c=`flex items-center p-2 rounded-lg group`,vc={className:`text-white hover:bg-gray-700`},yc={className:`text-black bg-white pointer-events-none cursor-default`};function bc(){let{organizationId:e}=j({strict:!1}),{update:t}=Ti(e);return t?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(no,{}),(0,J.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,J.jsxs)(`div`,{className:`md:grid gap-4 md:grid-cols-12 min-h-[calc(100vh-theme(spacing.36))] mb-12`,children:[(0,J.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,J.jsx)(xc,{}),(0,J.jsx)(Sc,{})]}),(0,J.jsx)(`section`,{className:`col-span-1 text-white md:col-span-8 lg:col-span-9`,children:(0,J.jsx)(Ye,{})})]})})]}):(0,J.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 xc(){let e=j({strict:!1});return(0,J.jsxs)(`div`,{className:`hidden md:block`,children:[(0,J.jsxs)(`span`,{className:_c,children:[(0,J.jsx)($n,{className:`inline-block`}),(0,J.jsx)(`h3`,{className:`ms-3 text-2xl font-extrabold dark:text-white`,children:`Billing`})]}),(0,J.jsxs)(`ul`,{className:`border-t border-gray-700 pt-4 mt-4 space-y-2`,children:[(0,J.jsx)(`li`,{children:(0,J.jsxs)(A,{to:gc(e,`billing`),className:_c,activeOptions:{exact:!0},inactiveProps:vc,activeProps:yc,children:[(0,J.jsx)(mn,{className:`inline-block`}),` `,(0,J.jsx)(`span`,{className:`ms-3`,children:`Payment Method`})]})}),(0,J.jsx)(`li`,{children:(0,J.jsxs)(A,{to:gc(e,`billing/invoices`),className:_c,inactiveProps:vc,activeProps:yc,children:[(0,J.jsx)(ur,{className:`inline-block`}),(0,J.jsx)(`span`,{className:`ms-3`,children:`Invoices & Payments`})]})})]})]})}function Sc(){let e=j({strict:!1});return(0,J.jsxs)(`ul`,{className:`flex space-x-4 md:hidden py-2`,children:[(0,J.jsx)(`li`,{children:(0,J.jsxs)(A,{to:gc(e,`billing`),className:_c,activeOptions:{exact:!0},inactiveProps:vc,activeProps:yc,children:[(0,J.jsx)(mn,{className:`inline-block`}),` `,(0,J.jsx)(`span`,{className:`ms-3`,children:`Payment Method`})]})}),(0,J.jsx)(`li`,{children:(0,J.jsxs)(A,{to:gc(e,`billing/invoices`),className:_c,inactiveProps:vc,activeProps:yc,children:[(0,J.jsx)(ur,{className:`inline-block`}),` `,(0,J.jsx)(`span`,{className:`ms-3`,children:`Invoices & Payments`})]})})]})}function Cc({className:e,containerClassName:t,...n}){return(0,J.jsx)(`div`,{"data-slot":`table-container`,className:g(`relative w-full overflow-x-auto`,t),children:(0,J.jsx)(`table`,{"data-slot":`table`,className:g(`w-full caption-bottom text-sm`,e),...n})})}function wc({className:e,...t}){return(0,J.jsx)(`thead`,{"data-slot":`table-header`,className:g(`[&_tr]:border-b`,e),...t})}function Tc({className:e,...t}){return(0,J.jsx)(`tbody`,{"data-slot":`table-body`,className:g(`[&_tr:last-child]:border-0`,e),...t})}function Ec({className:e,...t}){return(0,J.jsx)(`tr`,{"data-slot":`table-row`,className:g(`border-b border-grey-700 transition-colors`,e),...t})}function Dc({className:e,...t}){return(0,J.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 Oc({header:e,onColumnClick:t,...n}){let r=(0,Y.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:kt(e.column.columnDef.header,e.getContext()),s=(0,Y.useCallback)(()=>{e.column.resetSize()},[e]);return(0,J.jsx)(Dc,{...n,style:{width:`${e.getSize()}px`},className:i?`px-0`:`px-2`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[i?(0,J.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,J.jsx)(Te,{}):e.column.getIsSorted()===`desc`?(0,J.jsx)(ue,{}):(0,J.jsx)(xe,{className:`text-gray-600`})]}):o,a&&(0,J.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,J.jsx)(gt,{})})]})})}function kc({className:e,...t}){return(0,J.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 Ac({columns:e,data:t,isFetching:n,onRowClick:r,onColumnClick:i,sortingState:a,children:o}){let s=Ft({data:t,columns:e,getCoreRowModel:Je(),getSortedRowModel:Ge(),initialState:{sorting:a}});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-end space-x-2 pb-4`,children:[(0,J.jsx)(`div`,{className:`grow lg:hidden`}),o,(0,J.jsx)(`div`,{className:`grow hidden lg:visible`})]}),(0,J.jsxs)(Cc,{containerClassName:`rounded-md bg-black-dark`,children:[(0,J.jsx)(wc,{children:s.getHeaderGroups().map(e=>(0,J.jsx)(Ec,{className:`border-none`,children:e.headers.map(e=>(0,J.jsx)(Oc,{header:e,onColumnClick:i},e.id))},e.id))}),(0,J.jsx)(Tc,{className:`bg-black border border-grey-700`,children:s.getRowModel().rows?.length?s.getRowModel().rows.map(e=>(0,J.jsx)(Ec,{"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,J.jsx)(kc,{className:`py-2 px-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,style:{width:`${e.column.getSize()}px`},children:kt(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,J.jsx)(Ec,{children:(0,J.jsx)(kc,{colSpan:e.length,className:`h-24 text-center`,children:n?(0,J.jsx)(`div`,{children:(0,J.jsx)(Fr,{className:`p-12`})}):(0,J.jsx)(`span`,{children:`No results.`})})})})]})]})}function jc(e){switch(e){case`paid`:return`success`;case`void`:case`uncollectible`:return`destructive`;default:return`default`}}function Mc(e){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e)}var Nc=[{header:`Invoice Id`,accessorKey:`id`,enableSorting:!1},{header:`Status`,accessorKey:`status`,enableSorting:!1,cell:({cell:e})=>(0,J.jsx)(go,{variant:jc(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?ni(r,t):[t?ni(r,t):`-`,n?ni(i,n):`-`].join(` to `)}},{header:`Amount Due`,accessorKey:`amountDue`,enableSorting:!1,cell:({cell:e})=>Mc(e.getValue()?e.getValue()/100:0)},{header:`Amount Paid`,accessorKey:`amountPaid`,enableSorting:!1,cell:({cell:e})=>Mc(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} @ ${Mc(e.amount/100)}`);return n.join(`
|
|
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-BOQea7EA.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-CvqwRnws.js";import{$i as D,$n as ce,$r as le,Ai as ue,An as O,Ar as de,At as fe,Bi as pe,Bn as me,Br as he,Bt as ge,Ci as _e,Cn as ve,Cr as ye,Ct as be,Di as xe,Dn as Se,Dr as Ce,Dt as we,Ei as Te,En as Ee,Er as De,Et as Oe,Fi as ke,Fn as k,Fr as Ae,Ft as je,Gi as Me,Gn as Ne,Gr as Pe,Gt as Fe,Hi as A,Hn as Ie,Hr as Le,Ht as Re,Ii as ze,Ir as Be,It as Ve,Ji as He,Jn as Ue,Jr as We,Jt as Ge,Ki as j,Kn as Ke,Kr as qe,Kt as Je,Li as Ye,Ln as Xe,Lr as Ze,Lt as Qe,Mi as $e,Mr as et,Mt as tt,Ni as nt,Nr as rt,Nt as it,Oi as at,On as ot,Or as st,Ot as ct,Pi as lt,Pn as ut,Pr as dt,Pt as ft,Qi as M,Qn as N,Qr as pt,Ri as mt,Rn as ht,Rr as gt,Rt as _t,Si as vt,Sn as yt,Sr as bt,St as xt,Ti as St,Tn as Ct,Tr as wt,Tt,Ui as Et,Un as Dt,Ur as Ot,Ut as kt,Vi as P,Vn as At,Vr as jt,Vt as Mt,Wi as F,Wn as Nt,Wr as Pt,Wt as Ft,Xi as It,Xn as Lt,Xr as Rt,Yi as zt,Yn as Bt,Yr as Vt,Zi as I,Zn as Ht,Zr as Ut,_n as Wt,_r as Gt,ai as Kt,ar as qt,bn as Jt,br as Yt,bt as Xt,ci as Zt,cr as Qt,di as $t,dn as en,dr as tn,ea as L,ei as nn,er as rn,fi as an,fn as on,fr as sn,gn as cn,gr as ln,hi as un,hn as dn,hr as fn,ia as pn,ii as mn,ir as hn,ji as gn,jr as _n,jt as vn,ki as yn,kn as bn,kr as xn,kt as Sn,li as Cn,ln as wn,lr as Tn,mi as En,mn as Dn,mr as On,na as kn,ni as An,nr as jn,oi as Mn,or as Nn,pi as Pn,pn as Fn,pr as In,qi as Ln,qn as Rn,qr as zn,qt as Bn,ra as Vn,ri as Hn,rr as Un,si as Wn,sr as Gn,ta as Kn,ti as qn,ui as Jn,un as Yn,ur as Xn,vi as Zn,vn as Qn,vr as $n,wi as er,wn as tr,wr as nr,wt as rr,xi as ir,xn as ar,xr as or,xt as sr,yi as cr,yn as lr,yr as ur,yt as dr,zn as fr,zt as pr}from"./vendor-react-Vbe32VU9.js";import{a as mr,i as hr,n as gr,o as _r,r as vr,t as R}from"./button-BxVMmVxn.js";import{_ as yr,a as br,b as xr,c as Sr,d as Cr,f as wr,g as Tr,i as Er,l as Dr,m as Or,n as kr,o as Ar,p as jr,r as Mr,s as Nr,t as Pr,u as Fr,v as Ir,y as Lr}from"./getRegistrationInfo-LbRH9o_1.js";import{a as z,c as B,i as V,l as Rr,n as H,o as U,r as W,s as zr,t as G,u as Br}from"./input-Kn9SJu2o.js";import{a as Vr,i as Hr,n as Ur,r as K,t as Wr}from"./useInstanceClient-B-0rgxDK.js";import{i as Gr,r as Kr}from"./vendor-datadog-DVU9bdcc.js";import{t as qr}from"./label-DTuYaIbU.js";import"./vendor-stripe-RArI0wEC.js";import{c as Jr,d as Yr,f as Xr,i as Zr,l as Qr,m as $r,n as ei,p as ti,r as ni,s as ri,t as ii,u as q}from"./getStatus-D2vddYdp.js";import{t as ai}from"./vendor-markdown-C_pbQ5C-.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 J=Vn();function oi(){let{user:e,isLoading:t}=mr();return Or(e),(0,J.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,J.jsxs)(Tr,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,J.jsx)(Lr,{children:(0,J.jsx)(xr,{className:`text-2xl`,children:(0,J.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,J.jsx)(yr,{children:e&&!t?(0,J.jsx)(A,{to:`/`,children:(0,J.jsxs)(R,{children:[` `,(0,J.jsx)(yn,{}),` Return to Home`]})}):(0,J.jsx)(A,{to:`/sign-in`,children:(0,J.jsxs)(R,{children:[` `,(0,J.jsx)(yn,{}),` Go Sign In Page`]})})})]})})}function si(){return`ontouchstart`in window||navigator.maxTouchPoints>0}var Y=e(pn(),1),ci=!1,li=!1;function ui(){(0,Y.useEffect)(()=>{ci||(ci=!0,li&&(Kr.init({applicationId:`f590deee-4bac-49b4-a202-3b6963d9721d`,clientToken:`pub27aa29cea521492f4fef73032f86a023`,site:`datadoghq.com`,service:`studio`,env:void 0,version:`v5.0.7`,trackViewsManually:!0,trackUserInteractions:!0,sessionSampleRate:100,sessionReplaySampleRate:0,defaultPrivacyLevel:`mask`,plugins:[Lt()]}),Kr.onReady(()=>{Kr.startView({service:`studio`,version:`v5.0.7`,name:window.location.pathname||`initial`})})))},[])}function di(e){if(!li)return;Kr.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)?Kr.addAction(`return_login`):(Kr.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&&Kr.addAction(`login_time_gap`,{value:e})}localStorage.setItem(n,String(i)),Kr.addAction(`login_success`,{userId:e.id})}function fi(){return(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(Ye,{})})}var pi=pe()({component:fi});function mi(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,J.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 hi(){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`img`,{src:`/harper-studio_white.png`,alt:`Harper Studio`,className:`w-64 hidden md:inline-block`}),(0,J.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}function gi({className:e,...t}){return(0,J.jsx)(`div`,{className:g(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,J.jsx)(Ue,{"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 _i({className:e,children:t,viewport:n=!0,...r}){return(0,J.jsxs)(Rn,{"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,J.jsx)(gi,{})]})}function vi({className:e,...t}){return(0,J.jsx)(Nt,{"data-slot":`navigation-menu-item`,className:g(`relative`,e),...t})}function yi({className:e,...t}){return(0,J.jsx)(Ne,{"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 bi({className:e,...t}){return(0,J.jsx)(Ke,{"data-slot":`navigation-menu-list`,className:g(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}var xi=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 Si(){let e=`v5.0.7`;return(0,J.jsx)(`a`,{href:e?.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`,target:`_blank`,rel:`noopener noreferrer`,children:(0,J.jsxs)(`span`,{className:g(xi({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}async function Ci(e){await m.signOutFromPotentiallyAuthenticatedInstances(),await h({...e,entityId:d})}function wi(){let e=Ur();return I({mutationFn:()=>Ci({instanceClient:e}),onSuccess:Rr})}function Ti(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 Ei(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 Di(e,t){let{user:n}=vr(),{organizationId:r,clusterId:i}=j({strict:!1});return Oi(n,e??r,t??i)}function Oi(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 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)?.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 ji(e){let{clusterId:t,instanceId:n}=j({strict:!1}),{user:r}=hr(e??n??t),i=r?.role?.permission;return i?i.super_user===!0:!1}function Mi(e){let{clusterId:t,instanceId:n}=j({strict:!1}),{user:r}=hr(e??n??t),i=r?.role?.permission;return i?i.super_user===!0||i.structure_user===!0:!1}function Ni(e,t,n,r){let{clusterId:i,instanceId:a}=j({strict:!1}),{user:o}=hr(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 Pi={className:`text-white`};function Fi(){let{mutate:e}=wi(),t=F(),{user:n}=mr(),r=He(),{organizationId:i}=j({strict:!1}),{update:a}=Ti(i),{view:o}=Ei(i),s=a,c=(0,Y.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,Y.useMemo)(()=>[!1,!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,J.jsx)(er,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,J.jsx)(ir,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,J.jsx)(mi,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:c,icon:(0,J.jsx)(xn,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(Vr),[i,s,o,c]);return n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Bi,{menuItems:l}),(0,J.jsx)(Ri,{menuItems:l})]}):(0,J.jsx)(Li,{})}function Ii(e){return e.items!==void 0}function Li(){return(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`inline-block`,children:[(0,J.jsx)(A,{to:`/sign-in`,children:(0,J.jsx)(hi,{})}),(0,J.jsx)(Si,{})]}),(0,J.jsx)(_i,{children:(0,J.jsxs)(bi,{className:`text-grey-400`,children:[(0,J.jsx)(vi,{children:(0,J.jsx)(yi,{asChild:!0,children:(0,J.jsxs)(A,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,J.jsx)(er,{}),` `,(0,J.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,J.jsx)(vi,{children:(0,J.jsx)(yi,{asChild:!0,children:(0,J.jsxs)(A,{to:`/sign-in`,className:`flex-row items-center`,activeProps:Pi,children:[(0,J.jsx)(de,{}),` Sign In`]})})})]})})]})}function Ri({menuItems:e}){let{user:t}=mr();return Or(t),(0,J.jsx)(`div`,{className:`hidden md:block`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`inline-block`,children:[(0,J.jsx)(A,{to:`/`,children:(0,J.jsx)(hi,{})}),(0,J.jsx)(Si,{})]}),(0,J.jsx)(_i,{children:(0,J.jsx)(bi,{className:`text-grey-400`,children:e.map(e=>Ii(e)?!!e.items.length&&(0,J.jsx)(`div`,{className:`bg-black rounded-2xl flex`,children:e.items.map(e=>(0,J.jsx)(zi,{menuItem:e},e.text))},e.text):(0,J.jsx)(zi,{menuItem:e},e.text))})})]})})}function zi({menuItem:e}){return(0,J.jsx)(vi,{className:`text-gray-400 hover:text-white`,children:(0,J.jsx)(yi,{asChild:!0,children:(0,J.jsxs)(A,{to:e.to,onClick:e.onClick,className:`flex-row items-center`,target:e.target,activeProps:e.to?Pi:void 0,children:[e.icon,(0,J.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,J.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})})}function Bi({menuItems:e}){let{user:t}=mr();Or(t);let[n,r]=(0,Y.useState)(!1),i=(0,Y.useCallback)(()=>r(e=>!e),[]),a=(0,Y.useCallback)(()=>r(!1),[]);return(0,J.jsxs)(`div`,{className:`md:hidden`,id:`mobile-menu`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(A,{to:`/`,children:(0,J.jsx)(hi,{})}),(0,J.jsx)(Si,{}),(0,J.jsxs)(`button`,{type:`button`,className:`shadow-xs text-grey-400 hover:text-white hover:bg-black-dark`,onClick:i,children:[(0,J.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,J.jsx)(ce,{}):(0,J.jsx)(Ce,{})]})]}),(0,J.jsx)(`div`,{className:`${n?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-black-dark opacity-70`,onClick:a}),(0,J.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=>Ii(e)?!!e.items.length&&(0,J.jsx)(`div`,{className:`bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,J.jsx)(Vi,{menuItem:e,onClick:a},e.text))},e.text):(0,J.jsx)(Vi,{menuItem:e,onClick:a},e.text))})]})}function Vi({menuItem:e,onClick:t}){let n=(0,Y.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,J.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?Pi:void 0,children:[e.icon,(0,J.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function Hi(){return(0,J.jsxs)(J.Fragment,{children:[(0,J.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,J.jsx)(Fi,{})}),(0,J.jsxs)(`div`,{className:`pt-20 grid h-screen grid-cols-1 md:grid-cols-2`,children:[(0,J.jsx)(`section`,{className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,J.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,J.jsx)(`section`,{className:`flex items-center justify-center px-6 bg-linear-(--purple-gradient) dark:bg-linear-(--black-dark-gradient)`,children:(0,J.jsx)(Ye,{})})]})]})}var Ui;function Wi(){(0,Y.useEffect)(()=>{},[])}var Gi=[`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 Ki(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of Gi)if(t===e||t.endsWith(`.`+e))return null;return t}var qi=null;function Ji(){let e=F(),t=He(),n=kn(),{redirect:i}=Me({strict:!1});return(0,Y.useEffect)(()=>{qi||=(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=Or(a);di(a);let s=Ki(a.email);Ui?.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})}qi=null})()},[]),(0,J.jsxs)(`div`,{className:`text-white w-lg flex flex-col gap-4`,children:[(0,J.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,J.jsx)(`div`,{className:`underline flex gap-4`,children:(0,J.jsx)(A,{className:`text-sm opacity-50 hover:text-blue-300`,to:`/sign-in`,children:`Try signing in again`})})]})}function Yi({delayDuration:e=0,...t}){return(0,J.jsx)(At,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Xi({...e}){return(0,J.jsx)(Yi,{children:(0,J.jsx)(Ie,{"data-slot":`tooltip`,...e})})}function Zi({...e}){return(0,J.jsx)(Dt,{"data-slot":`tooltip-trigger`,...e})}function Qi({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,J.jsx)(me,{children:(0,J.jsxs)(fr,{"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,J.jsx)(ht,{className:g(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}var $i=new Map;function ea(e){if(!e)return``;if($i.has(e))return $i.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return $i.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return $i.set(e,``),``;let r=[];for(let e=0;e<n.length;e++){let t=n[e],i=e+1<n.length?n[e+1]:void 0;/^[A-Z]{2,}$/.test(t)&&i&&/[A-Z]*s$/.test(i)||/^[A-Z]$/.test(t)&&i!==void 0&&/^[A-Z]s$/.test(i)?(r.push(t+i),e++):r.push(t)}let i=r.map(ta).join(` `);return $i.set(e,i),i}function ta(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function na({restartRequired:e}){let t=nt(),{organization:n,instance:r,cluster:i}=lt({strict:!1});return(0,J.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,Y.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,J.jsxs)(A,{to:`/`,children:[(0,J.jsx)(Be,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,J.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=ea(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,J.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,J.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,J.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,J.jsxs)(Xi,{children:[(0,J.jsx)(Zi,{asChild:!0,children:(0,J.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,J.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,J.jsxs)(Qi,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,J.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var ra=[`RUNNING`],ia=[`TERMINATING`,`TERMINATED`,`REMOVED`];function aa(){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 oa({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 sa(){return I({mutationFn:oa})}function ca({cluster:e,instance:t,instanceParams:n}){let r=F(),i=He(),{redirect:a}=Me({strict:!1}),{mutate:o,isPending:s}=sa();return{isPending:s,submitForm:(0,Y.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])}}var la=oe({error:`Please enter a valid email address.`}).toLowerCase().trim(),ua=w().nonempty({error:`Please enter your password.`}),da=w().nonempty({error:`Please enter a username.`}),fa=T({username:da,password:ua}),pa=T({email:la,password:ua});function ma({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 ha=[`localhost`,`127.0.0.1`],ga=function(e){return e.MixedLoopback=`MixedLoopback`,e.InsecureCookieOutsideChromeAndFirefox=`InsecureCookieOutsideChromeAndFirefox`,e}({});function _a(e,t,n){if(!n||!t||!e)return null;let r=new URL(n).hostname,i=ha.includes(t),a=ha.includes(r);if(i&&a&&r!==t)return ga.MixedLoopback;if(!i&&a){let t=e.indexOf(`Chrome`)>=0,n=e.indexOf(`Firefox`)>=0;if(!t&&!n)return ga.InsecureCookieOutsideChromeAndFirefox}return null}function va(){let{clusterId:e,instanceId:t}=j({strict:!1}),{data:r}=L(wr(e,!0)),i=(0,Y.useMemo)(()=>t&&r&&r?.instances?.find(e=>e.id===t)||void 0,[r,t]),a=(0,Y.useMemo)(()=>r?.status&&ra.includes(r.status),[r?.status]),o=`instance`,s=(0,Y.useMemo)(()=>r?i?(m.flagForFabricConnect(i.id,!1),c(i)):(m.flagForFabricConnect(r.id,!1),n(r)):null,[r,i]),l=K({operationsUrl:s}),u=(0,Y.useMemo)(()=>s?.includes(`localhost`)||s?.includes(`127.0.0.1`),[s]),d=(0,Y.useMemo)(()=>_a(navigator.userAgent,location.hostname,s),[s]),{data:f}=L(ma(l)),p=k({resolver:O(fa),defaultValues:{username:``,password:``}}),{control:h,handleSubmit:g}=p,{submitForm:_,isPending:v}=ca({cluster:r,instance:i,instanceParams:l});return!t&&r&&!r?.fqdn?(0,J.jsx)(Et,{to:`../instances`,replace:!0}):a&&r?.resetPassword?(0,J.jsx)(Et,{to:`/${r.organizationId}/${r.id}/finish-setup`,replace:!0}):!a&&r?.resetPassword?(0,J.jsx)(Et,{to:`/${r.organizationId}/${r.id}/starting-up`,replace:!0}):(0,J.jsxs)(J.Fragment,{children:[!1,(0,J.jsx)(`div`,{className:`h-screen items-center justify-center flex`,children:(0,J.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,J.jsxs)(`h2`,{className:`text-2xl font-light`,children:[`Sign in to Harper `,`Local`]}),(0,J.jsx)(B,{...p,children:(0,J.jsxs)(`form`,{id:`auth-${o}-signin-form`,name:`auth-${o}-signin-form`,onSubmit:g(_),className:`my-4`,children:[(0,J.jsx)(z,{control:h,name:`username`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-4`,children:[(0,J.jsx)(W,{children:`Username`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{autoComplete:`username`,autoFocus:!0,type:`text`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:h,name:`password`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-4`,children:[(0,J.jsx)(W,{children:`Password`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`password`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(R,{disabled:v,type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,children:`Sign In`}),f===!1&&(0,J.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,J.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` This `,o,` is not responding to GET`,` `,(0,J.jsxs)(`a`,{href:`${s}health`,className:`underline`,target:`_blank`,children:[s,`health`]}),` `,`checks.`,(0,J.jsxs)(`ol`,{className:`list-decimal ml-8 mt-2`,children:[(0,J.jsx)(`li`,{children:`Is the server running?`}),(0,J.jsxs)(`li`,{children:[`Have you`,` `,(0,J.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,J.jsxs)(`li`,{children:[`Have you allowed`,` `,(0,J.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===ga.MixedLoopback&&(0,J.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,J.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===ga.InsecureCookieOutsideChromeAndFirefox&&(0,J.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,J.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,J.jsxs)(`div`,{className:`p-4 mt-4 text-sm rounded-lg bg-purple-950`,role:`alert`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`Did you know?`}),` `,`You can add this instance to your Harper account to manage it remotely.`,(0,J.jsx)(`div`,{className:`text-center pt-2`,children:(0,J.jsx)(A,{to:aa(),target:`_blank`,children:(0,J.jsx)(R,{type:`button`,variant:`positive`,children:`Connect to Harper Fabric`})})})]})]})})]})})]})}async function ya({email:e}){let{data:t}=await u.post(`/ForgotPassword/`,{email:e});if(t)return t;throw Error(`Something went wrong`)}function ba(){return I({mutationFn:e=>ya(e)})}var xa=T({email:la});function Sa(){let e=F(),{me:t}=Me({strict:!1}),n=k({resolver:O(xa),defaultValues:{email:t||``}}),r=n.watch(`email`),{setFocus:i,control:a,handleSubmit:o}=n;(0,Y.useEffect)(()=>{i(`email`)},[i]);let{mutate:s,isPending:c}=ba(),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,J.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,J.jsx)(`h2`,{className:`text-2xl font-light`,children:`Enter your account email`}),(0,J.jsx)(`p`,{className:`text-sm pt-1`,children:`If a matching account exists, we'll send you a password reset link.`}),(0,J.jsx)(B,{...n,children:(0,J.jsxs)(`form`,{id:`auth-forgot-password-form`,name:`auth-forgot-password-form`,onSubmit:o(l),className:`my-4`,children:[(0,J.jsx)(z,{control:a,name:`email`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-2`,children:[(0,J.jsx)(W,{children:`Email`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{disabled:c,type:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(R,{type:`submit`,variant:`submit`,disabled:c,className:`w-full my-2 rounded-full`,children:`Send Password Reset Email`})]})}),(0,J.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,J.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:r},children:`Sign in to your account`}),(0,J.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:r},children:`Sign up for free`})]})]})}var Ca=async({token:e,password:t})=>{let{data:n}=await u.put(`/ResetPassword/`,{token:e,newPassword:t});return n};function wa(){return I({mutationFn:e=>Ca(e)})}var Ta=T({password:ua.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 Ea(){let{token:e}=Me({strict:!1}),t=F();(0,Y.useEffect)(()=>{e||t({to:`/sign-in`})},[e,t]);let n=k({resolver:O(Ta),defaultValues:{password:``,confirmPassword:``}}),{setFocus:r,control:i,handleSubmit:a}=n;(0,Y.useEffect)(()=>{r(`password`)},[r]);let{mutate:o,isPending:s}=wa(),c=(0,Y.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,J.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,J.jsx)(`h2`,{className:`text-2xl font-light`,children:`Reset Password`}),(0,J.jsx)(B,{...n,children:(0,J.jsxs)(`form`,{id:`auth-reset-password-form`,name:`auth-reset-password-form`,className:`my-4`,onSubmit:a(c),children:[(0,J.jsx)(z,{control:i,name:`password`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-2`,children:[(0,J.jsx)(W,{children:`New Password`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{disabled:s,type:`password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:i,name:`confirmPassword`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-2`,children:[(0,J.jsx)(W,{children:`Confirm Password`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{disabled:s,type:`password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(R,{variant:`submit`,type:`submit`,disabled:s,className:`w-full my-2 rounded-full`,children:`Submit New Password`})]})})]})}function Da({text:e,disabled:t,onClick:n}){return(0,J.jsx)(`a`,{href:`/oauth/github/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,children:(0,J.jsxs)(`button`,{className:C(`github-signin-btn`,t&&`opacity-50`),type:`button`,children:[(0,J.jsx)(`img`,{src:`/github/GitHub_Invertocat_White.svg`,alt:`GitHub Logo`,className:`github-icon`}),e]})})}function Oa({text:e,disabled:t,onClick:n}){return(0,J.jsx)(`a`,{href:`/oauth/google/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,children:(0,J.jsxs)(`button`,{className:C(`gsi-material-button`,t&&`opacity-50`),type:`button`,children:[(0,J.jsx)(`div`,{className:`gsi-material-button-state`}),(0,J.jsxs)(`div`,{className:`gsi-material-button-content-wrapper`,children:[(0,J.jsx)(`div`,{className:`gsi-material-button-icon`,children:(0,J.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,J.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,J.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,J.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,J.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,J.jsx)(`path`,{fill:`none`,d:`M0 0h48v48H0z`})]})}),(0,J.jsx)(`span`,{className:`gsi-material-button-contents`,children:e}),(0,J.jsx)(`span`,{className:`hidden`,children:e})]})]})})}function ka(){let e=F(),t=kn(),n=He(),{redirect:i}=Me({strict:!1}),{mutate:a,isPending:o}=Aa();return{isPending:o,submitForm:(0,Y.useCallback)(o=>{a(o,{onSuccess:async a=>{m.setUserForEntity(d,a);let o=Or(a);di(a);let s=Ki(a.email);Ui?.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 Aa(){return I({mutationFn:e=>ja(e)})}async function ja({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 Ma(){let{me:e}=Me({strict:!1}),t=k({resolver:O(pa),defaultValues:{email:e||``,password:``}}),{handleSubmit:n,control:r}=t,i=t.watch(`email`),{submitForm:a,isPending:o}=ka();return(0,J.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,J.jsx)(`h2`,{className:`text-2xl font-light`,children:`Sign in to Harper Fabric`}),(0,J.jsx)(B,{...t,children:(0,J.jsxs)(`form`,{id:`auth-signin-form`,name:`auth-signin-form`,onSubmit:n(a),className:`my-4`,children:[(0,J.jsx)(z,{control:r,name:`email`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-4`,children:[(0,J.jsx)(W,{children:`Email`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`email`,autoFocus:!0,autoComplete:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:r,name:`password`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-4`,children:[(0,J.jsx)(W,{children:`Password`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`password`,autoComplete:`current-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(R,{type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,disabled:o,children:`Sign In`}),(0,J.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,J.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:i},children:`Sign up for free`}),(0,J.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/forgot-password`,search:{me:i},children:`Forgot password?`})]})]})}),(0,J.jsx)(`hr`,{className:`border-gray-600 my-6`}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(Oa,{text:`Sign in with Google`}),(0,J.jsx)(Da,{text:`Sign in with GitHub`})]})]})}var Na=/^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžæÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,'-]+$/u;async function Pa(e){let{data:t}=await u.post(`/User/`,e);if(t)return t;throw Error(`Something went wrong`)}function Fa(){return I({mutationFn:e=>Pa(e)})}var Ia=T({email:la.max(80,{error:`Email cannot be longer than 80 characters.`}),firstname:w().trim().min(2,{error:`Please enter your first name.`}).regex(Na,{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(Na,{error:`Last name can only contain letters, spaces, and hyphens.`}).max(80,{error:`Last name cannot be longer than 80 characters.`}),password:ua.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 La(){let e=F(),{email:t,me:n}=Me({strict:!1}),[r,i]=(0,Y.useState)(!1),a=k({resolver:O(Ia),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,Y.useEffect)(()=>{c(`firstname`)},[c]);let{mutate:d}=Fa(),f=(0,Y.useCallback)(async t=>{let{confirmPassword:n,acceptTerms:r,...i}=t;d(i,{onSuccess:()=>{let t=Ki(i.email);Ui?.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,Y.useCallback)(e=>{if(!s)return i(!0),setTimeout(()=>i(!1),1e3),e.preventDefault(),!1},[s]),m=(0,J.jsx)(z,{control:l,name:`acceptTerms`,render:({field:e})=>(0,J.jsxs)(V,{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,J.jsx)(U,{children:(0,J.jsx)(G,{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,J.jsxs)(`div`,{className:`space-y-1 leading-none`,children:[(0,J.jsxs)(W,{className:`text-xs font-normal`,children:[`I accept the`,` `,(0,J.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,J.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,J.jsx)(H,{})]})]})});return(0,J.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,J.jsx)(`h2`,{className:`text-2xl font-light`,children:`Sign up for Harper Fabric`}),(0,J.jsxs)(B,{...a,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 my-6`,children:[m,(0,J.jsx)(Oa,{text:`Sign up with Google`,disabled:!s,onClick:p}),(0,J.jsx)(Da,{text:`Sign up with GitHub`,disabled:!s,onClick:p})]}),(0,J.jsx)(`hr`,{className:`border-gray-600`}),(0,J.jsxs)(`form`,{id:`auth-signup-form`,name:`auth-signup-form`,onSubmit:u(f),className:`grid gap-4 my-4`,children:[(0,J.jsx)(z,{control:l,name:`firstname`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`First Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`text`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:l,name:`lastname`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Last Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`text`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:l,name:`email`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Email`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{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,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:l,name:`password`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Password`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`password`,autoComplete:`new-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:l,name:`confirmPassword`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Confirm Password`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`password`,autoComplete:`new-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),m,(0,J.jsx)(R,{type:`submit`,variant:`submit`,className:`w-full rounded-full my-4`,children:`Sign Up For Free`})]})]}),(0,J.jsx)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:(0,J.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 Ra=async({email:e})=>{let{data:t}=await u.post(`/ResendVerificationEmail/`,{email:e});return t};function za(){return I({mutationFn:e=>Ra(e)})}var Ba=async e=>{let{data:t}=await u.put(`/VerifyEmail/`,{token:e.toString()});return t};function Va(){return I({mutationFn:e=>Ba(e)})}var Ha=T({email:la});function Ua(){let e=F(),{mutate:t,isPending:n}=za(),r=k({resolver:O(Ha),defaultValues:{email:``}}),i=r.watch(`email`),{setFocus:a,control:o,handleSubmit:s}=r;(0,Y.useEffect)(()=>{a(`email`)},[a]);let c=(0,Y.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,J.jsxs)(B,{...r,children:[(0,J.jsx)(`p`,{className:`text-sm py-2`,children:`Please Enter an Email`}),(0,J.jsxs)(`form`,{id:`auth-verify-email-form`,name:`auth-verify-email-form`,onSubmit:s(c),className:`my-4`,children:[(0,J.jsx)(z,{control:o,name:`email`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-2`,children:[(0,J.jsx)(W,{children:`Email`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{disabled:n,type:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(R,{type:`submit`,variant:`submit`,disabled:n,className:`w-full my-2 rounded-full`,children:`Send Verification Email`})]})]})}function Wa(){let{token:e}=Me({strict:!1}),t=F(),{mutate:n,isPending:r}=Va(),i=(0,Y.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,Y.useEffect)(()=>{e&&i(e)},[i,e]),(0,J.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,J.jsx)(`h1`,{className:`text-3xl font-light`,children:`Verify Email`}),r?(0,J.jsx)(`p`,{className:`text-sm pt-1`,children:`Verifying email...`}):(0,J.jsx)(Ua,{})]})}function Ga(){let{email:e}=Me({strict:!1}),{mutate:t,isPending:n}=za(),r=(0,Y.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,J.jsxs)(`div`,{className:`text-white w-lg flex flex-col gap-4`,children:[(0,J.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Check your email!`]}),(0,J.jsxs)(`p`,{children:[`Your account has been created! You should receive an email with a link to `,(0,J.jsx)(`strong`,{children:`[Verify My Email]`}),`!`]}),(0,J.jsxs)(`p`,{children:[`From: `,(0,J.jsx)(`strong`,{children:`harper@notifications.harperfabric.com`})]}),(0,J.jsxs)(`p`,{children:[`To: `,(0,J.jsx)(`strong`,{children:e||`your email`})]}),(0,J.jsx)(`p`,{children:`Can you click it? Then we can carry on to more fun things!`}),(0,J.jsxs)(`div`,{className:`underline flex gap-4`,children:[(0,J.jsx)(A,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:e},children:`I did it, let me sign in!`}),(0,J.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 Ka=P({getParentRoute:()=>pi,id:`_authLayout`,component:Hi}),qa=P({getParentRoute:()=>Ka,path:`sign-in`,component:Ma,beforeLoad:({context:e,location:t})=>{let n=e.authentication[d]?.user;if(n){let e=t?.search,r=Or(n);throw zt({to:e?.redirect?.startsWith(`/`)?e.redirect:r})}}}),Ja=P({getParentRoute:()=>pi,path:`sign-in`,component:va,beforeLoad:({context:e,location:t})=>{if(e.authentication.OverallAppSignIn?.user){let e=t?.search;throw zt({to:e?.redirect?.startsWith(`/`)?e.redirect:`/`})}}}),Ya=P({getParentRoute:()=>Ka,path:`sign-up`,component:La}),Xa=P({getParentRoute:()=>Ka,path:`forgot-password`,component:Sa}),Za=P({getParentRoute:()=>Ka,path:`verify-email`,component:Wa}),Qa=P({getParentRoute:()=>Ka,path:`verifying`,component:Ga}),$a=P({getParentRoute:()=>Ka,path:`check-oauth`,component:Ji}),eo=P({getParentRoute:()=>Ka,path:`reset-password`,component:Ea});Ka.addChildren([qa,Ya,$a,Xa,Za,Qa,eo]);var to=[Ja];function no({children:e}){return(0,J.jsx)(`nav`,{className:`fixed top-20 w-full h-12 z-39 py-2 px-4 md:px-12 bg-grey-700`,children:(0,J.jsxs)(`div`,{className:`flex items-center h-full space-x-2`,children:[(0,J.jsx)(na,{}),e]})})}function ro(e){if(so(e)||co(e))return`warning`;if(io(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 io(e){switch(e){case`RUNNING`:case`UPDATED`:return!0;default:return!1}}function ao(e){switch(e){case`FAILED`:return!0;default:return!1}}function oo(e){switch(e){case`TERMINATED`:return!0;default:return!1}}function so(e){switch(e){case`CLONE_PENDING`:return!0;default:return!1}}function co(e){switch(e){case`PROVISIONING`:case`CLONING`:case`CLONE_READY`:case`UPDATING_HDB_NODES`:case`UPDATING`:return!0;default:return!1}}function X({...e}){return(0,J.jsx)(Se,{"data-slot":`dialog`,...e})}function lo({...e}){return(0,J.jsx)(bn,{"data-slot":`dialog-trigger`,...e})}function uo({...e}){return(0,J.jsx)(Ee,{"data-slot":`dialog-portal`,...e})}function fo({className:e,...t}){return(0,J.jsx)(Ct,{"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 Z({className:e,children:t,...n}){return(0,J.jsxs)(uo,{"data-slot":`dialog-portal`,children:[(0,J.jsx)(fo,{}),(0,J.jsxs)(ve,{"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,J.jsxs)(yt,{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,J.jsx)(ce,{className:`text-white`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function po({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`dialog-header`,className:g(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function Q({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`dialog-footer`,className:g(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function $({className:e,...t}){return(0,J.jsx)(ot,{"data-slot":`dialog-title`,className:g(`text-lg leading-none text-white font-semibold`,e),...t})}function mo({className:e,...t}){return(0,J.jsx)(tr,{"data-slot":`dialog-description`,className:g(`text-muted-foreground text-sm`,e),...t})}function ho({typeOfThingBeingDeleted:e,nameOfThingBeingDeleted:t,isModalOpen:n,hideDataLossWarning:r,setIsModalOpen:i,deletionConfirmed:a,deletionPending:o,trigger:s,presentParticiple:c=`Deleting`,transitiveVerb:l=`Delete`}){return(0,J.jsxs)(X,{open:n,onOpenChange:i,children:[s&&(0,J.jsx)(lo,{asChild:!0,children:s}),(0,J.jsxs)(Z,{className:`sm:max-w-[750px]`,children:[(0,J.jsxs)(po,{children:[(0,J.jsxs)($,{children:[`Are you sure you want to `,l.toLowerCase(),` this `,e,`?`]}),(0,J.jsx)(mo,{children:`This action cannot be undone.`})]}),!r&&(0,J.jsxs)(`div`,{className:`p-3 my-5 text-white rounded-md bg-amber-600`,children:[(0,J.jsxs)(`p`,{className:`flex space-x-1 font-semibold align-baseline`,children:[(0,J.jsx)(Un,{className:`inline-block size-5`}),` `,(0,J.jsx)(`span`,{children:`Warning`})]}),(0,J.jsxs)(`p`,{className:`pt-2 text-base`,children:[`By `,c.toLowerCase(),` `,e,` `,(0,J.jsx)(`span`,{className:`font-semibold`,children:t}),` `,`you will lose the data stored in it permanently.`]})]}),(0,J.jsx)(Q,{children:(0,J.jsxs)(`div`,{className:`flex justify-center space-x-5`,children:[(0,J.jsxs)(R,{className:`rounded-full`,onClick:()=>i(!1),children:[(0,J.jsx)(yn,{}),` Cancel`]}),(0,J.jsxs)(R,{variant:`destructive`,className:`rounded-full`,onClick:a,disabled:o,children:[(0,J.jsx)(hn,{}),` `,l]})]})})]})]})}function go({className:e,variant:t,asChild:n=!1,...r}){return(0,J.jsx)(n?$e:`span`,{"data-slot":`badge`,className:g(xi({variant:t}),e),...r})}function _o({...e}){return(0,J.jsx)(lr,{"data-slot":`dropdown-menu`,...e})}function vo({...e}){return(0,J.jsx)(ar,{"data-slot":`dropdown-menu-trigger`,...e})}function yo({className:e,sideOffset:t=4,...n}){return(0,J.jsx)(Qn,{children:(0,J.jsx)(Dn,{"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 bo({className:e,inset:t,variant:n=`default`,...r}){return(0,J.jsx)(dn,{"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 xo({className:e,children:t,checked:n,...r}){return(0,J.jsxs)(Fn,{"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,J.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,J.jsx)(cn,{children:(0,J.jsx)(Zn,{className:`size-4`})})}),t]})}function So({className:e,inset:t,...n}){return(0,J.jsx)(Wt,{"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 Co({className:e,...t}){return(0,J.jsx)(Jt,{"data-slot":`dropdown-menu-separator`,className:g(`bg-grey-700 -mx-1 my-1 h-px`,e),...t})}function wo(e){return!!e?.plans?.[0]?.planId?.startsWith(`self-hosted`)}function To({cluster:e}){let t=hr(e.id),{view:n,update:r}=Di(e.organizationId,e.id),i=!m.checkForFabricConnect(e.id)&&!!t.user;if(n){if(!e.fqdn)return(0,J.jsx)(A,{to:`/${e.organizationId}/${e.id}/instances`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,J.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Instances `,(0,J.jsx)(at,{className:`inline-block`})]})});if(e.resetPassword)return r?(0,J.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,J.jsxs)(R,{variant:`positive`,className:`py-2 hover:border-b-2 animate-glow-pulse`,children:[`Finish Setup `,(0,J.jsx)(at,{className:`inline-block`})]})}):(0,J.jsx)(`span`,{className:`py-2 text-nowrap`,children:`Pending Owner Setup`});if(!t.isLoading)return i?(0,J.jsx)(A,{to:`/${e.organizationId}/${e.id}/`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,J.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Direct Connect `,(0,J.jsx)(at,{className:`inline-block`})]})}):r&&!wo(e)?(0,J.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,J.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Fabric Connect `,(0,J.jsx)(at,{className:`inline-block`})]})}):(0,J.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,J.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Direct Sign In `,(0,J.jsx)(at,{className:`inline-block`})]})})}}function Eo(e,t){let n=[];if(e)for(let r of e)n.push(r[t]);return n}function Do({cluster:e,forceProgressBarVisible:t}){let[n,r]=(0,Y.useState)(t||!1),{data:i}=L(wr(n&&e.id,2e3));(0,Y.useEffect)(function(){(so(e.status)||co(e.status))&&r(!0)},[n,e.status,i?.instances]);let a=(0,Y.useMemo)(()=>{let e=Eo(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||oo(t)||(so(t)?(n+=1,r[t]=`${n} ${ea(t)}`):co(t)?(a+=1,o[t]=`${a} ${ea(t)}`):ao(t)?(l+=1,u[t]=`${l} ${ea(t)}`):!i.planId||!e.includes(i.planId)?(a+=1,o.DRAINING_TRAFFIC=`${a} ${ea(`Draining Traffic`)}`):io(t)&&(s+=1,c[t]=`${s} ${ea(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,J.jsxs)(`div`,{className:`w-full text-center`,children:[(0,J.jsxs)(`div`,{className:`w-full h-2.5 rounded-full overflow-clip flex shadow`,children:[(0,J.jsx)(`div`,{style:{width:a.runningWidth},className:`grow bg-green/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,J.jsx)(`div`,{style:{width:a.failedWidth},className:`grow bg-red/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,J.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,J.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,J.jsx)(`div`,{className:`text-xs text-muted-foreground font-light mt-2`,children:a.text})]}):null}async function Oo(e){let{data:t}=await u.delete(`/Cluster/${e}`,{timeout:0});return t}function ko(){return I({mutationFn:e=>Oo(e)})}function Ao(...e){return(0,Y.useMemo)(()=>e.map(e=>(()=>{navigator.clipboard.writeText(e),N.info(`Copied to clipboard!`,{icon:(0,J.jsx)(an,{}),duration:1e3})})),e)}function jo(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 Mo(e,t){return jo(localStorage.getItem(e))??t}function No(e,t){t==null?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}function Po(e,t){let n=(0,Y.useState)(Mo(e,t)),[r]=n;return(0,Y.useEffect)(()=>No(e,r),[e,r]),n}var Fo=function(e){return e.SavedClusterState=`SavedClusterState`,e}({});function Io({cluster:e}){let t=He(),r=kn(),i=(0,Y.useMemo)(()=>n(e),[e]),a=Ur({operationsUrl:i}),o=hr(e.id),[,s]=Po(Fo.SavedClusterState,null),{view:c,update:l,remove:u,create:d}=Di(e.organizationId,e.id),{mutate:f,isPending:p}=ko(),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(!1),b=(0,Y.useMemo)(()=>e.status&&ra.includes(e.status),[e.status]),x=wo(e),S=m.checkForFabricConnect(e.id),ee=!S&&!!o.user,te=(0,Y.useMemo)(()=>e.status&&ia.includes(e.status),[e.status]),C=(0,Y.useMemo)(()=>e.status&&ao(e.status),[e.status]),ne=(0,Y.useCallback)(async()=>{_(!0);let t=await Cr(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,Y.useCallback)(()=>{s(e),t.navigate({to:`/${e.organizationId}/new-cluster`})},[e,t,s]),w=(0,Y.useCallback)(()=>y(!0),[]),ie=(0,Y.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]=Ao(`${ae}`,`https://${ae}`),E=[b&&l&&!o.isLoading&&(!ee||S)&&(0,J.jsx)(A,{to:`${e.id}/sign-in`,disabled:g,children:(0,J.jsxs)(bo,{children:[(0,J.jsx)(Ae,{className:`text-green`}),` Direct Sign In`]})},`sign-in`),b&&l&&(0,J.jsx)(A,{to:`${e.id}/edit`,disabled:g,children:(0,J.jsxs)(bo,{children:[(0,J.jsx)(In,{className:`text-purple-600`}),` Edit Scaling`]})},`edit`),b&&l&&(0,J.jsx)(A,{to:`${e.id}/edit/version`,disabled:g,children:(0,J.jsxs)(bo,{children:[(0,J.jsx)(jt,{className:`text-fuchsia-300`}),` Edit Version`]})},`edit`),b&&l&&!1,b&&c&&(0,J.jsx)(A,{to:`${e.id}/instances`,disabled:g,children:(0,J.jsxs)(bo,{children:[(0,J.jsx)(sn,{className:`text-orange-300`}),` Instances`]})},`instances`),b&&c&&e.fqdn&&(0,J.jsx)(Co,{},`copy-separator`),b&&c&&e.fqdn&&(0,J.jsxs)(bo,{onClick:oe,disabled:g,children:[(0,J.jsx)($t,{}),` Copy Host Name`]},`copy-host-name`),b&&c&&e.fqdn&&(0,J.jsxs)(bo,{onClick:T,disabled:g,children:[(0,J.jsx)($t,{}),` Copy API URL`]},`copy-api-url`),b&&c&&!!i&&!o.isLoading&&ee&&(0,J.jsx)(bo,{onClick:ne,disabled:g,children:`Direct Sign Out`},`direct-sign-out`),C&&d&&(0,J.jsx)(bo,{className:`focus:bg-green/70 focus:text-white`,onClick:re,children:`Try Again`},`try-again`),!te&&u&&b&&(0,J.jsx)(Co,{},`remove-separator`),!te&&u&&(0,J.jsxs)(bo,{className:`focus:bg-red/70 focus:text-white`,onClick:w,children:[(0,J.jsx)(hn,{className:`text-red-300`}),` `,x?`Remove`:`Terminate`]},`remove`)].filter(Vr);return(0,J.jsxs)(Tr,{className:`relative h-full justify-between`,children:[(0,J.jsxs)(Lr,{children:[(0,J.jsxs)(Ir,{className:`flex items-center justify-between`,children:[ae?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`truncate max-w-48`,children:ae}),(0,J.jsx)(Kt,{onClick:oe,size:16,className:`cursor-pointer`}),(0,J.jsx)(`span`,{className:`grow`})]}):(0,J.jsx)(`span`,{children:`Self-Hosted`}),!te&&(0,J.jsxs)(_o,{children:[(0,J.jsx)(vo,{children:(0,J.jsx)(qn,{"aria-label":`Cluster options`})}),(0,J.jsx)(yo,{children:[...E]})]})]}),(0,J.jsx)(xr,{children:(0,J.jsx)(`h2`,{children:e.name})})]}),(0,J.jsxs)(yr,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsx)(Do,{cluster:e}),b&&c&&(0,J.jsx)(To,{cluster:e}),C&&e.status&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(go,{variant:ro(e.status),children:ea(e.status)}),(0,J.jsx)(`span`,{className:`text-xs`,children:`Click "..." to choose how to proceed.`})]})]}),(0,J.jsx)(ho,{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 Lo({overEmail:e}){return(0,J.jsx)(`a`,{href:e?`mailto:support@harperdb.io`:`https://discord.com/channels/1415002037439041710/1415002038286286994`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Contact us`})}function Ro({children:e,className:t}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(no,{}),(0,J.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] relative ${t??``}`,children:e})]})}async function zo(e){let{data:t}=await u.get(`/Plan/`,{params:{organizationId:e}});return t}function Bo(e){return M({queryKey:[e,`instancePlan`],queryFn:()=>zo(e),retry:!1})}async function Vo(){let{data:e}=await u.get(`/HarperVersions/`);return e}function Ho(){return M({queryKey:[`HarperVersions`],queryFn:Vo,staleTime:6e4,retry:!1})}async function Uo({organizationId:e,availableHosts:t}={}){let{data:n}=await u.get(`/Region/`,{params:{availableHosts:t,organizationId:e}});return n}function Wo({organizationId:e,availableHosts:t}={}){return M({queryKey:[e,`regionLocations`,t],queryFn:()=>Uo({organizationId:e,availableHosts:t}),retry:!1})}function Go(e){return(t,n)=>t[e]===n[e]?0:t[e]>n[e]?1:-1}function Ko(e){let t=e.split(`.`).map(Number);return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0}function qo(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 Jo(e,t){return e.instanceFqdn===t.instanceFqdn?e.operationsApiPort-t.operationsApiPort:qo(e.instanceFqdn)&&qo(t.instanceFqdn)?Ko(e.instanceFqdn)-Ko(t.instanceFqdn):e.instanceFqdn>t.instanceFqdn?1:-1}function Yo(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 Xo(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 Zo(e,t,n){let r=Yo(e,t),i={};for(let e in r)i[e]=Xo(r[e],n);return i}function Qo({duration:e,message:t,lateMessage:n}){let r=(0,Y.useRef)(0),i=(0,Y.useRef)(0),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(`5%`),l=(0,Y.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,Y.useEffect)(()=>(r.current=requestAnimationFrame(l),()=>cancelAnimationFrame(r.current)),[l]),(0,J.jsxs)(J.Fragment,{children:[a?n:t,(0,J.jsx)(Nr,{width:s,animated:!1})]})}async function $o(e){let{data:t}=await u.post(`/Cluster/`,e,{timeout:0});return t}function es(){return I({mutationFn:e=>$o(e)})}async function ts(e){let{id:t,...n}=e,{data:r}=await u.put(`/Cluster/${t}`,n,{timeout:0});return r}function ns(){return I({mutationFn:e=>ts(e)})}async function rs(e){let{data:t}=await u.get(`/Organization/${e}`);return t}function is(e){return M({queryKey:[e],queryFn:()=>rs(e),retry:!1,refetchInterval:1e4})}var as=`ENTERPRISE`;function os(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 ss(e,t,n=`-`){let r=t.split(n)[0];return e.findIndex(e=>e.startsWith(r))!==-1}function cs(e){return e.replace(/[^a-zA-Z0-9]/g,`-`).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase().replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}async function ls(e){await u.put(`/Payment/`,e)}function us(){return I({mutationFn:e=>ls(e)})}function ds(e){let{mutate:t}=us();return(0,Y.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 fs=(0,Y.createContext)(null);function ps(){return(0,Y.useContext)(fs)}function ms({hasExistingBilling:e,onPaymentAdded:t,onSaveStateForBillingRedirect:n}){let{organizationId:r}=j({strict:!1}),i=on(),a=ps(),o=en(),[s,c]=(0,Y.useState)(!1),l=ds(r),u=(0,Y.useCallback)(()=>{t(!1)},[t]);return(0,J.jsxs)(`form`,{id:`billing-add-payment-method-form`,name:`billing-add-payment-method-form`,onSubmit:(0,Y.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,J.jsx)(Yn,{}),(0,J.jsx)(wn,{options:{mode:`billing`}}),(0,J.jsxs)(`div`,{className:`mt-4 flex gap-8 items-center`,children:[(0,J.jsxs)(R,{disabled:!i||!o||s,variant:`submit`,className:`rounded-full`,children:[(0,J.jsx)(On,{}),` Add Payment Method`]}),e&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`text-xs text-gray-600`,children:`Your existing payment method will be overwritten.`}),(0,J.jsx)(R,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Cancel`})]})]})]})}async function hs(e){let{data:t}=await u.post(`/StripeAccount/`,e);return t}function gs(){return I({mutationFn:e=>hs(e)})}async function _s(e){let{data:t}=await u.post(`/Payment/`,{organizationId:e.organizationId});return t}function vs(){return I({mutationFn:e=>_s(e)})}function ys(e){let{enabled:t,existingStripeId:n,organizationId:r}=e,{mutate:i}=gs(),{mutate:a}=vs(),[o,s]=(0,Y.useState)(void 0);return(0,Y.useEffect)(()=>{},[i,t,n,a,(0,Y.useCallback)(e=>{s(e.clientSecret)},[]),r]),o}function bs({children:e}){let{organizationId:t}=j({strict:!1}),{data:n}=L(is(t)),r=ys({organizationId:t,enabled:!!n,existingStripeId:n?.stripeId});return(0,Y.useMemo)(()=>({clientSecret:r||``,appearance:{theme:`night`}}),[r]),console.error(`No VITE_PUBLIC_STRIPE_KEY is configured for this environment.`),(0,J.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 xs({onPaymentAdded:e,onSaveStateForBillingRedirect:t}){let{organizationId:n}=j({strict:!1}),{data:r}=L(is(n)),i=r?.billing,a=i?.paymentMethod;return(0,J.jsxs)(bs,{children:[(0,J.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,J.jsx)(ms,{hasExistingBilling:!!i,onSaveStateForBillingRedirect:t,onPaymentAdded:e})]})}var Ss=function(e){return e.PASS=`pass`,e.FAIL=`fail`,e.PENDING=`pending`,e.ERROR=`error`,e}({});function Cs(e){switch(e){case Ss.PASS:return`success`;case Ss.FAIL:case Ss.ERROR:return`destructive`;case Ss.PENDING:default:return`default`}}function ws(e){switch(e){case Ss.PASS:return`READY`;case Ss.FAIL:case Ss.ERROR:case Ss.PENDING:default:return e.toUpperCase()}}function Ts(e,t){return`${String(e).padStart(2,`0`)}/${String(t%100).padStart(2,`0`)}`}function Es(e){let{onSaveStateForBillingRedirect:t,onReplacingPaymentMethod:n}=e??{},{organizationId:r}=j({strict:!1}),{update:i}=Ti(r),{data:a,refetch:o}=L(is(r)),s=a?.billing?.paymentMethod,[c,l]=(0,Y.useState)(!1),u=(0,Y.useCallback)(()=>{l(!c),n?.(!c)},[n,c]),d=(0,Y.useCallback)(e=>{l(!1),n?.(!1),e&&o()},[n,o]);return a?.type===`ENTERPRISE`?(0,J.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,J.jsx)(Lo,{}),`, we would love to talk!`]}):s&&!c?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mt-2`,children:[s.brand?.toUpperCase()??`Card`,` ending in `,s.last4??`••••`,s.expMonth&&s.expYear?(0,J.jsxs)(J.Fragment,{children:[`(exp `,Ts(s.expMonth,s.expYear),`)`]}):null,s.status?(0,J.jsxs)(J.Fragment,{children:[`—`,` `,(0,J.jsx)(go,{variant:Cs(s.status),children:ws(s.status)})]}):null]}),i&&(0,J.jsx)(`div`,{className:`mt-2 mb-6`,children:(0,J.jsx)(R,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Replace Payment Method`})})]}):i?(0,J.jsx)(xs,{onSaveStateForBillingRedirect:t,onPaymentAdded:d}):(0,J.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 Ds(e){return e!==void 0&&e>0}function Os({clusterId:e,isPending:t,onGoBackToDetails:n,onSaveStateForBillingRedirect:r,onSubmit:i,organizationId:a,selectedPlan:o}){let{data:s}=L(is(a)),c=s?.billing,l=s?.type===as,u=l||c?.paymentMethod?.status===Ss.PASS,[d,f]=(0,Y.useState)(!1),m=Ds(o?.planLimits?.expirationMonths)&&o.planLimits.expirationMonths<1e3&&o.planLimits.expirationMonths,h=(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end mt-3 max-w-xl`,children:[(0,J.jsxs)(R,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,disabled:t,onClick:n,children:[(0,J.jsx)(yn,{}),` Back to Details`]}),(0,J.jsxs)(R,{disabled:t||!u||d,type:`submit`,variant:`submit`,className:`rounded-full`,onClick:i,children:[e?`Edit Cluster`:`Create New Cluster`,` `,(0,J.jsx)(at,{})]})]})});if(l)return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`ul`,{className:`list-disc ml-6 max-w-lg`,children:[(0,J.jsx)(`li`,{children:`Reminder: you will be billed at your contracted rate for any additional infrastructure.`}),(0,J.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,J.jsx)(Lo,{overEmail:!0}),`, we are here to help.`]})]}),h]});let g=m&&`, or ${p(m,`month`,`months`)} elapse`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`ul`,{className:`list-disc ml-6 mb-6`,children:[(0,J.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,J.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,J.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,J.jsxs)(`li`,{children:[`When that block is used up`,g,`, you will be automatically renewed.`]}),(0,J.jsx)(`li`,{children:`While refunds are not available, we’d be happy to assist you with troubleshooting.`}),(0,J.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,J.jsx)(Lo,{overEmail:!0}),`, we are here to help.`]})]}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-sm mb-6`,children:`Payment method:`}),(0,J.jsx)(Es,{onSaveStateForBillingRedirect:r,onReplacingPaymentMethod:f}),h]})}var ks=/(^$|^(?: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,As=65535,js=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.`),Ms=T({clusterName:w().nonempty(`Please enter a cluster name.`).max(255,`Cluster name cannot be longer than 255 characters long.`),abbreviatedName:se([S(``),y(),js]),fqdn:w().regex(ks,`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(ks,`Please enter a valid host name without the port or any path.`),port:ae().min(0,`Positive thinking only, please.`).max(As,`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 Ns({calculatedNames:e,disabled:t,form:n}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(z,{control:n.control,name:`abbreviatedName`,render:({field:n})=>(0,J.jsxs)(V,{className:`col-span-3`,children:[(0,J.jsx)(W,{className:`pb-1`,children:`Host Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{...n,type:`text`,maxLength:js.maxLength,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:e.suggestedAbbreviatedName,disabled:t})}),(0,J.jsx)(H,{})]})}),(0,J.jsxs)(V,{className:`col-span-3 `,children:[(0,J.jsx)(W,{className:`pb-1`,children:`Full Host Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(`span`,{children:e.fullHostName})}),(0,J.jsx)(H,{})]})]})}var Ps={Colocated:`Shared infrastructure for optimized value`,Dedicated:`Dedicated infrastructure for consistent performance`,"Self-Hosted":`Your own infrastructure`};function Fs({availableDeploymentTypes:e,disabled:t,form:n}){return(0,J.jsx)(z,{control:n.control,name:`deploymentDescription`,render:({field:r})=>(0,J.jsxs)(V,{className:`col-span-3`,children:[(0,J.jsx)(W,{className:`pb-1`,children:`Harper Deployment`}),(0,J.jsx)(Y.Suspense,{fallback:(0,J.jsx)($r,{}),children:(0,J.jsx)(U,{children:(0,J.jsxs)(ri,{...r,disabled:t,onValueChange:e=>{r.onChange(e),n.trigger()},children:[(0,J.jsx)(Xr,{className:`w-full h-auto`,children:(0,J.jsx)(ti,{placeholder:`Choose Tier`})}),(0,J.jsx)(Jr,{children:(0,J.jsx)(Qr,{children:e.map(e=>(0,J.jsxs)(q,{value:e,children:[(0,J.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e}),Ps[e]&&(0,J.jsx)(`dd`,{className:`font-light`,children:Ps[e]})]},e))})})]})})}),(0,J.jsx)(H,{})]})})}function Is({disabled:e,form:t}){return(0,J.jsx)(z,{control:t.control,name:`fqdn`,render:({field:t})=>(0,J.jsxs)(V,{className:`md:col-span-6 col-span-3`,children:[(0,J.jsx)(W,{className:`pb-1`,children:`Optional Cluster Load Balancer Host Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{...t,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:`example.your-company.com`,disabled:e})}),(0,J.jsx)(H,{})]})})}function Ls({className:e,disabled:t,form:n}){return(0,J.jsx)(z,{control:n.control,name:`clusterName`,render:({field:n})=>(0,J.jsxs)(V,{className:e,children:[(0,J.jsx)(W,{className:`pb-1`,children:`Cluster Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{autoFocus:!0,type:`text`,maxLength:Ms.shape.clusterName.maxLength,autoCapitalize:`words`,disabled:t,...n})}),(0,J.jsx)(H,{})]})})}function Rs({availablePerformanceDescriptions:e,form:t,selectedDeployment:n}){return(0,J.jsx)(z,{control:t.control,name:`performanceDescription`,render:({field:r})=>(0,J.jsxs)(V,{className:`col-span-3`,children:[(0,J.jsxs)(W,{className:`pb-1`,children:[n.startsWith(`Self`)?`Support`:`Performance`,` & Usage`]}),(0,J.jsx)(Y.Suspense,{fallback:(0,J.jsx)($r,{}),children:(0,J.jsx)(U,{children:(0,J.jsxs)(ri,{...r,onValueChange:e=>{r.onChange(e),t.trigger()},disabled:!e?.length,children:[(0,J.jsx)(Xr,{className:`w-full h-auto`,children:(0,J.jsx)(ti,{placeholder:`Choose Tier`})}),(0,J.jsx)(Jr,{children:(0,J.jsx)(Qr,{children:e.map(e=>(0,J.jsxs)(q,{value:e.performanceTier,children:[(0,J.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e.name}),e.description&&(0,J.jsx)(`dd`,{className:`font-light`,children:e.description})]},e.name))})})]})})}),(0,J.jsx)(H,{})]})})}function zs({className:e,...t}){let{formDescriptionId:n}=zr();return(0,J.jsx)(`p`,{"data-slot":`form-description`,id:n,className:g(`text-muted-foreground text-sm`,e),...t})}function Bs({className:e,form:t}){return(0,J.jsx)(z,{control:t.control,name:`skipGtmWait`,render:({field:t})=>(0,J.jsxs)(V,{className:e,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(U,{children:(0,J.jsx)(G,{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,J.jsx)(W,{className:`cursor-pointer`,children:`Immediate upgrade and restart`})]}),(0,J.jsx)(zs,{children:`Apply changes immediately without waiting for each instance to be taken out of the load balancer (faster, but potentially less safe).`})]})})}function Vs({className:e,disabled:t,form:n,harperVersions:r}){return r?.value?.length?(0,J.jsx)(z,{control:n.control,name:`version`,render:({field:i})=>(0,J.jsxs)(V,{className:e,children:[(0,J.jsx)(W,{className:`pb-1`,children:`Harper Version`}),(0,J.jsx)(Y.Suspense,{fallback:(0,J.jsx)($r,{}),children:(0,J.jsx)(U,{children:(0,J.jsxs)(ri,{...i,disabled:t,onValueChange:e=>{i.onChange(e),n.trigger()},children:[(0,J.jsx)(Xr,{className:`w-full h-auto`,children:(0,J.jsx)(ti,{placeholder:`Choose Version`})}),(0,J.jsx)(Jr,{children:(0,J.jsx)(Qr,{children:r?.value.map(e=>(0,J.jsxs)(q,{value:e.version,children:[e.version,` `,(0,J.jsx)(`span`,{className:`font-light opacity-50`,children:e.name})]},e.version))})})]})})}),(0,J.jsx)(H,{})]})}):null}var Hs=new RegExp(/^\d+/);function Us(e,t){let n=parseInt(e.match(Hs)?.[0]||`0`,10),r=parseInt(t.match(Hs)?.[0]||`0`,10);return n===r?0:n>r?1:-1}function Ws(e){return new Intl.NumberFormat().format(e)}var Gs=[`K`,`M`,`B`,`T`,`Qa`,`Qi`,`Sx`,`Sp`,`Oc`,`No`,`Dc`];function Ks(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<Gs.length-1);return`${Ws(Math.round(n))} ${Gs[r]}`}function qs({selectedPlan:e,selectedRegion:t,isEnterprise:n}){let[r,i]=(0,Y.useState)(!1),a=(0,Y.useCallback)(()=>{i(!r)},[r,i]),o=e?.planLimits,s=e?.resourcesPerInstance,c=Ds(o?.expirationMonths)&&o.expirationMonths<1e3&&o.expirationMonths,l=t?.purchasedBlockMultiplier??1,u=(0,Y.useMemo)(()=>o?[Ds(o.totalReadCount)&&{label:`Total Reads`,value:`${Ks(o.totalReadCount*l)} reads`},Ds(o.totalReadsBytes)&&{label:`Total Read Transfer`,value:`${Zr(o.totalReadsBytes*l)}`},Ds(o.readsPerMinuteCount)&&{label:`Read Rate`,value:`${Ks(o.readsPerMinuteCount*60*l)}/min`},Ds(o.readsPerMinuteBytes)&&{label:`Read Bandwidth`,value:`${Zr(o.readsPerMinuteBytes*60*l)}/min`},Ds(o.totalWriteCount)&&{label:`Total Writes`,value:`${Ks(o.totalWriteCount)} reads`},Ds(o.totalWritesBytes)&&{label:`Total Write Transfer`,value:`${Zr(o.totalWritesBytes)}`},Ds(o.writesPerMinuteCount)&&{label:`Write Rate`,value:`${Ks(o.writesPerMinuteCount*60)}/min`},Ds(o.writesPerMinuteBytes)&&{label:`Write Bandwidth`,value:`${Zr(o.writesPerMinuteBytes*60)}/min`},Ds(o.totalRealTimeMessageDeliveries)&&{label:`Total Real-Time Messages`,value:`${Ks(o.totalRealTimeMessageDeliveries*l)} messages`},Ds(o.totalRealTimeMessageDeliveryBytes)&&{label:`Total Real-Time Message Transfer`,value:`${Zr(o.totalRealTimeMessageDeliveryBytes*l)}`},Ds(o.realTimeMessageDeliveriesPerMinute)&&{label:`Real-Time Message Rate`,value:`${Ks(o.realTimeMessageDeliveriesPerMinute*60*l)}/min`},Ds(o.realTimeMessageDeliveryBytesPerMinute)&&{label:`Real-Time Message Bandwidth`,value:`${Zr(o.realTimeMessageDeliveryBytesPerMinute*60*l)}/min`},Ds(o.tlsHandshakes)&&{label:`TLS Handshakes`,value:`${Ks(o.tlsHandshakes*60*l)}`},Ds(o.applicationComputeHours)&&{label:`Application Compute Hours`,value:`${Ks(o.applicationComputeHours*l)}`},!!s&&Ds(s.storageGb)&&{label:`Storage`,value:`${Zr(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(Vr):[],[c,t,e,l]);if(!o)return``;if(!Ds(o.totalReadCount))return`This plan has no usage limits.`;let d=n?` Pricing subject to contracted rate.`:` Beta pricing subject to change.`,f=Ds(o.readsPerMinuteCount)?`${Ks(o.readsPerMinuteCount*l)} reads/min & `:``,m=Ds(o.writesPerMinuteCount)?` ${Ks(o.writesPerMinuteCount)} writes/min & `:` `,h=Ds(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,J.jsxs)(V,{className:`basis-full`,children:[(0,J.jsxs)(W,{onClick:a,children:[(0,J.jsx)(`em`,{className:`text-muted-foreground`,children:e?.id}),` Purchasing usage block for `,f,Ks(o.totalReadCount*l),` total reads `,h,`,`,(0,J.jsx)(`br`,{className:`hidden sm:block`}),m,` `,Ks(o.totalWriteCount),` total writes`,_,`.`,d,(0,J.jsx)(`br`,{className:`block sm:hidden`}),(0,J.jsxs)(R,{type:`button`,variant:`link`,className:`text-white`,children:[`Learn More `,r?(0,J.jsx)(ue,{}):(0,J.jsx)(at,{})]})]}),(0,J.jsx)(U,{children:(0,J.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,J.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,J.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,J.jsx)(`dt`,{className:`text-sm/6 font-medium text-gray-300`,children:e.label}),(0,J.jsx)(`dd`,{className:`mt-1 text-sm/6 sm:col-span-2 sm:mt-0`,children:e.value})]},e.label))]})}),(0,J.jsx)(H,{})]})}function Js({control:e,fieldArray:t,form:n,index:r,regionNameToLatencyToRegion:i,selectedPlan:a,isEnterprise:o}){let s=(0,Y.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,Y.useMemo)(()=>Object.keys(i[l]||{}).sort(Us).reverse(),[i,l]);(0,Y.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,Y.useCallback)(()=>{t?.remove(r),n.trigger()},[t,n,r]);return(0,J.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,J.jsx)(z,{control:e,name:`regionPlans.${r}.regionName`,render:({field:e})=>(0,J.jsxs)(V,{className:`flex-1`,children:[(0,J.jsxs)(W,{children:[`Region `,t.fields.length>1?r+1:``]}),(0,J.jsx)(U,{children:(0,J.jsxs)(ri,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,children:[(0,J.jsx)(Xr,{className:`w-full`,children:(0,J.jsx)(ti,{placeholder:`Choose Region`})}),(0,J.jsx)(Jr,{children:(0,J.jsx)(Qr,{children:s.map(e=>(0,J.jsx)(q,{value:e,children:e},e))})})]})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:e,name:`regionPlans.${r}.latencyDescription`,render:({field:e})=>(0,J.jsxs)(V,{className:`flex-1`,children:[(0,J.jsxs)(W,{children:[`Estimated `,c?`P95`:`P90`,` Latency, Distribution`]}),(0,J.jsx)(U,{children:(0,J.jsxs)(ri,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,disabled:!d?.length,children:[(0,J.jsx)(Xr,{className:`w-full`,children:(0,J.jsx)(ti,{placeholder:`Choose Latency Tier`})}),(0,J.jsx)(Jr,{children:(0,J.jsx)(Qr,{children:d.map(e=>(0,J.jsx)(q,{value:e,children:e},e))})})]})}),(0,J.jsx)(H,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,J.jsx)(`div`,{className:`flex-none mt-6`,children:(0,J.jsxs)(R,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:f,children:[(0,J.jsx)(hn,{}),` `,(0,J.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})}),(0,J.jsx)(qs,{selectedPlan:a,selectedRegion:i[l]?.[u],isEnterprise:o})]})}function Ys({form:e,regionLocations:t,regionNameToLatencyToRegion:n,selectedPlan:r,totalPrice:i,isEnterprise:a}){let o=e.watch(`regionPlans`),s=ut({control:e.control,name:`regionPlans`}),c=(0,Y.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,Y.useCallback)(()=>{c&&(s.append({regionName:c.region,latencyDescription:c.latencyDescription}),e.trigger())},[e,c,s]);return t?.length?(0,J.jsxs)(J.Fragment,{children:[s.fields.map((t,i)=>(0,J.jsx)(Js,{control:e.control,fieldArray:s,form:e,index:i,regionNameToLatencyToRegion:n,selectedPlan:r,isEnterprise:a},t.id)),c&&(0,J.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,J.jsxs)(R,{type:`button`,variant:`positiveOutline`,className:`rounded-full`,onClick:l,children:[(0,J.jsx)(Yt,{}),`Add Additional Region Usage`]})})]}):(0,J.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,J.jsx)(jr,{className:`mt-0 m-0`,title:`No Regions Available`,showReturnToHome:!1,error:{message:(0,J.jsxs)(J.Fragment,{children:[`The deployment type you selected currently has no available regions. Please try a different deployment type, try again later, or `,(0,J.jsx)(Lo,{}),`.`]})}})})}function Xs({control:e,fieldArray:t,form:n,index:r}){let i=(0,Y.useCallback)(()=>{t?.remove(r)},[t,r]);return(0,J.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,J.jsx)(z,{control:e,name:`instances.${r}.secure`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsxs)(W,{children:[`Instance `,t.fields.length>1?r+1:``]}),(0,J.jsx)(U,{children:(0,J.jsxs)(ri,{...e,onValueChange:t=>{e.onChange(t),n.trigger()},children:[(0,J.jsx)(Xr,{className:`w-full`,children:(0,J.jsx)(ti,{placeholder:`https://`})}),(0,J.jsx)(Jr,{children:(0,J.jsxs)(Qr,{children:[(0,J.jsx)(q,{value:`true`,children:`https://`}),(0,J.jsx)(q,{value:`false`,children:`http://`})]})})]})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:e,name:`instances.${r}.fqdn`,render:({field:e})=>(0,J.jsxs)(V,{className:`flex-3`,children:[(0,J.jsx)(W,{children:`Host Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{...e,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:e,name:`instances.${r}.port`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{children:`Operations API Port`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{...e,type:`number`,min:0,max:As,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,J.jsx)(H,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,J.jsx)(`div`,{className:`flex-none mt-6`,children:(0,J.jsxs)(R,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:i,children:[(0,J.jsx)(hn,{}),` `,(0,J.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})})]})}function Zs({form:e}){let t=ut({control:e.control,name:`instances`}),n=(0,Y.useCallback)(()=>{t.append({secure:`true`,fqdn:``,port:o})},[t]);return(0,J.jsxs)(J.Fragment,{children:[t.fields.map((n,r)=>(0,J.jsx)(Xs,{control:e.control,fieldArray:t,form:e,index:r},n.id)),(0,J.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,J.jsxs)(R,{type:`button`,variant:`positiveOutline`,className:`rounded-full`,onClick:n,children:[(0,J.jsx)(Yt,{}),`Add Instance`]})})]})}function Qs({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}=Xe(),g=(0,Y.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,Y.useMemo)(()=>Object.keys(n).sort(),[n]);(0,Y.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,J.jsx)(Q,{className:`mt-3 mb-12`,children:(0,J.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,J.jsx)(at,{})]})});return s===`version`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-3 gap-6 text-white md:grid-cols-6`,children:[(0,J.jsx)(Ls,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!0,form:r}),(0,J.jsx)(Vs,{className:`col-span-3`,form:r,harperVersions:i}),(0,J.jsx)(Bs,{className:`col-span-3 md:col-span-6`,form:r})]}),y]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-3 gap-6 text-white md:grid-cols-6`,children:[(0,J.jsx)(Ls,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!!t,form:r}),(0,J.jsx)(Vs,{className:`col-span-3`,disabled:!!t,form:r,harperVersions:i}),v?(0,J.jsx)(Is,{form:r,disabled:!!t}):(0,J.jsx)(Ns,{form:r,calculatedNames:e,disabled:!!t}),(0,J.jsx)(Fs,{form:r,availableDeploymentTypes:_}),(0,J.jsx)(Rs,{availablePerformanceDescriptions:g,form:r,selectedDeployment:u}),v?(0,J.jsx)(Zs,{form:r}):(0,J.jsx)(Ys,{form:r,regionLocations:c,regionNameToLatencyToRegion:l,selectedPlan:f,totalPrice:p,isEnterprise:a}),t&&(0,J.jsx)(Bs,{className:`col-span-3 md:col-span-6`,form:r})]}),y]})}function $s(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 ec(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 tc(e,t,n){if(t&&n){let r=e.getValues();if(!r.deploymentDescription||!r.performanceDescription||!r.regionPlans.length){let i=ec(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,J.jsx)(`span`,{className:`text-4xl`,children:new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).formatToParts(e||0).map((e,t)=>(0,J.jsx)(rc,{type:e.type,value:e.value},t))})}function rc({type:e,value:t}){switch(e){case`currency`:case`decimal`:case`fraction`:return(0,J.jsx)(`sup`,{className:`font-light text-xl`,children:t});default:return t}}function ic({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=He(),g=s?.type===as,_=kn(),{mutate:v,isPending:y}=es(),{mutate:b,isPending:x}=ns(),[S,ee]=(0,Y.useState)(p),te=(0,Y.useMemo)(()=>Zo(u?.sort(Go(`latencyDescription`))||[],`region`,`latencyDescription`),[u]),ne=(0,Y.useMemo)(()=>Zo(d?.sort(Go(`latencyDescription`))||[],`region`,`latencyDescription`),[d]),re=(0,Y.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=$s(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!`}):ss(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(Ms.superRefine(re)),defaultValues:n}),[ie,ae]=(0,Y.useState)(!0);(0,Y.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,Y.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||tc(w,l,ue)))},[w,l,ue,E]);let de=(0,Y.useMemo)(()=>{let e=os(cs(oe),js.maxLength);return{suggestedAbbreviatedName:e,fullHostName:`${T||e}.${s.subdomain||`your-org`}.harperfabric.com`}},[oe,T,s]),fe=(0,Y.useMemo)(()=>r?.[E]?.[se],[r,E,se]);(0,Y.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,Y.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,Y.useCallback)(({creating:e,deploymentDescription:t})=>N.message(e?`Creating Cluster`:`Updating Cluster`,{description:(0,J.jsx)(Qo,{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,Y.useCallback)(async({clusterId:e,sourceClusterId:t,creating:n,toastId:r,isSelfManaged:i})=>{if(t){let e=(await rs(c)).clusters?.find(e=>e.id===t);ao(e?.status)&&await Oo(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,Y.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,Y.useCallback)(()=>{if(a!==`version`&&pe>0){ee(!0);return}return ge()},[a,ge,pe]),ve=(0,Y.useCallback)(e=>{f(e?{clusterId:t,...w.getValues(),skipToBilling:!0}:null)},[t,w,f]),ye=(0,Y.useCallback)(()=>{ee(!1)},[]),be=!g&&`mr-37.5`;return(0,J.jsxs)(J.Fragment,{children:[!g&&a!==`version`&&(0,J.jsxs)(`div`,{className:`absolute top-3 right-4 md:right-12 text-right`,children:[(0,J.jsx)(`dt`,{className:`font-light`,children:`Total Price`}),(0,J.jsx)(`dd`,{className:`font-bold`,children:(0,J.jsx)(nc,{price:pe})})]}),(0,J.jsx)(B,{...w,children:S?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h1`,{className:C(`text-lg leading-none text-white font-semibold mb-4`,be),children:`Cluster Billing`}),(0,J.jsx)(`p`,{className:C(`text-muted-foreground text-sm mb-2`,be),children:`Please confirm the following billing details:`}),(0,J.jsx)(Os,{clusterId:t,isPending:y||x,onGoBackToDetails:ye,onSaveStateForBillingRedirect:ve,onSubmit:ge,organizationId:c,selectedPlan:fe})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h1`,{className:C(`text-lg leading-none text-white font-semibold mb-4`,be),children:`Cluster Configuration`}),(0,J.jsx)(`p`,{className:C(`text-muted-foreground text-sm mb-6`,be),children:`Configure your Harper cluster and define deployment plans.`}),(0,J.jsx)(`form`,{id:`cluster-upsert-form`,name:`cluster-upsert-form`,onSubmit:w.handleSubmit(_e),children:(0,J.jsx)(Qs,{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 ac(e){return e?.clusterName!==void 0}function oc(){let{organizationId:e,clusterId:t,mode:n}=j({strict:!1}),{create:r,update:i}=Di(e),{organization:a,cluster:o}=lt({strict:!1}),[s,c]=Po(Fo.SavedClusterState,null),{data:l}=L(Bo(e)),{data:u}=L(Wo({availableHosts:!0,organizationId:e})),{data:d}=L(Wo({organizationId:e})),{data:f}=L(Ho()),p=(0,Y.useMemo)(()=>{if(o){let e=o.instances?.map(e=>e.version).filter(Vr);if(f&&e){let t=e.sort(Sr).pop();return{...f,value:[!!t&&{name:`current`,version:t},...(f?.value||[]).filter(e=>t!==e.version&&(!t||Dr(t,e.version)))].filter(Vr)}}}return f},[f,o]),m=(0,Y.useMemo)(()=>{for(let e of a?.clusters??[])if(e.id!==o?.id&&l&&!oo(e.status)&&!ao(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,Y.useMemo)(()=>Zo(l?.sort(Go(`priceUsd`))||[],`deploymentDescription`,`performanceDescription`),[l]),g=(0,Y.useMemo)(()=>{if(!l||!p||!u||!d||t&&!o)return null;let e=o;if(s){if(ac(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=ec(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&&!ia.includes(e.status)).sort(Jo);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,J.jsx)(Ro,{children:(0,J.jsx)(Fr,{centered:!0,text:`Loading...`})}):(o?.id?!i:!r)?(0,J.jsx)(Ro,{children:(0,J.jsx)(jr,{title:`Not Allowed`,error:{message:(0,J.jsxs)(J.Fragment,{children:[`You do not have permission to `,o?.id?`update`:`create`,` clusters in this org.`]})}})}):l.length===0?(0,J.jsx)(Ro,{children:(0,J.jsx)(jr,{title:`Cluster ${t?`Modification`:`Creation`} Not Currently Allowed`,error:{message:(0,J.jsxs)(J.Fragment,{children:[`There are no available deployment types right now! Please try again later, or `,(0,J.jsx)(Lo,{}),`.`]})}})}):(0,J.jsx)(Ro,{className:`max-w-4xl mx-auto`,children:(0,J.jsx)(ic,{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:ac(s)&&s.skipToBilling===!0})})}var sc={FAILED:0,UPDATING:1,PROVISIONING:2,RUNNING:3,TERMINATED:4},cc=sc.RUNNING;function lc(e,t){return e.status===t.status?e.name.localeCompare(t.name):(e.status?sc[e.status]??cc:cc)-(t.status?sc[t.status]??cc:cc)}function uc(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 dc(){let{organizationId:e}=j({strict:!1}),{create:t}=Di(e),{data:n,isSuccess:r}=D(is(e)),[i]=Po(Fo.SavedClusterState,null),[a,o]=(0,Y.useState)(``),s=(0,Y.useCallback)(()=>o(``),[]),c=(0,Y.useCallback)(e=>{o(e.currentTarget.value?.toLowerCase()||``)},[]),l=(0,Y.useMemo)(()=>n?.clusters?.slice().filter(e=>!oo(e.status)).sort(lc)||[],[n?.clusters]),u=(0,Y.useMemo)(()=>l.filter(uc([`id`,`name`],a))||[],[a,l]);return n&&l.length===0&&t?(0,J.jsx)(oc,{}):i?(0,J.jsx)(Et,{to:`/${e}/new-cluster`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(no,{children:r?(0,J.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,J.jsx)(G,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:a,onChange:c}),t&&(0,J.jsx)(A,{to:`new-cluster`,children:(0,J.jsxs)(R,{variant:`positive`,accessKey:`n`,children:[(0,J.jsx)(Yt,{}),` `,(0,J.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,J.jsx)(`u`,{children:`N`}),`ew `,(0,J.jsx)(`span`,{className:`hidden md:inline-block`,children:`Cluster`})]})]})})]}):null}),(0,J.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12 mb-4`,children:[u.map(e=>(0,J.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,J.jsx)(Io,{cluster:e})},e.id)),!u.length&&(0,J.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,J.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,J.jsx)(R,{variant:`outline`,onClick:s,children:`Clear Filters`})]})]})})]})}function fc(){let e=URL.parse(location.href);return e?.hash?e.hash.startsWith(`#/`)?e.hash.slice(1):e.hash:`/`}function pc(){return`/#`+fc()}function mc(){let{organizationId:e}=j({strict:!1}),t=F(),n=new URLSearchParams(window.location.search).get(`setup_intent_client_secret`),{setup_intent_client_secret:r}=Me({strict:!1}),[i]=Po(Fo.SavedClusterState,null),a=n||r,o=on(),s=ds(e),c=(0,Y.useCallback)(()=>{let e=i?i.clusterId?`../../${i.clusterId}/edit`:`../../new-cluster`:`../`;window.history.replaceState(null,``,pc()),t({search:void 0,to:e})},[t,i]);return(0,Y.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,J.jsx)(Fr,{centered:!0})}function hc(){return(0,J.jsx)(bs,{children:(0,J.jsx)(mc,{})})}function gc({clusterId:e,instanceId:t,organizationId:n},r){return`/`+[n,e,t&&`instance`,t,r].filter(Vr).join(`/`)}var _c=`flex items-center p-2 rounded-lg group`,vc={className:`text-white hover:bg-gray-700`},yc={className:`text-black bg-white pointer-events-none cursor-default`};function bc(){let{organizationId:e}=j({strict:!1}),{update:t}=Ti(e);return t?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(no,{}),(0,J.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,J.jsxs)(`div`,{className:`md:grid gap-4 md:grid-cols-12 min-h-[calc(100vh-theme(spacing.36))] mb-12`,children:[(0,J.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,J.jsx)(xc,{}),(0,J.jsx)(Sc,{})]}),(0,J.jsx)(`section`,{className:`col-span-1 text-white md:col-span-8 lg:col-span-9`,children:(0,J.jsx)(Ye,{})})]})})]}):(0,J.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 xc(){let e=j({strict:!1});return(0,J.jsxs)(`div`,{className:`hidden md:block`,children:[(0,J.jsxs)(`span`,{className:_c,children:[(0,J.jsx)($n,{className:`inline-block`}),(0,J.jsx)(`h3`,{className:`ms-3 text-2xl font-extrabold dark:text-white`,children:`Billing`})]}),(0,J.jsxs)(`ul`,{className:`border-t border-gray-700 pt-4 mt-4 space-y-2`,children:[(0,J.jsx)(`li`,{children:(0,J.jsxs)(A,{to:gc(e,`billing`),className:_c,activeOptions:{exact:!0},inactiveProps:vc,activeProps:yc,children:[(0,J.jsx)(mn,{className:`inline-block`}),` `,(0,J.jsx)(`span`,{className:`ms-3`,children:`Payment Method`})]})}),(0,J.jsx)(`li`,{children:(0,J.jsxs)(A,{to:gc(e,`billing/invoices`),className:_c,inactiveProps:vc,activeProps:yc,children:[(0,J.jsx)(ur,{className:`inline-block`}),(0,J.jsx)(`span`,{className:`ms-3`,children:`Invoices & Payments`})]})})]})]})}function Sc(){let e=j({strict:!1});return(0,J.jsxs)(`ul`,{className:`flex space-x-4 md:hidden py-2`,children:[(0,J.jsx)(`li`,{children:(0,J.jsxs)(A,{to:gc(e,`billing`),className:_c,activeOptions:{exact:!0},inactiveProps:vc,activeProps:yc,children:[(0,J.jsx)(mn,{className:`inline-block`}),` `,(0,J.jsx)(`span`,{className:`ms-3`,children:`Payment Method`})]})}),(0,J.jsx)(`li`,{children:(0,J.jsxs)(A,{to:gc(e,`billing/invoices`),className:_c,inactiveProps:vc,activeProps:yc,children:[(0,J.jsx)(ur,{className:`inline-block`}),` `,(0,J.jsx)(`span`,{className:`ms-3`,children:`Invoices & Payments`})]})})]})}function Cc({className:e,containerClassName:t,...n}){return(0,J.jsx)(`div`,{"data-slot":`table-container`,className:g(`relative w-full overflow-x-auto`,t),children:(0,J.jsx)(`table`,{"data-slot":`table`,className:g(`w-full caption-bottom text-sm`,e),...n})})}function wc({className:e,...t}){return(0,J.jsx)(`thead`,{"data-slot":`table-header`,className:g(`[&_tr]:border-b`,e),...t})}function Tc({className:e,...t}){return(0,J.jsx)(`tbody`,{"data-slot":`table-body`,className:g(`[&_tr:last-child]:border-0`,e),...t})}function Ec({className:e,...t}){return(0,J.jsx)(`tr`,{"data-slot":`table-row`,className:g(`border-b border-grey-700 transition-colors`,e),...t})}function Dc({className:e,...t}){return(0,J.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 Oc({header:e,onColumnClick:t,...n}){let r=(0,Y.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:kt(e.column.columnDef.header,e.getContext()),s=(0,Y.useCallback)(()=>{e.column.resetSize()},[e]);return(0,J.jsx)(Dc,{...n,style:{width:`${e.getSize()}px`},className:i?`px-0`:`px-2`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[i?(0,J.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,J.jsx)(Te,{}):e.column.getIsSorted()===`desc`?(0,J.jsx)(ue,{}):(0,J.jsx)(xe,{className:`text-gray-600`})]}):o,a&&(0,J.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,J.jsx)(gt,{})})]})})}function kc({className:e,...t}){return(0,J.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 Ac({columns:e,data:t,isFetching:n,onRowClick:r,onColumnClick:i,sortingState:a,children:o}){let s=Ft({data:t,columns:e,getCoreRowModel:Je(),getSortedRowModel:Ge(),initialState:{sorting:a}});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-end space-x-2 pb-4`,children:[(0,J.jsx)(`div`,{className:`grow lg:hidden`}),o,(0,J.jsx)(`div`,{className:`grow hidden lg:visible`})]}),(0,J.jsxs)(Cc,{containerClassName:`rounded-md bg-black-dark`,children:[(0,J.jsx)(wc,{children:s.getHeaderGroups().map(e=>(0,J.jsx)(Ec,{className:`border-none`,children:e.headers.map(e=>(0,J.jsx)(Oc,{header:e,onColumnClick:i},e.id))},e.id))}),(0,J.jsx)(Tc,{className:`bg-black border border-grey-700`,children:s.getRowModel().rows?.length?s.getRowModel().rows.map(e=>(0,J.jsx)(Ec,{"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,J.jsx)(kc,{className:`py-2 px-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,style:{width:`${e.column.getSize()}px`},children:kt(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,J.jsx)(Ec,{children:(0,J.jsx)(kc,{colSpan:e.length,className:`h-24 text-center`,children:n?(0,J.jsx)(`div`,{children:(0,J.jsx)(Fr,{className:`p-12`})}):(0,J.jsx)(`span`,{children:`No results.`})})})})]})]})}function jc(e){switch(e){case`paid`:return`success`;case`void`:case`uncollectible`:return`destructive`;default:return`default`}}function Mc(e){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e)}var Nc=[{header:`Invoice Id`,accessorKey:`id`,enableSorting:!1},{header:`Status`,accessorKey:`status`,enableSorting:!1,cell:({cell:e})=>(0,J.jsx)(go,{variant:jc(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?ni(r,t):[t?ni(r,t):`-`,n?ni(i,n):`-`].join(` to `)}},{header:`Amount Due`,accessorKey:`amountDue`,enableSorting:!1,cell:({cell:e})=>Mc(e.getValue()?e.getValue()/100:0)},{header:`Amount Paid`,accessorKey:`amountPaid`,enableSorting:!1,cell:({cell:e})=>Mc(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} @ ${Mc(e.amount/100)}`);return n.join(`
|
|
3
3
|
`)}}];function Pc(e){return(0,Y.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 Fc(e){let{data:t}=await u.get(`/Invoice/${e}`);return t}function Ic(e,t){return M({queryKey:[e,`invoices`],queryFn:()=>Fc(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function Lc(){let{organizationId:e}=j({strict:!1}),{data:t}=L(is(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=L(Ic(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=Pc(r);return t?.type===`ENTERPRISE`?(0,J.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,J.jsx)(Lo,{}),`, we would love to talk!`]}):i?(0,J.jsx)(Fr,{centered:!0}):!n||!n.length?(0,J.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,J.jsx)(Lo,{overEmail:!0}),`, we would love to talk!`]}):(0,J.jsx)(Ac,{data:n,columns:Nc,children:(0,J.jsxs)(R,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,J.jsx)(Gt,{}),(0,J.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,J.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function Rc(e){let t=P({getParentRoute:()=>e,path:`billing`,component:bc}),n=P({getParentRoute:()=>t,path:`/`,component:Es}),r=P({getParentRoute:()=>t,path:`invoices`,component:Lc}),i=P({getParentRoute:()=>t,path:`confirm`,component:hc});return t.addChildren([n,r,i])}async function zc(e){let{data:t}=await u.get(`/OrganizationRole/${e}`);return t}function Bc(e){return M({queryKey:[e,`roles`],queryFn:()=>zc(e),retry:!1,refetchInterval:10*1e3})}var Vc=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},Fe().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 Hc(e){let{data:t}=await u.post(`/Role/`,e);return t}function Uc(){return I({mutationFn:Hc})}var Wc=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 Gc={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function Kc({isModalOpen:e,setIsModalOpen:t}){let n=kn(),{organizationId:r}=j({strict:!1}),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(JSON.stringify(Gc,null,2)),{mutate:c,isPending:l}=Uc(),u=k({resolver:O(Wc),defaultValues:{name:``,update:!1,delete:!1}}),d=(0,Y.useCallback)(e=>{a(e.length===0)},[a]),f=(0,Y.useCallback)(async e=>{let a=jo(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,J.jsx)(X,{onOpenChange:t,open:e,children:(0,J.jsxs)(Z,{children:[(0,J.jsx)($,{children:`Add New Organization Role`}),(0,J.jsx)(mo,{children:`Set the new organization role permissions.`}),(0,J.jsx)(B,{...u,children:(0,J.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,J.jsx)(z,{control:u.control,name:`name`,render:({field:e})=>(0,J.jsxs)(V,{className:`col-span-2`,children:[(0,J.jsx)(W,{className:`pb-1`,children:`Role Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`text`,className:``,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:u.control,name:`update`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Can Update Organization`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:u.control,name:`delete`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Can Delete Organization`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(`div`,{className:`col-span-2`,children:(0,J.jsx)(Re,{theme:`vs-dark`,height:`300px`,defaultLanguage:`json`,onValidate:d,onChange:e=>{e&&s(e)},defaultValue:JSON.stringify(Gc,null,2)})}),(0,J.jsx)(Q,{className:`col-span-2`,children:(0,J.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,J.jsx)(R,{variant:`destructiveOutline`,className:`rounded-full`,type:`button`,onClick:()=>t(!1),disabled:l,children:`Cancel`}),(0,J.jsx)(R,{variant:`submit`,className:`rounded-full`,disabled:l||!i||!u.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function qc({roleId:e}){let{data:t}=await u.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function Jc(){return I({mutationFn:({roleId:e})=>qc({roleId:e})})}async function Yc({roleId:e,updatedRoleInfo:t}){let{data:n}=await u.put(`/Role/${e}`,t);return n}function Xc(){return I({mutationFn:({roleId:e,updatedRoleInfo:t})=>Yc({roleId:e,updatedRoleInfo:t})})}function Zc({organizationId:e,roleId:t}){return M({queryKey:[e,`roles`,t],queryFn:()=>Qc(t),refetchInterval:10*1e3})}async function Qc(e){let{data:t}=await u.get(`/Role/${e}`);return t}function $c({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{children:`Confirm Role Deletion`}),(0,J.jsx)(mo,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,J.jsxs)(Q,{children:[(0,J.jsx)(R,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,onClick:()=>t(!1),children:`Cancel`}),(0,J.jsx)(R,{variant:`destructiveOutline`,className:`rounded-full`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function el({data:e,isModalOpen:t,closeModal:n}){let r=kn(),{data:i}=D(Zc({roleId:e.id,organizationId:e.organizationId})),a=vr(),o=a.user&&a.user?.roles?.[e.organizationId]?.role===e.roleName,{update:s,remove:c}=Ei(e.organizationId),{mutate:l,isPending:u}=Xc(),{mutate:d,isPending:f}=Jc(),[p,m]=(0,Y.useState)(!1),h=k({resolver:O(Wc),defaultValues:{name:e.roleName,update:i.organization.update||!1,delete:i.organization.delete||!1}}),g=(0,Y.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,Y.useState)(!0),[y,b]=(0,Y.useState)(JSON.stringify({roles:{...i.organization.roles},clusters:{...i.organization.clusters}},null,2)),x=(0,Y.useCallback)(e=>{v(e.length===0)},[v]),S=(0,Y.useCallback)(async t=>{if(!s)return;let i=jo(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,J.jsx)(X,{onOpenChange:(0,Y.useCallback)(()=>n(!1),[n]),open:t,children:(0,J.jsx)(Z,{children:p?(0,J.jsx)($c,{onRoleDeleteClick:g,setIsConfirmingRoleDeletion:m,isRoleDeletionPending:f}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)($,{children:[o||!s?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,J.jsx)(B,{...h,children:(0,J.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,J.jsx)(z,{control:h.control,name:`name`,render:({field:e})=>(0,J.jsxs)(V,{className:`col-span-2`,children:[(0,J.jsx)(W,{className:`pb-1`,children:`Role Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:h.control,name:`update`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Can Update Organization`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:h.control,name:`delete`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Can Delete Organization`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(`div`,{className:`col-span-2`,children:(0,J.jsx)(Re,{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,J.jsx)(Q,{className:`col-span-2`,children:(0,J.jsxs)(`div`,{className:`flex justify-between w-full`,children:[c&&(0,J.jsx)(R,{type:`button`,variant:`destructiveOutline`,className:`rounded-full`,onClick:()=>m(!0),disabled:u,children:`Delete Role`}),s&&(0,J.jsx)(R,{variant:`submit`,className:`rounded-full`,disabled:!_||u||!h.formState.isValid||!h.formState.isDirty,children:`Save Changes`})]})})]})})]})})})}function tl(){let e=F(),t=kn(),{organizationId:n,orgRoleId:r}=j({strict:!1}),{create:i}=Ei(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=D(Bc(n)),l=(0,Y.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,Y.useState)(!1),p=(0,Y.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,Y.useCallback)(()=>{f(!0)},[f]),h=(0,Y.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,Y.useCallback)(e=>p(void 0,e),[p]),_=Pc(o);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(no,{}),(0,J.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,J.jsxs)(Y.Suspense,{fallback:(0,J.jsx)(Fr,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,J.jsxs)(Ac,{data:a,columns:Vc,onRowClick:h,children:[(0,J.jsxs)(R,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,J.jsx)(Gt,{}),(0,J.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,J.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,J.jsxs)(R,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,J.jsx)(Yt,{}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,J.jsx)(Kc,{isModalOpen:d,setIsModalOpen:f}),u&&(0,J.jsx)(el,{data:l,isModalOpen:u,closeModal:g})]})})]})}var nl=[{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},Fe().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}],rl=x.object({email:la.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 al(){return I({mutationFn:e=>il(e)})}x.object({email:la.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:x.string().nonempty({error:`Please select a role.`})});async function ol(e){let{data:t}=await u.post(`/UserInvite/`,e);return t}function sl(){return I({mutationFn:e=>ol(e)})}function cl({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=j({strict:!1}),{data:i}=D(Bc(r)),[a,o]=(0,Y.useState)(!1),s=k({resolver:O(rl),defaultValues:{email:``,roleId:``}}),{mutate:c,isPending:l}=al(),{mutate:u,isPending:d}=sl(),f=(0,Y.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,J.jsx)(X,{onOpenChange:()=>{n(!1),o(!1),s.reset()},open:e,children:(0,J.jsx)(Z,{"aria-describedby":void 0,children:(0,J.jsx)(B,{...s,children:(0,J.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:s.handleSubmit(f),className:`grid gap-4 my-4`,children:[(0,J.jsx)(po,{children:(0,J.jsx)($,{children:a?`Invite User`:`Add User`})}),(0,J.jsx)(z,{control:s.control,name:`email`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Email`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:s.control,name:`roleId`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Roles`}),(0,J.jsx)(Y.Suspense,{fallback:(0,J.jsx)($r,{}),children:(0,J.jsx)(U,{children:(0,J.jsxs)(ri,{...e,onValueChange:t=>e.onChange(t),children:[(0,J.jsx)(Xr,{className:`w-full`,children:(0,J.jsx)(ti,{placeholder:`Choose Role`})}),(0,J.jsx)(Jr,{children:(0,J.jsxs)(Qr,{children:[(0,J.jsx)(Yr,{children:`Role`}),i?.map(e=>(0,J.jsx)(q,{value:e.id,children:e.roleName},e.id))]})})]})})}),(0,J.jsx)(H,{})]})}),a&&(0,J.jsxs)(mo,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,J.jsx)(st,{className:`inline-block size-12 pr-2`}),(0,J.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,J.jsx)(Q,{children:(0,J.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,J.jsxs)(R,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:l||d,children:[(0,J.jsx)(On,{}),` `,a?`Invite User`:`Add User`]})})})]})})})})}async function ll({roleId:e,userId:t}){let{data:n}=await u.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function ul(){return I({mutationFn:({roleId:e,userId:t})=>ll({roleId:e,userId:t})})}function dl(e){let[t,n]=(0,Y.useState)(e||!1);return[t,(0,Y.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function fl({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=al(),{mutate:c,isPending:l}=ul(),u=!!i[r.roleName],[d,f]=(0,Y.useState)(u),[p,m]=dl(u);return(0,Y.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,J.jsxs)(qr,{className:`flex`,children:[(0,J.jsx)(G,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,J.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function pl({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r}){let{organizationId:i}=j({strict:!1}),a=vr(),{update:o,remove:s}=Ei(i),c=a.user?.email===t.email,{data:l}=D(Bc(i)),u=(0,Y.useMemo)(()=>t.roles?Xo(t.roles,`roleName`):{},[t]),[d,f]=(0,Y.useState)(!1);return(0,J.jsx)(X,{onOpenChange:d?r:e,open:n,children:(0,J.jsxs)(Z,{className:`sm:max-w-[750px]`,children:[(0,J.jsx)(po,{children:(0,J.jsxs)($,{children:[o?`Edit `:`View `,` `,t.email,` `,c?`(yourself)`:``]})}),o&&(0,J.jsxs)(mo,{children:[`To remove `,c?`your self`:`this user`,` from the organization, uncheck all of the boxes below.`]}),l.map(e=>(0,J.jsx)(fl,{readOnly:!o,canRemove:s,data:t,orgRole:e,selectedRoles:u,setChangesMade:f},e.id))]})})}function ml(e,t){return e.email>t.email?1:-1}function hl(){let e=F(),{organizationId:t,orgUserId:n}=j({strict:!1}),{update:r}=Ei(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=D(Bc(t)),c=(0,Y.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(ml)},[i]),l=(0,Y.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),u=(0,Y.useCallback)(t=>{e({to:[n?`..`:``,t].filter(Boolean).join(`/`)})},[n,e]),d=!!n&&!!l,[f,p]=(0,Y.useState)(!1),[m]=(0,Y.useState)({attribute:`email`,descending:!1}),h=(0,Y.useMemo)(()=>[{desc:m.descending,id:m.attribute}],[m]),g=(0,Y.useCallback)(()=>{p(!0)},[p]),_=(0,Y.useCallback)(()=>{a(),p(!1)},[a,p]),v=(0,Y.useCallback)(e=>{u(e.original.id)},[u]),y=(0,Y.useCallback)(()=>{u(void 0)},[u]),b=(0,Y.useCallback)(()=>{a(),u(void 0)},[u,a]),x=Pc(a);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(no,{}),(0,J.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,J.jsxs)(Y.Suspense,{fallback:(0,J.jsx)(Fr,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,J.jsxs)(Ac,{data:c,isFetching:o||s,columns:nl,onRowClick:v,sortingState:h,children:[(0,J.jsxs)(R,{variant:`defaultOutline`,onClick:x,accessKey:`r`,disabled:o||s,children:[(0,J.jsx)(Gt,{}),` `,(0,J.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,J.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,J.jsxs)(R,{variant:`positiveOutline`,onClick:g,accessKey:`a`,disabled:f,children:[(0,J.jsx)(Yt,{}),` `,(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,J.jsx)(cl,{isModalOpen:f,onChangesSaved:_,setIsModalOpen:p}),d&&(0,J.jsx)(pl,{closeModal:y,data:l,isModalOpen:d,onUserUpdated:b})]})})]})}function gl({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=Ti(n),s=o,{view:c}=Ei(n),l=(0,Y.useCallback)(()=>{t(e)},[t,e]);return(0,J.jsxs)(Tr,{className:`relative h-full justify-between`,children:[(0,J.jsxs)(Lr,{children:[(0,J.jsxs)(Ir,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`truncate`,children:n}),a&&(0,J.jsxs)(_o,{children:[(0,J.jsx)(vo,{className:`p-4 -m-4 -mr-6 hover:text-white`,children:(0,J.jsx)(qn,{"aria-label":`Options`})}),(0,J.jsxs)(yo,{children:[(0,J.jsx)(So,{className:`text-gray-600 text-xs`,children:`Options`}),(0,J.jsx)(Co,{}),(0,J.jsx)(A,{to:`${n}`,children:(0,J.jsx)(bo,{children:`Clusters`})}),c&&(0,J.jsx)(A,{to:`${n}/roles`,children:(0,J.jsx)(bo,{children:`Roles`})}),c&&(0,J.jsx)(A,{to:`${n}/users`,children:(0,J.jsx)(bo,{children:`Users`})}),s&&(0,J.jsx)(A,{to:`${n}/billing`,children:(0,J.jsx)(bo,{children:`Billing`})}),(0,J.jsx)(Co,{}),a&&(0,J.jsx)(bo,{className:`focus:bg-red/70 focus:text-white`,onClick:l,children:`Delete`})]})]})]}),(0,J.jsx)(xr,{children:(0,J.jsx)(`h2`,{children:r})})]}),(0,J.jsxs)(yr,{className:`flex justify-between`,children:[(0,J.jsx)(go,{children:ea(i)}),(0,J.jsx)(A,{to:n,className:`text-sm`,"aria-label":`View ${r}`,title:`View ${r}`,children:(0,J.jsxs)(`span`,{className:`py-2 transition-all duration-100 ease-in-out border-0 hover:border-b-2`,children:[`View `,(0,J.jsx)(at,{className:`inline-block`})]})})]})]})}async function _l(e){let{data:t}=await u.delete(`/Organization/${e}`);return t}function vl(){return I({mutationFn:e=>_l(e)})}async function yl(e){let{data:t}=await u.post(`/Organization/`,{...e});return t}function bl(){return I({mutationFn:e=>yl(e)})}var xl=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.`}),Sl=T({name:w().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:se([S(``),y(),xl])});function Cl(){let{user:e}=vr(),t=F(),n=k({resolver:O(Sl),defaultValues:{name:``,subdomain:``}}),{setFocus:i,watch:a}=n;(0,Y.useEffect)(()=>{i(`name`)},[i]);let o=`${e?.firstname} ${e?.lastname} Org`,s=a(`name`)||o,c=a(`subdomain`),l=(0,Y.useMemo)(()=>{let e=os(cs(s),xl.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${c||e}.harperfabric.com`}},[s,c]),{mutate:u,isPending:f}=bl(),p=kn(),h=(0,Y.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,J.jsx)(J.Fragment,{children:(0,J.jsx)(B,{...n,children:(0,J.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,J.jsx)(z,{control:n.control,name:`name`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`text`,maxLength:Sl.shape.name.maxLength,autoCapitalize:`words`,placeholder:o,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:n.control,name:`subdomain`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Subdomain`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`text`,maxLength:xl.maxLength,autoCapitalize:`none`,placeholder:l.suggestedSubdomain,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{className:`pb-1`,children:`Full Host Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(`span`,{children:l.fullHostName})}),(0,J.jsx)(H,{})]}),(0,J.jsx)(Q,{children:(0,J.jsxs)(R,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:f,children:[`Create New Organization `,(0,J.jsx)(at,{})]})})]})})})}function wl(){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(no,{}),(0,J.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,J.jsx)(Cl,{})})]})}function Tl(){let e=kn(),{data:t}=D(_()),{mutate:n,isPending:r}=vl(),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(``),u=(0,Y.useCallback)(()=>l(``),[]),d=(0,Y.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(uc([`organizationId`,`organizationName`],c)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1)||[]},[c,t?.roles]),f=(0,Y.useCallback)(e=>{l(e.currentTarget.value?.toLowerCase()||``)},[]),p=(0,Y.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,Y.useCallback)(e=>{s(e),a(!0)},[]),{createCluster:h}=Me({strict:!1});return d.length===1&&!c.length&&h?(0,J.jsx)(Et,{to:`/${d[0].organizationId}/new-cluster`,replace:!0}):!d.length&&!c.length?(0,J.jsx)(wl,{}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(no,{children:(0,J.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,J.jsx)(G,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:c,onChange:f}),(0,J.jsx)(A,{to:`/new-org`,children:(0,J.jsxs)(R,{variant:`positive`,accessKey:`n`,children:[(0,J.jsx)(Yt,{}),(0,J.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,J.jsx)(`u`,{children:`N`}),`ew `,(0,J.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,J.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[d.map(e=>(0,J.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,J.jsx)(gl,{organizationRole:e,onDeleteOrgModal:m})},e.organizationId)),!d.length&&(0,J.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,J.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,J.jsx)(R,{variant:`outline`,onClick:u,children:`Clear Filters`})]})]})}),o&&(0,J.jsx)(ho,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:o.organizationName,isModalOpen:i,setIsModalOpen:()=>a(!1),deletionConfirmed:()=>p(o),deletionPending:r})]})}function El(){let{isLoading:e}=mr(),{createCluster:t}=Me({strict:!1}),[,n]=Po(Fo.SavedClusterState,null);return(0,Y.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,J.jsx)(Fr,{className:`fixed z-50 translate-1/2`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.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,J.jsx)(Fi,{})}),(0,J.jsx)(`main`,{children:(0,J.jsx)(Ye,{})})]})}var Dl=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function Ol(){let e=fc();return!Dl.includes(e)&&{redirect:e}}var kl=P({getParentRoute:()=>pi,id:`_dashboardLayout`,component:El,beforeLoad:({context:e})=>{let t=e.authentication[d];if(t&&!t.isLoading&&!t.user)throw zt({to:`/sign-in`,search:Ol()})}}),Al=P({getParentRoute:()=>kl,id:`_orgsLayout`});P({getParentRoute:()=>Al,path:`/`,component:Tl}),P({getParentRoute:()=>Al,path:`/new-org`,component:wl});var jl=P({getParentRoute:()=>Al,path:`$organizationId`,beforeLoad:async e=>({organization:await e.context.queryClient.ensureQueryData(is(e.params.organizationId))})});P({getParentRoute:()=>jl,path:`/roles`,component:tl}),P({getParentRoute:()=>jl,path:`/roles/$orgRoleId`,component:tl}),P({getParentRoute:()=>jl,path:`/users`,component:hl}),P({getParentRoute:()=>jl,path:`/users/$orgUserId`,component:hl}),Rc(jl);var Ml=P({getParentRoute:()=>jl,id:`_clusterLayout`});P({getParentRoute:()=>Ml,path:`/`,component:dc}),P({getParentRoute:()=>jl,path:`/new-cluster`,component:oc}),P({getParentRoute:()=>Pl,path:`/edit`,component:oc}),P({getParentRoute:()=>Pl,path:`/edit/$mode`,component:oc});function Nl(){return(0,J.jsx)(Ye,{})}var Pl=P({getParentRoute:()=>Ml,path:`$clusterId`,component:Nl,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(wr(t.clusterId))})});function Fl({children:e,className:t}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(no,{}),(0,J.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 Il=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function Ll(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&&Il.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function Rl({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=Ll(t),[i,a,o]=Ao(r,e||``,n);return(0,J.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,J.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,J.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,J.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,J.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,J.jsx)(R,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,J.jsx)(Kt,{className:`w-3.5 h-3.5`})})]})}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,J.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,J.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,J.jsx)(R,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,J.jsx)(Kt,{className:`w-3.5 h-3.5`})})]})}),(0,J.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,J.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,J.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,J.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,J.jsx)(R,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,J.jsx)(Kt,{className:`w-3 h-3`})})]})}),(0,J.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 zl({certificate:e,domain:t,cluster:n}){let r=Ll(t.domain),[i,a,o]=Ao(r,n.fqdn||``,t.id),s=(0,Y.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,J.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,J.jsxs)(`div`,{className:`mb-4`,children:[(0,J.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,J.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,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,J.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,J.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,J.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 px-2 py-0.5 rounded text-xs`,children:[(0,J.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,J.jsx)(R,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,J.jsx)(Kt,{className:`w-3 h-3`})})]}),(0,J.jsx)(Bl,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 px-2 py-0.5 rounded text-xs`,children:[(0,J.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,J.jsx)(R,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,J.jsx)(Kt,{className:`w-3 h-3`})})]})]}),(0,J.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,J.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,J.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,J.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,J.jsx)(R,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,J.jsx)(Kt,{className:`w-2.5 h-2.5`})})]})})]})]})}function Bl(){return(0,J.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,J.jsx)(`path`,{d:`M5 12h14`}),(0,J.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function Vl(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:()=>Hl(e)})}async function Hl({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 Ul(e){return M({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await Hl({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 Wl(e){return L(Ul(e))}function Gl({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=Ll(n),[o,s,c,l,u]=Ao(t,e,a,i||``,r);return(0,J.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,J.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,J.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,J.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,J.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,J.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,J.jsx)(Kt,{className:`w-3.5 h-3.5`})})]})}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,J.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,J.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,J.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,J.jsx)(Kt,{className:`w-3.5 h-3.5`})})]})}),(0,J.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,J.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,J.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,J.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,J.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,J.jsx)(Kt,{className:`w-3.5 h-3.5`})})]})}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,J.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,J.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,J.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,J.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,J.jsx)(Kt,{className:`w-3.5 h-3.5`})})]})}),(0,J.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,J.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,J.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,J.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,J.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,J.jsx)(Kt,{className:`w-3 h-3`})})]})}),(0,J.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 Kl({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await u.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function ql(){return I({mutationFn:e=>Kl(e)})}x.object({domainId:x.string()});async function Jl(e){let{data:t}=await u.delete(`/Domain/${e.domainId}`);return t}function Yl(){return I({mutationFn:e=>Jl(e)})}function Xl(e){return[...new Set(e)]}var Zl=Fe();function Ql(e,t,n){let{data:r}=Wl(e.id),i=(0,Y.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=ql(),{mutate:s,isPending:c}=Yl(),l=o||c,u=(0,Y.useCallback)((t,n)=>{if(!io(e.status)){N.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:Xl((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{Br.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),N.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,Y.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{Br.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),N.success(`Domain removed!`)}})},[s]),f=(0,Y.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{Br.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),N.success(`Domain unbound!`)}})},[s]);return(0,Y.useMemo)(()=>[Zl.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!wo(e)?(0,J.jsx)(`label`,{className:`p-10 -m-10`,children:(0,J.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),Zl.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,J.jsxs)(Xi,{children:[(0,J.jsx)(Zi,{asChild:!0,children:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{children:t.domain}),(0,J.jsx)(R,{variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,J.jsx)(Qi,{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!`})]})}}),Zl.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,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,J.jsx)(`div`,{className:`py-2`,children:(0,J.jsx)(zl,{certificate:i,domain:n,cluster:e})}),(0,J.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,J.jsx)(Gl,{domain:n,cluster:e}):wo(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,J.jsx)(Rl,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var $l=x.object({domain:x.string(),organizationId:x.string()});async function eu(e){let{data:t}=await u.post(`/Domain/`,e);return t}function tu(){return I({mutationFn:e=>eu(e)})}async function nu(e){let{data:t}=await u.post(`/Domain/${e}/validate`);return t}async function ru(e){let{data:t}=await u.get(`/Domain/?organizationId=${e}`);return t}function iu(e){return M({queryKey:[e,`domains`],queryFn:()=>ru(e)})}function au(){let{organizationId:e,clusterId:t}=j({strict:!1}),{data:n}=D(wr(t,!0)),{update:r}=Ei(e),{data:i,refetch:a,isFetching:o,isRefetching:s}=L(iu(e)),c=(0,Y.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[l]=(0,Y.useState)({attribute:`domain`,descending:!1}),u=(0,Y.useMemo)(()=>[{desc:l.descending,id:l.attribute}],[l]),d=Pc(a),[f,m]=(0,Y.useState)([]),h=(0,Y.useCallback)(e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:g,isPending:_}=ql(),v=(0,Y.useCallback)(()=>{if(!io(n.status)){N.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}g({clusterId:n.id,domainIds:Xl((n.domainIds?.slice()||[]).concat(f)),generateDomainCerts:!0},{onSuccess:()=>{Br.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}=tu(),x=k({resolver:O($l),defaultValues:{domain:``,organizationId:e}}),S=(0,Y.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,Y.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 nu(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=Ql(n,f,h),C=x.watch(`domain`),ne=(0,Y.useMemo)(()=>typeof C==`string`?C.trim().split(`.`).length===2:!1,[C]),re=(0,Y.useCallback)(()=>{typeof C==`string`&&x.setValue(`domain`,`${C.trim()}, www.${C.trim()}`)},[C,x]);return(0,J.jsx)(Ac,{data:i||[],isFetching:o||s,columns:te,sortingState:u,children:(0,J.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,J.jsx)(B,{...x,children:(0,J.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,J.jsx)(z,{control:x.control,name:`domain`,render:({field:e})=>(0,J.jsxs)(V,{className:`flex-1`,children:[(0,J.jsx)(W,{className:`pb-1`,children:`New Domain Name`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),ne&&(0,J.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,J.jsx)(R,{variant:`positiveOutline`,type:`button`,onClick:re,children:`Add www as well`})]}),(0,J.jsx)(H,{children:(0,J.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,J.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,J.jsxs)(R,{type:`submit`,variant:`submit`,disabled:b,children:[(0,J.jsx)(Yt,{}),` Add`]}),c.length>0&&(0,J.jsxs)(R,{variant:`positiveOutline`,onClick:ee,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,J.jsx)(rt,{}),` `,(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,J.jsxs)(R,{variant:`defaultOutline`,onClick:d,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,J.jsx)(Gt,{}),` `,(0,J.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,J.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),f.length>0&&(0,J.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,J.jsxs)(R,{variant:`submit`,onClick:v,disabled:_,children:[(0,J.jsx)(On,{}),` Bind `,p(f.length,`Domain`,`Domains`)]})})]})})}function ou(){return(0,J.jsx)(Fl,{className:`flex flex-col justify-start max-w-4xl`,children:(0,J.jsx)(au,{})})}var su=T({username:da,role:w().nonempty({error:`Please select a role.`}),password:ua.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 cu(e){await u.patch(`/ResetPasswordUpdater/${e}`)}async function lu(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function uu(){return I({mutationFn:lu})}async function du({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 fu(){return I({mutationFn:du})}async function pu({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function mu(){return I({mutationFn:pu})}async function hu({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 oa({username:t,password:i,instanceClient:o,entityId:e});return a.instanceClient&&(o=a.instanceClient),n===`HDB_ADMIN`?await du({username:n,password:r,instanceClient:o}):(await lu({username:n,password:r,role:`super_user`,active:!0,instanceClient:o}),await oa({username:n,password:r,instanceClient:o,entityId:e}),await pu({username:s,instanceClient:o})),await cu(e),a}catch(t){throw await h({entityId:e,instanceClient:o}),t}}function gu(){return I({mutationFn:hu})}function _u(){let{user:e}=vr(),{clusterId:t}=j({strict:!1}),{data:r}=L(wr(t,!0)),i=F(),a=(0,Y.useMemo)(()=>n(r),[r]),o=Ur({operationsUrl:a}),{redirect:c}=Me({strict:!1}),l=He(),u=k({resolver:O(su),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:d,control:f,handleSubmit:p}=u;(0,Y.useEffect)(()=>{d(`password`)},[d]);let h=r?.instances?.find(e=>e.tempPassword)?.tempPassword,{mutate:g,isPending:_}=gu(),v=(0,Y.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,J.jsx)(Et,{to:`../sign-in`,replace:!0}):(0,J.jsxs)(J.Fragment,{children:[(0,J.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,J.jsx)(na,{})}),(0,J.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,J.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,J.jsx)(`h2`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,J.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,J.jsx)(B,{...u,children:(0,J.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:p(v),className:`my-4`,children:[(0,J.jsx)(z,{control:f,name:`username`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-4`,children:[(0,J.jsx)(W,{children:`Username`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{autoComplete:`username`,type:`text`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:f,name:`password`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-4`,children:[(0,J.jsx)(W,{children:`Password`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`password`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:f,name:`confirmPassword`,render:({field:e})=>(0,J.jsxs)(V,{className:`my-4`,children:[(0,J.jsx)(W,{children:`Confirm Password`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`password`,...e})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(R,{disabled:_,type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,children:`Create Admin User`})]})}),(0,J.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,J.jsx)(gn,{size:36,className:`flex-none`}),(0,J.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 vu({columns:e,data:t}){let n=Ft({data:t,columns:e,getCoreRowModel:Je()});return(0,J.jsx)(`div`,{className:`bg-black-dark rounded-md`,children:(0,J.jsxs)(Cc,{children:[(0,J.jsx)(wc,{children:n.getHeaderGroups().map(e=>(0,J.jsx)(Ec,{className:`border-none`,children:e.headers.map(e=>(0,J.jsx)(Dc,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:kt(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,J.jsx)(Tc,{className:`bg-black`,children:n.getRowModel().rows?.length?n.getRowModel().rows.map(e=>(0,J.jsx)(Ec,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,J.jsx)(kc,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:kt(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,J.jsx)(Ec,{children:(0,J.jsx)(kc,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function yu(){return(0,J.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,J.jsx)(`p`,{children:`No instances found.`})})}function bu({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=hr(t.id),i=Ur({operationsUrl:(0,Y.useMemo)(()=>c(t),[t])}),{update:a}=ki(),o=m.checkForFabricConnect(t.id),s=(0,Y.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,J.jsx)(et,{className:`animate-spin`,color:`gray`}):!n||o?(0,J.jsxs)(`span`,{className:`flex gap-4`,children:[a&&!e&&(0,J.jsx)(A,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,J.jsx)(R,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,J.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,J.jsx)(R,{variant:a?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,J.jsxs)(`span`,{className:`flex gap-4`,children:[(0,J.jsx)(A,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,J.jsx)(R,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,J.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`})]})}async function xu({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function Su(){return I({mutationFn:xu,onSuccess:(e,t)=>Br.invalidateQueries({queryKey:[t.entityId,`get_status`]})})}function Cu({instance:e,index:t}){let{update:n}=ki(),r=K({operationsUrl:(0,Y.useMemo)(()=>c(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:i,isPending:a}=Su(),[o,s]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{let e=setTimeout(()=>s(!0),t*500);return()=>clearTimeout(e)},[t]);let{data:l,isLoading:u,isFetching:d}=L(ii(r,o&&n)),f=ei(l,`availability`)||`Unknown`,p=f===`Available`,m=f===`Unavailable`;return n?(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(Xi,{children:[(0,J.jsx)(Zi,{asChild:!0,children:(0,J.jsx)(`div`,{className:`flex items-center`,children:u||!o||d&&!l?(0,J.jsx)(et,{className:`animate-spin size-5 text-muted-foreground`}):(0,J.jsx)(go,{variant:p?`success`:m?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,J.jsx)(`span`,{className:`sr-only`,children:p?`Online`:`Offline`})})})}),(0,J.jsxs)(Qi,{children:[d&&l?`Refreshing... `:``,f]})]}),n&&(0,J.jsxs)(`div`,{className:`flex gap-1`,children:[p&&(0,J.jsxs)(Xi,{children:[(0,J.jsx)(Zi,{asChild:!0,children:(0,J.jsx)(R,{variant:`destructiveGhost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Unavailable`}),disabled:a,children:a?(0,J.jsx)(et,{className:`animate-spin size-4`}):(0,J.jsx)(Tn,{className:`size-4`})})}),(0,J.jsx)(Qi,{children:`Bring out of rotation`})]}),m&&(0,J.jsxs)(Xi,{children:[(0,J.jsx)(Zi,{asChild:!0,children:(0,J.jsx)(R,{variant:`ghost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Available`}),disabled:a,children:a?(0,J.jsx)(et,{className:`animate-spin size-4`}):(0,J.jsx)(Xn,{className:`size-4`})})}),(0,J.jsx)(Qi,{children:`Bring back into rotation`})]})]})]}):null}function wu(){let{clusterId:e}=j({strict:!1}),{data:t,isLoading:n}=L(wr(e,!0)),r=wo(t),i=(0,Y.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,J.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,J.jsx)(bu,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>$s({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,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Cu,{instance:e.row.original,index:e.row.index}),t?(0,J.jsx)(go,{variant:ro(t),children:ea(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,J.jsxs)(J.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(Vr),[r]),a=(0,Y.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!ia.includes(e.status)).sort(Jo):[],[t]);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(no,{}),(0,J.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,J.jsx)(Tr,{className:`p-0 mt-4 min-h-96`,children:(0,J.jsx)(yr,{className:`p-0 min-h-96`,children:n?(0,J.jsx)($r,{}):a.length?(0,J.jsx)(vu,{data:a,columns:i}):(0,J.jsx)(yu,{})})})})]})}function Tu(){let{clusterId:e}=j({strict:!1}),{data:t,isLoading:n}=L(wr(e,2e3)),r=t?.status,i=(0,Y.useMemo)(()=>r&&ra.includes(r),[r]);return n||!t?(0,J.jsx)(Fl,{className:`flex justify-center`,children:(0,J.jsx)($r,{})}):i?(0,J.jsx)(Fl,{className:`flex justify-center`,children:(0,J.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,J.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,J.jsx)(Do,{cluster:t,forceProgressBarVisible:!0}),(0,J.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,J.jsx)(`div`,{className:`text-center`,children:(0,J.jsx)(To,{cluster:t})})]})}):(0,J.jsx)(Fl,{className:`flex justify-center`,children:(0,J.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,J.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,J.jsx)(Do,{cluster:t,forceProgressBarVisible:!0}),(0,J.jsxs)(`p`,{children:[`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,J.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,J.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 Eu(){let e=He(),{clusterId:t}=j({strict:!1}),{data:n,isLoading:r}=L(wr(t,2e3)),i=n?.status,a=(0,Y.useMemo)(()=>i&&ra.includes(i),[i]),o=ao(i),[,s]=Po(Fo.SavedClusterState,null),c=(0,Y.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,J.jsx)(Fl,{className:`flex justify-center`,children:(0,J.jsx)($r,{})}):o?(0,J.jsx)(Fl,{className:`flex justify-center`,children:(0,J.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,J.jsx)(Jn,{className:`w-24 h-24`}),(0,J.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,J.jsx)(Lo,{}),` if you want more help.`]}),(0,J.jsx)(R,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,J.jsx)(Fl,{className:`flex justify-center`,children:(0,J.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,J.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,J.jsx)(Do,{cluster:n,forceProgressBarVisible:!0}),(0,J.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,J.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,J.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,J.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,J.jsx)(`div`,{className:`text-center`,children:(0,J.jsx)(To,{cluster:n})})]})}):(0,J.jsx)(Fl,{className:`flex justify-center`,children:(0,J.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,J.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,J.jsx)(Do,{cluster:n,forceProgressBarVisible:!0}),(0,J.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,J.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,J.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:()=>Pl,path:`instances`,component:wu}),P({getParentRoute:()=>Pl,path:`starting-up`,component:Eu}),P({getParentRoute:()=>Pl,path:`scaling`,component:Tu}),P({getParentRoute:()=>Pl,path:`domains`,component:ou}),P({getParentRoute:()=>Pl,path:`sign-in`,component:va,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 zt({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),P({getParentRoute:()=>Pl,path:`instance/$instanceId/sign-in`,component:va,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 zt({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),P({getParentRoute:()=>Pl,path:`finish-setup`,component:_u});function Du(e){return P({getParentRoute:()=>e,path:`apis`}).lazy(()=>Gr(()=>import(`./index.lazy-JvCzgHOj.js`).then(e=>e.route),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])))}function Ou(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 ku(e,t){let[n,r]=(0,Y.useState)(t),[i,a]=(0,Y.useState)(e);return(0,Y.useEffect)(()=>{Ou(n,t)||(r(t),a(e))},[n,t,e]),Ou(n,t)?[i,a]:[e,a]}var Au={};function ju(e,t,n){let r=(0,Y.useCallback)((e,n)=>t(e,n),[n]);(0,Y.useEffect)(()=>(Au[e]||(Au[e]=[]),Au[e].push(r),function(){let t=Au[e].indexOf(r);t>=0&&Au[e].splice(t,1)}),[e,t,r])}function Mu(e,t,n){let r=Au[e];if(r)for(let e of r)e(t,n)}function Nu(e,t,n){return r=>Mu(e,t,n??r)}function Pu(e,t,n){return(0,Y.useCallback)(r=>Mu(e,t,n??r),[e,t,n])}function Fu(e,t){return jo(sessionStorage.getItem(String(e)))??t}function Iu(e,t){t==null?sessionStorage.removeItem(String(e)):sessionStorage.setItem(String(e),JSON.stringify(t))}function Lu(e,t){let n=ku(Fu(e,t),[e]),[r,i]=n;return(0,Y.useEffect)(()=>{Iu(e,r),Mu(`Session:${e}`,r)},[e,r]),ju(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,Y.useEffect)(function(){let n=n=>{n.key===e&&i(Fu(e,t))};return window.addEventListener(`storage`,n),()=>{window.removeEventListener(`storage`,n)}},[e,i,t]),n}function Ru(e,t=!1){let[n,r]=Lu(e,t),i=(0,Y.useCallback)(e=>{e?.preventDefault?.(),r(e=>!e)},[r]),a=(0,Y.useCallback)(e=>{e?.preventDefault?.(),r(!0)},[r]),o=(0,Y.useCallback)(e=>{e?.preventDefault?.(),r(!1)},[r]);return(0,Y.useMemo)(()=>({toggled:n,setToggled:r,toggle:i,toggleOn:a,toggleOff:o}),[i,r,o,a,n])}var zu=(0,Y.createContext)(null);function Bu(){return(0,Y.useContext)(zu)}async function Vu({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 Hu(e){let t=(e||``)?.split(`.`);return t.length>1?t.slice(-1)[0]:``}function Uu(e){switch(Hu(e).toLowerCase()){case`jpg`:case`jpeg`:case`gif`:case`png`:case`pneg`:case`webp`:return!0;default:return!1}}async function Wu({instanceClient:e,file:t,project:n,encoding:r}){let{data:i}=await e.post(`/`,{operation:`get_component_file`,file:t,project:n,encoding:r??(Uu(t)?`base64`:`utf8`)});return{file:t,project:n,...i}}function Gu(e){return M({queryKey:Ku(e),queryFn:()=>Wu(e),enabled:!!e.file&&!!e.project,retry:!1})}function Ku(e){return[e.entityId,`get_component_file`,e.file,e.project,e.encoding]}async function qu({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 Ju(){return I({mutationFn:qu})}function Yu(){let{reloadRootEntries:e,setFocusedItem:t,setSelectedItems:n}=Bu(),r=K();return(0,Y.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,J.jsx)(Nr,{animated:!0,width:`0%`})});let l=o.length*3,u=0;function d(){u+=1,N.loading(s,{...c,description:(0,J.jsx)(Nr,{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 Wu({...r,file:i,project:n,encoding:`base64`});if(a||(d(),await qu({...r,file:c,project:s,encoding:`base64`,payload:l.message}),a)||(d(),await Vu({...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 Xu(e,t){return e[t]!==void 0}function Zu(e){return t=>Xu(t,e)}function Qu(e,t){let[n,r]=(0,Y.useState)({value:t});return ju(e,(e,t)=>r({value:e,trigger:t}),[r]),n}function $u(e,t,n){Mu(e,t,n)}function ed(e,t,n){return r=>$u(e,t,n??r)}function td(e,t,n){return(0,Y.useCallback)(r=>{$u(e,t,n??r)},[e,t,n])}var nd=[{handleGlobal(e,t){if((t.cmd||t.ctrl)&&e===`Delete`)return $u(`ShowDeleteDirectoryOrFileModal`,!0),!0},addEditorAction(e){return{id:`delete-file`,label:`Delete File`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.Delete],run:ed(`ShowDeleteDirectoryOrFileModal`,!0)}}},{handleGlobal(e,t){if(t.ctrl&&t.alt&&t.shift&&e===`˜`)return $u(`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:ed(`ShowAddDirectoryOrFileModalType`,`directory`)}}},{handleGlobal(e,t){if(t.ctrl&&e===`n`)return $u(`ShowAddDirectoryOrFileModalType`,`file`),!0},addEditorAction(e){return{id:`new-file`,label:`New File`,keybindings:[e.KeyMod.WinCtrl|e.KeyCode.KeyN],run:ed(`ShowAddDirectoryOrFileModalType`,`file`)}}},{handleGlobal(e){if(e===`F2`)return $u(`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:ed(`ShowRenameFileModal`,!0)}}},{addEditorAction(){return{id:`revert-file`,label:`Revert File`,run:Nu(`RevertChanges`,!0)}}},{handleGlobal(e,t){if(t.cmd&&e===`s`)return Mu(`SaveFile`,!0),!0},addEditorAction(e){return{id:`save-file`,label:`Save Changes`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.KeyS],run:Nu(`SaveFile`,!0)}}}],rd=nd.filter(Zu(`addEditorAction`)),id=nd.filter(Zu(`handleGlobal`));function ad(e){let[t,n]=e,r=rd.map(e=>t.addAction(e.addEditorAction(n)));return()=>{for(let e of r)e?.dispose()}}function od(){(0,Y.useEffect)(()=>(document.addEventListener(`keydown`,sd),()=>{document.removeEventListener(`keydown`,sd)}),[])}function sd(e){let t={cmd:e.getModifierState(`Meta`),alt:e.getModifierState(`Alt`),shift:e.getModifierState(`Shift`),ctrl:e.getModifierState(`Control`)};for(let n of id)if(n.handleGlobal(e.key,t)){e.preventDefault();return}}function cd(e){return e.split(`/`).pop()}function ld(...e){return e.flat(1).join(`/`)}function ud(e){return!!e?.entries}var dd=`__root__`,fd=`importedApplications`,pd=`newApplication`;function md(e){let t={},n=[],r=[],i=[];for(let a of e)ud(a)?a.package?r.push(a.path):n.push(a.path):i.push(a.path),hd(t,a);return t[dd]={index:dd,isFolder:!0,children:[pd,fd,...n,...i],data:void 0,canMove:!1,canRename:!1},t[fd]={index:fd,isFolder:!0,children:r,data:{name:`Imported Applications`,path:fd,package:fd,project:``,entries:[]},canMove:!1,canRename:!1},t[pd]={index:pd,isFolder:!1,data:{name:`New Application`,path:pd,project:``},canMove:!1,canRename:!1},{items:t,rootId:dd}}function hd(e,t){let n=t.path;if(ud(t)){let r=t,i=[],a=[];for(let e of r.entries)ud(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)hd(e,t)}else e[n]={index:n,isFolder:!1,data:t,canMove:!t.package,canRename:!t.package}}function gd(){let[e,t]=(0,Y.useState)(!1),[n,r]=(0,Y.useState)(void 0),i=(0,Y.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,Y.useCallback)(()=>{t(!1),r(e=>{e&&e.classList.remove(`rct-tree-item-title-container-dragging-over`)})},[]),o=(0,Y.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,Y.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,Y.useMemo)(()=>({dragging:e,dragTarget:n}),[e,n])}function _d(e){return new Promise((t,n)=>{let r=new FileReader;r.onabort=n,r.onerror=n,r.onload=t,r.readAsDataURL(e)})}function vd(){let[e,n]=(0,Y.useState)(``),{clusterId:r}=j({strict:!1}),{openedEntry:i,restrictPackageModification:a,reloadRootEntries:o,entryExists:s}=Bu(),c=!!i&&!i.package&&!a,l=K(),{dragging:u,dragTarget:d}=gd(),f=(d?.getAttribute?.(`data-rct-item-id`))?.split?.(`/`)?.pop?.(),h=i?.project,g=!1,_;if(i?.path){let e=i.path.split(`/`),t=ud(i);g=c&&(t?e.slice(1):e.slice(1,-1)).join(`/`),_=e[e.length-(t?1:2)]}let y=(0,Y.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=yd(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`)}
|
|
4
4
|
${e.name}
|
|
5
5
|
${Zr(x)} of ${Zr(b)}`,action:v});let t=yd(a,e),n=(await _d(e)).target.result,r=n.indexOf(`base64,`);m?f.push({file:e,errors:[{message:`${t} cancelled`,code:`cancelled`}]}):(await qu({...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(`
|
|
@@ -40,4 +40,4 @@ Check the console for the full list.`:``)})),n(``)},[d,c,h,g,s,l,o]),{getRootPro
|
|
|
40
40
|
focus-visible:outline-1
|
|
41
41
|
focus-visible:ring-purple-200
|
|
42
42
|
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 Ph({className:e,variant:t,size:n,...r}){return(0,J.jsx)(sr,{"data-slot":`toggle`,className:g(Nh({variant:t,size:n,className:e})),...r})}function Fh(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 Ih=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],Lh=0,Rh=new Map,zh=e=>{if(Rh.has(e))return Rh.get(e);Lh++;let t=Ih[Lh%Ih.length];return Rh.set(e,t),t};function Bh({columns:e,data:t,onRowClick:n}){let r=Ft({data:t,columns:e,getCoreRowModel:Je()});return(0,J.jsx)(`div`,{className:`rounded-md bg-black-dark logsTable`,children:(0,J.jsxs)(Cc,{className:`text-xs`,children:[(0,J.jsx)(wc,{children:r.getHeaderGroups().map(e=>(0,J.jsx)(Ec,{className:`border-none`,children:e.headers.map(e=>(0,J.jsx)(Dc,{className:`p-4 max-w-96`,children:e.isPlaceholder?null:kt(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,J.jsx)(Tc,{className:`bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>(0,J.jsx)(Ec,{"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,J.jsx)(kc,{className:`p-1`,children:kt(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,J.jsx)(Ec,{children:(0,J.jsx)(kc,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function Vh(e){try{JSON.parse(e)}catch{return!1}return!0}function Hh({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?zh(n.node):`default`;return(0,J.jsx)(X,{onOpenChange:e,open:t,children:(0,J.jsxs)(Z,{"aria-describedby":void 0,children:[(0,J.jsx)(po,{children:(0,J.jsx)($,{children:`Edit Row`})}),n?(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 text-white`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`inline-block pr-2`,children:`Level:`}),(0,J.jsx)(go,{variant:Fh(n.level),children:ea(n.level)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{children:`Timestamp:`}),(0,J.jsx)(`p`,{className:`text-sm`,children:n.timestamp})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{children:`Thread:`}),(0,J.jsx)(`p`,{className:`text-sm`,children:n.thread})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{children:`Node:`}),(0,J.jsx)(go,{variant:r,children:n.node})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{children:`Tags:`}),(0,J.jsx)(`p`,{className:`text-sm`,children:n.tags&&n.tags.length>0?(0,J.jsx)(`span`,{children:n.tags}):`N/A`})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-lg font-bold`,children:`Message`}),(0,J.jsx)(Mt,{className:`w-full h-72`,language:Vh(n.message)?`json`:`text`,theme:`vs-dark`,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1}})]})]}):(0,J.jsx)(Fr,{}),(0,J.jsx)(Q,{children:(0,J.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,J.jsxs)(R,{type:`button`,variant:`destructive`,className:`rounded-full`,children:[(0,J.jsx)(hn,{}),` Delete Row`]}),(0,J.jsxs)(R,{variant:`submit`,className:`rounded-full`,children:[(0,J.jsx)(On,{}),` Save Changes`]})]})})]})})}function Uh({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 Wh=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 Gh({form:e,resetFilters:t,submitFilters:n}){return(0,J.jsx)(`div`,{children:(0,J.jsx)(B,{...e,children:(0,J.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,J.jsx)(z,{control:e.control,name:`limit`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{children:`Log Limit:`}),(0,J.jsxs)(ri,{onValueChange:e.onChange,value:e.value,children:[(0,J.jsx)(Xr,{className:`w-full`,children:(0,J.jsx)(ti,{placeholder:`Select log limit`})}),(0,J.jsx)(Jr,{children:(0,J.jsxs)(Qr,{children:[(0,J.jsx)(q,{value:`1000`,children:`1000`}),(0,J.jsx)(q,{value:`500`,children:`500`}),(0,J.jsx)(q,{value:`250`,children:`250`}),(0,J.jsx)(q,{value:`100`,children:`100`}),(0,J.jsx)(q,{value:`10`,children:`10`})]})})]}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:e.control,name:`level`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{children:`Log Level:`}),(0,J.jsxs)(ri,{onValueChange:e.onChange,value:e.value,children:[(0,J.jsx)(Xr,{className:`w-full`,children:(0,J.jsx)(ti,{placeholder:`Select log level`})}),(0,J.jsx)(Jr,{children:(0,J.jsxs)(Qr,{children:[(0,J.jsx)(q,{value:`undefined`,children:`All`}),(0,J.jsx)(q,{value:`notify`,children:`Notify`}),(0,J.jsx)(q,{value:`error`,children:`Error`}),(0,J.jsx)(q,{value:`warn`,children:`Warn`}),(0,J.jsx)(q,{value:`info`,children:`Info`}),(0,J.jsx)(q,{value:`debug`,children:`Debug`}),(0,J.jsx)(q,{value:`trace`,children:`Trace`})]})})]}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:e.control,name:`from`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{children:`Start Date:`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`datetime-local`,value:e.value,onChange:e.onChange})}),(0,J.jsx)(H,{})]})}),(0,J.jsx)(z,{control:e.control,name:`until`,render:({field:e})=>(0,J.jsxs)(V,{children:[(0,J.jsx)(W,{children:`End Date:`}),(0,J.jsx)(U,{children:(0,J.jsx)(G,{type:`datetime-local`,value:e.value,onChange:e.onChange})}),(0,J.jsx)(H,{})]})}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between space-x-2 mt-2`,children:[(0,J.jsx)(R,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,J.jsx)(R,{type:`reset`,variant:`destructiveOutline`,onClick:()=>t(),children:`Clear Filters`})]})]})})})}var Kh={limit:`100`,level:`undefined`,from:``,until:``},qh=[{accessorKey:`level`,header:`Status`,cell:({row:e})=>{let{level:t}=e.original;return(0,J.jsx)(go,{variant:Fh(t),children:ea(t)})}},{accessorKey:`timestamp`,header:`Date`,cell:({row:e})=>{let{timestamp:t}=e.original;return(0,J.jsx)(`span`,{children:new Date(t).toLocaleDateString()})}},{accessorKey:`time`,header:`Time`,cell:({row:e})=>{let{timestamp:t}=e.original;return(0,J.jsx)(`span`,{children:new Date(t).toLocaleTimeString()})}},{accessorKey:`thread`,header:`Thread`},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=zh(t);return(0,J.jsx)(J.Fragment,{children:t?(0,J.jsxs)(Xi,{children:[(0,J.jsx)(Zi,{asChild:!0,children:(0,J.jsxs)(go,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,J.jsx)(Qi,{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,J.jsx)(`pre`,{children:(0,J.jsx)(`code`,{children:t})})}}],Jh=(e,t)=>!e&&!t||!e||!t?!0:new Date(e)<=new Date(t);function Yh(){let[e,t]=(0,Y.useState)(Kh),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(!1),c=K(),{data:l,isLoading:u,refetch:d,isFetching:f}=L(Uh({logFilters:e,...c,replicated:c.entityType===`cluster`,isAutoRefreshEnabled:o})),p=k({resolver:O(Wh),defaultValues:Kh,mode:`onChange`}),m=e=>{a(e.original),r(!0)},h=async e=>{if(!Jh(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(Kh)},_=Pc(d);return(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 text-white md:grid-cols-12`,children:[(0,J.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pt-4 md:pt-12`,children:[(0,J.jsx)(Gh,{form:p,resetFilters:g,submitFilters:h}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between space-x-2 mt-2`,children:[(0,J.jsxs)(R,{variant:`defaultOutline`,onClick:_,disabled:f||u||o,className:`grow`,children:[(0,J.jsx)(Gt,{}),`Refresh`]}),(0,J.jsxs)(Ph,{variant:`outline`,"aria-label":`Toggle Auto Refresh`,onPressedChange:s,children:[(0,J.jsx)(Gt,{}),`Auto Refresh `,o?`On`:`Off`]})]})]}),(0,J.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:u?(0,J.jsx)(`div`,{children:`Loading...`}):(0,J.jsx)(`div`,{children:(0,J.jsx)(Bh,{columns:qh,data:l||[],onRowClick:m})})}),(0,J.jsx)(Hh,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function Xh(e){return P({getParentRoute:()=>e,path:`logs`,component:Yh})}function Zh(e){return P({getParentRoute:()=>e,path:`status`,component:mt(async()=>Gr(()=>import(`./status-BpQLcjsg.js`),__vite__mapDeps([18,1,3,2,4,5,6,7,8,9,10,19,13,20,14])),`StatusIndex`)})}function Qh(e){let t=jh(e),n=[Xh(t),...qf(t),Du(t),Zh(t),Cm(t),Th(t)];return t.addChildren(n)}P({getParentRoute:()=>kl,path:`profile`,component:mt(async()=>Gr(()=>import(`./profile-BuZ1ni1t.js`),__vite__mapDeps([21,1,3,2,4,5,6,7,8,9,10,12,13,22,23,20])),`ProfileIndex`)});var $h=pi.addChildren([...to,kl.addChildren([Qh(`local`)])]);function eg({routeTree:e=$h,authentication:t}){return ze({routeTree:e,history:It(),defaultNotFoundComponent:oi,defaultErrorComponent:jr,defaultPreload:si()?!1:`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:Br,authentication:t||{}}})}function tg(){let e=_r();return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ke,{router:eg({authentication:e}),context:{authentication:e}}),!1]})}var ng=({...e})=>(0,J.jsx)(Ht,{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}),rg=!1,ig=!1;function ag(){(0,Y.useEffect)(()=>{rg||(rg=!0,ig&&(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 og(){return Wi(),ui(),ag(),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Kn,{client:Br,children:[(0,J.jsx)(tg,{}),(0,J.jsx)(Xt,{buttonPosition:`bottom-right`})]}),(0,J.jsx)(ng,{richColors:!0})]})}(0,dr().createRoot)(document.getElementById(`root`),{onUncaughtError:(e,t)=>{Bt(e,t),console.error(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{Bt(e,t),console.error(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{Bt(e,t),console.warn(`Recoverable error:`,e,t)}}).render((0,J.jsx)(Y.StrictMode,{children:(0,J.jsx)(og,{})}));
|
|
43
|
-
//# sourceMappingURL=index-
|
|
43
|
+
//# sourceMappingURL=index-C0And10y.js.map
|