@harperfast/harper 5.0.28 → 5.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/config-root.schema.json +4 -0
  2. package/dist/resources/RecordEncoder.d.ts +11 -0
  3. package/dist/resources/RecordEncoder.js +57 -4
  4. package/dist/resources/RecordEncoder.js.map +1 -1
  5. package/dist/resources/Table.js +22 -0
  6. package/dist/resources/Table.js.map +1 -1
  7. package/dist/resources/auditStore.js +5 -1
  8. package/dist/resources/auditStore.js.map +1 -1
  9. package/dist/resources/databases.js +9 -9
  10. package/dist/resources/databases.js.map +1 -1
  11. package/dist/utility/hdbTerms.d.ts +1 -0
  12. package/dist/utility/hdbTerms.js +1 -0
  13. package/dist/utility/hdbTerms.js.map +1 -1
  14. package/package.json +2 -2
  15. package/resources/RecordEncoder.ts +56 -3
  16. package/resources/Table.ts +23 -0
  17. package/resources/auditStore.ts +4 -1
  18. package/resources/databases.ts +10 -10
  19. package/static/defaultConfig.yaml +1 -0
  20. package/studio/web/assets/{index-BJjklK4V.js → index-BFZovM68.js} +5 -5
  21. package/studio/web/assets/{index-BJjklK4V.js.map → index-BFZovM68.js.map} +1 -1
  22. package/studio/web/assets/{index.lazy-DPTCQseJ.js → index.lazy-CTCt7C_C.js} +2 -2
  23. package/studio/web/assets/{index.lazy-DPTCQseJ.js.map → index.lazy-CTCt7C_C.js.map} +1 -1
  24. package/studio/web/assets/{profile-D77bwywc.js → profile-Dy4qT0vm.js} +2 -2
  25. package/studio/web/assets/{profile-D77bwywc.js.map → profile-Dy4qT0vm.js.map} +1 -1
  26. package/studio/web/assets/{status-ChxVrrli.js → status-DQBR5qBd.js} +2 -2
  27. package/studio/web/assets/{status-ChxVrrli.js.map → status-DQBR5qBd.js.map} +1 -1
  28. package/studio/web/index.html +1 -1
  29. package/utility/hdbTerms.ts +1 -0
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index.lazy-DPTCQseJ.js","assets/rolldown-runtime-Cyuzqnbw.js","assets/vendor-datadog-xl5t1ffd.js","assets/vendor-react-Cyct1o5I.js","assets/vendor-core-8FI3Cbaa.js","assets/vendor-misc-Bj3r0doz.js","assets/vendor-markdown-QRBWuGNe.js","assets/vendor-html-CubNlVgM.js","assets/vendor-monaco-DXu1dQeO.js","assets/vendor-charts-BCMLE3XK.js","assets/vendor-react-CrIa5r46.css","assets/button-BqaHkv91.js","assets/index-bNiPLS8i.css","assets/vendor-viz-DlC3nLj3.js","assets/status-ChxVrrli.js","assets/profile-D77bwywc.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{_ as t,a as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as _,v,y}from"./button-BqaHkv91.js";import{At as b,Bt as x,Dt as S,Et as C,Mt as ee,Nt as w,Ot as te,Pt as ne,St as T,Tt as E,bt as D,jt as O,kt as re,wt as ie,xt as ae,yt as k,zt as oe}from"./vendor-core-8FI3Cbaa.js";import{$n as se,$r as ce,$t as le,Aa as ue,Ai as de,An as fe,Ar as pe,Ba as A,Bi as me,Bn as he,Br as ge,Bt as _e,Ca as ve,Ci as ye,Cn as be,Cr as xe,Da as j,Di as Se,Dn as Ce,Dr as we,Ea as M,Ei as Te,En as Ee,Er as De,Fa as Oe,Fi as ke,Fn as Ae,Fr as je,Gi as Me,Gn as Ne,Gr as Pe,Gt as Fe,Ha as Ie,Hi as Le,Hn as Re,Hr as ze,Ht as Be,Ia as Ve,Ii as He,In as Ue,Ir as We,Ji as Ge,Jn as Ke,Jr as qe,Jt as Je,Ki as Ye,Kn as N,Kr as Xe,Kt as Ze,La as P,Li as Qe,Ln as $e,Lr as et,Ma as F,Mi as tt,Mn as nt,Mt as rt,Na as it,Ni as at,Nn as ot,Nr as st,Nt as ct,Oa as lt,Oi as ut,On as dt,Or as ft,Pa as pt,Pi as mt,Pn as ht,Pr as gt,Pt as _t,Qa as vt,Qi as yt,Qn as bt,Qt as xt,Ra as I,Ri as St,Rn as Ct,Rr as wt,Rt as Tt,Sa as Et,Si as Dt,Sn as Ot,Sr as kt,Ta as At,Tn as jt,Tr as Mt,Ua as Nt,Ui as Pt,Un as Ft,Ur as It,Ut as Lt,Va as Rt,Vn as zt,Vr as Bt,Vt,Wa as Ht,Wn as Ut,Wr as Wt,Wt as Gt,Xi as Kt,Xn as qt,Xt as Jt,Yi as Yt,Yn as Xt,Yr as Zt,Yt as Qt,Zn as L,Zr as $t,Zt as en,_a as tn,_i as nn,_n as rn,aa as an,ai as on,an as sn,ar as cn,ba as ln,bi as un,bn as dn,br as fn,ca as pn,ci as mn,cn as hn,cr as gn,da as _n,di as vn,dn as yn,dr as bn,ea as xn,ei as Sn,en as Cn,er as wn,fa as Tn,fi as En,fn as Dn,fr as On,ga as kn,gi as An,gn as jn,gr as Mn,ha as Nn,hi as Pn,hn as Fn,hr as In,ii as Ln,in as Rn,ir as zn,ja as Bn,ji as Vn,jn as Hn,jr as Un,jt as Wn,ka as Gn,ki as Kn,kn as qn,kr as Jn,la as Yn,li as Xn,ln as Zn,lr as Qn,ma as $n,mi as er,mn as tr,mr as R,na as nr,ni as rr,nn as ir,nr as ar,oi as or,on as sr,or as cr,pa as lr,pn as ur,pr as dr,qi as fr,qn as pr,qr as mr,qt as hr,ri as gr,rn as _r,rr as vr,sa as yr,si as br,sn as xr,sr as Sr,ta as Cr,tn as wr,tr as Tr,ua as Er,ui as Dr,un as Or,ur as kr,va as Ar,vi as jr,vn as Mr,vr as Nr,wi as Pr,wn as Fr,wr as Ir,xa as Lr,xi as Rr,xn as zr,xr as Br,ya as Vr,yi as Hr,yn as Ur,yr as Wr,za as Gr,zi as Kr,zn as qr,zr as Jr,zt as Yr}from"./vendor-react-Cyct1o5I.js";import{n as Xr,r as Zr,t as Qr}from"./vendor-tanstack-CsvCwFmI.js";import{n as $r,t as ei}from"./vendor-datadog-xl5t1ffd.js";import{Br as ti,Fr as ni,Gr as ri,Hr as ii,Ir as ai,Jr as oi,Kr as si,Lr as ci,Mr as li,Nr as ui,Pr as di,Ur as fi,Vr as pi,Wr as mi,Xr as hi,Yr as gi,qr as _i,zr as vi}from"./vendor-misc-Bj3r0doz.js";import"./vendor-stripe-5RM5oC9f.js";import{t as yi}from"./vendor-markdown-QRBWuGNe.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var z=e(Ht(),1);function bi(){let[e,t]=(0,z.useState)(c.getAllConnections());return(0,z.useEffect)(()=>c.listenToAllEntities((n,r)=>{t({...e,[r]:n})}),[e]),e}function xi(){let e=c.calculateIdFromEntity(m),[t,n]=(0,z.useState)(c.getConnectionById(m));return(0,z.useEffect)(()=>c.listenToEntity(e,n),[e]),t}function Si(){return xi()}function Ci(){let{user:e}=Si();return wi(e)}function wi(e){return e?.fabricRole===`fabric_admin`||e?.fabricRole===`super_user`}function Ti(e){let t=m,{clusterId:n,instanceId:r}=F({strict:!1}),[i,a]=(0,z.useState)(c.getConnectionById(t??r??n));return(0,z.useEffect)(()=>c.listenToEntity(t,a),[t]),i}var B=Nt();function Ei({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card`,className:d(`bg-card text-card-foreground flex flex-col gap-4 rounded-2xl py-5 shadow-deep ring-1 ring-black/5 dark:ring-white/5`,e),...t})}function Di({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-header`,className:d(`flex flex-col gap-1.5 px-6`,e),...t})}function Oi({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-title`,className:d(`leading-none text-lg`,e),...t})}function ki({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-description`,className:d(`text-muted-foreground text-xs`,e),...t})}function Ai({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-content`,className:d(`px-6`,e),...t})}function ji(e){return e!==null&&!!e.username}function Mi(e){if(e&&!ji(e)){let t=Object.keys(e.roles);if(t.length===1)return`/${t[0]}`}return`/`}function Ni({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=xi();return Mi(a),(0,B.jsxs)(Ei,{className:d(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,B.jsxs)(Di,{children:[(0,B.jsx)(Oi,{className:`text-2xl`,children:(0,B.jsx)(`h2`,{children:n??`Component Error`})}),(0,B.jsx)(ki,{children:t.message})]}),(0,B.jsxs)(Ai,{children:[i,r!==!1&&(a&&!o?(0,B.jsx)(j,{to:`/`,children:(0,B.jsxs)(g,{children:[` `,(0,B.jsx)(lr,{}),` Return to Home`]})}):(0,B.jsx)(j,{to:`/sign-in`,children:(0,B.jsxs)(g,{children:[` `,(0,B.jsx)(lr,{}),` Go to Sign In Page`]})}))]})]})}function Pi(){let{user:e,isLoading:t}=xi();return Mi(e),(0,B.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,B.jsxs)(Ei,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,B.jsx)(Di,{children:(0,B.jsx)(Oi,{className:`text-2xl`,children:(0,B.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,B.jsx)(Ai,{children:e&&!t?(0,B.jsx)(j,{to:`/`,children:(0,B.jsxs)(g,{children:[` `,(0,B.jsx)(lr,{}),` Return to Home`]})}):(0,B.jsx)(j,{to:`/sign-in`,children:(0,B.jsxs)(g,{children:[` `,(0,B.jsx)(lr,{}),` Go Sign In Page`]})})})]})})}function Fi(){return`ontouchstart`in window||navigator.maxTouchPoints>0}function Ii(e){let t=`Error`,n=`We had some trouble!`;console.error(e);let r=e,i=e;if(typeof e==`string`?n=e:r?.response?.data?typeof r.response.data==`string`?n=r.response.data:r.response.data.error?n=r.response.data.error:r.response.data.message&&(n=r.response.data.message):i?.message&&(n=i.message),n.includes(`:`)){let e=n.split(`:`);t=e.shift(),n=e.join(`:`)}let a=r?.code===`ECONNABORTED`||r?.code===`ETIMEDOUT`;R.error(t,{id:a?`request-timeout`:void 0,description:n,action:{label:`Dismiss`,onClick:()=>R.dismiss()}})}var Li=new Qr({queryCache:new Xr({onError:Ii}),mutationCache:new Zr({onError:Ii})});function Ri(e){return!!e}var zi=!1,Bi=!1;function Vi(e){if(e.type!==`error`)return!0;let t=e.error?.message??``,n=e.error?.source;if(/Request aborted/i.test(t)||t.includes(`Fabric Connect not established`))return!1;let r=e.error?.resource?.url??``,i=/\/(HDBInstance|Cluster)\/[^/]+\/operation/.test(r),a=/timeout of \d+ms exceeded/i.test(t)||/Network Error/i.test(t)||n===`network`;return!(i&&a)}function Hi(){(0,z.useEffect)(()=>{zi||(zi=!0,Bi&&(ei.init({applicationId:`f590deee-4bac-49b4-a202-3b6963d9721d`,clientToken:`pub27aa29cea521492f4fef73032f86a023`,site:`datadoghq.com`,service:`studio`,env:void 0,version:`v5.0.28`,trackViewsManually:!0,trackUserInteractions:!0,beforeSend:Vi,sessionSampleRate:100,sessionReplaySampleRate:0,defaultPrivacyLevel:`mask`,plugins:[On()]}),ei.onReady(()=>{ei.startView({service:`studio`,version:`v5.0.28`,name:window.location.pathname||`initial`})})))},[])}function Ui(e){if(!Bi)return;ei.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)?ei.addAction(`return_login`):(ei.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&&ei.addAction(`login_time_gap`,{value:e})}localStorage.setItem(n,String(i)),ei.addAction(`login_success`,{userId:e.id})}function Wi(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Ar,{}),(0,B.jsx)(Et,{})]})}var Gi=At()({component:Wi});function Ki(){return(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,B.jsx)(`path`,{fill:`currentColor`,d:`M81.15,0c-1.2376,2.1973-2.3489,4.4704-3.3591,6.794-9.5975-1.4396-19.3718-1.4396-28.9945,0-.985-2.3236-2.1216-4.5967-3.3591-6.794-9.0166,1.5407-17.8059,4.2431-26.1405,8.0568C2.779,32.5304-1.6914,56.3725.5312,79.8863c9.6732,7.1476,20.5083,12.603,32.0505,16.0884,2.6014-3.4854,4.8998-7.1981,6.8698-11.0623-3.738-1.3891-7.3497-3.1318-10.8098-5.1523.9092-.6567,1.7932-1.3386,2.6519-1.9953,20.281,9.547,43.7696,9.547,64.0758,0,.8587.7072,1.7427,1.3891,2.6519,1.9953-3.4601,2.0457-7.0718,3.7632-10.835,5.1776,1.97,3.8642,4.2683,7.5769,6.8698,11.0623,11.5419-3.4854,22.3769-8.9156,32.0509-16.0631,2.626-27.2771-4.496-50.9172-18.817-71.8548C98.9811,4.2684,90.1918,1.5659,81.1752.0505l-.0252-.0505ZM42.2802,65.4144c-6.2383,0-11.4159-5.6575-11.4159-12.6535s4.9755-12.6788,11.3907-12.6788,11.5169,5.708,11.4159,12.6788c-.101,6.9708-5.026,12.6535-11.3907,12.6535ZM84.3576,65.4144c-6.2637,0-11.3907-5.6575-11.3907-12.6535s4.9755-12.6788,11.3907-12.6788,11.4917,5.708,11.3906,12.6788c-.101,6.9708-5.026,12.6535-11.3906,12.6535Z`})})}function qi(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`img`,{src:`/harper-studio_white.png`,alt:`Harper Studio`,className:`w-64 hidden md:inline-block`}),(0,B.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}function Ji(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 Yi(e,t){return Ji(localStorage.getItem(e))??t}function Xi(e,t){t==null?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}function Zi(e,t){let n=(0,z.useState)(Yi(e,t)),[r]=n;return(0,z.useEffect)(()=>Xi(e,r),[e,r]),n}function Qi(){let[e,t]=(0,z.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);return(0,z.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=e=>t(e.matches?`dark`:`light`);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var $i=function(e){return e.ApplicationChatPosition=`ApplicationChatPosition`,e.ApplicationChatWidth=`ApplicationChatWidth`,e.ChatAlwaysApprovedTools=`ChatAlwaysApprovedTools`,e.SavedClusterState=`SavedClusterState`,e.Theme=`Theme`,e}({}),ea=(0,z.createContext)([`system`,()=>{}]);function ta({children:e}){let[t,n]=Zi($i.Theme,`system`),r=Qi();return(0,z.useEffect)(()=>{let e=t===`dark`||t===`system`&&r===`dark`;document.documentElement.classList.toggle(`dark`,e)},[t,r]),(0,B.jsx)(ea.Provider,{value:[t,n],children:e})}function na(){return(0,z.useContext)(ea)}var ra=[{value:`light`,icon:(0,B.jsx)(Mt,{className:`size-4`}),label:`Light`},{value:`system`,icon:(0,B.jsx)(Zt,{className:`size-4`}),label:`System`},{value:`dark`,icon:(0,B.jsx)(qe,{className:`size-4`}),label:`Dark`}];function ia(){let[e,t]=na();return(0,B.jsx)(`div`,{className:`flex items-center bg-muted dark:bg-black rounded-xl p-0.5 gap-0.5`,children:ra.map(({value:n,icon:r,label:i})=>(0,B.jsx)(`button`,{type:`button`,title:i,onClick:()=>t(n),className:`p-1.5 rounded-lg transition-colors ${e===n?`bg-background text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`}`,children:r},n))})}function aa({className:e,...t}){return(0,B.jsx)(`div`,{className:d(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,B.jsx)(kr,{"data-slot":`navigation-menu-viewport`,className:d(`origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--radix-navigation-menu-viewport-width)]`,e),...t})})}function oa({className:e,children:t,viewport:n=!0,...r}){return(0,B.jsxs)(Qn,{"data-slot":`navigation-menu`,"data-viewport":n,className:d(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,B.jsx)(aa,{})]})}function sa({className:e,...t}){return(0,B.jsx)(cr,{"data-slot":`navigation-menu-item`,className:d(`relative`,e),...t})}function ca({className:e,...t}){return(0,B.jsx)(Sr,{"data-slot":`navigation-menu-link`,className:d(`hover:text-foreground dark:hover:text-white ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 flex flex-col gap-1 rounded-sm p-2 text-sm transition-[color,box-shadow] focus-visible:ring-4 focus-visible:outline-1 [&_svg:not([class*='size-'])]:size-4`,e),...t})}function la({className:e,...t}){return(0,B.jsx)(gn,{"data-slot":`navigation-menu-list`,className:d(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}var ua=oe(`inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-auto`,{variants:{variant:{default:`border-primary bg-primary/40 text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-secondary bg-secondary/40 text-secondary-foreground [a&]:hover:bg-secondary/90`,warning:`border-yellow bg-yellow/40 text-foreground [a&]:hover:bg-yellow/90`,success:`border-green bg-green/40 text-foreground [a&]:hover:bg-green/90`,destructive:`border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`,outline:`text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`}},defaultVariants:{variant:`default`}});function da(){let e=`v5.0.28`;return(0,B.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,B.jsxs)(`span`,{className:d(ua({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function fa(e={}){let{instanceId:t,clusterId:n}=F({strict:!1});return a({id:m,...e})}function pa(e={}){let{instanceId:t,clusterId:n}=F({strict:!1});return{instanceClient:a({id:m,...e}),entityType:`instance`}}function V(e={}){let{instanceId:t,clusterId:n}=F({strict:!1});return(0,z.useMemo)(()=>ma({instanceId:t,clusterId:n,...e}),[e.instanceId??t,e.clusterId??n,e.operationsUrl,e.port,e.secure,e.disableFabricConnect,e.forceFabricConnect])}function ma({instanceId:e,clusterId:t,...n}){let r=m;if(!r)throw Error(`id could not be automatically calculated in useInstanceClientIdParams`);return{instanceClient:a({id:r,...n}),entityId:r,entityType:`instance`}}function ha(){localStorage.clear()}function ga(){sessionStorage.clear()}async function _a(){c.setUserForEntity(m,null),Li.getQueryCache().clear(),ha(),ga(),await Li.invalidateQueries({refetchType:`none`})}async function va(e){await c.signOutFromPotentiallyAuthenticatedInstances(),await r({...e,entityId:m})}function ya(){let e=fa();return P({mutationFn:()=>va({instanceClient:e}),onSuccess:_a})}function ba(e){let{user:t}=Si(),{organizationId:n}=F({strict:!1});if(wi(t))return{update:!0,remove:!0};let 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 xa(e){let{user:t}=Si(),{organizationId:n}=F({strict:!1});if(wi(t))return{create:!0,remove:!0,update:!0,view:!0};let 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 Sa(e,t){let{user:n}=Si(),{organizationId:r,clusterId:i}=F({strict:!1});return Ca(n,e??r,t??i)}function Ca(e,t,n){if(wi(e))return{create:!0,remove:!0,update:!0,view:!0};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 wa(e,t){let{user:n}=Si(),{organizationId:r,clusterId:i}=F({strict:!1});return Ta(n,e??r,t??i)}function Ta(e,t,n){if(wi(e))return{create:!0,remove:!0,update:!0,view:!0};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 Ea(e){let{clusterId:t,instanceId:n}=F({strict:!1}),{user:r}=Ti(e??n??t),i=r?.role?.permission;return i?i.super_user===!0:!1}function Da(e){let{clusterId:t,instanceId:n}=F({strict:!1}),{user:r}=Ti(e??n??t),i=r?.role?.permission;return i?i.super_user===!0||i.structure_user===!0:!1}function Oa(e,t,n,r){let{clusterId:i,instanceId:a}=F({strict:!1}),{user:o}=Ti(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 ka={className:`text-foreground dark:text-white font-semibold`};function Aa(){let{mutate:e}=ya(),t=ue(),{user:n}=xi(),r=pt(),{organizationId:i}=F({strict:!1}),{update:a}=ba(i),{view:o}=xa(i),s=a,c=(0,z.useCallback)(()=>{e(void 0,{onSuccess:async()=>{R.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>R.dismiss()}}),t({to:`/sign-in`}),r.invalidate()}})},[e,r,t]),l=(0,z.useMemo)(()=>[!1,!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,B.jsx)(an,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,B.jsx)(xn,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,B.jsx)(Ki,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:c,icon:(0,B.jsx)(rr,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(Ri),[i,s,o,c]);return n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Fa,{menuItems:l}),(0,B.jsx)(Na,{menuItems:l})]}):(0,B.jsx)(Ma,{})}function ja(e){return e.items!==void 0}function Ma(){return(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`inline-block`,children:[(0,B.jsx)(j,{to:`/sign-in`,children:(0,B.jsx)(qi,{})}),(0,B.jsx)(da,{})]}),(0,B.jsx)(oa,{children:(0,B.jsxs)(la,{className:`text-muted-foreground dark:text-grey-400`,children:[(0,B.jsx)(sa,{children:(0,B.jsx)(ca,{asChild:!0,children:(0,B.jsxs)(j,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,B.jsx)(an,{}),` `,(0,B.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,B.jsx)(sa,{children:(0,B.jsx)(ia,{})}),(0,B.jsx)(sa,{children:(0,B.jsx)(ca,{asChild:!0,children:(0,B.jsxs)(j,{to:`/sign-in`,className:`flex-row items-center`,activeProps:ka,children:[(0,B.jsx)(gr,{}),` Sign In`]})})})]})})]})}function Na({menuItems:e}){let{user:t}=xi();return Mi(t),(0,B.jsx)(`div`,{className:`hidden md:block`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`inline-block`,children:[(0,B.jsx)(j,{to:`/`,children:(0,B.jsx)(qi,{})}),(0,B.jsx)(da,{})]}),(0,B.jsx)(oa,{children:(0,B.jsxs)(la,{className:`text-muted-foreground dark:text-grey-400`,children:[e.map(e=>ja(e)?!!e.items.length&&(0,B.jsx)(`div`,{className:`bg-muted dark:bg-black rounded-2xl flex`,children:e.items.map(e=>(0,B.jsx)(Pa,{menuItem:e},e.text))},e.text):(0,B.jsx)(Pa,{menuItem:e},e.text)),(0,B.jsx)(sa,{children:(0,B.jsx)(ia,{})})]})})]})})}function Pa({menuItem:e}){return(0,B.jsx)(sa,{className:`text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,children:(0,B.jsx)(ca,{asChild:!0,children:(0,B.jsxs)(j,{to:e.to,onClick:e.onClick,className:`flex-row items-center`,target:e.target,activeProps:e.to?ka:void 0,children:[e.icon,(0,B.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,B.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})})}function Fa({menuItems:e}){let{user:t}=xi();Mi(t);let[n,r]=(0,z.useState)(!1),i=(0,z.useCallback)(()=>r(e=>!e),[]),a=(0,z.useCallback)(()=>r(!1),[]);return(0,B.jsxs)(`div`,{className:`md:hidden`,id:`mobile-menu`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(j,{to:`/`,children:(0,B.jsx)(qi,{})}),(0,B.jsx)(da,{}),(0,B.jsxs)(`button`,{type:`button`,className:`shadow-xs text-muted-foreground dark:text-grey-400 hover:text-foreground dark:hover:text-white hover:bg-muted dark:hover:bg-black-dark`,onClick:i,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,B.jsx)(In,{}):(0,B.jsx)($t,{})]})]}),(0,B.jsx)(`div`,{className:`${n?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-foreground/20 dark:bg-black-dark dark:opacity-70`,onClick:a}),(0,B.jsxs)(`div`,{className:`${n?`block`:`hidden`} md:hidden z-50 space-y-1 pb-3 bg-card border-b border-border dark:bg-black-dark dark:border-none absolute left-0 top-full w-full rounded-b-md`,children:[(0,B.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,B.jsx)(ia,{})}),e.map(e=>ja(e)?!!e.items.length&&(0,B.jsx)(`div`,{className:`bg-muted dark:bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,B.jsx)(Ia,{menuItem:e,onClick:a},e.text))},e.text):(0,B.jsx)(Ia,{menuItem:e,onClick:a},e.text))]})]})}function Ia({menuItem:e,onClick:t}){let n=(0,z.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,B.jsxs)(j,{to:e.to,onClick:n,target:e.target,className:`flex flex-row px-3 py-2 text-base font-medium rounded-md text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,activeProps:e.to?ka:void 0,children:[e.icon,(0,B.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function La(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-gradient-to-r from-violet-100 to-white border-b border-violet-200 dark:from-purple-950 dark:to-zinc-900 dark:border-purple-950 md:px-12`,children:(0,B.jsx)(Aa,{})}),(0,B.jsxs)(`div`,{className:`pt-20 h-screen grid grid-cols-1 md:grid-cols-2`,children:[(0,B.jsx)(`section`,{"aria-label":`Harper Fabric overview`,className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,B.jsx)(`img`,{className:`object-scale-down max-h-[calc(100vh-80px-40px)] min-h-115`,src:`/fabric-signup-text.png`,alt:`One Runtime: App, database, Cache and Messaging. Distributed by design, free to deploy, and live in minutes. Deploy!`})}),(0,B.jsx)(`main`,{className:`overflow-y-auto px-6 bg-white dark:bg-linear-(--black-dark-gradient) border-l border-border dark:border-none`,children:(0,B.jsx)(`div`,{className:`min-h-full flex items-start justify-center py-12`,children:(0,B.jsx)(Et,{})})})]})]})}var Ra;function za(){(0,z.useEffect)(()=>{},[])}var Ba=[`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 Va(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of Ba)if(t===e||t.endsWith(`.`+e))return null;return t}var Ha=null;function Ua(){let e=ue(),t=pt(),n=Ie(),{redirect:r}=Bn({strict:!1});return(0,z.useEffect)(()=>{Ha||=(async function(){let i=await _().catch(()=>null);if(!i)R.error(`We were not able to verify your sign-in. Please try signing in again.`,{duration:1e4}),await e({to:`/sign-in`});else{c.setUserForEntity(m,i);let a=Mi(i);Ui(i);let o=Va(i.email);Ra?.identify?.({username:i.email,type:`email`,...o?{company:o}:{}}),await n.invalidateQueries({queryKey:l,refetchType:`none`}),await t.invalidate(),await e({to:r?.startsWith(`/`)?r:a})}Ha=null})()},[]),(0,B.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,B.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,B.jsx)(`div`,{className:`underline flex gap-4`,children:(0,B.jsx)(j,{className:`text-sm opacity-50 text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/sign-in`,children:`Try signing in again`})})]})}function Wa({delayDuration:e=0,...t}){return(0,B.jsx)(vr,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Ga({...e}){return(0,B.jsx)(Wa,{children:(0,B.jsx)(zn,{"data-slot":`tooltip`,...e})})}function Ka({...e}){return(0,B.jsx)(cn,{"data-slot":`tooltip-trigger`,...e})}function qa({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,B.jsx)(ar,{children:(0,B.jsxs)(Tr,{"data-slot":`tooltip-content`,sideOffset:t,className:d(`bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...i,children:[r,(0,B.jsx)(wn,{className:d(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}var Ja=new Map;function Ya(e){if(!e)return``;if(Ja.has(e))return Ja.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return Ja.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return Ja.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(Xa).join(` `);return Ja.set(e,i),i}function Xa(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Za({restartRequired:e}){let t=Vr(),{organization:n,instance:r,cluster:i}=lt({strict:!1});return(0,B.jsxs)(`div`,{role:`list`,className:`flex items-center space-x-2 xl:space-x-4 sm:max-w-9/10 max-w-[calc(100%-56px)]`,children:[...(0,z.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,B.jsxs)(j,{to:`/`,children:[(0,B.jsx)(Dr,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Home`})]},`home`)];for(let t=0;t<e.length;t++){let o=e[t];if(o===`instance`)continue;let s=`/${e.slice(0,t+1).join(`/`)}`,c=Ya(o);o===`databases`&&e.length===t+3?(c=e[t+2],t+=2):c.startsWith(`Org `)?c=n?.name||`Org`:c.startsWith(`Clu `)?(c=i?.name||`Cluster`,e[t+1]===`instance`&&(s+=`/instances`)):c.startsWith(`Ins `)?c=r?.name?.split(`.`)?.shift()||`Instance`:c===`Apis`&&(c=`APIs`),a.push((0,B.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,B.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,B.jsx)(j,{to:s,className:`text-xs md:text-sm font-medium hover:text-grey truncate max-w-48`,children:c},s))}return a},[t.pathname,i?.name,r?.name,n?.name]),e&&(0,B.jsxs)(Ga,{children:[(0,B.jsx)(Ka,{asChild:!0,children:(0,B.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,B.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,B.jsxs)(qa,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,B.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var H=Xt,Qa=(0,z.createContext)({}),$a=(0,z.createContext)({});function eo(){let e=(0,z.useContext)(Qa),t=(0,z.useContext)($a),{getFieldState:n}=bt(),r=se({name:e.name}),i=n(e.name,r);if(!e)throw Error(`useFormField should be used within <FormField>`);let{id:a}=t;return{id:a,name:e.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...i}}function U({...e}){let{error:t,formItemId:n,formDescriptionId:r,formMessageId:i}=eo();return(0,B.jsx)(tn,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function W({...e}){return(0,B.jsx)(Qa,{value:{name:e.name},children:(0,B.jsx)(Ke,{...e})})}function G({className:e,...t}){return(0,B.jsx)($a,{value:{id:(0,z.useId)()},children:(0,B.jsx)(`div`,{"data-slot":`form-item`,className:d(`grid gap-2`,e),...t})})}function to({className:e,...t}){return(0,B.jsx)(pr,{"data-slot":`label`,className:d(`text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function K({className:e,...t}){let{error:n,formItemId:r}=eo();return(0,B.jsx)(to,{"data-slot":`form-label`,"data-error":!!n,className:d(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function q({className:e,...t}){let{error:n,formMessageId:r}=eo(),i=n?String(n?.message):t.children;return i?(0,B.jsx)(`p`,{"data-slot":`form-message`,id:r,className:d(`text-destructive text-sm`,e),...t,children:i}):null}function J({className:e,type:t,...n}){return(0,B.jsx)(`input`,{type:t,"data-slot":`input`,className:d(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index.lazy-CTCt7C_C.js","assets/rolldown-runtime-Cyuzqnbw.js","assets/vendor-datadog-xl5t1ffd.js","assets/vendor-react-Cyct1o5I.js","assets/vendor-core-8FI3Cbaa.js","assets/vendor-misc-Bj3r0doz.js","assets/vendor-markdown-QRBWuGNe.js","assets/vendor-html-CubNlVgM.js","assets/vendor-monaco-DXu1dQeO.js","assets/vendor-charts-BCMLE3XK.js","assets/vendor-react-CrIa5r46.css","assets/button-BqaHkv91.js","assets/index-bNiPLS8i.css","assets/vendor-viz-DlC3nLj3.js","assets/status-DQBR5qBd.js","assets/profile-Dy4qT0vm.js"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{_ as t,a as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as _,v,y}from"./button-BqaHkv91.js";import{At as b,Bt as x,Dt as S,Et as C,Mt as ee,Nt as w,Ot as te,Pt as ne,St as T,Tt as E,bt as D,jt as O,kt as re,wt as ie,xt as ae,yt as k,zt as oe}from"./vendor-core-8FI3Cbaa.js";import{$n as se,$r as ce,$t as le,Aa as ue,Ai as de,An as fe,Ar as pe,Ba as A,Bi as me,Bn as he,Br as ge,Bt as _e,Ca as ve,Ci as ye,Cn as be,Cr as xe,Da as j,Di as Se,Dn as Ce,Dr as we,Ea as M,Ei as Te,En as Ee,Er as De,Fa as Oe,Fi as ke,Fn as Ae,Fr as je,Gi as Me,Gn as Ne,Gr as Pe,Gt as Fe,Ha as Ie,Hi as Le,Hn as Re,Hr as ze,Ht as Be,Ia as Ve,Ii as He,In as Ue,Ir as We,Ji as Ge,Jn as Ke,Jr as qe,Jt as Je,Ki as Ye,Kn as N,Kr as Xe,Kt as Ze,La as P,Li as Qe,Ln as $e,Lr as et,Ma as F,Mi as tt,Mn as nt,Mt as rt,Na as it,Ni as at,Nn as ot,Nr as st,Nt as ct,Oa as lt,Oi as ut,On as dt,Or as ft,Pa as pt,Pi as mt,Pn as ht,Pr as gt,Pt as _t,Qa as vt,Qi as yt,Qn as bt,Qt as xt,Ra as I,Ri as St,Rn as Ct,Rr as wt,Rt as Tt,Sa as Et,Si as Dt,Sn as Ot,Sr as kt,Ta as At,Tn as jt,Tr as Mt,Ua as Nt,Ui as Pt,Un as Ft,Ur as It,Ut as Lt,Va as Rt,Vn as zt,Vr as Bt,Vt,Wa as Ht,Wn as Ut,Wr as Wt,Wt as Gt,Xi as Kt,Xn as qt,Xt as Jt,Yi as Yt,Yn as Xt,Yr as Zt,Yt as Qt,Zn as L,Zr as $t,Zt as en,_a as tn,_i as nn,_n as rn,aa as an,ai as on,an as sn,ar as cn,ba as ln,bi as un,bn as dn,br as fn,ca as pn,ci as mn,cn as hn,cr as gn,da as _n,di as vn,dn as yn,dr as bn,ea as xn,ei as Sn,en as Cn,er as wn,fa as Tn,fi as En,fn as Dn,fr as On,ga as kn,gi as An,gn as jn,gr as Mn,ha as Nn,hi as Pn,hn as Fn,hr as In,ii as Ln,in as Rn,ir as zn,ja as Bn,ji as Vn,jn as Hn,jr as Un,jt as Wn,ka as Gn,ki as Kn,kn as qn,kr as Jn,la as Yn,li as Xn,ln as Zn,lr as Qn,ma as $n,mi as er,mn as tr,mr as R,na as nr,ni as rr,nn as ir,nr as ar,oi as or,on as sr,or as cr,pa as lr,pn as ur,pr as dr,qi as fr,qn as pr,qr as mr,qt as hr,ri as gr,rn as _r,rr as vr,sa as yr,si as br,sn as xr,sr as Sr,ta as Cr,tn as wr,tr as Tr,ua as Er,ui as Dr,un as Or,ur as kr,va as Ar,vi as jr,vn as Mr,vr as Nr,wi as Pr,wn as Fr,wr as Ir,xa as Lr,xi as Rr,xn as zr,xr as Br,ya as Vr,yi as Hr,yn as Ur,yr as Wr,za as Gr,zi as Kr,zn as qr,zr as Jr,zt as Yr}from"./vendor-react-Cyct1o5I.js";import{n as Xr,r as Zr,t as Qr}from"./vendor-tanstack-CsvCwFmI.js";import{n as $r,t as ei}from"./vendor-datadog-xl5t1ffd.js";import{Br as ti,Fr as ni,Gr as ri,Hr as ii,Ir as ai,Jr as oi,Kr as si,Lr as ci,Mr as li,Nr as ui,Pr as di,Ur as fi,Vr as pi,Wr as mi,Xr as hi,Yr as gi,qr as _i,zr as vi}from"./vendor-misc-Bj3r0doz.js";import"./vendor-stripe-5RM5oC9f.js";import{t as yi}from"./vendor-markdown-QRBWuGNe.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var z=e(Ht(),1);function bi(){let[e,t]=(0,z.useState)(c.getAllConnections());return(0,z.useEffect)(()=>c.listenToAllEntities((n,r)=>{t({...e,[r]:n})}),[e]),e}function xi(){let e=c.calculateIdFromEntity(m),[t,n]=(0,z.useState)(c.getConnectionById(m));return(0,z.useEffect)(()=>c.listenToEntity(e,n),[e]),t}function Si(){return xi()}function Ci(){let{user:e}=Si();return wi(e)}function wi(e){return e?.fabricRole===`fabric_admin`||e?.fabricRole===`super_user`}function Ti(e){let t=m,{clusterId:n,instanceId:r}=F({strict:!1}),[i,a]=(0,z.useState)(c.getConnectionById(t??r??n));return(0,z.useEffect)(()=>c.listenToEntity(t,a),[t]),i}var B=Nt();function Ei({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card`,className:d(`bg-card text-card-foreground flex flex-col gap-4 rounded-2xl py-5 shadow-deep ring-1 ring-black/5 dark:ring-white/5`,e),...t})}function Di({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-header`,className:d(`flex flex-col gap-1.5 px-6`,e),...t})}function Oi({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-title`,className:d(`leading-none text-lg`,e),...t})}function ki({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-description`,className:d(`text-muted-foreground text-xs`,e),...t})}function Ai({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`card-content`,className:d(`px-6`,e),...t})}function ji(e){return e!==null&&!!e.username}function Mi(e){if(e&&!ji(e)){let t=Object.keys(e.roles);if(t.length===1)return`/${t[0]}`}return`/`}function Ni({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=xi();return Mi(a),(0,B.jsxs)(Ei,{className:d(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,B.jsxs)(Di,{children:[(0,B.jsx)(Oi,{className:`text-2xl`,children:(0,B.jsx)(`h2`,{children:n??`Component Error`})}),(0,B.jsx)(ki,{children:t.message})]}),(0,B.jsxs)(Ai,{children:[i,r!==!1&&(a&&!o?(0,B.jsx)(j,{to:`/`,children:(0,B.jsxs)(g,{children:[` `,(0,B.jsx)(lr,{}),` Return to Home`]})}):(0,B.jsx)(j,{to:`/sign-in`,children:(0,B.jsxs)(g,{children:[` `,(0,B.jsx)(lr,{}),` Go to Sign In Page`]})}))]})]})}function Pi(){let{user:e,isLoading:t}=xi();return Mi(e),(0,B.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,B.jsxs)(Ei,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,B.jsx)(Di,{children:(0,B.jsx)(Oi,{className:`text-2xl`,children:(0,B.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,B.jsx)(Ai,{children:e&&!t?(0,B.jsx)(j,{to:`/`,children:(0,B.jsxs)(g,{children:[` `,(0,B.jsx)(lr,{}),` Return to Home`]})}):(0,B.jsx)(j,{to:`/sign-in`,children:(0,B.jsxs)(g,{children:[` `,(0,B.jsx)(lr,{}),` Go Sign In Page`]})})})]})})}function Fi(){return`ontouchstart`in window||navigator.maxTouchPoints>0}function Ii(e){let t=`Error`,n=`We had some trouble!`;console.error(e);let r=e,i=e;if(typeof e==`string`?n=e:r?.response?.data?typeof r.response.data==`string`?n=r.response.data:r.response.data.error?n=r.response.data.error:r.response.data.message&&(n=r.response.data.message):i?.message&&(n=i.message),n.includes(`:`)){let e=n.split(`:`);t=e.shift(),n=e.join(`:`)}let a=r?.code===`ECONNABORTED`||r?.code===`ETIMEDOUT`;R.error(t,{id:a?`request-timeout`:void 0,description:n,action:{label:`Dismiss`,onClick:()=>R.dismiss()}})}var Li=new Qr({queryCache:new Xr({onError:Ii}),mutationCache:new Zr({onError:Ii})});function Ri(e){return!!e}var zi=!1,Bi=!1;function Vi(e){if(e.type!==`error`)return!0;let t=e.error?.message??``,n=e.error?.source;if(/Request aborted/i.test(t)||t.includes(`Fabric Connect not established`))return!1;let r=e.error?.resource?.url??``,i=/\/(HDBInstance|Cluster)\/[^/]+\/operation/.test(r),a=/timeout of \d+ms exceeded/i.test(t)||/Network Error/i.test(t)||n===`network`;return!(i&&a)}function Hi(){(0,z.useEffect)(()=>{zi||(zi=!0,Bi&&(ei.init({applicationId:`f590deee-4bac-49b4-a202-3b6963d9721d`,clientToken:`pub27aa29cea521492f4fef73032f86a023`,site:`datadoghq.com`,service:`studio`,env:void 0,version:`v5.0.29`,trackViewsManually:!0,trackUserInteractions:!0,beforeSend:Vi,sessionSampleRate:100,sessionReplaySampleRate:0,defaultPrivacyLevel:`mask`,plugins:[On()]}),ei.onReady(()=>{ei.startView({service:`studio`,version:`v5.0.29`,name:window.location.pathname||`initial`})})))},[])}function Ui(e){if(!Bi)return;ei.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)?ei.addAction(`return_login`):(ei.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&&ei.addAction(`login_time_gap`,{value:e})}localStorage.setItem(n,String(i)),ei.addAction(`login_success`,{userId:e.id})}function Wi(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Ar,{}),(0,B.jsx)(Et,{})]})}var Gi=At()({component:Wi});function Ki(){return(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,B.jsx)(`path`,{fill:`currentColor`,d:`M81.15,0c-1.2376,2.1973-2.3489,4.4704-3.3591,6.794-9.5975-1.4396-19.3718-1.4396-28.9945,0-.985-2.3236-2.1216-4.5967-3.3591-6.794-9.0166,1.5407-17.8059,4.2431-26.1405,8.0568C2.779,32.5304-1.6914,56.3725.5312,79.8863c9.6732,7.1476,20.5083,12.603,32.0505,16.0884,2.6014-3.4854,4.8998-7.1981,6.8698-11.0623-3.738-1.3891-7.3497-3.1318-10.8098-5.1523.9092-.6567,1.7932-1.3386,2.6519-1.9953,20.281,9.547,43.7696,9.547,64.0758,0,.8587.7072,1.7427,1.3891,2.6519,1.9953-3.4601,2.0457-7.0718,3.7632-10.835,5.1776,1.97,3.8642,4.2683,7.5769,6.8698,11.0623,11.5419-3.4854,22.3769-8.9156,32.0509-16.0631,2.626-27.2771-4.496-50.9172-18.817-71.8548C98.9811,4.2684,90.1918,1.5659,81.1752.0505l-.0252-.0505ZM42.2802,65.4144c-6.2383,0-11.4159-5.6575-11.4159-12.6535s4.9755-12.6788,11.3907-12.6788,11.5169,5.708,11.4159,12.6788c-.101,6.9708-5.026,12.6535-11.3907,12.6535ZM84.3576,65.4144c-6.2637,0-11.3907-5.6575-11.3907-12.6535s4.9755-12.6788,11.3907-12.6788,11.4917,5.708,11.3906,12.6788c-.101,6.9708-5.026,12.6535-11.3906,12.6535Z`})})}function qi(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`img`,{src:`/harper-studio_white.png`,alt:`Harper Studio`,className:`w-64 hidden md:inline-block`}),(0,B.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}function Ji(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 Yi(e,t){return Ji(localStorage.getItem(e))??t}function Xi(e,t){t==null?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}function Zi(e,t){let n=(0,z.useState)(Yi(e,t)),[r]=n;return(0,z.useEffect)(()=>Xi(e,r),[e,r]),n}function Qi(){let[e,t]=(0,z.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);return(0,z.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=e=>t(e.matches?`dark`:`light`);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var $i=function(e){return e.ApplicationChatPosition=`ApplicationChatPosition`,e.ApplicationChatWidth=`ApplicationChatWidth`,e.ChatAlwaysApprovedTools=`ChatAlwaysApprovedTools`,e.SavedClusterState=`SavedClusterState`,e.Theme=`Theme`,e}({}),ea=(0,z.createContext)([`system`,()=>{}]);function ta({children:e}){let[t,n]=Zi($i.Theme,`system`),r=Qi();return(0,z.useEffect)(()=>{let e=t===`dark`||t===`system`&&r===`dark`;document.documentElement.classList.toggle(`dark`,e)},[t,r]),(0,B.jsx)(ea.Provider,{value:[t,n],children:e})}function na(){return(0,z.useContext)(ea)}var ra=[{value:`light`,icon:(0,B.jsx)(Mt,{className:`size-4`}),label:`Light`},{value:`system`,icon:(0,B.jsx)(Zt,{className:`size-4`}),label:`System`},{value:`dark`,icon:(0,B.jsx)(qe,{className:`size-4`}),label:`Dark`}];function ia(){let[e,t]=na();return(0,B.jsx)(`div`,{className:`flex items-center bg-muted dark:bg-black rounded-xl p-0.5 gap-0.5`,children:ra.map(({value:n,icon:r,label:i})=>(0,B.jsx)(`button`,{type:`button`,title:i,onClick:()=>t(n),className:`p-1.5 rounded-lg transition-colors ${e===n?`bg-background text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`}`,children:r},n))})}function aa({className:e,...t}){return(0,B.jsx)(`div`,{className:d(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,B.jsx)(kr,{"data-slot":`navigation-menu-viewport`,className:d(`origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--radix-navigation-menu-viewport-width)]`,e),...t})})}function oa({className:e,children:t,viewport:n=!0,...r}){return(0,B.jsxs)(Qn,{"data-slot":`navigation-menu`,"data-viewport":n,className:d(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,B.jsx)(aa,{})]})}function sa({className:e,...t}){return(0,B.jsx)(cr,{"data-slot":`navigation-menu-item`,className:d(`relative`,e),...t})}function ca({className:e,...t}){return(0,B.jsx)(Sr,{"data-slot":`navigation-menu-link`,className:d(`hover:text-foreground dark:hover:text-white ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 flex flex-col gap-1 rounded-sm p-2 text-sm transition-[color,box-shadow] focus-visible:ring-4 focus-visible:outline-1 [&_svg:not([class*='size-'])]:size-4`,e),...t})}function la({className:e,...t}){return(0,B.jsx)(gn,{"data-slot":`navigation-menu-list`,className:d(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}var ua=oe(`inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-auto`,{variants:{variant:{default:`border-primary bg-primary/40 text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-secondary bg-secondary/40 text-secondary-foreground [a&]:hover:bg-secondary/90`,warning:`border-yellow bg-yellow/40 text-foreground [a&]:hover:bg-yellow/90`,success:`border-green bg-green/40 text-foreground [a&]:hover:bg-green/90`,destructive:`border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`,outline:`text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`}},defaultVariants:{variant:`default`}});function da(){let e=`v5.0.29`;return(0,B.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,B.jsxs)(`span`,{className:d(ua({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function fa(e={}){let{instanceId:t,clusterId:n}=F({strict:!1});return a({id:m,...e})}function pa(e={}){let{instanceId:t,clusterId:n}=F({strict:!1});return{instanceClient:a({id:m,...e}),entityType:`instance`}}function V(e={}){let{instanceId:t,clusterId:n}=F({strict:!1});return(0,z.useMemo)(()=>ma({instanceId:t,clusterId:n,...e}),[e.instanceId??t,e.clusterId??n,e.operationsUrl,e.port,e.secure,e.disableFabricConnect,e.forceFabricConnect])}function ma({instanceId:e,clusterId:t,...n}){let r=m;if(!r)throw Error(`id could not be automatically calculated in useInstanceClientIdParams`);return{instanceClient:a({id:r,...n}),entityId:r,entityType:`instance`}}function ha(){localStorage.clear()}function ga(){sessionStorage.clear()}async function _a(){c.setUserForEntity(m,null),Li.getQueryCache().clear(),ha(),ga(),await Li.invalidateQueries({refetchType:`none`})}async function va(e){await c.signOutFromPotentiallyAuthenticatedInstances(),await r({...e,entityId:m})}function ya(){let e=fa();return P({mutationFn:()=>va({instanceClient:e}),onSuccess:_a})}function ba(e){let{user:t}=Si(),{organizationId:n}=F({strict:!1});if(wi(t))return{update:!0,remove:!0};let 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 xa(e){let{user:t}=Si(),{organizationId:n}=F({strict:!1});if(wi(t))return{create:!0,remove:!0,update:!0,view:!0};let 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 Sa(e,t){let{user:n}=Si(),{organizationId:r,clusterId:i}=F({strict:!1});return Ca(n,e??r,t??i)}function Ca(e,t,n){if(wi(e))return{create:!0,remove:!0,update:!0,view:!0};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 wa(e,t){let{user:n}=Si(),{organizationId:r,clusterId:i}=F({strict:!1});return Ta(n,e??r,t??i)}function Ta(e,t,n){if(wi(e))return{create:!0,remove:!0,update:!0,view:!0};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 Ea(e){let{clusterId:t,instanceId:n}=F({strict:!1}),{user:r}=Ti(e??n??t),i=r?.role?.permission;return i?i.super_user===!0:!1}function Da(e){let{clusterId:t,instanceId:n}=F({strict:!1}),{user:r}=Ti(e??n??t),i=r?.role?.permission;return i?i.super_user===!0||i.structure_user===!0:!1}function Oa(e,t,n,r){let{clusterId:i,instanceId:a}=F({strict:!1}),{user:o}=Ti(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 ka={className:`text-foreground dark:text-white font-semibold`};function Aa(){let{mutate:e}=ya(),t=ue(),{user:n}=xi(),r=pt(),{organizationId:i}=F({strict:!1}),{update:a}=ba(i),{view:o}=xa(i),s=a,c=(0,z.useCallback)(()=>{e(void 0,{onSuccess:async()=>{R.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>R.dismiss()}}),t({to:`/sign-in`}),r.invalidate()}})},[e,r,t]),l=(0,z.useMemo)(()=>[!1,!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,B.jsx)(an,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,B.jsx)(xn,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,B.jsx)(Ki,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:c,icon:(0,B.jsx)(rr,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(Ri),[i,s,o,c]);return n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Fa,{menuItems:l}),(0,B.jsx)(Na,{menuItems:l})]}):(0,B.jsx)(Ma,{})}function ja(e){return e.items!==void 0}function Ma(){return(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`inline-block`,children:[(0,B.jsx)(j,{to:`/sign-in`,children:(0,B.jsx)(qi,{})}),(0,B.jsx)(da,{})]}),(0,B.jsx)(oa,{children:(0,B.jsxs)(la,{className:`text-muted-foreground dark:text-grey-400`,children:[(0,B.jsx)(sa,{children:(0,B.jsx)(ca,{asChild:!0,children:(0,B.jsxs)(j,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,B.jsx)(an,{}),` `,(0,B.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,B.jsx)(sa,{children:(0,B.jsx)(ia,{})}),(0,B.jsx)(sa,{children:(0,B.jsx)(ca,{asChild:!0,children:(0,B.jsxs)(j,{to:`/sign-in`,className:`flex-row items-center`,activeProps:ka,children:[(0,B.jsx)(gr,{}),` Sign In`]})})})]})})]})}function Na({menuItems:e}){let{user:t}=xi();return Mi(t),(0,B.jsx)(`div`,{className:`hidden md:block`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`inline-block`,children:[(0,B.jsx)(j,{to:`/`,children:(0,B.jsx)(qi,{})}),(0,B.jsx)(da,{})]}),(0,B.jsx)(oa,{children:(0,B.jsxs)(la,{className:`text-muted-foreground dark:text-grey-400`,children:[e.map(e=>ja(e)?!!e.items.length&&(0,B.jsx)(`div`,{className:`bg-muted dark:bg-black rounded-2xl flex`,children:e.items.map(e=>(0,B.jsx)(Pa,{menuItem:e},e.text))},e.text):(0,B.jsx)(Pa,{menuItem:e},e.text)),(0,B.jsx)(sa,{children:(0,B.jsx)(ia,{})})]})})]})})}function Pa({menuItem:e}){return(0,B.jsx)(sa,{className:`text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,children:(0,B.jsx)(ca,{asChild:!0,children:(0,B.jsxs)(j,{to:e.to,onClick:e.onClick,className:`flex-row items-center`,target:e.target,activeProps:e.to?ka:void 0,children:[e.icon,(0,B.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,B.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})})}function Fa({menuItems:e}){let{user:t}=xi();Mi(t);let[n,r]=(0,z.useState)(!1),i=(0,z.useCallback)(()=>r(e=>!e),[]),a=(0,z.useCallback)(()=>r(!1),[]);return(0,B.jsxs)(`div`,{className:`md:hidden`,id:`mobile-menu`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(j,{to:`/`,children:(0,B.jsx)(qi,{})}),(0,B.jsx)(da,{}),(0,B.jsxs)(`button`,{type:`button`,className:`shadow-xs text-muted-foreground dark:text-grey-400 hover:text-foreground dark:hover:text-white hover:bg-muted dark:hover:bg-black-dark`,onClick:i,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,B.jsx)(In,{}):(0,B.jsx)($t,{})]})]}),(0,B.jsx)(`div`,{className:`${n?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-foreground/20 dark:bg-black-dark dark:opacity-70`,onClick:a}),(0,B.jsxs)(`div`,{className:`${n?`block`:`hidden`} md:hidden z-50 space-y-1 pb-3 bg-card border-b border-border dark:bg-black-dark dark:border-none absolute left-0 top-full w-full rounded-b-md`,children:[(0,B.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,B.jsx)(ia,{})}),e.map(e=>ja(e)?!!e.items.length&&(0,B.jsx)(`div`,{className:`bg-muted dark:bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,B.jsx)(Ia,{menuItem:e,onClick:a},e.text))},e.text):(0,B.jsx)(Ia,{menuItem:e,onClick:a},e.text))]})]})}function Ia({menuItem:e,onClick:t}){let n=(0,z.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,B.jsxs)(j,{to:e.to,onClick:n,target:e.target,className:`flex flex-row px-3 py-2 text-base font-medium rounded-md text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,activeProps:e.to?ka:void 0,children:[e.icon,(0,B.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function La(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-gradient-to-r from-violet-100 to-white border-b border-violet-200 dark:from-purple-950 dark:to-zinc-900 dark:border-purple-950 md:px-12`,children:(0,B.jsx)(Aa,{})}),(0,B.jsxs)(`div`,{className:`pt-20 h-screen grid grid-cols-1 md:grid-cols-2`,children:[(0,B.jsx)(`section`,{"aria-label":`Harper Fabric overview`,className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,B.jsx)(`img`,{className:`object-scale-down max-h-[calc(100vh-80px-40px)] min-h-115`,src:`/fabric-signup-text.png`,alt:`One Runtime: App, database, Cache and Messaging. Distributed by design, free to deploy, and live in minutes. Deploy!`})}),(0,B.jsx)(`main`,{className:`overflow-y-auto px-6 bg-white dark:bg-linear-(--black-dark-gradient) border-l border-border dark:border-none`,children:(0,B.jsx)(`div`,{className:`min-h-full flex items-start justify-center py-12`,children:(0,B.jsx)(Et,{})})})]})]})}var Ra;function za(){(0,z.useEffect)(()=>{},[])}var Ba=[`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 Va(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of Ba)if(t===e||t.endsWith(`.`+e))return null;return t}var Ha=null;function Ua(){let e=ue(),t=pt(),n=Ie(),{redirect:r}=Bn({strict:!1});return(0,z.useEffect)(()=>{Ha||=(async function(){let i=await _().catch(()=>null);if(!i)R.error(`We were not able to verify your sign-in. Please try signing in again.`,{duration:1e4}),await e({to:`/sign-in`});else{c.setUserForEntity(m,i);let a=Mi(i);Ui(i);let o=Va(i.email);Ra?.identify?.({username:i.email,type:`email`,...o?{company:o}:{}}),await n.invalidateQueries({queryKey:l,refetchType:`none`}),await t.invalidate(),await e({to:r?.startsWith(`/`)?r:a})}Ha=null})()},[]),(0,B.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,B.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,B.jsx)(`div`,{className:`underline flex gap-4`,children:(0,B.jsx)(j,{className:`text-sm opacity-50 text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/sign-in`,children:`Try signing in again`})})]})}function Wa({delayDuration:e=0,...t}){return(0,B.jsx)(vr,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Ga({...e}){return(0,B.jsx)(Wa,{children:(0,B.jsx)(zn,{"data-slot":`tooltip`,...e})})}function Ka({...e}){return(0,B.jsx)(cn,{"data-slot":`tooltip-trigger`,...e})}function qa({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,B.jsx)(ar,{children:(0,B.jsxs)(Tr,{"data-slot":`tooltip-content`,sideOffset:t,className:d(`bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...i,children:[r,(0,B.jsx)(wn,{className:d(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}var Ja=new Map;function Ya(e){if(!e)return``;if(Ja.has(e))return Ja.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return Ja.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return Ja.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(Xa).join(` `);return Ja.set(e,i),i}function Xa(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Za({restartRequired:e}){let t=Vr(),{organization:n,instance:r,cluster:i}=lt({strict:!1});return(0,B.jsxs)(`div`,{role:`list`,className:`flex items-center space-x-2 xl:space-x-4 sm:max-w-9/10 max-w-[calc(100%-56px)]`,children:[...(0,z.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,B.jsxs)(j,{to:`/`,children:[(0,B.jsx)(Dr,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Home`})]},`home`)];for(let t=0;t<e.length;t++){let o=e[t];if(o===`instance`)continue;let s=`/${e.slice(0,t+1).join(`/`)}`,c=Ya(o);o===`databases`&&e.length===t+3?(c=e[t+2],t+=2):c.startsWith(`Org `)?c=n?.name||`Org`:c.startsWith(`Clu `)?(c=i?.name||`Cluster`,e[t+1]===`instance`&&(s+=`/instances`)):c.startsWith(`Ins `)?c=r?.name?.split(`.`)?.shift()||`Instance`:c===`Apis`&&(c=`APIs`),a.push((0,B.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,B.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,B.jsx)(j,{to:s,className:`text-xs md:text-sm font-medium hover:text-grey truncate max-w-48`,children:c},s))}return a},[t.pathname,i?.name,r?.name,n?.name]),e&&(0,B.jsxs)(Ga,{children:[(0,B.jsx)(Ka,{asChild:!0,children:(0,B.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,B.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,B.jsxs)(qa,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,B.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var H=Xt,Qa=(0,z.createContext)({}),$a=(0,z.createContext)({});function eo(){let e=(0,z.useContext)(Qa),t=(0,z.useContext)($a),{getFieldState:n}=bt(),r=se({name:e.name}),i=n(e.name,r);if(!e)throw Error(`useFormField should be used within <FormField>`);let{id:a}=t;return{id:a,name:e.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...i}}function U({...e}){let{error:t,formItemId:n,formDescriptionId:r,formMessageId:i}=eo();return(0,B.jsx)(tn,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function W({...e}){return(0,B.jsx)(Qa,{value:{name:e.name},children:(0,B.jsx)(Ke,{...e})})}function G({className:e,...t}){return(0,B.jsx)($a,{value:{id:(0,z.useId)()},children:(0,B.jsx)(`div`,{"data-slot":`form-item`,className:d(`grid gap-2`,e),...t})})}function to({className:e,...t}){return(0,B.jsx)(pr,{"data-slot":`label`,className:d(`text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function K({className:e,...t}){let{error:n,formItemId:r}=eo();return(0,B.jsx)(to,{"data-slot":`form-label`,"data-error":!!n,className:d(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function q({className:e,...t}){let{error:n,formMessageId:r}=eo(),i=n?String(n?.message):t.children;return i?(0,B.jsx)(`p`,{"data-slot":`form-message`,id:r,className:d(`text-destructive text-sm`,e),...t,children:i}):null}function J({className:e,type:t,...n}){return(0,B.jsx)(`input`,{type:t,"data-slot":`input`,className:d(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
3
3
  selection:text-primary-foreground
4
4
  dark:aria-invalid:outline-destructive dark:aria-invalid:ring-destructive/50 ring-ring/10
5
5
  dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 aria-invalid:outline-destructive/60
@@ -8,7 +8,7 @@ import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{_ as t,a as n,c as r,d
8
8
  file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium
9
9
  focus-visible:ring-1 focus-visible:outline-none focus-visible:ring-purple disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50
10
10
  aria-invalid:focus-visible:ring-[1px] aria-invalid:focus-visible:outline-none md:text-sm dark:aria-invalid:focus-visible:ring-1`,e),...n})}var no=[`RUNNING`],ro=[`TERMINATING`,`TERMINATED`,`REMOVED`];function io(){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 ao({username:e,password:t,instanceClient:n,entityId:r}){let i={username:e,password:t};c.checkForBasicAuth(r)&&(n.defaults.auth=i,n.defaults.withCredentials=!1);let{data:{message:o}}=await n.post(`/`,{operation:`login`,username:e,password:t});if(!c.checkForBasicAuth(r))try{return{message:o,user:await h({instanceClient:n})}}catch(e){console.error(`Failed to get user after login, trying basic auth`,e)}try{n.defaults.auth=i,n.defaults.withCredentials=!1;let e=await h({instanceClient:n,auth:i});return c.flagForBasicAuth(r,i),{message:o,user:e}}catch(e){throw n.defaults.auth=void 0,n.defaults.withCredentials=!0,e}let s=a({id:r,forceFabricConnect:!0}),l=await h({instanceClient:s});return c.flagForFabricConnect(r,!0),{message:o,user:l,instanceClient:s}}function oo(){return P({mutationFn:ao})}function so({cluster:e,instance:t,instanceParams:n}){let r=ue(),i=pt(),{redirect:a}=Bn({strict:!1}),{mutate:o,isPending:s}=oo();return{isPending:s,submitForm:(0,z.useCallback)(async s=>{o({...s,...n},{onSuccess:async({message:n,user:o})=>{if(R.success(n),e?.instances?.length&&!t)for(let t of e.instances)c.setUserForEntity(t,o);let s=m;if(!s)throw Error(`Sign in failed due to missing cluster or instance.`);c.setUserForEntity(s,o),i.invalidate(),await r({to:a?.startsWith(`/`)?a:`/`})}})},[e,t,n,r,a,i,o])}}async function co(e){let{data:t}=await s.get(`/Cluster/${e}`);return t}function lo(e,t){return I({queryKey:[e],queryFn:()=>co(e),retry:!1,staleTime:1900,enabled:!!e,refetchInterval:t?t===!0?1e4:t:void 0})}var uo=S({error:`Please enter a valid email address.`}).toLowerCase().trim(),fo=w().nonempty({error:`Please enter your password.`}),po=w().nonempty({error:`Please enter a username.`}),mo=O({username:po,password:fo}),ho=O({email:uo,password:fo});function go({entityId:e,instanceClient:t}){return I({queryKey:[e,`health`],queryFn:async()=>{try{return await t.get(`/health`),!0}catch{return!1}},retry:2,refetchInterval:5e3})}var _o=[`localhost`,`127.0.0.1`],vo=function(e){return e.MixedLoopback=`MixedLoopback`,e.InsecureCookieOutsideChromeAndFirefox=`InsecureCookieOutsideChromeAndFirefox`,e}({});function yo(e,t,n){if(!n||!t||!e)return null;let r=new URL(n).hostname,i=_o.includes(t),a=_o.includes(r);if(i&&a&&r!==t)return`MixedLoopback`;if(!i&&a){let t=e.indexOf(`Chrome`)>=0,n=e.indexOf(`Firefox`)>=0;if(!t&&!n)return`InsecureCookieOutsideChromeAndFirefox`}return null}function bo(){let{clusterId:e,instanceId:t}=F({strict:!1}),{data:r}=A(lo(e,!0)),i=(0,z.useMemo)(()=>t&&r&&r?.instances?.find(e=>e.id===t)||void 0,[r,t]),a=(0,z.useMemo)(()=>r?.status&&no.includes(r.status),[r?.status]),o=`instance`,s=(0,z.useMemo)(()=>r?i?(c.flagForFabricConnect(i.id,!1),n(i)):(c.flagForFabricConnect(r.id,!1),f(r)):null,[r,i]),l=V({operationsUrl:s}),u=(0,z.useMemo)(()=>s?.includes(`localhost`)||s?.includes(`127.0.0.1`),[s]),d=(0,z.useMemo)(()=>yo(navigator.userAgent,location.hostname,s),[s]),{data:p}=A(go(l)),m=L({resolver:N(mo),defaultValues:{username:``,password:``}}),{control:h,handleSubmit:_}=m,{submitForm:v,isPending:y}=so({cluster:r,instance:i,instanceParams:l});return!t&&r&&!r?.fqdn?(0,B.jsx)(Gn,{to:`../instances`,replace:!0}):a&&r?.resetPassword?(0,B.jsx)(Gn,{to:`/${r.organizationId}/${r.id}/finish-setup`,replace:!0}):!a&&r?.resetPassword?(0,B.jsx)(Gn,{to:`/${r.organizationId}/${r.id}/starting-up`,replace:!0}):(0,B.jsxs)(B.Fragment,{children:[!1,(0,B.jsx)(`div`,{className:x(`min-h-screen`,`items-center justify-center flex`),children:(0,B.jsxs)(`div`,{className:`text-foreground w-xs py-8`,children:[(0,B.jsxs)(`h1`,{className:`text-2xl font-light`,children:[`Sign in to Harper `,`Local`]}),(0,B.jsx)(H,{...m,children:(0,B.jsxs)(`form`,{id:`auth-${o}-signin-form`,name:`auth-${o}-signin-form`,onSubmit:_(v),className:`my-4`,children:[(0,B.jsx)(W,{control:h,name:`username`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Username`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{autoComplete:`username`,autoFocus:!0,type:`text`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:h,name:`password`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(g,{disabled:y,type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,children:`Sign In`}),p===!1&&(0,B.jsxs)(`div`,{className:`p-4 mt-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300`,role:`alert`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` This `,o,` is not responding to GET`,` `,(0,B.jsxs)(`a`,{href:`${s}health`,className:`underline`,target:`_blank`,children:[s,`health`]}),` `,`checks.`,(0,B.jsxs)(`ol`,{className:`list-decimal ml-8 mt-2`,children:[(0,B.jsx)(`li`,{children:`Is the server running?`}),(0,B.jsxs)(`li`,{children:[`Have you`,` `,(0,B.jsx)(`a`,{href:`https://docs.harperdb.io/docs/developers/security/configuration#cors`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`enabled CORS`}),` `,`for the operations API?`]}),u&&(0,B.jsxs)(`li`,{children:[`Have you allowed`,` `,(0,B.jsx)(`a`,{href:`https://www.google.com/search?q=How+do+I+enable+local+network+access+in+my+browser%3F`,className:`underline`,target:`_blank`,rel:`noreferrer`,children:`local network access`}),` `,`in your browser?`]})]})]}),d===vo.MixedLoopback&&(0,B.jsxs)(`div`,{className:`p-4 mt-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300`,role:`alert`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` `,`Your login might not work because you're mixing 127.0.0.1 and localhost. Pick one or the other.`]}),d===vo.InsecureCookieOutsideChromeAndFirefox&&(0,B.jsxs)(`div`,{className:`p-4 mt-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300`,role:`alert`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` `,`Your login might not work because your browser doesn't consider localhost to be secure, so it doesn't pass the cookies along. Firefox or Chromium based browsers should pass the cookies properly.`]}),(0,B.jsxs)(`div`,{className:`p-4 mt-4 text-sm rounded-lg bg-purple-950`,role:`alert`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:`Did you know?`}),` `,`You can add this instance to your Harper account to manage it remotely.`,(0,B.jsx)(`div`,{className:`text-center pt-2`,children:(0,B.jsx)(j,{to:io(),target:`_blank`,children:(0,B.jsx)(g,{type:`button`,variant:`positive`,children:`Connect to Harper Fabric`})})})]})]})})]})})]})}async function xo({email:e}){let{data:t}=await s.post(`/ForgotPassword/`,{email:e});if(t)return t;throw Error(`Something went wrong`)}function So(){return P({mutationFn:e=>xo(e)})}var Co=O({email:uo});function wo(){let e=ue(),{me:t}=Bn({strict:!1}),n=L({resolver:N(Co),defaultValues:{email:t||``}}),r=n.watch(`email`),{setFocus:i,control:a,handleSubmit:o}=n;(0,z.useEffect)(()=>{i(`email`)},[i]);let{mutate:s,isPending:c}=So(),l=async t=>{s(t,{onSuccess:t=>{R.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>R.dismiss()}}),e({to:`/sign-in`,search:{me:r}})}})};return(0,B.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,B.jsx)(`h1`,{className:`text-2xl font-light`,children:`Enter your account email`}),(0,B.jsx)(`p`,{className:`text-sm pt-1`,children:`If a matching account exists, we'll send you a password reset link.`}),(0,B.jsx)(H,{...n,children:(0,B.jsxs)(`form`,{id:`auth-forgot-password-form`,name:`auth-forgot-password-form`,onSubmit:o(l),className:`my-4`,children:[(0,B.jsx)(W,{control:a,name:`email`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-2`,children:[(0,B.jsx)(K,{children:`Email`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{disabled:c,type:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(g,{type:`submit`,variant:`submit`,disabled:c,className:`w-full my-2 rounded-full`,children:`Send Password Reset Email`})]})}),(0,B.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,B.jsx)(j,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:r},children:`Sign in to your account`}),(0,B.jsx)(j,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:r},children:`Sign up for free`})]})]})}var To=async({token:e,password:t})=>{let{data:n}=await s.put(`/ResetPassword/`,{token:e,newPassword:t});return n};function Eo(){return P({mutationFn:e=>To(e)})}var Do=O({password:fo.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 Oo(){let{token:e}=Bn({strict:!1}),t=ue();(0,z.useEffect)(()=>{e||t({to:`/sign-in`})},[e,t]);let n=L({resolver:N(Do),defaultValues:{password:``,confirmPassword:``}}),{setFocus:r,control:i,handleSubmit:a}=n;(0,z.useEffect)(()=>{r(`password`)},[r]);let{mutate:o,isPending:s}=Eo(),c=(0,z.useCallback)(async n=>{o({token:e,password:n.password},{onSuccess:()=>{R.success(`Success`,{description:`Your password has been reset successfully.`,action:{label:`Dismiss`,onClick:()=>R.dismiss()}}),t({to:`/sign-in`})}})},[t,o,e]);return(0,B.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,B.jsx)(`h1`,{className:`text-2xl font-light`,children:`Reset Password`}),(0,B.jsx)(H,{...n,children:(0,B.jsxs)(`form`,{id:`auth-reset-password-form`,name:`auth-reset-password-form`,className:`my-4`,onSubmit:a(c),children:[(0,B.jsx)(W,{control:i,name:`password`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-2`,children:[(0,B.jsx)(K,{children:`New Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{disabled:s,type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:i,name:`confirmPassword`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-2`,children:[(0,B.jsx)(K,{children:`Confirm Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{disabled:s,type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(g,{variant:`submit`,type:`submit`,disabled:s,className:`w-full my-2 rounded-full`,children:`Submit New Password`})]})})]})}function ko({text:e,disabled:t,onClick:n}){return(0,B.jsxs)(`a`,{href:`/oauth/github/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,"aria-disabled":t||void 0,className:x(`github-signin-btn`,t&&`opacity-50 cursor-default`),children:[(0,B.jsx)(`img`,{src:`/github/GitHub_Invertocat_White.svg`,alt:``,className:`github-icon`}),e]})}function Ao({text:e,disabled:t,onClick:n}){return(0,B.jsxs)(`a`,{href:`/oauth/google/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,"aria-disabled":t||void 0,className:x(`gsi-material-button`,t&&`opacity-50 cursor-default`),children:[(0,B.jsx)(`div`,{"aria-hidden":`true`,className:`gsi-material-button-state`}),(0,B.jsxs)(`div`,{className:`gsi-material-button-content-wrapper`,children:[(0,B.jsx)(`div`,{"aria-hidden":`true`,className:`gsi-material-button-icon`,children:(0,B.jsxs)(`svg`,{version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 48 48`,xmlnsXlink:`http://www.w3.org/1999/xlink`,className:`block`,children:[(0,B.jsx)(`path`,{fill:`#EA4335`,d:`M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z`}),(0,B.jsx)(`path`,{fill:`#4285F4`,d:`M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z`}),(0,B.jsx)(`path`,{fill:`#FBBC05`,d:`M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z`}),(0,B.jsx)(`path`,{fill:`#34A853`,d:`M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z`}),(0,B.jsx)(`path`,{fill:`none`,d:`M0 0h48v48H0z`})]})}),(0,B.jsx)(`span`,{className:`gsi-material-button-contents`,children:e}),(0,B.jsx)(`span`,{className:`hidden`,children:e})]})]})}function jo(){let e=ue(),t=Ie(),n=pt(),{redirect:r}=Bn({strict:!1}),{mutate:i,isPending:a}=Mo();return{isPending:a,submitForm:(0,z.useCallback)(a=>{i(a,{onSuccess:async i=>{c.setUserForEntity(m,i);let a=Mi(i);Ui(i);let o=Va(i.email);Ra?.identify?.({username:i.email,type:`email`,...o?{company:o}:{}}),await t.invalidateQueries({queryKey:l,refetchType:`none`}),n.invalidate(),await e({to:r?.startsWith(`/`)?r:a})}})},[e,t,r,n,i])}}function Mo(){return P({mutationFn:e=>No(e)})}async function No({email:e,password:t}){let{data:n}=await s.post(`/Login/`,{email:e,password:t});if(n)return n;throw Error(`Something went wrong`)}function Po(){let{me:e}=Bn({strict:!1}),t=L({resolver:N(ho),defaultValues:{email:e||``,password:``}}),{handleSubmit:n,control:r}=t,i=t.watch(`email`),{submitForm:a,isPending:o}=jo();return(0,B.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,B.jsx)(`h1`,{className:`text-2xl font-light text-center`,children:`Sign in to Harper Fabric`}),(0,B.jsx)(H,{...t,children:(0,B.jsxs)(`form`,{id:`auth-signin-form`,name:`auth-signin-form`,onSubmit:n(a),className:`my-4`,children:[(0,B.jsx)(W,{control:r,name:`email`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Email`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`email`,autoFocus:!0,autoComplete:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:r,name:`password`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,autoComplete:`current-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(g,{type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,disabled:o,children:`Sign In`}),(0,B.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,B.jsx)(j,{className:`text-sm text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/sign-up`,search:{me:i},children:`Sign up for free`}),(0,B.jsx)(j,{className:`text-sm text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/forgot-password`,search:{me:i},children:`Forgot password?`})]})]})}),(0,B.jsx)(`hr`,{"aria-hidden":`true`,className:`border-border dark:border-gray-600 my-6`}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(Ao,{text:`Sign in with Google`}),(0,B.jsx)(ko,{text:`Sign in with GitHub`})]})]})}var Fo=/^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžæÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,'-]+$/u;async function Io(e){let{data:t}=await s.post(`/User/`,e);if(t)return t;throw Error(`Something went wrong`)}function Lo(){return P({mutationFn:e=>Io(e)})}var Ro=O({email:uo.max(80,{error:`Email cannot be longer than 80 characters.`}),firstname:w().trim().min(2,{error:`Please enter your first name.`}).regex(Fo,{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(Fo,{error:`Last name can only contain letters, spaces, and hyphens.`}).max(80,{error:`Last name cannot be longer than 80 characters.`}),password:fo.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 zo(){let e=ue(),{email:t,me:n}=Bn({strict:!1}),[r,i]=(0,z.useState)(!1),a=L({resolver:N(Ro),defaultValues:{firstname:``,lastname:``,email:n||t||``,password:``,confirmPassword:``,acceptTerms:!1}}),o=a.watch(`email`),s=a.watch(`acceptTerms`),{setFocus:c,control:l,handleSubmit:u}=a;(0,z.useEffect)(()=>{c(`firstname`)},[c]);let{mutate:d}=Lo(),f=(0,z.useCallback)(async t=>{let{confirmPassword:n,acceptTerms:r,...i}=t;d(i,{onSuccess:()=>{let t=Va(i.email);Ra?.identify?.({username:i.email,type:`email`,firstname:i.firstname,lastname:i.lastname,...t?{company:t}:{}}),e({to:`/verifying?email=`+encodeURIComponent(i.email)})}})},[e,d]),p=(0,z.useCallback)(e=>{if(!s)return i(!0),setTimeout(()=>i(!1),1e3),e.preventDefault(),!1},[s]),m=(0,B.jsx)(W,{control:l,name:`acceptTerms`,render:({field:e})=>(0,B.jsxs)(G,{className:`flex flex-row items-start space-x-3 space-y-0 p-1 transition-colors duration-300 ${r?`bg-red-500/20 animate-pulse rounded`:``}`,children:[(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`size-4 rounded border-gray-300 bg-white text-purple-600 focus:ring-purple-500`,checked:e.value,onChange:e.onChange})}),(0,B.jsxs)(`div`,{className:`space-y-1 leading-none`,children:[(0,B.jsxs)(K,{className:`text-xs font-normal`,children:[`I accept the`,` `,(0,B.jsx)(`a`,{href:`https://www.harper.fast/resources/privacy-policy`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,"aria-label":`Privacy Policy (opens in new tab)`,children:`Privacy Policy`}),` `,`and`,` `,(0,B.jsx)(`a`,{href:`https://www.harper.fast/resources/paas-terms-of-service`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,"aria-label":`Terms of Service (opens in new tab)`,children:`Terms of Service`})]}),(0,B.jsx)(q,{})]})]})});return(0,B.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,B.jsx)(`h1`,{className:`text-2xl font-light text-center`,children:`Sign up for Harper Fabric`}),(0,B.jsxs)(H,{...a,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-2 my-6`,children:[m,(0,B.jsx)(Ao,{text:`Sign up with Google`,disabled:!s,onClick:p}),(0,B.jsx)(ko,{text:`Sign up with GitHub`,disabled:!s,onClick:p})]}),(0,B.jsx)(`hr`,{className:`border-gray-600`}),(0,B.jsxs)(`form`,{id:`auth-signup-form`,name:`auth-signup-form`,onSubmit:u(f),className:`grid gap-4 my-4`,children:[(0,B.jsx)(W,{control:l,name:`firstname`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`First Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,className:`dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:l,name:`lastname`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Last Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,className:`dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:l,name:`email`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Email`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`email`,readOnly:!!t,disabled:!!t,className:`dark:bg-black dark:border-black`,autoComplete:`email`,autoCapitalize:`none`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:l,name:`password`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:l,name:`confirmPassword`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Confirm Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),m,(0,B.jsx)(g,{type:`submit`,variant:`submit`,className:`w-full rounded-full my-4`,children:`Sign Up For Free`})]})]}),(0,B.jsx)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:(0,B.jsx)(j,{className:`m-auto text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:o},children:`Already have an account? Sign in instead.`})})]})}var Bo=async({email:e})=>{let{data:t}=await s.post(`/ResendVerificationEmail/`,{email:e});return t};function Vo(){return P({mutationFn:e=>Bo(e)})}var Ho=async e=>{let{data:t}=await s.put(`/VerifyEmail/`,{token:e.toString()});return t};function Uo(){return P({mutationFn:e=>Ho(e)})}var Wo=O({email:uo});function Go(){let e=ue(),{mutate:t,isPending:n}=Vo(),r=L({resolver:N(Wo),defaultValues:{email:``}}),i=r.watch(`email`),{setFocus:a,control:o,handleSubmit:s}=r;(0,z.useEffect)(()=>{a(`email`)},[a]);let c=(0,z.useCallback)(async n=>{t(n,{onSuccess:t=>{R.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>R.dismiss()}}),e({to:`/sign-in`,search:{me:i}})}})},[i,e,t]);return(0,B.jsxs)(H,{...r,children:[(0,B.jsx)(`p`,{className:`text-sm py-2`,children:`Please Enter an Email`}),(0,B.jsxs)(`form`,{id:`auth-verify-email-form`,name:`auth-verify-email-form`,onSubmit:s(c),className:`my-4`,children:[(0,B.jsx)(W,{control:o,name:`email`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-2`,children:[(0,B.jsx)(K,{children:`Email`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{disabled:n,type:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(g,{type:`submit`,variant:`submit`,disabled:n,className:`w-full my-2 rounded-full`,children:`Send Verification Email`})]})]})}function Ko(){let{token:e}=Bn({strict:!1}),t=ue(),{mutate:n,isPending:r}=Uo(),i=(0,z.useCallback)(e=>{n(e,{onSuccess:()=>{R.success(`Success`,{description:`Email verified successfully`,action:{label:`Dismiss`,onClick:()=>R.dismiss()}}),t({to:`/sign-in`})}})},[n,t]);return(0,z.useEffect)(()=>{e&&i(e)},[i,e]),(0,B.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,B.jsx)(`h1`,{className:`text-3xl font-light`,children:`Verify Email`}),r?(0,B.jsx)(`p`,{className:`text-sm pt-1`,children:`Verifying email...`}):(0,B.jsx)(Go,{})]})}function qo(){let{email:e}=Bn({strict:!1}),{mutate:t,isPending:n}=Vo(),r=(0,z.useCallback)(n=>(n.preventDefault(),e&&t({email:e},{onSuccess:e=>{R.success(`Code Sent`,{description:`${e}`,action:{label:`Dismiss`,onClick:()=>R.dismiss()}})}}),!1),[e,t]);return(0,B.jsxs)(`div`,{className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,B.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Check your email!`]}),(0,B.jsxs)(`p`,{children:[`Your account has been created! You should receive an email with a link to `,(0,B.jsx)(`strong`,{children:`[Verify My Email]`}),`!`]}),(0,B.jsxs)(`p`,{children:[`From: `,(0,B.jsx)(`strong`,{children:`harper@notifications.harperfabric.com`})]}),(0,B.jsxs)(`p`,{children:[`To: `,(0,B.jsx)(`strong`,{children:e||`your email`})]}),(0,B.jsx)(`p`,{children:`Can you click it? Then we can carry on to more fun things!`}),(0,B.jsxs)(`div`,{className:`underline flex gap-4`,children:[(0,B.jsx)(j,{className:`text-sm text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/sign-in`,search:{me:e},children:`I did it, let me sign in!`}),(0,B.jsx)(j,{className:`text-sm opacity-50 text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:void 0,onClick:r,disabled:n,children:`Send me another code, please.`})]})]})}var Jo=M({getParentRoute:()=>Gi,id:`_authLayout`,component:La}),Yo=M({getParentRoute:()=>Jo,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:Po,beforeLoad:({context:e,location:t})=>{let n=e.authentication[m]?.user;if(n){let e=t?.search,r=Mi(n);throw Ve({to:e?.redirect?.startsWith(`/`)?e.redirect:r})}}}),Xo=M({getParentRoute:()=>Gi,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:bo,beforeLoad:({context:e,location:t})=>{if(e.authentication.OverallAppSignIn?.user){let e=t?.search;throw Ve({to:e?.redirect?.startsWith(`/`)?e.redirect:`/`})}}}),Zo=M({getParentRoute:()=>Jo,path:`sign-up`,head:()=>({meta:[{title:`Sign Up — Harper Fabric`}]}),component:zo}),Qo=M({getParentRoute:()=>Jo,path:`forgot-password`,head:()=>({meta:[{title:`Forgot Password — Harper Fabric`}]}),component:wo}),$o=M({getParentRoute:()=>Jo,path:`verify-email`,head:()=>({meta:[{title:`Verify Email — Harper Fabric`}]}),component:Ko}),es=M({getParentRoute:()=>Jo,path:`verifying`,head:()=>({meta:[{title:`Check Your Email — Harper Fabric`}]}),component:qo}),ts=M({getParentRoute:()=>Jo,path:`check-oauth`,head:()=>({meta:[{title:`Signing In — Harper Fabric`}]}),component:Ua}),ns=M({getParentRoute:()=>Jo,path:`reset-password`,head:()=>({meta:[{title:`Reset Password — Harper Fabric`}]}),component:Oo});Jo.addChildren([Yo,Zo,ts,Qo,$o,es,ns]);var rs=[Xo];function is({children:e}){return(0,B.jsx)(`nav`,{className:`fixed top-20 w-full h-12 z-39 py-2 px-4 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none`,children:(0,B.jsxs)(`div`,{className:`flex items-center h-full space-x-2`,children:[(0,B.jsx)(Za,{}),e]})})}function as(e){if(ls(e)||us(e))return`warning`;if(os(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 os(e){switch(e){case`RUNNING`:case`UPDATED`:return!0;default:return!1}}function ss(e){switch(e){case`FAILED`:return!0;default:return!1}}function cs(e){switch(e){case`TERMINATED`:return!0;default:return!1}}function ls(e){switch(e){case`CLONE_PENDING`:case`PENDING_UPGRADE`:return!0;default:return!1}}function us(e){switch(e){case`PROVISIONING`:case`CLONING`:case`CLONE_READY`:case`UPDATING_HDB_NODES`:case`DRAINING`:case`UPDATING`:return!0;default:return!1}}function Y({...e}){return(0,B.jsx)(Ft,{"data-slot":`dialog`,...e})}function ds({...e}){return(0,B.jsx)(Ne,{"data-slot":`dialog-trigger`,...e})}function fs({...e}){return(0,B.jsx)(Re,{"data-slot":`dialog-portal`,...e})}function ps({className:e,...t}){return(0,B.jsx)(zt,{"data-slot":`dialog-overlay`,className:d(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-white/80 backdrop-blur-xs dark:bg-black-dark/90 dark:backdrop-blur-none`,e),...t})}function X({className:e,children:t,...n}){return(0,B.jsxs)(fs,{"data-slot":`dialog-portal`,children:[(0,B.jsx)(ps,{}),(0,B.jsxs)(qr,{"data-slot":`dialog-content`,className:d(`bg-popover 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 border p-6 shadow-2xl duration-200`,e),...n,children:[t,(0,B.jsxs)(Ct,{className:`ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,B.jsx)(In,{className:`text-popover-foreground`}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function ms({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`dialog-header`,className:d(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function hs({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`dialog-footer`,className:d(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function Z({className:e,...t}){return(0,B.jsx)(Ut,{"data-slot":`dialog-title`,className:d(`text-lg leading-none text-popover-foreground font-semibold`,e),...t})}function gs({className:e,...t}){return(0,B.jsx)(he,{"data-slot":`dialog-description`,className:d(`text-muted-foreground text-sm`,e),...t})}function _s({typeOfThingBeingDeleted:e,nameOfThingBeingDeleted:t,isModalOpen:n,hideDataLossWarning:r,setIsModalOpen:i,deletionConfirmed:a,deletionPending:o,trigger:s,presentParticiple:c=`Deleting`,transitiveVerb:l=`Delete`}){return(0,B.jsxs)(Y,{open:n,onOpenChange:i,children:[s&&(0,B.jsx)(ds,{asChild:!0,children:s}),(0,B.jsxs)(X,{className:`sm:max-w-[750px]`,children:[(0,B.jsxs)(ms,{children:[(0,B.jsxs)(Z,{children:[`Are you sure you want to `,l.toLowerCase(),` this `,e,`?`]}),(0,B.jsx)(gs,{children:`This action cannot be undone.`})]}),!r&&(0,B.jsxs)(`div`,{className:`p-3 my-5 text-white rounded-md bg-amber-600`,children:[(0,B.jsxs)(`p`,{className:`flex space-x-1 font-semibold align-baseline`,children:[(0,B.jsx)(Wr,{className:`inline-block size-5`}),` `,(0,B.jsx)(`span`,{children:`Warning`})]}),(0,B.jsxs)(`p`,{className:`pt-2 text-base`,children:[`By `,c.toLowerCase(),` `,e,` `,(0,B.jsx)(`span`,{className:`font-semibold`,children:t}),` `,`you will lose the data stored in it permanently.`]})]}),(0,B.jsx)(hs,{children:(0,B.jsxs)(`div`,{className:`flex justify-center space-x-5`,children:[(0,B.jsxs)(g,{type:`button`,className:`rounded-full`,onClick:()=>i(!1),children:[(0,B.jsx)(lr,{}),` Cancel`]}),(0,B.jsxs)(g,{variant:`destructive`,className:`rounded-full`,onClick:a,disabled:o,children:[(0,B.jsx)(fn,{}),` `,l]})]})})]})]})}function vs({className:e,variant:t,asChild:n=!1,...r}){return(0,B.jsx)(n?tn:`span`,{"data-slot":`badge`,className:d(ua({variant:t}),e),...r})}function ys({...e}){return(0,B.jsx)(Ae,{"data-slot":`dropdown-menu`,...e})}function bs({...e}){return(0,B.jsx)($e,{"data-slot":`dropdown-menu-trigger`,...e})}function xs({className:e,sideOffset:t=4,...n}){return(0,B.jsx)(ht,{children:(0,B.jsx)(fe,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:d(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border p-1 shadow-md`,e),...n})})}function Ss({className:e,inset:t,variant:n=`default`,...r}){return(0,B.jsx)(Hn,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:d(`focus:bg-accent focus:text-grey data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r})}function Cs({className:e,children:t,checked:n,...r}){return(0,B.jsxs)(qn,{"data-slot":`dropdown-menu-checkbox-item`,className:d(`focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...r,children:[(0,B.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,B.jsx)(nt,{children:(0,B.jsx)(Yt,{className:`size-4`})})}),t]})}function ws({className:e,inset:t,...n}){return(0,B.jsx)(ot,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:d(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function Ts({className:e,...t}){return(0,B.jsx)(Ue,{"data-slot":`dropdown-menu-separator`,className:d(`bg-border -mx-1 my-1 h-px`,e),...t})}function Es(e){return!!e?.plans?.[0]?.planId?.startsWith(`self-hosted`)}function Ds({cluster:e}){let t=Ti(e.id),{view:n,update:r}=Sa(e.organizationId,e.id),i=!c.checkForFabricConnect(e.id)&&!!t.user,a=(0,z.useCallback)(()=>{c.setUserForEntity(e,null),c.flagForFabricConnect(e.id,!1)},[e]);if(n){if(!e.fqdn)return(0,B.jsx)(j,{to:`/${e.organizationId}/${e.id}/instances`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,B.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Instances `,(0,B.jsx)(Tn,{className:`inline-block`})]})});if(e.resetPassword)return r?(0,B.jsx)(j,{to:`/${e.organizationId}/${e.id}/finish-setup`,className:`text-sm text-nowrap`,"aria-label":`Set Password on ${e.name}`,title:`Set Password on ${e.name}`,children:(0,B.jsxs)(g,{variant:`positive`,className:`py-2 hover:border-b-2 animate-glow-pulse`,children:[`Finish Setup `,(0,B.jsx)(Tn,{className:`inline-block`})]})}):(0,B.jsx)(`span`,{className:`py-2 text-nowrap`,children:`Pending Owner Setup`});if(!t.isLoading)return i?(0,B.jsx)(j,{to:`/${e.organizationId}/${e.id}/`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,B.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Direct Connect `,(0,B.jsx)(Tn,{className:`inline-block`})]})}):r&&!Es(e)?(0,B.jsx)(j,{to:`/${e.organizationId}/${e.id}/`,className:`text-sm text-nowrap`,"aria-label":`Connect to ${e.name}`,title:`Connect to ${e.name}`,children:(0,B.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Fabric Connect `,(0,B.jsx)(Tn,{className:`inline-block`})]})}):(0,B.jsx)(j,{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}`,onClick:a,children:(0,B.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Direct Sign In `,(0,B.jsx)(Tn,{className:`inline-block`})]})})}}function Os(e,t){let n=[];if(e)for(let r of e)n.push(r[t]);return n}function ks({cluster:e,forceProgressBarVisible:t}){let[n,r]=(0,z.useState)(t||!1),{data:i}=A(lo(n&&e.id,2e3));(0,z.useEffect)(function(){(ls(e.status)||us(e.status))&&r(!0)},[n,e.status,i?.instances]);let a=(0,z.useMemo)(()=>{let e=Os(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||cs(t)||(ls(t)?(n+=1,r[t]=`${n} ${Ya(t)}`):us(t)?(a+=1,o[t]=`${a} ${Ya(t)}`):ss(t)?(l+=1,u[t]=`${l} ${Ya(t)}`):!i.planId||!e.includes(i.planId)?(a+=1,o.DRAINING_TRAFFIC=`${a} ${Ya(`Draining Traffic`)}`):os(t)&&(s+=1,c[t]=`${s} ${Ya(t)}`))}let d=n+a+s;return{pendingWidth:`${d===0?100:n===0?0:n/d*100}%`,updatingWidth:`${a===0?0:a/d*100}%`,failedWidth:`${l===0?0:l/d*100}%`,runningWidth:`${s===0?0:s/d*100}%`,text:[...Object.values(c).sort(),...Object.values(u).sort(),...Object.values(o).sort(),...Object.values(r).sort()].join(` · `)}},[i]);return n?(0,B.jsxs)(`div`,{className:`w-full text-center`,children:[(0,B.jsxs)(`div`,{className:`w-full h-2.5 rounded-full overflow-clip flex shadow`,children:[(0,B.jsx)(`div`,{style:{width:a.runningWidth},className:`grow bg-green/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,B.jsx)(`div`,{style:{width:a.failedWidth},className:`grow bg-red/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,B.jsx)(`div`,{style:{width:a.updatingWidth},className:`grow animate-pulse bg-yellow/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,B.jsx)(`div`,{style:{width:a.pendingWidth},className:`grow bg-gray-600 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`})]}),a.text&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground font-light mt-2`,children:a.text})]}):null}async function As(e){let{data:t}=await s.delete(`/Cluster/${e}`,{timeout:0});return t}function js(){return P({mutationFn:e=>As(e)})}function Ms(...e){return(0,z.useMemo)(()=>e.map(e=>(()=>{navigator.clipboard.writeText(e),R.info(`Copied to clipboard!`,{icon:(0,B.jsx)(Le,{}),duration:1e3})})),e)}function Ns({cluster:e}){let t=pt(),n=Ie(),i=(0,z.useMemo)(()=>f(e),[e]),a=fa({operationsUrl:i}),o=Ti(e.id),[,s]=Zi($i.SavedClusterState,null),{view:l,update:u,remove:d,create:p}=Sa(e.organizationId,e.id),{mutate:m,isPending:h}=js(),[g,_]=(0,z.useState)(!1),[v,y]=(0,z.useState)(!1),b=(0,z.useMemo)(()=>e.status&&no.includes(e.status),[e.status]),x=Es(e),S=c.checkForFabricConnect(e.id),C=!S&&!!o.user,ee=(0,z.useMemo)(()=>e.status&&ro.includes(e.status),[e.status]),w=(0,z.useMemo)(()=>e.status&&ss(e.status),[e.status]),te=(0,z.useCallback)(async()=>{_(!0);let t=await co(e.id).catch(e=>(console.error(`Failed to lookup cluster details, proceeding without checking instances.`,e),null));if(await r({entityId:e.id,instanceClient:a}),t?.instances?.length)for(let e of t.instances)c.setUserForEntity(e,null);c.setUserForEntity(e,null)},[e,a]),ne=(0,z.useCallback)(()=>{s(e),t.navigate({to:`/${e.organizationId}/new-cluster`})},[e,t,s]),T=(0,z.useCallback)(()=>y(!0),[]),E=(0,z.useCallback)(()=>{let r=e.organizationId;m(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[r],refetchType:`active`}),await t.invalidate(),R.success(`Success`,{description:x?`Cluster successfully removed.`:`Cluster successfully terminated.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>R.dismiss()}}),y(!1)},onError:()=>{R.error(`Error`,{description:x?`Failed to remove cluster: ${e.name}`:`Failed to terminate cluster: ${e.name}.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>R.dismiss()}}),y(!1)}})},[t,e.organizationId,e.id,e.name,m,x,n]),D=e.domains?.[0]?.domain||e.fqdn,[O,re]=Ms(`${D}`,`https://${D}`),ie=[b&&u&&!o.isLoading&&(!C||S)&&(0,B.jsx)(j,{to:`${e.id}/sign-in`,disabled:g,children:(0,B.jsxs)(Ss,{children:[(0,B.jsx)(mn,{className:`text-green`}),` Direct Sign In`]})},`sign-in`),b&&l&&!!i&&!o.isLoading&&C&&(0,B.jsx)(Ss,{onClick:te,disabled:g,children:`Direct Sign Out`},`direct-sign-out`),b&&u&&(0,B.jsx)(j,{to:`${e.id}/edit`,disabled:g,children:(0,B.jsxs)(Ss,{children:[(0,B.jsx)(gt,{className:`text-purple-600`}),` `,x?`Edit`:`Edit Scaling`]})},`edit`),b&&u&&!x&&(0,B.jsx)(j,{to:`${e.id}/edit/version`,disabled:g,children:(0,B.jsxs)(Ss,{children:[(0,B.jsx)(Pn,{className:`text-fuchsia-300`}),` Edit Version`]})},`edit-version`),b&&u&&!1,b&&l&&(0,B.jsx)(j,{to:`${e.id}/instances`,disabled:g,children:(0,B.jsxs)(Ss,{children:[(0,B.jsx)(Un,{className:`text-orange-300`}),` Instances`]})},`instances`),b&&l&&e.fqdn&&(0,B.jsx)(Ts,{},`copy-separator`),b&&l&&e.fqdn&&(0,B.jsxs)(Ss,{onClick:O,disabled:g,children:[(0,B.jsx)(me,{}),` Copy Host Name`]},`copy-host-name`),b&&l&&e.fqdn&&(0,B.jsxs)(Ss,{onClick:re,disabled:g,children:[(0,B.jsx)(me,{}),` Copy API URL`]},`copy-api-url`),w&&p&&(0,B.jsx)(Ss,{className:`focus:bg-green/70 focus:text-white`,onClick:ne,children:`Try Again`},`try-again`),!ee&&d&&b&&(0,B.jsx)(Ts,{},`remove-separator`),!ee&&d&&(0,B.jsxs)(Ss,{className:`focus:bg-red/70 focus:text-white`,onClick:T,children:[(0,B.jsx)(fn,{className:`text-red-300`}),` `,x?`Remove`:`Terminate`]},`remove`)].filter(Ri);return(0,B.jsxs)(Ei,{className:`relative h-full justify-between hover:shadow-lg transition-shadow duration-200`,children:[(0,B.jsxs)(Di,{children:[(0,B.jsxs)(ki,{className:`flex items-center justify-between`,children:[D?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`truncate max-w-48`,children:D}),(0,B.jsx)(mt,{onClick:O,size:16,className:`cursor-pointer`}),(0,B.jsx)(`span`,{className:`grow`})]}):(0,B.jsx)(`span`,{children:`Self-Hosted`}),!ee&&(0,B.jsxs)(ys,{children:[(0,B.jsx)(bs,{children:(0,B.jsx)(de,{"aria-label":`Cluster options`})}),(0,B.jsx)(xs,{children:[...ie]})]})]}),(0,B.jsx)(Oi,{children:(0,B.jsx)(`h2`,{children:e.name})})]}),(0,B.jsxs)(Ai,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(ks,{cluster:e}),b&&l&&(0,B.jsx)(Ds,{cluster:e}),w&&e.status&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(vs,{variant:as(e.status),children:Ya(e.status)}),(0,B.jsx)(`span`,{className:`text-xs`,children:`Click "..." to choose how to proceed.`})]})]}),(0,B.jsx)(_s,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:x?`Remove`:`Terminate`,presentParticiple:x?`Removing`:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:v,hideDataLossWarning:x,setIsModalOpen:e=>y(e),deletionConfirmed:E,deletionPending:h})]})}function Ps({overEmail:e}){return(0,B.jsx)(`a`,{href:e?`mailto:support@harperdb.io`:`https://discord.com/channels/1415002037439041710/1415002038286286994`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Contact us`})}function Fs({className:e,text:t,centered:n,...r}){return(0,B.jsxs)(`div`,{className:`text-foreground h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,B.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,B.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function Is({children:e,className:t}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] relative ${t??``}`,children:e})]})}async function Ls(e){let{data:t}=await s.get(`/Plan/`,{params:{organizationId:e}});return t}function Rs(e){return I({queryKey:[e,`instancePlan`],queryFn:()=>Ls(e),retry:!1})}async function zs(){let{data:e}=await s.get(`/HarperVersions/`);return e}function Bs(){return I({queryKey:[`HarperVersions`],queryFn:zs,staleTime:6e4,retry:!1})}async function Vs({organizationId:e,availableHosts:t}={}){let{data:n}=await s.get(`/Region/`,{params:{availableHosts:t,organizationId:e}});return n}function Hs({organizationId:e,availableHosts:t}={}){return I({queryKey:[e,`regionLocations`,t],queryFn:()=>Vs({organizationId:e,availableHosts:t}),retry:!1})}function Us(e){return(t,n)=>t[e]===n[e]?0:t[e]>n[e]?1:-1}function Ws(e){let t=e.split(`.`).map(Number);return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0}function Gs(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 Ks(e,t){return e.instanceFqdn===t.instanceFqdn?e.operationsApiPort-t.operationsApiPort:Gs(e.instanceFqdn)&&Gs(t.instanceFqdn)?Ws(e.instanceFqdn)-Ws(t.instanceFqdn):e.instanceFqdn>t.instanceFqdn?1:-1}function qs(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 Js(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 Ys(e,t,n){let r=qs(e,t),i={};for(let e in r)i[e]=Js(r[e],n);return i}function Xs(e,t){let n=Qs(e),r=Qs(t);return!n||!r?!1:tc(r,n)>=0}function Zs(e,t){let n=Qs(e),r=Qs(t);return!n&&!r?0:n?r?tc(n,r):1:-1}function Qs(e){if(typeof e!=`string`)return null;let[t]=e.split(`+`,1).concat(``),n=t.indexOf(`-`),r=n===-1?t:t.slice(0,n),i=n===-1?``:t.slice(n+1),a=r.split(`.`);if(a.length===0)return null;let o=$s(a[0]),s=$s(a[1]??`0`),c=$s(a[2]??`0`);return o==null||s==null||c==null?null:{major:o,minor:s,patch:c,pre:i?i.split(`.`).map(e=>ec(e)?Number(e):e):[]}}function $s(e){return e==null||e===``||!/^\d+$/.test(e)?null:Number(e)}function ec(e){return/^\d+$/.test(e)}function tc(e,t){if(e.major!==t.major)return e.major<t.major?-1:1;if(e.minor!==t.minor)return e.minor<t.minor?-1:1;if(e.patch!==t.patch)return e.patch<t.patch?-1:1;let n=e.pre.length>0,r=t.pre.length>0;if(!n&&!r)return 0;if(!n&&r)return 1;if(n&&!r)return-1;let i=Math.min(e.pre.length,t.pre.length);for(let n=0;n<i;n++){let r=e.pre[n],i=t.pre[n],a=typeof r==`number`,o=typeof i==`number`;if(a&&o){if(r!==i)return r<i?-1:1;continue}if(a&&!o)return-1;if(!a&&o)return 1;if(r!==i)return String(r)<String(i)?-1:1}return e.pre.length===t.pre.length?0:e.pre.length<t.pre.length?-1:1}function nc({width:e,className:t,animated:n,placeholder:r}){return(0,B.jsxs)(`div`,{className:x(`w-full bg-gray-200 rounded-full relative`,r?`h-6`:`h-2.5`),children:[r&&(0,B.jsx)(`div`,{className:`absolute top-0 h-full w-full font-bold text-xs flex flex-col items-center justify-center text-black/60 text-shadow-2xs`,children:r}),(0,B.jsx)(`div`,{className:x(`rounded-full`,r?`h-6`:`h-2.5`,!t?.includes(`bg-`)&&`bg-purple/40`,n&&`transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`,t),style:{width:e}})]})}function rc({duration:e,message:t,lateMessage:n}){let r=(0,z.useRef)(0),i=(0,z.useRef)(0),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(`5%`),l=(0,z.useCallback)(function t(n){i.current||=n;let a=n-i.current,s=Math.min(a/e,1);c(Math.max(5,s*100)+`%`),s<1?r.current=requestAnimationFrame(t):o(!0)},[e]);return(0,z.useEffect)(()=>(r.current=requestAnimationFrame(l),()=>cancelAnimationFrame(r.current)),[l]),(0,B.jsxs)(B.Fragment,{children:[a?n:t,(0,B.jsx)(nc,{width:s,animated:!1})]})}async function ic(e){let{data:t}=await s.post(`/Cluster/`,e,{timeout:0});return t}function ac(){return P({mutationFn:e=>ic(e)})}async function oc(e){let{id:t,...n}=e,{data:r}=await s.put(`/Cluster/${t}`,n,{timeout:0});return r}function sc(){return P({mutationFn:e=>oc(e)})}function cc(e){return!!e&&e!==`undefined`&&e!==`null`}async function lc(e){if(!cc(e))throw Error(`getOrganization called without a valid organization id (got: ${e})`);let{data:t}=await s.get(`/Organization/${e}`);return t}function uc(e){return I({queryKey:[e],queryFn:()=>lc(e),retry:!1,enabled:cc(e),refetchInterval:1e4})}var dc=`ENTERPRISE`;function fc(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 pc(e,t,n=`-`){let r=t.split(n)[0];return e.findIndex(e=>e.startsWith(r))!==-1}function mc(e){return e.replace(/[^a-zA-Z0-9]/g,`-`).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase().replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}function Q(e){return e!==void 0&&e>0}async function hc(e){await s.put(`/Payment/`,e)}function gc(){return P({mutationFn:e=>hc(e)})}function _c(e){let{mutate:t}=gc();return(0,z.useCallback)((n,r)=>{t({paymentMethodId:typeof n==`string`?n:n.id,organizationId:e},{onSuccess:()=>{R.success(`Success! Your payment method has been saved.`),r(!0)},onError:()=>{R.error(`Failed to process payment method details. Please try another payment method.`),r(!1)}})},[t,e])}var vc=(0,z.createContext)(null);function yc(){return(0,z.useContext)(vc)}function bc({hasExistingBilling:e,onPaymentAdded:t,onSaveStateForBillingRedirect:n}){let{organizationId:r}=F({strict:!1}),i=dt(),a=yc(),o=Ce(),[s,c]=(0,z.useState)(!1),l=_c(r),u=(0,z.useCallback)(()=>{t(!1)},[t]);return(0,B.jsxs)(`form`,{id:`billing-add-payment-method-form`,name:`billing-add-payment-method-form`,onSubmit:(0,z.useCallback)(async e=>{if(e.preventDefault(),!i||!o)return;c(!0),await o.submit(),n?.(!0);let s=await i.confirmSetup({clientSecret:a.clientSecret,elements:o,redirect:`if_required`,confirmParams:{return_url:`${window.location.origin}/#/${r}/billing/confirm`}});s.error?(console.error(s.error.message),R.error(s.error.message),c(!1),n?.(!1)):s.setupIntent.payment_method&&(l(s.setupIntent.payment_method,t),n?.(!1))},[o,t,n,r,l,i,a.clientSecret]),className:`max-w-xl`,children:[(0,B.jsx)(Ee,{}),(0,B.jsx)(jt,{options:{mode:`billing`}}),(0,B.jsxs)(`div`,{className:`mt-4 flex gap-8 items-center`,children:[(0,B.jsxs)(g,{disabled:!i||!o||s,variant:`submit`,className:`rounded-full`,children:[(0,B.jsx)(je,{}),` Add Payment Method`]}),e&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`text-xs text-gray-600`,children:`Your existing payment method will be overwritten.`}),(0,B.jsx)(g,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Cancel`})]})]})]})}async function xc(e){let{data:t}=await s.post(`/StripeAccount/`,e);return t}function Sc(){return P({mutationFn:e=>xc(e)})}async function Cc(e){let{data:t}=await s.post(`/Payment/`,{organizationId:e.organizationId});return t}function wc(){return P({mutationFn:e=>Cc(e)})}function Tc(e){let{enabled:t,existingStripeId:n,organizationId:r}=e,{mutate:i}=Sc(),{mutate:a}=wc(),[o,s]=(0,z.useState)(void 0);return(0,z.useEffect)(()=>{},[i,t,n,a,(0,z.useCallback)(e=>{s(e.clientSecret)},[]),r]),o}function Ec({children:e}){let{organizationId:t}=F({strict:!1}),{data:n}=A(uc(t)),r=Tc({organizationId:t,enabled:!!n,existingStripeId:n?.stripeId}),i=Qi();return(0,z.useMemo)(()=>({clientSecret:r||``,appearance:{theme:i===`dark`?`night`:`stripe`}}),[r,i]),console.error(`No VITE_PUBLIC_STRIPE_KEY is configured for this environment.`),(0,B.jsx)(`div`,{className:`mt-20 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:`Setting up your billing is currently disabled. Please check back again later.`})}function Dc({onPaymentAdded:e,onSaveStateForBillingRedirect:t}){let{organizationId:n}=F({strict:!1}),{data:r}=A(uc(n)),i=r?.billing,a=i?.paymentMethod;return(0,B.jsxs)(Ec,{children:[(0,B.jsx)(`div`,{className:`mt-2 mb-6`,children:!a&&`You currently have no payment method on file. Please fill out the secure form below.`}),(0,B.jsx)(bc,{hasExistingBilling:!!i,onSaveStateForBillingRedirect:t,onPaymentAdded:e})]})}var Oc=function(e){return e.PASS=`pass`,e.FAIL=`fail`,e.PENDING=`pending`,e.ERROR=`error`,e}({});function kc(e){switch(e){case Oc.PASS:return`success`;case Oc.FAIL:case Oc.ERROR:return`destructive`;case Oc.PENDING:default:return`default`}}function Ac(e){switch(e){case Oc.PASS:return`READY`;case Oc.FAIL:case Oc.ERROR:case Oc.PENDING:default:return e.toUpperCase()}}function jc(e,t){return`${String(e).padStart(2,`0`)}/${String(t%100).padStart(2,`0`)}`}function Mc(e){let{onSaveStateForBillingRedirect:t,onReplacingPaymentMethod:n}=e??{},{organizationId:r}=F({strict:!1}),{update:i}=ba(r),{data:a,refetch:o}=A(uc(r)),s=a?.billing?.paymentMethod,[c,l]=(0,z.useState)(!1),u=(0,z.useCallback)(()=>{l(!c),n?.(!c)},[n,c]),d=(0,z.useCallback)(e=>{l(!1),n?.(!1),e&&o()},[n,o]);return a?.type===`ENTERPRISE`?(0,B.jsxs)(`span`,{children:[`You are part of an enterprise organization! We don’t currently show your payment methods on this page. Want to explore your solution with Harper more? `,(0,B.jsx)(Ps,{}),`, we would love to talk!`]}):s&&!c?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`mt-2`,children:[s.brand?.toUpperCase()??`Card`,` ending in `,s.last4??`••••`,s.expMonth&&s.expYear?(0,B.jsxs)(B.Fragment,{children:[`(exp `,jc(s.expMonth,s.expYear),`)`]}):null,s.status?(0,B.jsxs)(B.Fragment,{children:[`—`,` `,(0,B.jsx)(vs,{variant:kc(s.status),children:Ac(s.status)})]}):null]}),i&&(0,B.jsx)(`div`,{className:`mt-2 mb-6`,children:(0,B.jsx)(g,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Replace Payment Method`})})]}):i?(0,B.jsx)(Dc,{onSaveStateForBillingRedirect:t,onPaymentAdded:d}):(0,B.jsx)(`div`,{children:`This org doesn't have a payment method, and you don't have access to add one. Please contact your administrator.`})}function Nc({clusterId:e,isPending:t,onGoBackToDetails:n,onSaveStateForBillingRedirect:r,onSubmit:i,organizationId:a,selectedPlan:o}){let{data:s}=A(uc(a)),c=s?.billing,l=s?.type===dc,d=l||c?.paymentMethod?.status===Oc.PASS,[f,p]=(0,z.useState)(!1),m=Q(o?.planLimits?.expirationMonths)&&o.planLimits.expirationMonths<1e3&&o.planLimits.expirationMonths,h=(0,B.jsx)(B.Fragment,{children:(0,B.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end mt-3 max-w-xl`,children:[(0,B.jsxs)(g,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,disabled:t,onClick:n,children:[(0,B.jsx)(lr,{}),` Back to Details`]}),(0,B.jsxs)(g,{disabled:t||!d||f,type:`submit`,variant:`submit`,className:`rounded-full`,onClick:i,children:[e?`Edit Cluster`:`Create New Cluster`,` `,(0,B.jsx)(Tn,{})]})]})});if(l)return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`ul`,{className:`list-disc ml-6 max-w-lg`,children:[(0,B.jsx)(`li`,{children:`Reminder: you will be billed at your contracted rate for any additional infrastructure.`}),(0,B.jsxs)(`li`,{children:[`Your account representative can work with you to sort out more precise details, and to help accomplish your objectives with this cluster. `,(0,B.jsx)(Ps,{overEmail:!0}),`, we are here to help.`]})]}),h]});let _=m&&`, or ${u(m,`month`,`months`)} elapse`;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`ul`,{className:`list-disc ml-6 mb-6`,children:[(0,B.jsx)(`li`,{children:`You will be billed for this cluster today, and will receive a license for the block of usage you've requested.`}),e&&(0,B.jsx)(`li`,{children:`If you scale up, you'll be charged for the additional blocks you've purchased now, and your next auto renewal will be for all purchased blocks.`}),e&&(0,B.jsx)(`li`,{children:`If you remove a region, that region's usage block will not be used anymore (because it is specific to that region).`}),(0,B.jsxs)(`li`,{children:[`When that block is used up`,_,`, you will be automatically renewed.`]}),(0,B.jsx)(`li`,{children:`While refunds are not available, we’d be happy to assist you with troubleshooting.`}),(0,B.jsxs)(`li`,{children:[`We would love to work with you to sort out more precise details, and to help accomplish your objectives with this cluster. `,(0,B.jsx)(Ps,{overEmail:!0}),`, we are here to help.`]})]}),(0,B.jsx)(`p`,{className:`text-muted-foreground text-sm mb-6`,children:`Payment method:`}),(0,B.jsx)(Mc,{onSaveStateForBillingRedirect:r,onReplacingPaymentMethod:p}),h]})}var Pc=/(^$|^(?: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,Fc=65535,Ic=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.`),Lc=O({clusterName:w().nonempty(`Please enter a cluster name.`).max(255,`Cluster name cannot be longer than 255 characters long.`),abbreviatedName:ne([re(``),T(),Ic]).optional(),fqdn:w().regex(Pc,`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:ie(O({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:ie(O({secure:D([`true`,`false`]),fqdn:w().nonempty(`Please enter the host name of your instance.`).regex(Pc,`Please enter a valid host name without the port or any path.`),port:b().min(0,`Positive thinking only, please.`).max(Fc,`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 Rc({calculatedNames:e,disabled:t,form:n}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(W,{control:n.control,name:`abbreviatedName`,render:({field:n})=>(0,B.jsxs)(G,{className:`col-span-3`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Host Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{...n,type:`text`,maxLength:Ic.maxLength,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:e.suggestedAbbreviatedName,disabled:t})}),(0,B.jsx)(q,{})]})}),(0,B.jsxs)(G,{className:`col-span-3 `,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Full Host Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(`span`,{children:e.fullHostName})}),(0,B.jsx)(q,{})]})]})}function zc({className:e}={}){return(0,B.jsx)(`div`,{className:(0,z.useMemo)(()=>x(`animate-pulse h-2.5 bg-gray-200 rounded-full dark:bg-gray-700`,!e?.includes(`mb-`)&&`mb-4 `,!e?.includes(`w-`)&&`w-48 `,e),[e])})}function Bc({...e}){return(0,B.jsx)(Ur,{"data-slot":`select`,...e})}function Vc({...e}){return(0,B.jsx)(Dn,{"data-slot":`select-group`,...e})}function Hc({...e}){return(0,B.jsx)(be,{"data-slot":`select-value`,...e})}function Uc({className:e,children:t,...n}){return(0,B.jsxs)(Ot,{"data-slot":`select-trigger`,className:d(`border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex h-9 w-fit items-center justify-between gap-2 rounded-md border bg-white text-foreground dark:bg-grey-700 dark:text-white px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:truncate *:data-[slot=select-value]:block *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,B.jsx)(ur,{asChild:!0,children:(0,B.jsx)(Ge,{className:`opacity-50 size-4`})})]})}function Wc({className:e,children:t,position:n=`popper`,...r}){return(0,B.jsx)(Mr,{children:(0,B.jsxs)(yn,{"data-slot":`select-content`,className:d(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,B.jsx)(Kc,{}),(0,B.jsx)(Fr,{className:d(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,B.jsx)(qc,{})]})})}function Gc({className:e,...t}){return(0,B.jsx)(rn,{"data-slot":`select-label`,className:d(`px-2 py-1.5 text-sm font-medium`,e),...t})}function $({className:e,children:t,...n}){return(0,B.jsxs)(tr,{"data-slot":`select-item`,className:d(`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,B.jsx)(jn,{children:t}),(0,B.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,B.jsx)(Fn,{children:(0,B.jsx)(Yt,{className:`size-4`})})})]})}function Kc({className:e,...t}){return(0,B.jsx)(zr,{"data-slot":`select-scroll-up-button`,className:d(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,B.jsx)(fr,{className:`size-4`})})}function qc({className:e,...t}){return(0,B.jsx)(dn,{"data-slot":`select-scroll-down-button`,className:d(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,B.jsx)(Ge,{className:`size-4`})})}var Jc={Colocated:`Shared infrastructure for optimized value`,Dedicated:`Dedicated infrastructure for consistent performance`,"Self-Hosted":`Your own infrastructure`};function Yc({availableDeploymentTypes:e,disabled:t,form:n}){return(0,B.jsx)(W,{control:n.control,name:`deploymentDescription`,render:({field:r})=>(0,B.jsxs)(G,{className:`col-span-3`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Harper Deployment`}),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(zc,{}),children:(0,B.jsx)(U,{children:(0,B.jsxs)(Bc,{...r,disabled:t,onValueChange:e=>{r.onChange(e),n.trigger()},children:[(0,B.jsx)(Uc,{className:`w-full h-auto`,children:(0,B.jsx)(Hc,{placeholder:`Choose Tier`})}),(0,B.jsx)(Wc,{children:(0,B.jsx)(Vc,{children:e.map(e=>(0,B.jsxs)($,{value:e,children:[(0,B.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e}),Jc[e]&&(0,B.jsx)(`dd`,{className:`font-light`,children:Jc[e]})]},e))})})]})})}),(0,B.jsx)(q,{})]})})}function Xc({disabled:e,form:t}){return(0,B.jsx)(W,{control:t.control,name:`fqdn`,render:({field:t})=>(0,B.jsxs)(G,{className:`md:col-span-6 col-span-3`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Optional Cluster Load Balancer Host Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{...t,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:`example.your-company.com`,disabled:e})}),(0,B.jsx)(q,{})]})})}function Zc({className:e,disabled:t,form:n}){return(0,B.jsx)(W,{control:n.control,name:`clusterName`,render:({field:n})=>(0,B.jsxs)(G,{className:e,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Cluster Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{autoFocus:!0,type:`text`,maxLength:Lc.shape.clusterName.maxLength,autoCapitalize:`words`,disabled:t,...n})}),(0,B.jsx)(q,{})]})})}function Qc({availablePerformanceDescriptions:e,form:t,selectedDeployment:n}){return(0,B.jsx)(W,{control:t.control,name:`performanceDescription`,render:({field:r})=>(0,B.jsxs)(G,{className:`col-span-3`,children:[(0,B.jsxs)(K,{className:`pb-1`,children:[n.startsWith(`Self`)?`Support`:`Performance`,` & Usage`]}),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(zc,{}),children:(0,B.jsx)(U,{children:(0,B.jsxs)(Bc,{...r,onValueChange:e=>{r.onChange(e),t.trigger()},disabled:!e?.length,children:[(0,B.jsx)(Uc,{className:`w-full h-auto`,children:(0,B.jsx)(Hc,{placeholder:`Choose Tier`})}),(0,B.jsx)(Wc,{children:(0,B.jsx)(Vc,{children:e.map(e=>(0,B.jsxs)($,{value:e.performanceTier,children:[(0,B.jsxs)(`dt`,{className:`text-left font-bold text-sm/6 flex items-center gap-2`,children:[e.name,e.isPremium&&(0,B.jsx)(vs,{children:`Premium`})]}),e.description&&(0,B.jsx)(`dd`,{className:`text-left font-light`,children:e.description})]},e.name))})})]})})}),(0,B.jsx)(q,{})]})})}function $c({className:e,...t}){let{formDescriptionId:n}=eo();return(0,B.jsx)(`p`,{"data-slot":`form-description`,id:n,className:d(`text-muted-foreground text-sm`,e),...t})}function el({className:e,form:t}){return(0,B.jsx)(W,{control:t.control,name:`skipGtmWait`,render:({field:t})=>(0,B.jsxs)(G,{className:e,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-4 h-4 cursor-pointer`,checked:t.value||!1,onChange:t.onChange,onBlur:t.onBlur,name:t.name,ref:t.ref})}),(0,B.jsx)(K,{className:`cursor-pointer`,children:`Immediate upgrade and restart`})]}),(0,B.jsx)($c,{children:`Apply changes immediately without waiting for each instance to be taken out of the load balancer (faster, but potentially less safe).`})]})})}function tl({className:e,disabled:t,form:n,harperVersions:r}){return r?.value?.length?(0,B.jsx)(W,{control:n.control,name:`version`,render:({field:i})=>(0,B.jsxs)(G,{className:e,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Harper Version`}),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(zc,{}),children:(0,B.jsx)(U,{children:(0,B.jsxs)(Bc,{...i,disabled:t,onValueChange:e=>{i.onChange(e),n.trigger()},children:[(0,B.jsx)(Uc,{className:`w-full h-auto`,children:(0,B.jsx)(Hc,{placeholder:`Choose Version`})}),(0,B.jsx)(Wc,{children:(0,B.jsx)(Vc,{children:r?.value.map(e=>(0,B.jsxs)($,{value:e.version,children:[e.version,` `,(0,B.jsx)(`span`,{className:`font-light opacity-50`,children:e.name})]},e.version))})})]})})}),(0,B.jsx)(q,{})]})}):null}var nl=new RegExp(/^\d+/);function rl(e,t){let n=parseInt(e.match(nl)?.[0]||`0`,10),r=parseInt(t.match(nl)?.[0]||`0`,10);return n===r?0:n>r?1:-1}var il=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],al=[`secs`,`mins`,`hrs`],ol={bytes:1e3,secs:60};function sl(e,t,n){let r,i;switch(t){case`bytes`:r=il,i=ol.bytes;break;case`secs`:r=al,i=ol.secs;break;default:return e}let a=r.indexOf(n);return a===-1?e:e/i**a}function cl(e,t){let n,r;switch(e){case`bytes`:n=il,r=ol.bytes;break;case`secs`:n=al,r=ol.secs;break;default:return e}let i=0;for(;t>=r&&i<n.length-1;)t/=r,i++;return n[i]}function ll(e,t=1){let n=e*t,r=cl(`bytes`,n),i=sl(n,`bytes`,r);return`${new Intl.NumberFormat().format(Math.round(i))} ${r}`}function ul(e){return new Intl.NumberFormat().format(e)}var dl=[`K`,`M`,`B`,`T`,`Qa`,`Qi`,`Sx`,`Sp`,`Oc`,`No`,`Dc`];function fl(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<dl.length-1);return`${ul(Math.round(n))} ${dl[r]}`}function pl(e,t){let n=Object.values(t).flatMap(e=>Object.values(e)).map(e=>e.purchasedBlockMultiplier??1),r=Math.max(...n,1),i=Math.min(...n,r),a=t=>{let n=e.map(t).filter(e=>typeof e==`number`&&e>0);return n.length?{min:Math.min(...n),max:Math.max(...n)}:{min:0,max:0}},o=a(e=>e.planLimits?.readsPerMinuteCount),s=a(e=>e.planLimits?.totalReadCount);return{readRate:{min:o.min*i,max:o.max*r},totalReads:{min:s.min*i,max:s.max*r},writeRate:a(e=>e.planLimits?.writesPerMinuteCount),totalWrites:a(e=>e.planLimits?.totalWriteCount)}}function ml(e,{min:t,max:n}){if(e<=0)return 0;let r=Math.max(Math.min(t,e),1),i=Math.max(n,e);if(i<=r)return 1;let a=(Math.log(e)-Math.log(r))/(Math.log(i)-Math.log(r));return Math.min(Math.max(a,0),1)}function hl({selectedPlan:e,selectedRegion:t,usageScale:n,isEnterprise:r,cloudProvider:i}){let[a,o]=(0,z.useState)(!1),s=(0,z.useCallback)(()=>{o(!a)},[a,o]),c=e?.planLimits,l=e?.resourcesPerInstance,f=i&&e?.cloudInstanceTypes?.[i],p=Q(c?.expirationMonths)&&c.expirationMonths<1e3&&c.expirationMonths,m=t?.purchasedBlockMultiplier??1,h=(0,z.useMemo)(()=>c?[Q(c.totalReadCount)&&{label:`Total Reads`,value:`${fl(c.totalReadCount*m)} reads`},Q(c.totalReadsBytes)&&{label:`Total Read Transfer`,value:`${ll(c.totalReadsBytes*m)}`},Q(c.readsPerMinuteCount)&&{label:`Read Rate`,value:`${fl(c.readsPerMinuteCount*60*m)}/min`},Q(c.readsPerMinuteBytes)&&{label:`Read Bandwidth`,value:`${ll(c.readsPerMinuteBytes*60*m)}/min`},Q(c.totalWriteCount)&&{label:`Total Writes`,value:`${fl(c.totalWriteCount)} reads`},Q(c.totalWritesBytes)&&{label:`Total Write Transfer`,value:`${ll(c.totalWritesBytes)}`},Q(c.writesPerMinuteCount)&&{label:`Write Rate`,value:`${fl(c.writesPerMinuteCount*60)}/min`},Q(c.writesPerMinuteBytes)&&{label:`Write Bandwidth`,value:`${ll(c.writesPerMinuteBytes*60)}/min`},Q(c.totalRealTimeMessageDeliveries)&&{label:`Total Real-Time Messages`,value:`${fl(c.totalRealTimeMessageDeliveries*m)} messages`},Q(c.totalRealTimeMessageDeliveryBytes)&&{label:`Total Real-Time Message Transfer`,value:`${ll(c.totalRealTimeMessageDeliveryBytes*m)}`},Q(c.realTimeMessageDeliveriesPerMinute)&&{label:`Real-Time Message Rate`,value:`${fl(c.realTimeMessageDeliveriesPerMinute*60*m)}/min`},Q(c.realTimeMessageDeliveryBytesPerMinute)&&{label:`Real-Time Message Bandwidth`,value:`${ll(c.realTimeMessageDeliveryBytesPerMinute*60*m)}/min`},Q(c.tlsHandshakes)&&{label:`TLS Handshakes`,value:`${fl(c.tlsHandshakes*60*m)}`},Q(c.applicationComputeHours)&&{label:`Application Compute Hours`,value:`${fl(c.applicationComputeHours*m)}`},!!l&&Q(l.storageGb)&&{label:`Storage`,value:`${ll(l.storageGb*1e9)}`},!!l&&Q(l.cpuCores)&&{label:`Maximum CPU Cores`,value:`${fl(l.cpuCores)}`},!!l&&Q(l.memoryMb)&&{label:`Memory`,value:`${l.memoryMb/1024} GB`},!!f&&{label:`Cloud Instance Type`,value:f},!!p&&{label:`Expiration`,value:u(p,`month`,`months`)},!!t?.id&&{label:`Region ID`,value:t.id},!!e?.id&&{label:`Plan ID`,value:e.id}].filter(Ri):[],[p,t,e,m]);if(!c)return``;if(!Q(c.totalReadCount))return`This plan has no usage limits.`;let _=r?`for the contracted rate`:`for the price listed above`,v=p?` in ${u(p,`month`,`months`)} or`:``,y=Q(c.readsPerMinuteCount)?c.readsPerMinuteCount*m:0,b=Q(c.writesPerMinuteCount)?c.writesPerMinuteCount:0,x=c.totalReadCount*m,S=Q(c.totalWriteCount)?c.totalWriteCount:0,C=[y>0&&{icon:nn,label:`Read Rate`,value:`${fl(y)}/min`,fill:ml(y,n.readRate)},x>0&&{icon:Er,label:`Total Reads`,value:fl(x),fill:ml(x,n.totalReads)},b>0&&{icon:nn,label:`Write Rate`,value:`${fl(b)}/min`,fill:ml(b,n.writeRate)},S>0&&{icon:Nn,label:`Total Writes`,value:fl(S),fill:ml(S,n.totalWrites)},!!p&&{icon:yt,label:`License Term`,value:u(p,`month`,`months`)}].filter(Ri);return(0,B.jsxs)(G,{className:`basis-full`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-2`,children:[(0,B.jsx)(K,{onClick:s,className:`cursor-pointer`,children:`Usage block included with this plan`}),(0,B.jsxs)(g,{type:`button`,variant:`link`,className:`text-foreground`,onClick:s,children:[`Learn More `,a?(0,B.jsx)($n,{}):(0,B.jsx)(Tn,{})]})]}),(0,B.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5`,children:C.map(e=>(0,B.jsx)(gl,{icon:e.icon,label:e.label,value:e.value,fill:e.fill},e.label))}),(0,B.jsx)(U,{children:(0,B.jsxs)(`dl`,{className:d(`divide-y divide-border rounded-md overflow-hidden transition-[max-height] duration-200 ease-in`,a?`max-h-fit border border-border`:`max-h-0`),children:[(0,B.jsxs)(`div`,{className:`text-sm px-4 py-5 leading-relaxed text-muted-foreground`,children:[`This plan licenses Harper for the usage limits below, `,_,`. The usage license expires`,v,` `,`when any usage limit is reached. New usage blocks are automatically purchased/billed as blocks are consumed.`]}),h.map((e,t)=>(0,B.jsxs)(`div`,{className:d(`px-4 py-1 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-3`,t%2==0&&`bg-muted dark:bg-grey-700`),children:[(0,B.jsx)(`dt`,{className:`text-sm/6 font-medium text-foreground`,children:e.label}),(0,B.jsx)(`dd`,{className:`mt-1 text-sm/6 text-muted-foreground sm:col-span-2 sm:mt-0`,children:e.value})]},e.label))]})}),(0,B.jsx)(q,{})]})}function gl({icon:e,label:t,value:n,fill:r}){return(0,B.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-background/50 p-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,B.jsx)(e,{className:`size-4 shrink-0`}),(0,B.jsx)(`span`,{className:`text-xs font-medium`,children:t})]}),(0,B.jsx)(`span`,{className:`text-lg font-bold text-foreground tabular-nums`,children:n}),r!==void 0&&(0,B.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-sky-500/15`,children:(0,B.jsx)(`div`,{className:`h-full rounded-full bg-sky-500 transition-[width] duration-300`,style:{width:`${Math.max(Math.min(r,1)*100,4)}%`}})})]})}function _l({control:e,fieldArray:t,form:n,index:r,regionNameToLatencyToRegion:i,premiumOnlyRegions:a,usageScale:o,selectedPlan:s,isEnterprise:c,cloudProvider:l}){let u=(0,z.useMemo)(()=>Object.keys(i).sort(),[i]),d=n.watch(`deploymentDescription`)?.startsWith(`Dedicated`),f=n.watch(`regionPlans.${r}.regionName`),p=n.watch(`regionPlans.${r}.latencyDescription`),m=(0,z.useMemo)(()=>Object.keys(i[f]||{}).sort(rl).reverse(),[i,f]),h=s?.allowedRegionIds,_=(0,z.useCallback)(e=>!h?.length||Object.values(i[e]||{}).some(e=>h.includes(e.id)),[h,i]),v=(0,z.useCallback)(e=>{if(!h?.length)return!0;let t=i[f]?.[e]?.id;return!t||h.includes(t)},[h,i,f]);(0,z.useEffect)(function(){if(f&&m?.length&&!m?.includes(p)){let e=p?.split(` `)[0].toLowerCase(),t=m.find(t=>e?t.split(` `)[0].toLowerCase()===e:!0)||m[0];n.setValue(`regionPlans.${r}.latencyDescription`,t),n.trigger()}},[m,n,r,p,f]);let y=(0,z.useCallback)(()=>{t?.remove(r),n.trigger()},[t,n,r]);return(0,B.jsxs)(`div`,{className:`md:col-span-6 col-span-3 py-2 pl-4 border-l-4 border-border gap-6 flex flex-wrap items-start`,children:[(0,B.jsx)(W,{control:e,name:`regionPlans.${r}.regionName`,render:({field:e})=>(0,B.jsxs)(G,{className:`flex-1`,children:[(0,B.jsxs)(K,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(ce,{className:`size-4 shrink-0`}),`Region `,t.fields.length>1?r+1:``]}),(0,B.jsx)(U,{children:(0,B.jsxs)(Bc,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,children:[(0,B.jsx)(Uc,{className:`w-full`,children:(0,B.jsx)(Hc,{placeholder:`Choose Region`})}),(0,B.jsx)(Wc,{children:(0,B.jsx)(Vc,{children:u.map(e=>(0,B.jsx)($,{value:e,disabled:!_(e),children:(0,B.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,a.regionNames.has(e)&&(0,B.jsx)(vs,{children:`Premium`})]})},e))})})]})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e,name:`regionPlans.${r}.latencyDescription`,render:({field:e})=>(0,B.jsxs)(G,{className:`flex-1`,children:[(0,B.jsxs)(K,{children:[`Estimated `,d?`P95`:`P90`,` Latency, Distribution`]}),(0,B.jsx)(U,{children:(0,B.jsxs)(Bc,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,disabled:!m?.length,children:[(0,B.jsx)(Uc,{className:`w-full`,children:(0,B.jsx)(Hc,{placeholder:`Choose Latency Tier`})}),(0,B.jsx)(Wc,{children:(0,B.jsx)(Vc,{children:m.map(e=>(0,B.jsx)($,{value:e,disabled:!v(e),children:(0,B.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,(()=>{let t=i[f]?.[e]?.id;return t&&a.regionIds.has(t)&&(0,B.jsx)(vs,{children:`Premium`})})()]})},e))})})]})}),(0,B.jsx)(q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,B.jsx)(`div`,{className:`flex-none mt-6`,children:(0,B.jsxs)(g,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:y,children:[(0,B.jsx)(fn,{}),` `,(0,B.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})}),(0,B.jsx)(hl,{selectedPlan:s,selectedRegion:i[f]?.[p],usageScale:o,isEnterprise:c,cloudProvider:l})]})}function vl({form:e,regionLocations:t,regionNameToLatencyToRegion:n,premiumOnlyRegions:r,usageScale:i,selectedPlan:a,totalPrice:o,isEnterprise:s,cloudProvider:c}){let l=e.watch(`regionPlans`),u=qt({control:e.control,name:`regionPlans`}),d=(0,z.useMemo)(()=>{let e=l.map(e=>n?.[e.regionName]?.[e.latencyDescription]?.region);return o?t?.find(t=>!e.includes(t.region)):null},[t,n,l,o]),f=(0,z.useCallback)(()=>{d&&(u.append({regionName:d.region,latencyDescription:d.latencyDescription}),e.trigger())},[e,d,u]);return t?.length?(0,B.jsxs)(B.Fragment,{children:[u.fields.map((t,o)=>(0,B.jsx)(_l,{control:e.control,fieldArray:u,form:e,index:o,regionNameToLatencyToRegion:n,premiumOnlyRegions:r,usageScale:i,selectedPlan:a,isEnterprise:s,cloudProvider:c},t.id)),d&&(0,B.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,B.jsxs)(g,{type:`button`,variant:`positiveOutline`,className:`rounded-full`,onClick:f,children:[(0,B.jsx)(Bt,{}),`Add Additional Region Usage`]})})]}):(0,B.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,B.jsx)(Ni,{className:`mt-0 m-0`,title:`No Regions Available`,showReturnToHome:!1,error:{message:(0,B.jsxs)(B.Fragment,{children:[`The deployment type you selected currently has no available regions. Please try a different deployment type, try again later, or `,(0,B.jsx)(Ps,{}),`.`]})}})})}function yl({control:e,fieldArray:n,form:r,index:i}){let a=(0,z.useCallback)(()=>{n?.remove(i)},[n,i]);return(0,B.jsxs)(`div`,{className:`md:col-span-6 col-span-3 p-4 rounded-md bg-accent gap-6 flex flex-wrap items-start`,children:[(0,B.jsx)(W,{control:e,name:`instances.${i}.secure`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsxs)(K,{children:[`Instance `,n.fields.length>1?i+1:``]}),(0,B.jsx)(U,{children:(0,B.jsxs)(Bc,{...e,onValueChange:t=>{e.onChange(t),r.trigger()},children:[(0,B.jsx)(Uc,{className:`w-full`,children:(0,B.jsx)(Hc,{placeholder:`https://`})}),(0,B.jsx)(Wc,{children:(0,B.jsxs)(Vc,{children:[(0,B.jsx)($,{value:`true`,children:`https://`}),(0,B.jsx)($,{value:`false`,children:`http://`})]})})]})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e,name:`instances.${i}.fqdn`,render:({field:e})=>(0,B.jsxs)(G,{className:`flex-3`,children:[(0,B.jsx)(K,{children:`Host Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{...e,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,onChange:t=>{e.onChange(t);let n=t.target.value,a=n===`localhost`||n===`127.0.0.1`,o=r.getFieldState(`instances.${i}.secure`);a&&!o.isDirty&&r.setValue(`instances.${i}.secure`,`false`)}})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e,name:`instances.${i}.port`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Operations API Port`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{...e,type:`number`,min:0,max:Fc,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:String(t),onChange:t=>{e.onChange(t.target.value?parseInt(t.target.value,10):void 0),r.trigger()}})}),(0,B.jsx)(q,{})]})}),n?.fields?.length&&n?.fields?.length>1&&(0,B.jsx)(`div`,{className:`flex-none mt-6`,children:(0,B.jsxs)(g,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:a,children:[(0,B.jsx)(fn,{}),` `,(0,B.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})})]})}function bl({form:e}){let n=qt({control:e.control,name:`instances`}),r=(0,z.useCallback)(()=>{n.append({secure:`true`,fqdn:``,port:t})},[n]);return(0,B.jsxs)(B.Fragment,{children:[n.fields.map((t,r)=>(0,B.jsx)(yl,{control:e.control,fieldArray:n,form:e,index:r},t.id)),(0,B.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,B.jsxs)(g,{type:`button`,variant:`positiveOutline`,className:`rounded-full`,onClick:r,children:[(0,B.jsx)(Bt,{}),`Add Instance`]})})]})}function xl(e,t){return!e.allowedRegionIds?.length||e.allowedRegionIds.includes(t)}function Sl(e,t){let n=new Set,r=new Set;if(!e.length)return{regionNames:n,regionIds:r};let i=Math.min(...e.map(e=>e.planLevel??0)),a=e.filter(e=>(e.planLevel??0)===i),o=e.filter(e=>(e.planLevel??0)>i);if(!o.length)return{regionNames:n,regionIds:r};for(let[e,i]of Object.entries(t)){let t=!1,s=!0;for(let e of Object.values(i)){let n=a.some(t=>xl(t,e.id)),i=o.some(t=>xl(t,e.id));!n&&!i||(t=!0,n?s=!1:r.add(e.id))}t&&s&&n.add(e)}return{regionNames:n,regionIds:r}}function Cl({calculatedNames:e,clusterId:t,deploymentToPerformanceToPlan:n,form:r,harperVersions:i,isEnterprise:a,cloudProvider:o,isPending:s,mode:c,regionLocations:l,regionNameToLatencyToRegion:u,selectedDeployment:d,selectedPerformance:f,selectedPlan:p,totalPrice:m}){let{isDirty:h,isValid:_}=se(),v=(0,z.useMemo)(()=>{let e=n[d]||{},t=Object.values(e).map(e=>e.planLevel??0),r=t.length?Math.min(...t):0;return Object.keys(e).map(t=>{let n=(e[t].planLevel??0)>r,i=t.slice(0,-1).split(`(`);if(i.length>1)return{performanceTier:t,name:i[0],description:i[1],isPremium:n};let a=t.split(` for `);return a.length>1?{performanceTier:t,name:a[0],description:`For `+a[1],isPremium:n}:{performanceTier:t,name:t,description:``,isPremium:n}})},[n,d]),y=(0,z.useMemo)(()=>Object.keys(n).sort(),[n]),b=(0,z.useMemo)(()=>Sl(Object.values(n[d]||{}),u),[n,u,d]),x=(0,z.useMemo)(()=>pl(Object.values(n).flatMap(e=>Object.values(e)),u),[n,u]);(0,z.useEffect)(function(){v?.length&&!v.find(e=>e.performanceTier===f)&&(r.setValue(`performanceDescription`,v[0].performanceTier),r.trigger())},[d,f,v,r]);let S=d===`Self-Hosted`,C=(0,B.jsx)(hs,{className:`mt-3 mb-12`,children:(0,B.jsxs)(g,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:s||t&&!h||!_,children:[c!==`version`&&m>0?`Confirm Payment Details`:t?`Edit Cluster`:`Create New Cluster`,(0,B.jsx)(Tn,{})]})});return c===`version`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-3 items-start gap-6 text-foreground md:grid-cols-6`,children:[(0,B.jsx)(Zc,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!0,form:r}),(0,B.jsx)(tl,{className:`col-span-3`,form:r,harperVersions:i}),(0,B.jsx)(el,{className:`col-span-3 md:col-span-6`,form:r})]}),C]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-3 items-start gap-6 text-foreground md:grid-cols-6`,children:[(0,B.jsx)(Zc,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!!t,form:r}),(0,B.jsx)(tl,{className:`col-span-3`,disabled:!!t,form:r,harperVersions:i}),S?(0,B.jsx)(Xc,{form:r,disabled:!!t}):(0,B.jsx)(Rc,{form:r,calculatedNames:e,disabled:!!t}),(0,B.jsx)(Yc,{form:r,availableDeploymentTypes:y}),(0,B.jsx)(Qc,{availablePerformanceDescriptions:v,form:r,selectedDeployment:d}),S?(0,B.jsx)(bl,{form:r}):(0,B.jsx)(vl,{form:r,regionLocations:l,regionNameToLatencyToRegion:u,premiumOnlyRegions:b,usageScale:x,selectedPlan:p,totalPrice:m,isEnterprise:a,cloudProvider:o}),t&&!S&&(0,B.jsx)(el,{className:`col-span-3 md:col-span-6`,form:r})]}),C]})}function wl(e){let{fqdn:n}=e,{secure:r,port:i}=e;return i||=t,i===443&&r===`false`&&(r=`true`),i===80&&r===`true`&&(r=`false`),`${r===`true`?`https`:`http`}://${n}${i===443||i===80?``:`:`+i}`.toLowerCase()}function Tl(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 El(e,t,n){if(t&&n){let r=e.getValues();if(!r.deploymentDescription||!r.performanceDescription||!r.regionPlans.length){let i=Tl(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 Dl({price:e}){return(0,B.jsx)(`span`,{className:`text-4xl`,children:new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).formatToParts(e||0).map((e,t)=>(0,B.jsx)(Ol,{type:e.type,value:e.value},t))})}function Ol({type:e,value:t}){switch(e){case`currency`:case`decimal`:case`fraction`:return(0,B.jsx)(`sup`,{className:`font-light text-xl`,children:t});default:return t}}function kl({alreadyUsingFree:e,clusterId:n,defaultValues:r,deploymentToPerformanceToPlan:i,harperVersions:a,mode:o,organization:s,organizationId:c,planTypes:l,regionLocationsColocated:d,regionLocationsDedicated:f,setSavedClusterState:p,startOffOnBilling:m}){let h=ue(),g=pt(),_=s?.type===dc,v=s?.channel===`Akamai`?`linode`:void 0,y=Ie(),{mutate:b,isPending:S}=ac(),{mutate:C,isPending:ee}=sc(),[w,te]=(0,z.useState)(m),ne=(0,z.useMemo)(()=>Ys(d?.sort(Us(`latencyDescription`))||[],`region`,`latencyDescription`),[d]),T=(0,z.useMemo)(()=>Ys(f?.sort(Us(`latencyDescription`))||[],`region`,`latencyDescription`),[f]),E=(0,z.useCallback)((t,n)=>{let r=new Set,a=i?.[t.deploymentDescription]?.[t.performanceDescription];if(t.deploymentDescription===`Self-Hosted`)for(let e=0;e<t.instances.length;e++){let i=wl(t.instances[e]);r.has(i)?n.addIssue({code:`custom`,path:[`instances.${e}.fqdn`],message:`Every instance url must be unique!`}):r.add(i)}else{a?.priceUsd===0&&e&&n.addIssue({code:`custom`,path:[`performanceDescription`],message:`Only one free cluster is allowed per organization.`});let i=a?.deploymentDescription===`Dedicated`?T:ne;for(let e=0;e<t.regionPlans.length;e++){let o=t.regionPlans[e],s=i[o.regionName]?.[o.latencyDescription];r.has(o.regionName)?n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`You can only select a region once!`}):r.add(o.regionName),a?.allowedRegionIds?.length&&s?.id&&(a.allowedRegionIds.includes(s.id)?e>=1&&n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`You can only select one region with this performance tier!`}):pc(a.allowedRegionIds,s.id)?n.addIssue({code:`custom`,path:[`regionPlans.${e}.latencyDescription`],message:`This latency is not available with the selected performance tier!`}):n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`This region is not available with the selected performance tier!`}))}}},[e,ne,T,i]),D=L({mode:`onChange`,resolver:N(Lc.superRefine(E)),defaultValues:r}),[O,re]=(0,z.useState)(!0);(0,z.useEffect)(()=>{O&&r&&(p(null),re(!1))},[r,O,p]);let ie=D.watch(`clusterName`),ae=D.watch(`abbreviatedName`),k=D.watch(`deploymentDescription`),oe=D.watch(`performanceDescription`),se=D.watch(`regionPlans`),ce=D.watch(`instances`),le=k===`Dedicated`?T:ne,de=k===`Dedicated`?f:d;(0,z.useEffect)(function(){let e=D.getValues();k&&(k===`Self-Hosted`?(e.abbreviatedName&&D.setValue(`abbreviatedName`,``),e.regionPlans.length&&D.setValue(`regionPlans`,[]),e.instances.length||D.setValue(`instances`,[{secure:`true`,fqdn:``,port:t}])):(e.fqdn&&D.setValue(`fqdn`,``),e.instances.length&&D.setValue(`instances`,[]),e.regionPlans.length||El(D,l,de)))},[D,l,de,k]);let fe=(0,z.useMemo)(()=>{let e=fc(mc(ie),Ic.maxLength);return{suggestedAbbreviatedName:e,fullHostName:`${ae||e}.${s.subdomain||`your-org`}.harperfabric.com`}},[ie,ae,s]),pe=(0,z.useMemo)(()=>i?.[k]?.[oe],[i,k,oe]);(0,z.useEffect)(function(){let e=pe?.allowedRegionIds;if(e?.length&&se?.length===1){let t=se[0],n=le?.[t.regionName]?.[t.latencyDescription];if(!e.includes(n?.id)){let t=de?.filter(t=>e.includes(t.id)),n=t?.find(e=>e.region===`US`)||t?.[0];n&&(D.setValue(`regionPlans.0.regionName`,n.region),D.setValue(`regionPlans.0.latencyDescription`,n.latencyDescription),D.trigger())}}},[pe,se,D,le,de]),(0,z.useEffect)(function(){if(k!==`Self-Hosted`&&Object.keys(le).length&&se.length)for(let e=0;e<se.length;e++)le[se[e].regionName]||D.setValue(`regionPlans.${e}.regionName`,``)},[D,le,k,se]);let A=pe?.priceUsd?k===`Self-Hosted`?ce.length*pe.priceUsd:se.reduce((e,t)=>{let n=le?.[t.regionName]?.[t.latencyDescription];return e+(n?pe.priceUsd*n.instanceCount/2:0)},0):0,me=pe?.planLimits?.expirationMonths,he=Q(me)&&me<1e3?me:void 0,ge=he?A/he:A,_e=(0,z.useCallback)(({creating:e,deploymentDescription:t})=>R.message(e?`Creating Cluster`:`Updating Cluster`,{description:(0,B.jsx)(rc,{message:`This may take a little bit, hold tight!`,lateMessage:`Still working on it... why don't you grab a coffee, and I'll let you know when it's done?`,duration:t===`Dedicated`?6e4:5e3}),duration:0}),[]),ve=(0,z.useCallback)(async({clusterId:e,sourceClusterId:t,creating:n,toastId:r,isSelfManaged:i})=>{if(t){let e=(await lc(c)).clusters?.find(e=>e.id===t);ss(e?.status)&&await As(t)}y.invalidateQueries({queryKey:[c],refetchType:`active`}),n||y.invalidateQueries({queryKey:[e],refetchType:`active`}),g.invalidate(),h(i?{to:`/${c}/${e}/instances`}:n?{to:`/${c}/${e}/starting-up`}:{to:`/${c}/${e}/scaling`}),D.reset(),R.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})},[y,g,h,c,D]),ye=(0,z.useCallback)(async()=>{let e=D.getValues(),t=[],r=i[e.deploymentDescription][e.performanceDescription],a=e.deploymentDescription===`Self-Hosted`;if(a)for(let n of e.instances)t.push({autoRenew:!0,instanceFqdn:n.fqdn,operationsApiPort:n.port||9925,operationsApiSecure:n.secure===`true`,planId:r.id});else for(let n of e.regionPlans){let e=le[n.regionName][n.latencyDescription];t.push({autoRenew:!0,planId:r.id,regionId:e.id})}p(null);let s=_e({creating:!n,deploymentDescription:e.deploymentDescription}),l=()=>R.dismiss(s);n?C(o===`version`?{id:n,version:e.version,skipGtmWait:e.skipGtmWait}:{id:n,regionPlans:t,skipGtmWait:e.skipGtmWait},{onSuccess:t=>ve({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:a,creating:!1,toastId:s}),onError:l}):b({abbreviatedName:a?void 0:e.abbreviatedName||fe.suggestedAbbreviatedName,autoRenew:!0,fqdn:a&&e.fqdn||void 0,name:e.clusterName,version:e.version,organizationId:c,regionPlans:t},{onSuccess:t=>ve({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:a,creating:!0,toastId:s}),onError:l})},[fe.suggestedAbbreviatedName,n,i,D,ve,_e,c,le,p,C,b]),be=(0,z.useCallback)(()=>{if(o!==`version`&&A>0){te(!0);return}return ye()},[o,ye,A]),xe=(0,z.useCallback)(e=>{p(e?{clusterId:n,...D.getValues(),skipToBilling:!0}:null)},[n,D,p]),j=(0,z.useCallback)(()=>{te(!1)},[]),Se=!_&&`mr-37.5`;return(0,B.jsxs)(B.Fragment,{children:[!_&&o!==`version`&&(0,B.jsxs)(`div`,{className:`absolute top-3 right-4 md:right-12 flex flex-col items-end text-right`,children:[(0,B.jsx)(`dt`,{className:`font-light`,children:he?`Monthly Price`:`Total Price`}),(0,B.jsx)(`dd`,{className:`font-bold`,children:A>0?(0,B.jsxs)(`span`,{className:`inline-flex items-baseline`,children:[(0,B.jsx)(Dl,{price:ge}),!!he&&(0,B.jsxs)(`span`,{className:`font-light text-base text-muted-foreground`,children:[`/mo`,he>1&&(0,B.jsx)(`sup`,{children:`*`})]})]}):(0,B.jsx)(`span`,{className:`text-4xl text-green`,children:`Free`})})]}),(0,B.jsx)(H,{...D,children:w?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`h1`,{className:x(`text-lg leading-none text-foreground font-semibold mb-4`,Se),children:`Cluster Billing`}),(0,B.jsx)(`p`,{className:x(`text-muted-foreground text-sm mb-2`,Se),children:`Please confirm the following billing details:`}),(0,B.jsx)(Nc,{clusterId:n,isPending:S||ee,onGoBackToDetails:j,onSaveStateForBillingRedirect:xe,onSubmit:ye,organizationId:c,selectedPlan:pe})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`h1`,{className:x(`text-lg leading-none text-foreground font-semibold mb-4`,Se),children:`Cluster Configuration`}),(0,B.jsxs)(`div`,{className:x(`mb-6 flex flex-col items-start gap-2`,Se),children:[(0,B.jsx)(`p`,{className:`sr-only`,children:`Configure your Harper cluster and define deployment plans.`}),!_&&o!==`version`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(vs,{variant:`warning`,children:`Beta pricing subject to change.`}),!!he&&he>1&&A>0&&(0,B.jsxs)(`p`,{className:`max-w-prose text-xs font-light text-muted-foreground`,children:[`* Billed as`,` `,new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(A),` `,`every`,` `,u(he,`month`,`months`),`, or sooner if you reach a usage limit — then a new license is issued.`]})]})]}),(0,B.jsx)(`form`,{id:`cluster-upsert-form`,name:`cluster-upsert-form`,onSubmit:D.handleSubmit(be),children:(0,B.jsx)(Cl,{calculatedNames:fe,clusterId:n,deploymentToPerformanceToPlan:i,form:D,isPending:S||ee,harperVersions:a,mode:o,regionLocations:de,regionNameToLatencyToRegion:le,selectedDeployment:k,selectedPerformance:oe,selectedPlan:pe,totalPrice:A,isEnterprise:_,cloudProvider:v})})]})})]})}function Al(e){return e?.clusterName!==void 0}function jl(){let{organizationId:e,clusterId:t,mode:n}=F({strict:!1}),{create:r,update:i}=Sa(e),{organization:a,cluster:o}=lt({strict:!1}),[s,c]=Zi($i.SavedClusterState,null),{data:l}=A(Rs(e)),{data:u}=A(Hs({availableHosts:!0,organizationId:e})),{data:d}=A(Hs({organizationId:e})),{data:f}=A(Bs()),p=(0,z.useMemo)(()=>{if(o){let e=o.instances?.map(e=>e.version).filter(Ri);if(f&&e){let t=e.sort(Zs).pop();return{...f,value:[!!t&&{name:`current`,version:t},...(f?.value||[]).filter(e=>t!==e.version&&(!t||Xs(t,e.version)))].filter(Ri)}}}return f},[f,o]),m=(0,z.useMemo)(()=>{for(let e of a?.clusters??[])if(e.id!==o?.id&&l&&!cs(e.status)&&!ss(e.status)&&e.plans)for(let t of e.plans){let e=l.find(e=>e.id===t.planId);if(e?.priceUsd===0&&!e.id.startsWith(`self-hosted`))return!0}return!1},[o?.id,a?.clusters,l]),h=(0,z.useMemo)(()=>Ys(l?.sort(Us(`priceUsd`))||[],`deploymentDescription`,`performanceDescription`),[l]),g=(0,z.useMemo)(()=>{if(!l||!p||!u||!d||t&&!o)return null;let e=o;if(s){if(Al(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=Tl(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&&!ro.includes(e.status)).sort(Ks);for(let e of t)f=!0,i.push({fqdn:e.instanceFqdn,port:e.operationsApiPort,secure:e.operationsApiSecure?`true`:`false`})}}else c&&r.push(...c.regionPlans);!f&&!r.length&&r.push({regionName:``,latencyDescription:``});let h=p.value?.find(e=>e.name===`current`)?.version??p.value?.find(e=>e.name===`stable`)?.version;return{sourceClusterId:e?.id,autoRenew:e?.plans?.[0]?.autoRenew??!0,clusterName:e?.name??``,abbreviatedName:e?.abbreviatedName??``,version:h,deploymentDescription:n?.deploymentDescription??c?.deploymentDescription??``,performanceDescription:n?.performanceDescription??c?.performanceDescription??``,fqdn:f?e?.fqdn??``:``,instances:i,regionPlans:r}},[m,o,t,l,p,u,d,s]);return!g||!a||!l||!u||!d?(0,B.jsx)(Is,{children:(0,B.jsx)(Fs,{centered:!0,text:`Loading...`})}):(o?.id?!i:!r)?(0,B.jsx)(Is,{children:(0,B.jsx)(Ni,{title:`Not Allowed`,error:{message:(0,B.jsxs)(B.Fragment,{children:[`You do not have permission to `,o?.id?`update`:`create`,` clusters in this org.`]})}})}):l.length===0?(0,B.jsx)(Is,{children:(0,B.jsx)(Ni,{title:`Cluster ${t?`Modification`:`Creation`} Not Currently Allowed`,error:{message:(0,B.jsxs)(B.Fragment,{children:[`There are no available deployment types right now! Please try again later, or `,(0,B.jsx)(Ps,{}),`.`]})}})}):(0,B.jsx)(Is,{className:`max-w-4xl mx-auto`,children:(0,B.jsx)(kl,{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:Al(s)&&s.skipToBilling===!0})})}var Ml={FAILED:0,UPDATING:1,PROVISIONING:2,RUNNING:3,TERMINATED:4},Nl=Ml.RUNNING;function Pl(e,t){return e.status===t.status?e.name.localeCompare(t.name):(e.status?Ml[e.status]??Nl:Nl)-(t.status?Ml[t.status]??Nl:Nl)}function Fl(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 Il(){let{organizationId:e}=F({strict:!1}),{create:t}=Sa(e),{data:n,isSuccess:r}=Gr(uc(e)),[i]=Zi($i.SavedClusterState,null),[a,o]=(0,z.useState)(``),s=(0,z.useCallback)(()=>o(``),[]),c=(0,z.useCallback)(e=>{o(e.currentTarget.value?.toLowerCase()||``)},[]),l=(0,z.useMemo)(()=>n?.clusters?.slice().filter(e=>!cs(e.status)).sort(Pl)||[],[n?.clusters]),u=(0,z.useMemo)(()=>l.filter(Fl([`id`,`name`],a))||[],[a,l]);return n&&l.length===0&&t?(0,B.jsx)(jl,{}):i?(0,B.jsx)(Gn,{to:`/${e}/new-cluster`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{children:r?(0,B.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,B.jsx)(J,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:a,onChange:c}),t&&(0,B.jsx)(j,{to:`new-cluster`,children:(0,B.jsxs)(g,{variant:`positive`,accessKey:`n`,children:[(0,B.jsx)(Bt,{}),` `,(0,B.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,B.jsx)(`u`,{children:`N`}),`ew `,(0,B.jsx)(`span`,{className:`hidden md:inline-block`,children:`Cluster`})]})]})})]}):null}),(0,B.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12 mb-4`,children:[u.map(e=>(0,B.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,B.jsx)(Ns,{cluster:e})},e.id)),!u.length&&(0,B.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,B.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,B.jsx)(g,{type:`button`,variant:`outline`,onClick:s,children:`Clear Filters`})]})]})})]})}function Ll(){let e=location.hash;return e?e.startsWith(`#/`)?e.slice(1):e:`/`}function Rl(){return`/#`+Ll()}function zl(){let{organizationId:e}=F({strict:!1}),t=ue(),n=new URLSearchParams(window.location.search).get(`setup_intent_client_secret`),{setup_intent_client_secret:r}=Bn({strict:!1}),[i]=Zi($i.SavedClusterState,null),a=n||r,o=dt(),s=_c(e),c=(0,z.useCallback)(()=>{let e=i?i.clusterId?`../../${i.clusterId}/edit`:`../../new-cluster`:`../`;window.history.replaceState(null,``,Rl()),t({search:void 0,to:e})},[t,i]);return(0,z.useEffect)(()=>{!o||!a||!s||!e||!c||(async function(){try{let{setupIntent:e}=await o.retrieveSetupIntent(a);switch(e?.status){case`succeeded`:e.payment_method===null?(R.error(`Failed to process payment method details. Please try another payment method.`),c()):s(e.payment_method,c);break;case`processing`:R.warning(`Processing payment method. Please check back later.`),c();break;case`requires_payment_method`:R.error(`Failed to process payment method details. Please try another payment method.`),c();break;default:R.error(`Failed to process payment method details. Please try another payment method.`),c();break}}catch(e){console.error(e),R.error(`Failed to process payment method details. Please try another payment method.`),c()}})()},[a,c,e,s,o]),(0,B.jsx)(Fs,{centered:!0})}function Bl(){return(0,B.jsx)(Ec,{children:(0,B.jsx)(zl,{})})}function Vl({clusterId:e,instanceId:t,organizationId:n},r){return`/`+[n,e,t&&`instance`,t,r].filter(Ri).join(`/`)}var Hl=`flex items-center p-2 rounded-lg group`,Ul={className:`text-foreground hover:bg-accent dark:text-white dark:hover:bg-gray-700`},Wl={className:`text-black bg-white pointer-events-none cursor-default`};function Gl(){let{organizationId:e}=F({strict:!1}),{update:t}=ba(e);return t?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,B.jsxs)(`div`,{className:`md:grid gap-4 md:grid-cols-12 min-h-[calc(100vh-theme(spacing.36))] mb-12`,children:[(0,B.jsxs)(`section`,{className:`col-span-1 text-foreground md:col-span-4 lg:col-span-3 md:border-r-1 border-b md:border-b-0 md:pr-4 border-gray-700`,children:[(0,B.jsx)(Kl,{}),(0,B.jsx)(ql,{})]}),(0,B.jsx)(`section`,{className:`col-span-1 text-foreground md:col-span-8 lg:col-span-9`,children:(0,B.jsx)(Et,{})})]})})]}):(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:`You don't have access to manage payments for this organization. Please contact your administrator.`})}function Kl(){let e=F({strict:!1});return(0,B.jsxs)(`div`,{className:`hidden md:block`,children:[(0,B.jsxs)(`span`,{className:Hl,children:[(0,B.jsx)(Jr,{className:`inline-block`}),(0,B.jsx)(`h3`,{className:`ms-3 text-2xl font-extrabold text-foreground`,children:`Billing`})]}),(0,B.jsxs)(`ul`,{className:`border-t border-gray-700 pt-4 mt-4 space-y-2`,children:[(0,B.jsx)(`li`,{children:(0,B.jsxs)(j,{to:Vl(e,`billing`),className:Hl,activeOptions:{exact:!0},inactiveProps:Ul,activeProps:Wl,children:[(0,B.jsx)(at,{className:`inline-block`}),` `,(0,B.jsx)(`span`,{className:`ms-3`,children:`Payment Method`})]})}),(0,B.jsx)(`li`,{children:(0,B.jsxs)(j,{to:Vl(e,`billing/invoices`),className:Hl,inactiveProps:Ul,activeProps:Wl,children:[(0,B.jsx)(ge,{className:`inline-block`}),(0,B.jsx)(`span`,{className:`ms-3`,children:`Invoices & Payments`})]})})]})]})}function ql(){let e=F({strict:!1});return(0,B.jsxs)(`ul`,{className:`flex space-x-4 md:hidden py-2`,children:[(0,B.jsx)(`li`,{children:(0,B.jsxs)(j,{to:Vl(e,`billing`),className:Hl,activeOptions:{exact:!0},inactiveProps:Ul,activeProps:Wl,children:[(0,B.jsx)(at,{className:`inline-block`}),` `,(0,B.jsx)(`span`,{className:`ms-3`,children:`Payment Method`})]})}),(0,B.jsx)(`li`,{children:(0,B.jsxs)(j,{to:Vl(e,`billing/invoices`),className:Hl,inactiveProps:Ul,activeProps:Wl,children:[(0,B.jsx)(ge,{className:`inline-block`}),` `,(0,B.jsx)(`span`,{className:`ms-3`,children:`Invoices & Payments`})]})})]})}function Jl({className:e,containerClassName:t,...n}){return(0,B.jsx)(`div`,{"data-slot":`table-container`,className:d(`relative w-full overflow-x-auto`,t),children:(0,B.jsx)(`table`,{"data-slot":`table`,className:d(`w-full caption-bottom text-sm`,e),...n})})}function Yl({className:e,...t}){return(0,B.jsx)(`thead`,{"data-slot":`table-header`,className:d(`[&_tr]:border-b`,e),...t})}function Xl({className:e,...t}){return(0,B.jsx)(`tbody`,{"data-slot":`table-body`,className:d(`[&_tr:last-child]:border-0`,e),...t})}function Zl({className:e,...t}){return(0,B.jsx)(`tr`,{"data-slot":`table-row`,className:d(`border-b border-grey-700 transition-colors`,e),...t})}function Ql({className:e,...t}){return(0,B.jsx)(`th`,{"data-slot":`table-head`,className:d(`h-10 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function $l({header:e,onColumnClick:t,...n}){let r=(0,z.useCallback)(()=>{e.column.toggleSorting(e.column.getIsSorted()===`asc`);let n=e.column.getIsSorted()===!1||e.column.getIsSorted()!==`asc`;t?.(e.column.columnDef.accessorKey,n)},[e,t]),i=e.column.columnDef.enableSorting,a=e.column.columnDef.enableResizing,o=e.isPlaceholder?null:sn(e.column.columnDef.header,e.getContext()),s=(0,z.useCallback)(()=>{e.column.resetSize()},[e]);return(0,B.jsx)(Ql,{...n,style:{width:`${e.getSize()}px`},className:i?`px-0`:`px-2`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[i?(0,B.jsxs)(g,{type:`button`,variant:`ghost`,className:d(`rounded-none`,!e.column.getIsSorted()||e.column.getIsSorted()===`asc`?`cursor-n-resize`:`cursor-s-resize`),onClick:r,children:[o,e.column.getIsSorted()===`asc`?(0,B.jsx)(Yn,{}):e.column.getIsSorted()===`desc`?(0,B.jsx)($n,{}):(0,B.jsx)(_n,{className:`text-gray-600`})]}):o,a&&(0,B.jsx)(g,{type:`button`,variant:`ghost`,className:`cursor-col-resize`,onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),onDoubleClick:s,style:{transform:e.column.getIsResizing()?`translateX(${e.getContext().table.getState().columnSizingInfo.deltaOffset}px)`:``},children:(0,B.jsx)(En,{})})]})})}function eu({className:e,...t}){return(0,B.jsx)(`td`,{"data-slot":`table-cell`,className:d(`align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function tu({columns:e,data:t,isFetching:n,onRowClick:r,onColumnClick:i,sortingState:a,children:o}){let s=sr({data:t,columns:e,getCoreRowModel:hn(),getSortedRowModel:Or(),initialState:{sorting:a}});return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-end space-x-2 pb-4`,children:[(0,B.jsx)(`div`,{className:`grow lg:hidden`}),o,(0,B.jsx)(`div`,{className:`grow hidden lg:visible`})]}),(0,B.jsxs)(Jl,{containerClassName:`rounded-md bg-card dark:bg-black-dark`,children:[(0,B.jsx)(Yl,{children:s.getHeaderGroups().map(e=>(0,B.jsx)(Zl,{className:`border-none`,children:e.headers.map(e=>(0,B.jsx)($l,{header:e,onColumnClick:i},e.id))},e.id))}),(0,B.jsx)(Xl,{className:`bg-background dark:bg-black border border-border dark:border-grey-700`,children:s.getRowModel().rows?.length?s.getRowModel().rows.map(e=>(0,B.jsx)(Zl,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>r?.(e),className:d(`hover:bg-muted/10 data-[state=selected]:bg-muted`,r&&`cursor-pointer`),children:e.getVisibleCells().map(e=>(0,B.jsx)(eu,{className:`py-2 px-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,style:{width:`${e.column.getSize()}px`},children:sn(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,B.jsx)(Zl,{children:(0,B.jsx)(eu,{colSpan:e.length,className:`h-24 text-center`,children:n?(0,B.jsx)(`div`,{children:(0,B.jsx)(Fs,{className:`p-12`})}):(0,B.jsx)(`span`,{children:`No results.`})})})})]})]})}function nu(e){switch(e){case`paid`:return`success`;case`void`:case`uncollectible`:return`destructive`;default:return`default`}}function ru(e){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e)}function iu(e,t){if(e<45)return`a few seconds ago`;if(e<120)return`a minute ago`;let n=Math.floor(e/60);if(n<60)return`${n} minutes ago`;if(n<120)return`an hour ago`;let r=Math.floor(e/3600);return r>48?new Date(t).toLocaleString():`${r} hours ago`}var au=[{header:`Invoice Id`,accessorKey:`id`,enableSorting:!1},{header:`Status`,accessorKey:`status`,enableSorting:!1,cell:({cell:e})=>(0,B.jsx)(vs,{variant:nu(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?iu(r,t):[t?iu(r,t):`-`,n?iu(i,n):`-`].join(` to `)}},{header:`Amount Due`,accessorKey:`amountDue`,enableSorting:!1,cell:({cell:e})=>ru(e.getValue()?e.getValue()/100:0)},{header:`Amount Paid`,accessorKey:`amountPaid`,enableSorting:!1,cell:({cell:e})=>ru(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} @ ${ru(e.amount/100)}`);return n.join(`
11
- `)}}];function ou(e){return(0,z.useCallback)(async()=>{R.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await p(500),R.success(`Refreshed!`,{id:`refreshing`})},[e])}async function su(e){let{data:t}=await s.get(`/Invoice/${e}`);return t}function cu(e,t){return I({queryKey:[e,`invoices`],queryFn:()=>su(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function lu(){let{organizationId:e}=F({strict:!1}),{data:t}=A(uc(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=A(cu(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=ou(r);return t?.type===`ENTERPRISE`?(0,B.jsxs)(`span`,{children:[`You are part of an enterprise organization! We don’t currently show your invoices on this page. Want to explore your solution with Harper more? `,(0,B.jsx)(Ps,{}),`, we would love to talk!`]}):i?(0,B.jsx)(Fs,{centered:!0}):!n||!n.length?(0,B.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,B.jsx)(Ps,{overEmail:!0}),`, we would love to talk!`]}):(0,B.jsx)(tu,{data:n,columns:au,children:(0,B.jsxs)(g,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,B.jsx)(wt,{}),(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function uu(e){let t=M({getParentRoute:()=>e,path:`billing`,head:()=>({meta:[{title:`Billing — Harper Fabric`}]}),component:Gl}),n=M({getParentRoute:()=>t,path:`/`,head:()=>({meta:[{title:`Payment Methods — Harper Fabric`}]}),component:Mc}),r=M({getParentRoute:()=>t,path:`invoices`,head:()=>({meta:[{title:`Invoices — Harper Fabric`}]}),component:lu}),i=M({getParentRoute:()=>t,path:`confirm`,head:()=>({meta:[{title:`Confirm Payment — Harper Fabric`}]}),component:Bl});return t.addChildren([n,r,i])}async function du(e){let{data:t}=await s.get(`/OrganizationRole/${e}`);return t}function fu(e){return I({queryKey:[e,`roles`],queryFn:()=>du(e),retry:!1,refetchInterval:10*1e3})}var pu=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},xr().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 mu(e){let{data:t}=await s.post(`/Role/`,e);return t}function hu(){return P({mutationFn:mu})}var gu=O({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()});O({roles:O({create:E(),delete:E(),update:E(),view:E()}),clusters:O({create:E(),delete:E(),update:E(),view:E(),resources:ie(O({id:w(),delete:E(),update:E(),view:E(),instances:O({create:E(),delete:E(),update:E(),view:E()})}))})});function _u(){let[e]=na(),t=Qi();return e===`dark`||e===`system`&&t===`dark`?`vs-dark`:`light`}var vu={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function yu({isModalOpen:e,setIsModalOpen:t}){let n=_u(),r=Ie(),{organizationId:i}=F({strict:!1}),[a,o]=(0,z.useState)(!0),[s,c]=(0,z.useState)(JSON.stringify(vu,null,2)),{mutate:l,isPending:u}=hu(),d=L({resolver:N(gu),defaultValues:{name:``,update:!1,delete:!1}}),f=(0,z.useCallback)(e=>{o(e.length===0)},[o]),p=(0,z.useCallback)(async e=>{let n=Ji(s);if(!n)return;let o={...e,...n,organizationId:i};e&&a&&l(o,{onSuccess:()=>{R.success(`Organization role added successfully!`),t(!1),r.invalidateQueries({queryKey:[i,`roles`],refetchType:`active`}),d.reset()},onError:e=>{R.error(`Failed to add organization role: ${e.message}`)}})},[a,s,l,d,r,t,i]);return(0,B.jsx)(Y,{onOpenChange:t,open:e,children:(0,B.jsxs)(X,{children:[(0,B.jsx)(Z,{children:`Add New Organization Role`}),(0,B.jsx)(gs,{children:`Set the new organization role permissions.`}),(0,B.jsx)(H,{...d,children:(0,B.jsxs)(`form`,{id:`org-add-role-form`,name:`org-add-role-form`,className:`grid grid-cols-2 gap-4 my-4`,onSubmit:d.handleSubmit(p),children:[(0,B.jsx)(W,{control:d.control,name:`name`,render:({field:e})=>(0,B.jsxs)(G,{className:`col-span-2`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Role Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,className:``,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:d.control,name:`update`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Update Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:d.control,name:`delete`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Delete Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(`div`,{className:`col-span-2`,children:(0,B.jsx)(Rn,{theme:n,height:`300px`,defaultLanguage:`json`,onValidate:f,onChange:e=>{e&&c(e)},defaultValue:JSON.stringify(vu,null,2)})}),(0,B.jsx)(hs,{className:`col-span-2`,children:(0,B.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,B.jsx)(g,{variant:`destructiveOutline`,className:`rounded-full`,type:`button`,onClick:()=>t(!1),disabled:u,children:`Cancel`}),(0,B.jsx)(g,{variant:`submit`,className:`rounded-full`,disabled:u||!a||!d.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function bu({roleId:e}){let{data:t}=await s.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function xu(){return P({mutationFn:({roleId:e})=>bu({roleId:e})})}async function Su({roleId:e,updatedRoleInfo:t}){let{data:n}=await s.put(`/Role/${e}`,t);return n}function Cu(){return P({mutationFn:({roleId:e,updatedRoleInfo:t})=>Su({roleId:e,updatedRoleInfo:t})})}function wu({organizationId:e,roleId:t}){return I({queryKey:[e,`roles`,t],queryFn:()=>Tu(t),refetchInterval:10*1e3})}async function Tu(e){let{data:t}=await s.get(`/Role/${e}`);return t}function Eu({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Z,{children:`Confirm Role Deletion`}),(0,B.jsx)(gs,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,B.jsxs)(hs,{children:[(0,B.jsx)(g,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,onClick:()=>t(!1),children:`Cancel`}),(0,B.jsx)(g,{variant:`destructiveOutline`,className:`rounded-full`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function Du({data:e,isModalOpen:t,closeModal:n}){let r=Ie(),{data:i}=Gr(wu({roleId:e.id,organizationId:e.organizationId})),a=Si(),o=a.user&&a.user?.roles?.[e.organizationId]?.role===e.roleName,{update:s,remove:c}=xa(e.organizationId),{mutate:l,isPending:u}=Cu(),{mutate:d,isPending:f}=xu(),p=_u(),[m,h]=(0,z.useState)(!1),_=L({resolver:N(gu),defaultValues:{name:e.roleName,update:i.organization.update||!1,delete:i.organization.delete||!1}}),v=(0,z.useCallback)(()=>{d({roleId:e.id},{onSuccess:()=>{R.success(`Role deleted successfully!`),n(!0),_.reset()},onError:e=>{R.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>R.dismiss()}})}})},[e.id,d,_,n]),[y,b]=(0,z.useState)(!0),[x,S]=(0,z.useState)(JSON.stringify({roles:{...i.organization.roles},clusters:{...i.organization.clusters}},null,2)),C=(0,z.useCallback)(e=>{b(e.length===0)},[b]),ee=(0,z.useCallback)(async t=>{if(!s)return;let i=Ji(x);if(!i)return;let a={...t,...i,organizationId:e.organizationId};x&&y&&l({roleId:e.id,updatedRoleInfo:a},{onSuccess:async()=>{R.success(`Role updated successfully!`),await r.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),n(!1),_.reset()},onError:e=>{R.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>R.dismiss()}})}})},[n,e.id,e.organizationId,_,y,r,i,s,x,l]);return(0,B.jsx)(Y,{onOpenChange:(0,z.useCallback)(()=>n(!1),[n]),open:t,children:(0,B.jsx)(X,{children:m?(0,B.jsx)(Eu,{onRoleDeleteClick:v,setIsConfirmingRoleDeletion:h,isRoleDeletionPending:f}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(Z,{children:[o||!s?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,B.jsx)(H,{..._,children:(0,B.jsxs)(`form`,{id:`org-edit-role-form`,name:`org-edit-role-form`,className:`grid grid-cols-2 gap-4 my-4`,onSubmit:_.handleSubmit(ee),children:[(0,B.jsx)(W,{control:_.control,name:`name`,render:({field:e})=>(0,B.jsxs)(G,{className:`col-span-2`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Role Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:_.control,name:`update`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Update Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:_.control,name:`delete`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Delete Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(`div`,{className:`col-span-2`,children:(0,B.jsx)(Rn,{theme:p,height:`300px`,defaultLanguage:`json`,onValidate:C,onChange:e=>{e&&S(e)},options:o||!s?{readOnly:!0}:void 0,defaultValue:x})}),!o&&(c||s)&&(0,B.jsx)(hs,{className:`col-span-2`,children:(0,B.jsxs)(`div`,{className:`flex justify-between w-full`,children:[c&&(0,B.jsx)(g,{type:`button`,variant:`destructiveOutline`,className:`rounded-full`,onClick:()=>h(!0),disabled:u,children:`Delete Role`}),s&&(0,B.jsx)(g,{variant:`submit`,className:`rounded-full`,disabled:!y||u||!_.formState.isValid||!_.formState.isDirty,children:`Save Changes`})]})})]})})]})})})}function Ou(){let e=ue(),t=Ie(),{organizationId:n,orgRoleId:r}=F({strict:!1}),{create:i}=xa(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=Gr(fu(n)),l=(0,z.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,z.useState)(!1),p=(0,z.useCallback)(async(i,a)=>{await e({to:[r?`..`:``,i].filter(Boolean).join(`/`)}),a&&await t.invalidateQueries({queryKey:[n,`roles`],refetchType:`active`})},[r,e,t]),m=(0,z.useCallback)(()=>{f(!0)},[f]),h=(0,z.useCallback)(e=>p(e.original.id,!1),[p]),_=(0,z.useCallback)(e=>p(void 0,e),[p]),v=ou(o);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,B.jsxs)(z.Suspense,{fallback:(0,B.jsx)(Fs,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,B.jsxs)(tu,{data:a,columns:pu,onRowClick:h,children:[(0,B.jsxs)(g,{variant:`defaultOutline`,onClick:v,accessKey:`r`,disabled:s||c,children:[(0,B.jsx)(wt,{}),(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,B.jsxs)(g,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,B.jsx)(Bt,{}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,B.jsx)(yu,{isModalOpen:d,setIsModalOpen:f}),u&&(0,B.jsx)(Du,{data:l,isModalOpen:u,closeModal:_})]})})]})}var ku=[{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},xr().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}],Au=k.object({email:uo.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:k.string().nonempty({error:`Please select a role.`})});async function ju(e){let{data:t}=await s.post(`/OrganizationRole/`,e);return t}function Mu(){return P({mutationFn:e=>ju(e)})}k.object({email:uo.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:k.string().nonempty({error:`Please select a role.`})});async function Nu(e){let{data:t}=await s.post(`/UserInvite/`,e);return t}function Pu(){return P({mutationFn:e=>Nu(e)})}function Fu({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=F({strict:!1}),{data:i}=Gr(fu(r)),[a,o]=(0,z.useState)(!1),s=L({resolver:N(Au),defaultValues:{email:``,roleId:``}}),{mutate:c,isPending:l}=Mu(),{mutate:u,isPending:d}=Pu(),f=(0,z.useCallback)(async e=>{e&&(a?u:c)(e,{onSuccess:()=>{let r=e.roleId;s.reset(),s.setValue(`roleId`,r),t(),R.success(`User invited successfully!`),n(!1),o(!1)},onError:e=>{e?.status===404&&o(!0)}})},[c,s,u,t,n,a]);return(0,B.jsx)(Y,{onOpenChange:()=>{n(!1),o(!1),s.reset()},open:e,children:(0,B.jsx)(X,{"aria-describedby":void 0,children:(0,B.jsx)(H,{...s,children:(0,B.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:s.handleSubmit(f),className:`grid gap-4 my-4`,children:[(0,B.jsx)(ms,{children:(0,B.jsx)(Z,{children:a?`Invite User`:`Add User`})}),(0,B.jsx)(W,{control:s.control,name:`email`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Email`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:s.control,name:`roleId`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Roles`}),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(zc,{}),children:(0,B.jsx)(U,{children:(0,B.jsxs)(Bc,{...e,onValueChange:t=>e.onChange(t),children:[(0,B.jsx)(Uc,{className:`w-full`,children:(0,B.jsx)(Hc,{placeholder:`Choose Role`})}),(0,B.jsx)(Wc,{children:(0,B.jsxs)(Vc,{children:[(0,B.jsx)(Gc,{children:`Role`}),i?.map(e=>(0,B.jsx)($,{value:e.id,children:e.roleName},e.id))]})})]})})}),(0,B.jsx)(q,{})]})}),a&&(0,B.jsxs)(gs,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,B.jsx)(Sn,{className:`inline-block size-12 pr-2`}),(0,B.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,B.jsx)(hs,{children:(0,B.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,B.jsxs)(g,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:l||d,children:[(0,B.jsx)(je,{}),` `,a?`Invite User`:`Add User`]})})})]})})})})}async function Iu({roleId:e,userId:t}){let{data:n}=await s.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function Lu(){return P({mutationFn:({roleId:e,userId:t})=>Iu({roleId:e,userId:t})})}function Ru(e){let[t,n]=(0,z.useState)(e||!1);return[t,(0,z.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function zu({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=Mu(),{mutate:c,isPending:l}=Lu(),u=!!i[r.roleName],[d,f]=(0,z.useState)(u),[p,m]=Ru(u);return(0,z.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),R.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),R.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,B.jsxs)(to,{className:`flex`,children:[(0,B.jsx)(J,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,B.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function Bu({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r}){let{organizationId:i}=F({strict:!1}),a=Si(),{update:o,remove:s}=xa(i),c=a.user?.email===t.email,{data:l}=Gr(fu(i)),u=(0,z.useMemo)(()=>t.roles?Js(t.roles,`roleName`):{},[t]),[d,f]=(0,z.useState)(!1);return(0,B.jsx)(Y,{onOpenChange:d?r:e,open:n,children:(0,B.jsxs)(X,{className:`sm:max-w-[750px]`,children:[(0,B.jsx)(ms,{children:(0,B.jsxs)(Z,{children:[o?`Edit `:`View `,` `,t.email,` `,c?`(yourself)`:``]})}),o&&(0,B.jsxs)(gs,{children:[`To remove `,c?`your self`:`this user`,` from the organization, uncheck all of the boxes below.`]}),l.map(e=>(0,B.jsx)(zu,{readOnly:!o,canRemove:s,data:t,orgRole:e,selectedRoles:u,setChangesMade:f},e.id))]})})}function Vu(e,t){return e.email>t.email?1:-1}function Hu(){let e=ue(),{organizationId:t,orgUserId:n}=F({strict:!1}),{update:r}=xa(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=Gr(fu(t)),c=(0,z.useMemo)(()=>{let e={};for(let t of i)if(t.users)for(let n of t.users)e[n.id]||(e[n.id]={...n,roles:[]}),e[n.id].roles.push(t);return Object.values(e).sort(Vu)},[i]),l=(0,z.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),u=(0,z.useCallback)(t=>{e({to:[n?`..`:``,t].filter(Boolean).join(`/`)})},[n,e]),d=!!n&&!!l,[f,p]=(0,z.useState)(!1),[m]=(0,z.useState)({attribute:`email`,descending:!1}),h=(0,z.useMemo)(()=>[{desc:m.descending,id:m.attribute}],[m]),_=(0,z.useCallback)(()=>{p(!0)},[p]),v=(0,z.useCallback)(()=>{a(),p(!1)},[a,p]),y=(0,z.useCallback)(e=>{u(e.original.id)},[u]),b=(0,z.useCallback)(()=>{u(void 0)},[u]),x=(0,z.useCallback)(()=>{a(),u(void 0)},[u,a]),S=ou(a);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,B.jsxs)(z.Suspense,{fallback:(0,B.jsx)(Fs,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,B.jsxs)(tu,{data:c,isFetching:o||s,columns:ku,onRowClick:y,sortingState:h,children:[(0,B.jsxs)(g,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,B.jsx)(wt,{}),` `,(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,B.jsxs)(g,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:f,children:[(0,B.jsx)(Bt,{}),` `,(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,B.jsx)(Fu,{isModalOpen:f,onChangesSaved:v,setIsModalOpen:p}),d&&(0,B.jsx)(Bu,{closeModal:b,data:l,isModalOpen:d,onUserUpdated:x})]})})]})}function Uu({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`skeleton`,className:d(`bg-primary/10 animate-pulse rounded-md`,e),...t})}function Wu({className:e,...t}){return(0,B.jsx)(wr,{"data-slot":`switch`,className:d(`peer data-[state=checked]:bg-green data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-grey-500 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,B.jsx)(ir,{"data-slot":`switch-thumb`,className:d(`bg-white dark:data-[state=unchecked]:bg-white dark:data-[state=checked]:bg-white pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}var Gu=O({couponId:w().nonempty({message:`Please enter a coupon ID.`}).trim()});async function Ku({organizationId:e,couponId:t}){let{data:n}=await s.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});return n}function qu(){return P({mutationFn:Ku})}function Ju({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=qu(),o=L({resolver:N(Gu),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,z.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,z.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?R.error(`Error`,{description:i||`Failed to add coupon.`}):(R.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,B.jsx)(Y,{open:n,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(X,{children:[(0,B.jsxs)(ms,{children:[(0,B.jsx)(Z,{children:`Add Coupon`}),(0,B.jsxs)(gs,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,B.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,B.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,B.jsx)(H,{...o,children:(0,B.jsxs)(`form`,{onSubmit:s(u),children:[(0,B.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,B.jsx)(W,{control:c,name:`couponId`,render:({field:e})=>(0,B.jsxs)(G,{className:`grid items-center gap-4`,children:[(0,B.jsx)(K,{children:`Coupon ID`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,B.jsx)(q,{})]})})}),(0,B.jsxs)(hs,{children:[(0,B.jsx)(g,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,B.jsx)(g,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function Yu({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=ba(n),s=o,{view:c}=xa(n),l=Ci(),[u,d]=(0,z.useState)(!1),f=(0,z.useCallback)(()=>{t(e)},[t,e]);return(0,B.jsxs)(Ei,{className:`relative h-full justify-between hover:shadow-lg transition-shadow duration-200`,children:[(0,B.jsxs)(Di,{children:[(0,B.jsxs)(ki,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`truncate`,children:n}),a&&(0,B.jsxs)(ys,{children:[(0,B.jsx)(bs,{className:`p-4 -m-4 -mr-6 hover:text-foreground`,children:(0,B.jsx)(de,{"aria-label":`Options`})}),(0,B.jsxs)(xs,{children:[(0,B.jsx)(ws,{className:`text-gray-600 text-xs`,children:`Options`}),(0,B.jsx)(Ts,{}),(0,B.jsx)(j,{to:`${n}`,children:(0,B.jsxs)(Ss,{children:[(0,B.jsx)(Un,{className:`size-4 mr-2 text-blue-500`}),`Clusters`]})}),c&&(0,B.jsx)(j,{to:`${n}/roles`,children:(0,B.jsxs)(Ss,{children:[(0,B.jsx)(Jn,{className:`size-4 mr-2 text-purple`}),`Roles`]})}),c&&(0,B.jsx)(j,{to:`${n}/users`,children:(0,B.jsxs)(Ss,{children:[(0,B.jsx)(Mn,{className:`size-4 mr-2 text-orange-500`}),`Users`]})}),s&&(0,B.jsx)(j,{to:`${n}/billing`,children:(0,B.jsxs)(Ss,{children:[(0,B.jsx)(at,{className:`size-4 mr-2 text-green-500`}),`Billing`]})}),l&&(0,B.jsxs)(Ss,{onClick:()=>d(!0),children:[(0,B.jsx)(kt,{className:`size-4 mr-2 text-pink-500`}),`Add Coupon`]}),(0,B.jsx)(Ts,{}),a&&(0,B.jsxs)(Ss,{className:`focus:bg-red/70 focus:text-white`,onClick:f,children:[(0,B.jsx)(Br,{className:`size-4 mr-2 text-red-500`}),`Delete`]})]})]})]}),(0,B.jsx)(Oi,{children:(0,B.jsx)(`h2`,{children:r})})]}),(0,B.jsxs)(Ai,{className:`flex justify-between`,children:[(0,B.jsx)(vs,{children:Ya(i)}),(0,B.jsx)(j,{to:n,className:`text-sm`,"aria-label":`View ${r}`,title:`View ${r}`,children:(0,B.jsxs)(`span`,{className:`py-2 transition-all duration-100 ease-in-out border-0 hover:border-b-2`,children:[`View `,(0,B.jsx)(Tn,{className:`inline-block`})]})})]}),(0,B.jsx)(Ju,{organizationId:n,organizationName:r,isOpen:u,onClose:()=>d(!1)})]})}async function Xu(e){let{data:t}=await s.delete(`/Organization/${e}`);return t}function Zu(){return P({mutationFn:e=>Xu(e)})}async function Qu(e){let{data:t}=await s.post(`/Organization/`,{...e});return t}function $u(){return P({mutationFn:e=>Qu(e)})}var ed=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.`}),td=O({name:w().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:ne([re(``),T(),ed]).optional()});function nd(){let{user:e}=Si(),t=ue(),n=L({resolver:N(td),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,z.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),u=(0,z.useMemo)(()=>{let e=fc(mc(o),ed.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:d,isPending:f}=$u(),p=Ie(),h=(0,z.useCallback)(async e=>{d({name:e.name||a,subdomain:e.subdomain||u.suggestedSubdomain},{onSuccess:e=>{p.invalidateQueries({queryKey:l,refetchType:`active`}),c.reloadUser(m),t({to:`/${e.id}`})}})},[u.suggestedSubdomain,p,d,a,t]);return(0,B.jsx)(B.Fragment,{children:(0,B.jsx)(H,{...n,children:(0,B.jsxs)(`form`,{id:`org-add-form`,name:`org-add-form`,onSubmit:n.handleSubmit(h),className:`grid gap-6 text-foreground max-w-xl`,children:[(0,B.jsx)(W,{control:n.control,name:`name`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,maxLength:td.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:n.control,name:`subdomain`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Subdomain`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,maxLength:ed.maxLength,autoCapitalize:`none`,placeholder:u.suggestedSubdomain,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Full Host Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(`span`,{children:u.fullHostName})}),(0,B.jsx)(q,{})]}),(0,B.jsx)(hs,{children:(0,B.jsxs)(g,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:f,children:[`Create New Organization `,(0,B.jsx)(Tn,{})]})})]})})})}function rd(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{}),(0,B.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,B.jsx)(nd,{})})]})}function id(e,t){let n=e*12;return`/Admin/Organization/?${[...t?[`name=ct=${encodeURIComponent(t)}`]:[],`status=ne=DELETED`,`sort(name)`,`limit(${n},${n+12+1})`].join(`&`)}`}async function ad(e,t){let{data:n}=await s.get(id(e,t));return{organizations:n.slice(0,12),hasNextPage:n.length>12}}function od(e,t){return I({queryKey:[`admin-all-organizations`,t,e],queryFn:()=>ad(e,t),placeholderData:vt,retry:!1})}function sd(e,t=300,n){let[r,i]=(0,z.useState)(e);return(0,z.useEffect)(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[n?n(e):e,t]),r}function cd(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||e[i]!==t[i])return!1;return!0}function ld(e,t){let[n,r]=(0,z.useState)(t),[i,a]=(0,z.useState)(e);return(0,z.useEffect)(()=>{cd(n,t)||(r(t),a(e))},[n,t,e]),cd(n,t)?[i,a]:[e,a]}var ud={};function dd(e,t,n){let r=(0,z.useCallback)((e,n)=>t(e,n),[n]);(0,z.useEffect)(()=>(ud[e]||(ud[e]=[]),ud[e].push(r),function(){let t=ud[e].indexOf(r);t>=0&&ud[e].splice(t,1)}),[e,t,r])}function fd(e,t,n){let r=ud[e];if(r)for(let e of r)e(t,n)}function pd(e,t,n){return r=>fd(e,t,n??r)}function md(e,t,n){return(0,z.useCallback)(r=>fd(e,t,n??r),[e,t,n])}function hd(e,t){return Ji(sessionStorage.getItem(String(e)))??t}function gd(e,t){t==null?sessionStorage.removeItem(String(e)):sessionStorage.setItem(String(e),JSON.stringify(t))}function _d(e,t){let n=ld(hd(e,t),[e]),[r,i]=n;return(0,z.useEffect)(()=>{gd(e,r),fd(`Session:${e}`,r)},[e,r]),dd(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,z.useEffect)(function(){let n=n=>{n.key===e&&i(hd(e,t))};return window.addEventListener(`storage`,n),()=>{window.removeEventListener(`storage`,n)}},[e,i,t]),n}function vd(){let e=Ie(),{data:t}=Gr(i()),{mutate:n,isPending:r}=Zu(),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(``),d=(0,z.useCallback)(()=>u(``),[]),f=Ci(),[p,m]=_d(`ShowAllOrganizations`,!1),[h,_]=(0,z.useState)(0),v=f&&p,y=(0,z.useCallback)(e=>{m(e),_(0)},[m]),{data:b,isPending:x}=A({...od(h,sd(l,300)),enabled:v}),S=(0,z.useMemo)(()=>{let e=t?.roles||{},n=Object.values(e);return Object.keys(e).map((e,t)=>({organizationId:e,organizationName:n[t].organizationName,roleName:n[t].role})).filter(Fl([`organizationId`,`organizationName`],l)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1)||[]},[l,t?.roles]),C=(0,z.useMemo)(()=>{let e=t?.roles||{};return(b?.organizations||[]).map(t=>({organizationId:t.id,organizationName:t.name,roleName:e[t.id]?.role||`fabric admin`}))},[b?.organizations,t?.roles]),ee=v?C:S,w=(0,z.useCallback)(e=>{u(e.currentTarget.value||``),_(0)},[]),te=(0,z.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{R.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>R.dismiss()}}),e.invalidateQueries({queryKey:[]}),o(!1)},onError:()=>o(!1)})},[n,e,o]),ne=(0,z.useCallback)(e=>{c(e),o(!0)},[]),{createCluster:T}=Bn({strict:!1});return!v&&S.length===1&&!l.length&&T?(0,B.jsx)(Gn,{to:`/${S[0].organizationId}/new-cluster`,replace:!0}):!v&&!S.length&&!l.length?(0,B.jsx)(rd,{}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{children:(0,B.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[f&&(0,B.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 text-xs`,children:[(0,B.jsx)(Wu,{checked:p,onCheckedChange:y,"aria-label":`Show all organizations`}),(0,B.jsx)(`span`,{className:`hidden sm:inline-block`,children:`All Orgs`})]}),(0,B.jsx)(J,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:l,onChange:w}),(0,B.jsx)(j,{to:`/new-org`,children:(0,B.jsxs)(g,{variant:`positive`,accessKey:`n`,children:[(0,B.jsx)(Bt,{}),(0,B.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,B.jsx)(`u`,{children:`N`}),`ew `,(0,B.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,B.jsxs)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[v&&x?Array.from({length:12},(e,t)=>(0,B.jsx)(Uu,{className:`col-span-1 h-40 md:col-span-4 lg:col-span-3 2xl:col-span-2`},t)):ee.map(e=>(0,B.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,B.jsx)(Yu,{organizationRole:e,onDeleteOrgModal:ne})},e.organizationId)),!ee.length&&!(v&&x)&&(0,B.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,B.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,B.jsx)(g,{variant:`outline`,onClick:d,children:`Clear Filters`})]})]}),v&&(h>0||b?.hasNextPage)&&(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-4 py-6`,children:[(0,B.jsxs)(g,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:h===0,onClick:()=>_(e=>e-1),children:[(0,B.jsx)(lr,{}),`Previous`]}),(0,B.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[`Page `,h+1]}),(0,B.jsxs)(g,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:!b?.hasNextPage,onClick:()=>_(e=>e+1),children:[`Next`,(0,B.jsx)(Tn,{})]})]})]}),s&&(0,B.jsx)(_s,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:s.organizationName,isModalOpen:a,setIsModalOpen:()=>o(!1),deletionConfirmed:()=>te(s),deletionPending:r})]})}function yd(){let{isLoading:e}=xi(),{createCluster:t}=Bn({strict:!1}),[,n]=Zi($i.SavedClusterState,null);return(0,z.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,B.jsx)(Fs,{className:`fixed z-50 translate-1/2`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-gradient-to-r from-violet-100 to-white border-b border-violet-200 dark:from-purple-950 dark:to-zinc-900 dark:border-purple-950 md:px-12`,children:(0,B.jsx)(Aa,{})}),(0,B.jsx)(`main`,{children:(0,B.jsx)(Et,{})})]})}var bd=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function xd(){let e=Ll();return!bd.includes(e)&&{redirect:e}}var Sd=M({getParentRoute:()=>Gi,id:`_dashboardLayout`,component:yd,beforeLoad:({context:e})=>{let t=e.authentication[m];if(t&&!t.isLoading&&!t.user)throw Ve({to:`/sign-in`,search:xd()})}}),Cd=M({getParentRoute:()=>Sd,id:`_orgsLayout`});M({getParentRoute:()=>Cd,path:`/`,head:()=>({meta:[{title:`Organizations — Harper Fabric`}]}),component:vd}),M({getParentRoute:()=>Cd,path:`/new-org`,head:()=>({meta:[{title:`New Organization — Harper Fabric`}]}),component:rd});var wd=M({getParentRoute:()=>Cd,path:`$organizationId`,beforeLoad:async e=>{let{organizationId:t}=e.params;if(!cc(t))throw Ve({to:`/`});return{organization:await e.context.queryClient.ensureQueryData(uc(t))}}});M({getParentRoute:()=>wd,path:`/roles`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Ou}),M({getParentRoute:()=>wd,path:`/roles/$orgRoleId`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Ou}),M({getParentRoute:()=>wd,path:`/users`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:Hu}),M({getParentRoute:()=>wd,path:`/users/$orgUserId`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:Hu}),uu(wd);var Td=M({getParentRoute:()=>wd,id:`_clusterLayout`});M({getParentRoute:()=>Td,path:`/`,head:()=>({meta:[{title:`Clusters — Harper Fabric`}]}),component:Il}),M({getParentRoute:()=>wd,path:`/new-cluster`,head:()=>({meta:[{title:`New Cluster — Harper Fabric`}]}),component:jl}),M({getParentRoute:()=>Dd,path:`/edit`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:jl}),M({getParentRoute:()=>Dd,path:`/edit/$mode`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:jl});function Ed(){return(0,B.jsx)(Et,{})}var Dd=M({getParentRoute:()=>Td,path:`$clusterId`,component:Ed,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(lo(t.clusterId))})});function Od({children:e,className:t}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{}),(0,B.jsx)(`div`,{className:x(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}var kd=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function Ad(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&&kd.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function jd({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=Ad(t),[i,a,o]=Ms(r,e||``,n);return(0,B.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,B.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`This domain has been verified! Now to associate it with this cluster, add the following to your DNS registrar:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:r,onClick:i}),(0,B.jsx)(g,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,B.jsx)(mt,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:e,onClick:a}),(0,B.jsx)(g,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,B.jsx)(mt,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:n,onClick:o}),(0,B.jsx)(g,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,B.jsx)(mt,{className:`w-3 h-3`})})]})}),(0,B.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap italic text-sm`,children:`Select this domain using the checkbox to the left, then click "Bind" in the top right to finish associating it with this cluster.`})]})}function Md({certificate:e,domain:t,cluster:n}){let r=Ad(t.domain),[i,a,o]=Ms(r,n.fqdn||``,t.id),s=(0,z.useMemo)(()=>e.issueDate&&!e.inProgress?{width:`100%`,color:`bg-green/80`,pulse:!1,text:`Certificate Issued`}:e.inProgress?{width:`100%`,color:`bg-yellow/80`,pulse:!0,text:`Generating Certificate...`}:{width:`100%`,color:`bg-gray-600`,pulse:!1,text:`Pending Certificate Generation...`},[e]);return(0,B.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,B.jsx)(`div`,{style:{width:s.width},className:`grow transition-[width] duration-1000 ease-in-out motion-reduce:transition-none ${s.color} ${s.pulse?`animate-pulse`:``}`})}),(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,B.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,B.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,B.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,B.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,B.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,B.jsx)(mt,{className:`w-3 h-3`})})]}),(0,B.jsx)(Nd,{}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,B.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,B.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,B.jsx)(mt,{className:`w-3 h-3`})})]})]}),(0,B.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,B.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,B.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,B.jsx)(mt,{className:`w-2.5 h-2.5`})})]})})]})]})}function Nd(){return(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-3 h-3 text-muted-foreground`,children:[(0,B.jsx)(`path`,{d:`M5 12h14`}),(0,B.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function Pd(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l}=e;return I({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:()=>Fd(e)})}async function Fd({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 Id(e){return I({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await Fd({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},instanceClient:a({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:5e3})}function Ld(e){return A(Id(e))}function Rd({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=Ad(n),[o,s,c,l,u]=Ms(t,e,a,i||``,r);return(0,B.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,B.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`Prove that you own this domain by adding the following to your DNS registrar:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeName`,value:t,onClick:o}),(0,B.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,B.jsx)(mt,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeToken`,value:e,onClick:s}),(0,B.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,B.jsx)(mt,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-4`,children:`While you're at it, you should also add the CNAME record to point to this cluster:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:a,onClick:c}),(0,B.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,B.jsx)(mt,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:i,onClick:l}),(0,B.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,B.jsx)(mt,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:r,onClick:u}),(0,B.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,B.jsx)(mt,{className:`w-3 h-3`})})]})}),(0,B.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-2`,children:`Then after your DNS TTL elapses, click the "Validate" button above.`})]})}async function zd({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await s.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function Bd(){return P({mutationFn:e=>zd(e)})}k.object({domainId:k.string()});async function Vd(e){let{data:t}=await s.delete(`/Domain/${e.domainId}`);return t}function Hd(){return P({mutationFn:e=>Vd(e)})}function Ud(e){return[...new Set(e)]}var Wd=xr();function Gd(e,t,n){let{data:r}=Ld(e.id),i=(0,z.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=Bd(),{mutate:s,isPending:c}=Hd(),l=o||c,u=(0,z.useCallback)((t,n)=>{if(!os(e.status)){R.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:Ud((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{Li.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),R.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,z.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{Li.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),R.success(`Domain removed!`)}})},[s]),f=(0,z.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{Li.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),R.success(`Domain unbound!`)}})},[s]);return(0,z.useMemo)(()=>[Wd.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!Es(e)?(0,B.jsx)(`label`,{className:`p-10 -m-10`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),Wd.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,B.jsxs)(Ga,{children:[(0,B.jsx)(Ka,{asChild:!0,children:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{children:t.domain}),(0,B.jsx)(g,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,B.jsx)(qa,{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!`})]})}}),Wd.display({header:`Next Steps`,enableSorting:!1,size:500,id:`nextSteps`,cell:t=>{let n=t.row.original,i=r?.find(e=>e.domain===n.domain);return n.status===`ACTIVE`&&n.clusterId?e.id===n.clusterId?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,B.jsx)(`div`,{className:`py-2`,children:(0,B.jsx)(Md,{certificate:i,domain:n,cluster:e})}),(0,B.jsx)(g,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l,onClick:()=>f(n.id),children:`Unbind Domain`})]}):`Bound to cluster ${n.clusterId}`:n.status===`PENDING_VALIDATION`?(0,B.jsx)(Rd,{domain:n,cluster:e}):Es(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,B.jsx)(jd,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var Kd=k.object({domain:k.string(),organizationId:k.string()});async function qd(e){let{data:t}=await s.post(`/Domain/`,e);return t}function Jd(){return P({mutationFn:e=>qd(e)})}async function Yd(e){let{data:t}=await s.post(`/Domain/${e}/validate`);return t}async function Xd(e){let{data:t}=await s.get(`/Domain/?organizationId=${e}`);return t}function Zd(e){return I({queryKey:[e,`domains`],queryFn:()=>Xd(e)})}function Qd(){let{organizationId:e,clusterId:t}=F({strict:!1}),{data:n}=Gr(lo(t,!0)),{update:r}=xa(e),{data:i,refetch:a,isFetching:o,isRefetching:s}=A(Zd(e)),c=(0,z.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[l]=(0,z.useState)({attribute:`domain`,descending:!1}),d=(0,z.useMemo)(()=>[{desc:l.descending,id:l.attribute}],[l]),f=ou(a),[p,m]=(0,z.useState)([]),h=(0,z.useCallback)(e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:_,isPending:v}=Bd(),y=(0,z.useCallback)(()=>{if(!os(n.status)){R.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}_({clusterId:n.id,domainIds:Ud((n.domainIds?.slice()||[]).concat(p)),generateDomainCerts:!0},{onSuccess:()=>{Li.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),R.success(`Domain(s) bound! Certificates are being generated in the background now.`),m([])}})},[n,p,_]),{mutateAsync:b,isPending:x}=Jd(),S=L({resolver:N(Kd),defaultValues:{domain:``,organizationId:e}}),C=(0,z.useCallback)(async e=>{if(e){let t=e.domain.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean);for(let n of t)await b({...e,domain:n});S.reset(),await a(),R.success(`${u(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[b,S,a]),ee=(0,z.useCallback)(async()=>{let e=`Validating ${u(c.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of c)try{R.loading(e,{description:`${n++} of ${c.length} checked`,id:t}),await Yd(i.id)}catch{r+=1}r>0?R.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(),R.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[c]),w=Gd(n,p,h),te=S.watch(`domain`),ne=(0,z.useMemo)(()=>typeof te==`string`?te.trim().split(`.`).length===2:!1,[te]),T=(0,z.useCallback)(()=>{typeof te==`string`&&S.setValue(`domain`,`${te.trim()}, www.${te.trim()}`)},[te,S]);return(0,B.jsx)(tu,{data:i||[],isFetching:o||s,columns:w,sortingState:d,children:(0,B.jsxs)(`div`,{className:`w-full flex flex-col md:flex-row items-center md:justify-between md:space-x-2 space-y-2 md:space-y-0`,children:[r&&(0,B.jsx)(H,{...S,children:(0,B.jsxs)(`form`,{id:`cluster-add-domain-form`,name:`cluster-add-domain-form`,onSubmit:S.handleSubmit(C),className:`flex gap-1 flex-col md:flex-row`,children:[(0,B.jsx)(W,{control:S.control,name:`domain`,render:({field:e})=>(0,B.jsxs)(G,{className:`flex-1`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`New Domain Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),ne&&(0,B.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,B.jsx)(g,{variant:`positiveOutline`,type:`button`,onClick:T,children:`Add www as well`})]}),(0,B.jsx)(q,{children:(0,B.jsx)(`span`,{className:`text-muted-foreground italic`,children:`Type in a domain like example.com or your.example.com, and you'll be guided through validating and binding your cluster to it.`})})]})}),(0,B.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,B.jsxs)(g,{type:`submit`,variant:`submit`,disabled:x,children:[(0,B.jsx)(Bt,{}),` Add`]}),c.length>0&&(0,B.jsxs)(g,{variant:`positiveOutline`,onClick:ee,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,B.jsx)(or,{}),` `,(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,B.jsxs)(g,{variant:`defaultOutline`,onClick:f,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,B.jsx)(wt,{}),` `,(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),p.length>0&&(0,B.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,B.jsxs)(g,{variant:`submit`,onClick:y,disabled:v,children:[(0,B.jsx)(je,{}),` Bind `,u(p.length,`Domain`,`Domains`)]})})]})})}function $d(){return(0,B.jsx)(Od,{className:`flex flex-col justify-start max-w-4xl`,children:(0,B.jsx)(Qd,{})})}var ef=O({username:po,role:w().nonempty({error:`Please select a role.`}),password:fo.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 tf(e){await s.patch(`/ResetPasswordUpdater/${e}`)}async function nf(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function rf(){return P({mutationFn:nf})}async function af({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 of(){return P({mutationFn:af})}async function sf({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function cf(){return P({mutationFn:sf})}async function lf({clusterId:e,initialUsername:t,desiredUsername:n,newPassword:i,tempPassword:a,instanceClient:s}){if(!a)throw Error(`You may not have permission to set the password on this cluster.`);let c=s;try{let r=await ao({username:t,password:a,instanceClient:c,entityId:e});return r.instanceClient&&(c=r.instanceClient),n===`HDB_ADMIN`?await af({username:n,password:i,instanceClient:c}):(await nf({username:n,password:i,role:`super_user`,active:!0,instanceClient:c}),await ao({username:n,password:i,instanceClient:c,entityId:e}),await sf({username:o,instanceClient:c})),await tf(e),r}catch(t){throw await r({entityId:e,instanceClient:c}),t}}function uf(){return P({mutationFn:lf})}function df(){let{user:e}=Si(),{clusterId:t}=F({strict:!1}),{data:n}=A(lo(t,!0)),r=ue(),i=(0,z.useMemo)(()=>f(n),[n]),a=fa({operationsUrl:i}),{redirect:s}=Bn({strict:!1}),l=pt(),u=L({resolver:N(ef),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:d,control:p,handleSubmit:m}=u;(0,z.useEffect)(()=>{d(`password`)},[d]);let h=n?.instances?.find(e=>e.tempPassword)?.tempPassword,{mutate:_,isPending:v}=uf(),y=(0,z.useCallback)(async e=>{if(!i){R.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}_({instanceClient:a,clusterId:t,newPassword:e.password,tempPassword:h,initialUsername:o,desiredUsername:e.username},{onSuccess:async({message:e,user:t})=>{R.success(e),c.setUserForEntity(n,t),l.invalidate(),await r({to:s?.startsWith(`/`)?s:`../`})}})},[n,t,a,r,i,s,l,_,h]);return n&&!n.resetPassword?(0,B.jsx)(Gn,{to:`../sign-in`,replace:!0}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`fixed top-20 w-full h-12 z-39 px-4 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none flex items-center`,children:(0,B.jsx)(Za,{})}),(0,B.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,B.jsxs)(`div`,{className:`text-foreground w-xs`,children:[(0,B.jsx)(`h1`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,B.jsx)(`p`,{className:`text-muted-foreground`,children:`You are ready to create your first user in your new cluster. These credentials belong to you alone, and you can create more users and roles once you create this first one.`}),(0,B.jsx)(H,{...u,children:(0,B.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:m(y),className:`my-4`,children:[(0,B.jsx)(W,{control:p,name:`username`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Username`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{autoComplete:`username`,type:`text`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:p,name:`password`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,autoComplete:`new-password`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:p,name:`confirmPassword`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Confirm Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,autoComplete:`new-password`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(g,{disabled:v,type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,children:`Create Admin User`})]})}),(0,B.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,B.jsx)(kn,{size:36,className:`flex-none`}),(0,B.jsx)(`span`,{children:`These credentials will be used to sign into your cluster directly, providing you a secure connection from your browser to your cluster.`})]})]})})]})}function ff({columns:e,data:t}){let n=sr({data:t,columns:e,getCoreRowModel:hn()});return(0,B.jsx)(`div`,{className:`bg-card dark:bg-black-dark rounded-md`,children:(0,B.jsxs)(Jl,{children:[(0,B.jsx)(Yl,{children:n.getHeaderGroups().map(e=>(0,B.jsx)(Zl,{className:`border-none`,children:e.headers.map(e=>(0,B.jsx)(Ql,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:sn(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,B.jsx)(Xl,{className:`bg-background dark:bg-black`,children:n.getRowModel().rows?.length?n.getRowModel().rows.map(e=>(0,B.jsx)(Zl,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,B.jsx)(eu,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:sn(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,B.jsx)(Zl,{children:(0,B.jsx)(eu,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function pf(){return(0,B.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,B.jsx)(`p`,{children:`No instances found.`})})}function mf({isSelfManaged:e,instance:t}){let{user:i,isLoading:a}=Ti(t.id),o=fa({operationsUrl:(0,z.useMemo)(()=>n(t),[t])}),{update:s}=wa(),l=c.checkForFabricConnect(t.id),u=(0,z.useCallback)(async()=>{await r({instanceClient:o,entityId:t.id}),c.setUserForEntity(t,null)},[t,o]);return a||!t.status||![`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`].includes(t.status)?(0,B.jsx)(on,{className:`animate-spin`,color:`gray`}):!i||l?(0,B.jsxs)(`span`,{className:`flex gap-4`,children:[s&&!e&&(0,B.jsx)(j,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,B.jsx)(g,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,B.jsx)(j,{to:`../instance/${t.id}/sign-in`,className:`text-sm`,"aria-label":`Sign in to ${t.name} instance`,title:`Sign in to ${t.name} instance`,children:(0,B.jsx)(g,{variant:s?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,B.jsxs)(`span`,{className:`flex gap-4`,children:[(0,B.jsx)(j,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,B.jsx)(g,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,B.jsx)(g,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:u,children:`Direct Sign Out`})]})}function hf({entityId:e,instanceClient:t},n){return I({queryKey:[e,`get_status`],staleTime:9e3,refetchInterval:1e4,retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function gf(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function _f({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function vf(){return P({mutationFn:_f,onSuccess:(e,t)=>Li.invalidateQueries({queryKey:[t.entityId,`get_status`]})})}function yf({instance:e,index:t}){let{update:r}=wa(),i=V({operationsUrl:(0,z.useMemo)(()=>n(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:a,isPending:o}=vf(),[s,c]=(0,z.useState)(!1);(0,z.useEffect)(()=>{let e=setTimeout(()=>c(!0),t*500);return()=>clearTimeout(e)},[t]);let{data:l,isLoading:u,isFetching:d}=A(hf(i,s&&r)),f=gf(l,`availability`)||`Unknown`,p=f===`Available`,m=f===`Unavailable`;return r?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsxs)(Ga,{children:[(0,B.jsx)(Ka,{asChild:!0,children:(0,B.jsx)(`div`,{className:`flex items-center`,children:u||!s||d&&!l?(0,B.jsx)(on,{className:`animate-spin size-5 text-muted-foreground`}):(0,B.jsx)(vs,{variant:p?`success`:m?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,B.jsx)(`span`,{className:`sr-only`,children:p?`Online`:`Offline`})})})}),(0,B.jsxs)(qa,{children:[d&&l?`Refreshing... `:``,f]})]}),r&&(0,B.jsxs)(`div`,{className:`flex gap-1`,children:[p&&(0,B.jsxs)(Ga,{children:[(0,B.jsx)(Ka,{asChild:!0,children:(0,B.jsx)(g,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>a({...i,id:`availability`,status:`Unavailable`}),disabled:o,children:o?(0,B.jsx)(on,{className:`animate-spin size-4`}):(0,B.jsx)(ft,{className:`size-4`})})}),(0,B.jsx)(qa,{children:`Bring out of rotation`})]}),m&&(0,B.jsxs)(Ga,{children:[(0,B.jsx)(Ka,{asChild:!0,children:(0,B.jsx)(g,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>a({...i,id:`availability`,status:`Available`}),disabled:o,children:o?(0,B.jsx)(on,{className:`animate-spin size-4`}):(0,B.jsx)(Jn,{className:`size-4`})})}),(0,B.jsx)(qa,{children:`Bring back into rotation`})]})]})]}):null}function bf(){let{clusterId:e}=F({strict:!1}),{data:t,isLoading:n}=A(lo(e,!0)),r=Es(t),i=(0,z.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,B.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,B.jsx)(mf,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>wl({secure:e.row.original.operationsApiSecure?`true`:`false`,port:e.row.original.operationsApiPort,fqdn:e.row.original.instanceFqdn})},!r&&{accessorKey:`name`,size:90,header:`Name`},{accessorKey:`status`,header:`Status`,size:1,minSize:1,cell:e=>{let t=e.getValue();return(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(yf,{instance:e.row.original,index:e.row.index}),t?(0,B.jsx)(vs,{variant:as(t),children:Ya(t)}):null]})}},!r&&{accessorKey:`version`,size:1,minSize:1,header:`Version`},!r&&{accessorKey:`storageGb`,size:1,minSize:1,header:`Storage`,cell:e=>`${e.getValue()} GB`},!r&&{accessorKey:`usedStorageGb`,size:1,minSize:1,header:`Used Storage`,cell:e=>{let t=e.getValue();return t===void 0?`-`:`${t} GB`}},!r&&{accessorKey:`cpuCores`,size:1,minSize:1,header:`Cores/Threads`,cell:e=>(0,B.jsxs)(B.Fragment,{children:[e.row.original.cpuCores,` / `,e.row.original.threads]})},!r&&{accessorKey:`memoryMb`,size:1,minSize:1,header:`Memory`,cell:e=>`${e.getValue()/1024} GB`}].filter(Ri),[r]),a=(0,z.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!ro.includes(e.status)).sort(Ks):[],[t]);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,B.jsx)(Ei,{className:`p-0 mt-4 min-h-96`,children:(0,B.jsx)(Ai,{className:`p-0 min-h-96`,children:n?(0,B.jsx)(zc,{}):a.length?(0,B.jsx)(ff,{data:a,columns:i}):(0,B.jsx)(pf,{})})})})]})}function xf(){let{clusterId:e}=F({strict:!1}),{data:t,isLoading:n}=A(lo(e,2e3)),r=t?.status,i=(0,z.useMemo)(()=>r&&no.includes(r),[r]);return n||!t?(0,B.jsx)(Od,{className:`flex justify-center`,children:(0,B.jsx)(zc,{})}):i?(0,B.jsx)(Od,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,B.jsx)(ks,{cluster:t,forceProgressBarVisible:!0}),(0,B.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,B.jsx)(`div`,{className:`text-center`,children:(0,B.jsx)(Ds,{cluster:t})})]})}):(0,B.jsx)(Od,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,B.jsx)(ks,{cluster:t,forceProgressBarVisible:!0}),(0,B.jsxs)(`p`,{children:[`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,B.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}function Sf(){let e=pt(),{clusterId:t}=F({strict:!1}),{data:n,isLoading:r}=A(lo(t,2e3)),i=n?.status,a=(0,z.useMemo)(()=>i&&no.includes(i),[i]),o=ss(i),[,s]=Zi($i.SavedClusterState,null),c=(0,z.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,B.jsx)(Od,{className:`flex justify-center`,children:(0,B.jsx)(zc,{})}):o?(0,B.jsx)(Od,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,B.jsx)(Kr,{className:`w-24 h-24`}),(0,B.jsxs)(`span`,{children:[`Your cluster failed to successfully start. This is usually caused by temporary communication problems. Would you like to try again? We also get notified about these failures. `,(0,B.jsx)(Ps,{}),` if you want more help.`]}),(0,B.jsx)(g,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,B.jsx)(Od,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,B.jsx)(ks,{cluster:n,forceProgressBarVisible:!0}),(0,B.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Did you know during this step, you connect straight to your cluster, providing a private secure connection? That's `,(0,B.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,B.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,B.jsx)(`div`,{className:`text-center`,children:(0,B.jsx)(Ds,{cluster:n})})]})}):(0,B.jsx)(Od,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,B.jsx)(ks,{cluster:n,forceProgressBarVisible:!0}),(0,B.jsxs)(`p`,{children:[`Your cluster is spinning up with the latest changes, including your own DNS records and private connections. Please wait while we get everything going.`,` `,(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,B.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}M({getParentRoute:()=>Dd,path:`instances`,head:()=>({meta:[{title:`Instances — Harper Fabric`}]}),component:bf}),M({getParentRoute:()=>Dd,path:`starting-up`,head:()=>({meta:[{title:`Starting Up — Harper Fabric`}]}),component:Sf}),M({getParentRoute:()=>Dd,path:`scaling`,head:()=>({meta:[{title:`Scaling — Harper Fabric`}]}),component:xf}),M({getParentRoute:()=>Dd,path:`domains`,head:()=>({meta:[{title:`Domains — Harper Fabric`}]}),component:$d}),M({getParentRoute:()=>Dd,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:bo,beforeLoad:({context:e,location:t,params:n})=>{let r=c.checkForFabricConnect(n.clusterId);if(e.authentication[n.clusterId]?.user&&!r){let e=t?.search;throw Ve({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),M({getParentRoute:()=>Dd,path:`instance/$instanceId/sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:bo,beforeLoad:({context:e,location:t,params:n})=>{if(!(c.checkForFabricConnect(n.clusterId)||c.checkForFabricConnect(n.instanceId))&&e.authentication[n.instanceId]?.user){let e=t?.search;throw Ve({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),M({getParentRoute:()=>Dd,path:`finish-setup`,head:()=>({meta:[{title:`Create Admin User — Harper Fabric`}]}),component:df});function Cf(e){return M({getParentRoute:()=>e,path:`apis`,head:()=>({meta:[{title:`APIs — Harper Fabric`}]})}).lazy(()=>$r(()=>import(`./index.lazy-DPTCQseJ.js`).then(e=>e.route),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])))}function wf(e,t=!1){let[n,r]=_d(e,t),i=(0,z.useCallback)(e=>{e?.preventDefault?.(),r(e=>!e)},[r]),a=(0,z.useCallback)(e=>{e?.preventDefault?.(),r(!0)},[r]),o=(0,z.useCallback)(e=>{e?.preventDefault?.(),r(!1)},[r]);return(0,z.useMemo)(()=>({toggled:n,setToggled:r,toggle:i,toggleOn:a,toggleOff:o}),[i,r,o,a,n])}var Tf=(0,z.createContext)(null);function Ef(){return(0,z.useContext)(Tf)}async function Df({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 Of(e){let t=(e||``)?.split(`.`);return t.length>1?t.slice(-1)[0]:``}function kf(e){switch(Of(e).toLowerCase()){case`jpg`:case`jpeg`:case`gif`:case`png`:case`pneg`:case`webp`:return!0;default:return!1}}async function Af({instanceClient:e,file:t,project:n,encoding:r}){let{data:i}=await e.post(`/`,{operation:`get_component_file`,project:n,file:t,encoding:r??(kf(t)?`base64`:`utf8`)});return{project:n,file:t,...i}}function jf(e){return I({queryKey:Mf(e),queryFn:()=>Af(e),enabled:!!e.file&&!!e.project,retry:!1})}function Mf(e){return[e.entityId,`get_component_file`,e.project,e.file,e.encoding]}async function Nf({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 Pf(){return P({mutationFn:Nf})}function Ff(){let{reloadRootEntries:e,setFocusedItem:t,setSelectedItems:n}=Ef(),r=V();return(0,z.useCallback)(async i=>{let a=!1,o=i.filter(e=>e.from!==e.to);if(o.length===0)return;let s=`Renaming ${u(o.length,`File`,`Files`)}`,c={duration:6e4,action:{label:`Cancel`,onClick:()=>{a=!0}}};c.id=R.loading(s,{...c,description:(0,B.jsx)(nc,{animated:!0,width:`0%`})});let l=o.length*3,d=0;function f(){d+=1,R.loading(s,{...c,description:(0,B.jsx)(nc,{animated:!0,width:(d===0?0:d/l*100)+`%`})})}for(let e of o){let t=e.from.split(`/`),n=t.shift(),i=t.join(`/`),o=e.to.split(`/`),s=o.shift(),c=o.join(`/`),l=await Af({...r,file:i,project:n,encoding:`base64`});if(a||(f(),await Nf({...r,file:c,project:s,encoding:`base64`,payload:l.message}),a)||(f(),await Df({...r,file:i,project:n}),a))break;f()}d>=l?R.success(`Renamed ${u(o.length,`File`,`Files`)}`,{id:c.id,description:`All done!`,duration:3e3,action:{label:`OK`,onClick:()=>{}}}):R.warning(`Rename Cancelled`,{id:c.id,description:`${d} of ${l} steps completed.`,duration:1e4,action:{label:`OK`,onClick:()=>{}}}),e(),n(e=>{let t=e.slice();for(let e of o){let n=t.indexOf(e.from);n>=0?t.splice(n,1,e.to):t.push(e.to)}return t}),t(e=>{for(let t of o)if(e===t.from)return t.to;return e})},[r,e,t,n])}function If(e,t){return e[t]!==void 0}function Lf(e){return t=>If(t,e)}function Rf(e,t){let[n,r]=(0,z.useState)({value:t});return dd(e,(e,t)=>r({value:e,trigger:t}),[r]),n}function zf(e,t,n){fd(e,t,n)}function Bf(e,t,n){return r=>zf(e,t,n??r)}function Vf(e,t,n){return(0,z.useCallback)(r=>{zf(e,t,n??r)},[e,t,n])}var Hf=[{handleGlobal(e,t){if((t.cmd||t.ctrl)&&e===`Delete`)return zf(`ShowDeleteDirectoryOrFileModal`,!0),!0},addEditorAction(e){return{id:`delete-file`,label:`Delete File`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.Delete],run:Bf(`ShowDeleteDirectoryOrFileModal`,!0)}}},{handleGlobal(e,t){if(t.ctrl&&t.alt&&t.shift&&e===`˜`)return zf(`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:Bf(`ShowAddDirectoryOrFileModalType`,`directory`)}}},{handleGlobal(e,t){if(t.ctrl&&e===`n`)return zf(`ShowAddDirectoryOrFileModalType`,`file`),!0},addEditorAction(e){return{id:`new-file`,label:`New File`,keybindings:[e.KeyMod.WinCtrl|e.KeyCode.KeyN],run:Bf(`ShowAddDirectoryOrFileModalType`,`file`)}}},{handleGlobal(e){if(e===`F2`)return zf(`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:Bf(`ShowRenameFileModal`,!0)}}},{addEditorAction(){return{id:`revert-file`,label:`Revert File`,run:pd(`RevertChanges`,!0)}}},{handleGlobal(e,t){if(t.cmd&&e===`s`)return fd(`SaveFile`,!0),!0},addEditorAction(e){return{id:`save-file`,label:`Save Changes`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.KeyS],run:pd(`SaveFile`,!0)}}}],Uf=Hf.filter(Lf(`addEditorAction`)),Wf=Hf.filter(Lf(`handleGlobal`));function Gf(e){let[t,n]=e,r=Uf.map(e=>t.addAction(e.addEditorAction(n)));return()=>{for(let e of r)e?.dispose()}}function Kf(){(0,z.useEffect)(()=>(document.addEventListener(`keydown`,qf),()=>{document.removeEventListener(`keydown`,qf)}),[])}function qf(e){let t={cmd:e.getModifierState(`Meta`),alt:e.getModifierState(`Alt`),shift:e.getModifierState(`Shift`),ctrl:e.getModifierState(`Control`)};for(let n of Wf)if(n.handleGlobal(e.key,t)){e.preventDefault();return}}function Jf(e){return e.split(`/`).pop()}function Yf(...e){let t=e.flat(1);return t.map((e,n)=>typeof e==`string`?Xf(e,n!==0,n!==t.length-1):e).join(`/`)}function Xf(e,t=!0,n=!0){let r=t&&e[0]===`/`,i=n&&e[e.length-1]===`/`;return r&&i?e.slice(1,-1):r?e.slice(1):i?e.slice(0,-1):e}function Zf(e){return!!e?.entries}var Qf=`__root__`,$f=`importedApplications`,ep=`newApplication`;function tp(e){let t={},n=[],r=[],i=[];for(let a of e)Zf(a)?a.package?r.push(a.path):n.push(a.path):i.push(a.path),np(t,a);return t[Qf]={index:Qf,isFolder:!0,children:[ep,$f,...n,...i].filter(Ri),data:void 0,canMove:!1,canRename:!1},t[$f]={index:$f,isFolder:!0,children:r,data:{name:`Imported Applications`,path:$f,package:$f,project:``,entries:[]},canMove:!1,canRename:!1},t[ep]={index:ep,isFolder:!1,data:{name:`New Application`,path:ep,project:``},canMove:!1,canRename:!1},{items:t,rootId:Qf}}function np(e,t){let n=t.path;if(Zf(t)){let r=t,i=[],a=[];for(let e of r.entries)Zf(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)np(e,t)}else e[n]={index:n,isFolder:!1,data:t,canMove:!t.package,canRename:!t.package}}function rp(){let[e,t]=(0,z.useState)(!1),[n,r]=(0,z.useState)(void 0),i=(0,z.useCallback)(e=>{if(!e.dataTransfer?.types?.includes(`Files`))return;let n=e.target;if(n instanceof Element&&n.classList.contains(`rct-tree-item-button-isFolder`)){let e=n.getAttribute(`data-rct-item-id`);!n.querySelector(`.packageIsLocked`)&&e&&e!==`importedApplications`&&e!==`newApplication`&&r(e=>e===n?e:(e?.classList?.remove?.(`rct-tree-item-title-container-dragging-over`),n.classList.add(`rct-tree-item-title-container-dragging-over`),n))}t(!0)},[]),a=(0,z.useCallback)(()=>{t(!1),r(e=>{e&&e.classList.remove(`rct-tree-item-title-container-dragging-over`)})},[]),o=(0,z.useCallback)(e=>{if(!e.dataTransfer?.types?.includes(`Files`)||e.detail===1337)return;t(!1),n&&(n.classList.remove(`rct-tree-item-title-container-dragging-over`),r(void 0));let i=document.getElementById(`dropTarget`);return i?i.dispatchEvent(new DragEvent(`drop`,{bubbles:!0,detail:1337,cancelable:!0,dataTransfer:e.dataTransfer})):!1},[n]);return(0,z.useEffect)(()=>(document.addEventListener(`dragenter`,i),document.addEventListener(`dragover`,i),document.addEventListener(`dragleave`,a),document.addEventListener(`drop`,o),()=>{document.removeEventListener(`dragenter`,i),document.removeEventListener(`dragover`,i),document.removeEventListener(`dragleave`,a),document.removeEventListener(`drop`,o)}),[i,o,a]),(0,z.useMemo)(()=>({dragging:e,dragTarget:n}),[e,n])}function ip(e){return new Promise((t,n)=>{let r=new FileReader;r.onabort=n,r.onerror=n,r.onload=t,r.readAsDataURL(e)})}function ap(){let[e,t]=(0,z.useState)(``),{clusterId:n}=F({strict:!1}),{openedEntry:r,restrictPackageModification:i,reloadRootEntries:a,entryExists:o}=Ef(),s=!!r&&!r.package&&!i,l=V(),{dragging:d,dragTarget:f}=rp(),p=(f?.getAttribute?.(`data-rct-item-id`))?.split?.(`/`)?.pop?.(),m=r?.project,h=!1,g;if(r?.path){let e=r.path.split(`/`),t=Zf(r);h=s&&(t?e.slice(1):e.slice(1,-1)).join(`/`),g=e[e.length-(t?1:2)]}let _=(0,z.useCallback)(async(e,n)=>{let r=f?.getAttribute?.(`data-rct-item-id`)?.split?.(`/`),i=r?.length?r[0]:s?m:!1,c=r?.length?r.slice(1).join(`/`):s?h:!1;if(i===!1||i===void 0||c===!1||c===void 0)return;let d=[],p=n.slice();for(let t of e){let e=op(c,t);t.name.startsWith(`.`)||t.relativePath?.includes(`/.`)?p.push({file:t,errors:[{message:`Sensitive files and folders starting with . are skipped.`,code:`dot-ignored`}]}):o(`${i}/${e}`)?p.push({file:t,errors:[{message:`${e} already exists`,code:`duplicate`}]}):d.push(t)}let g=!1,_=`uploading-files`,v={label:`Cancel`,onClick:()=>{g=!0}},y={label:`OK`,onClick:()=>void 0};t(`Uploading ${u(d.length,`file`,`files`)}...`);let b=d.reduce((e,t)=>e+t.size,0),x=0,S=0;for(let e of d){S+=1,R.loading(`Upload in progress...`,{id:_,descriptionClassName:`whitespace-pre`,description:`${S} of ${u(d.length,`file`,`files`)}
11
+ `)}}];function ou(e){return(0,z.useCallback)(async()=>{R.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await p(500),R.success(`Refreshed!`,{id:`refreshing`})},[e])}async function su(e){let{data:t}=await s.get(`/Invoice/${e}`);return t}function cu(e,t){return I({queryKey:[e,`invoices`],queryFn:()=>su(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function lu(){let{organizationId:e}=F({strict:!1}),{data:t}=A(uc(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=A(cu(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=ou(r);return t?.type===`ENTERPRISE`?(0,B.jsxs)(`span`,{children:[`You are part of an enterprise organization! We don’t currently show your invoices on this page. Want to explore your solution with Harper more? `,(0,B.jsx)(Ps,{}),`, we would love to talk!`]}):i?(0,B.jsx)(Fs,{centered:!0}):!n||!n.length?(0,B.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,B.jsx)(Ps,{overEmail:!0}),`, we would love to talk!`]}):(0,B.jsx)(tu,{data:n,columns:au,children:(0,B.jsxs)(g,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,B.jsx)(wt,{}),(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function uu(e){let t=M({getParentRoute:()=>e,path:`billing`,head:()=>({meta:[{title:`Billing — Harper Fabric`}]}),component:Gl}),n=M({getParentRoute:()=>t,path:`/`,head:()=>({meta:[{title:`Payment Methods — Harper Fabric`}]}),component:Mc}),r=M({getParentRoute:()=>t,path:`invoices`,head:()=>({meta:[{title:`Invoices — Harper Fabric`}]}),component:lu}),i=M({getParentRoute:()=>t,path:`confirm`,head:()=>({meta:[{title:`Confirm Payment — Harper Fabric`}]}),component:Bl});return t.addChildren([n,r,i])}async function du(e){let{data:t}=await s.get(`/OrganizationRole/${e}`);return t}function fu(e){return I({queryKey:[e,`roles`],queryFn:()=>du(e),retry:!1,refetchInterval:10*1e3})}var pu=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},xr().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 mu(e){let{data:t}=await s.post(`/Role/`,e);return t}function hu(){return P({mutationFn:mu})}var gu=O({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()});O({roles:O({create:E(),delete:E(),update:E(),view:E()}),clusters:O({create:E(),delete:E(),update:E(),view:E(),resources:ie(O({id:w(),delete:E(),update:E(),view:E(),instances:O({create:E(),delete:E(),update:E(),view:E()})}))})});function _u(){let[e]=na(),t=Qi();return e===`dark`||e===`system`&&t===`dark`?`vs-dark`:`light`}var vu={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function yu({isModalOpen:e,setIsModalOpen:t}){let n=_u(),r=Ie(),{organizationId:i}=F({strict:!1}),[a,o]=(0,z.useState)(!0),[s,c]=(0,z.useState)(JSON.stringify(vu,null,2)),{mutate:l,isPending:u}=hu(),d=L({resolver:N(gu),defaultValues:{name:``,update:!1,delete:!1}}),f=(0,z.useCallback)(e=>{o(e.length===0)},[o]),p=(0,z.useCallback)(async e=>{let n=Ji(s);if(!n)return;let o={...e,...n,organizationId:i};e&&a&&l(o,{onSuccess:()=>{R.success(`Organization role added successfully!`),t(!1),r.invalidateQueries({queryKey:[i,`roles`],refetchType:`active`}),d.reset()},onError:e=>{R.error(`Failed to add organization role: ${e.message}`)}})},[a,s,l,d,r,t,i]);return(0,B.jsx)(Y,{onOpenChange:t,open:e,children:(0,B.jsxs)(X,{children:[(0,B.jsx)(Z,{children:`Add New Organization Role`}),(0,B.jsx)(gs,{children:`Set the new organization role permissions.`}),(0,B.jsx)(H,{...d,children:(0,B.jsxs)(`form`,{id:`org-add-role-form`,name:`org-add-role-form`,className:`grid grid-cols-2 gap-4 my-4`,onSubmit:d.handleSubmit(p),children:[(0,B.jsx)(W,{control:d.control,name:`name`,render:({field:e})=>(0,B.jsxs)(G,{className:`col-span-2`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Role Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,className:``,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:d.control,name:`update`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Update Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:d.control,name:`delete`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Delete Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(`div`,{className:`col-span-2`,children:(0,B.jsx)(Rn,{theme:n,height:`300px`,defaultLanguage:`json`,onValidate:f,onChange:e=>{e&&c(e)},defaultValue:JSON.stringify(vu,null,2)})}),(0,B.jsx)(hs,{className:`col-span-2`,children:(0,B.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,B.jsx)(g,{variant:`destructiveOutline`,className:`rounded-full`,type:`button`,onClick:()=>t(!1),disabled:u,children:`Cancel`}),(0,B.jsx)(g,{variant:`submit`,className:`rounded-full`,disabled:u||!a||!d.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function bu({roleId:e}){let{data:t}=await s.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function xu(){return P({mutationFn:({roleId:e})=>bu({roleId:e})})}async function Su({roleId:e,updatedRoleInfo:t}){let{data:n}=await s.put(`/Role/${e}`,t);return n}function Cu(){return P({mutationFn:({roleId:e,updatedRoleInfo:t})=>Su({roleId:e,updatedRoleInfo:t})})}function wu({organizationId:e,roleId:t}){return I({queryKey:[e,`roles`,t],queryFn:()=>Tu(t),refetchInterval:10*1e3})}async function Tu(e){let{data:t}=await s.get(`/Role/${e}`);return t}function Eu({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Z,{children:`Confirm Role Deletion`}),(0,B.jsx)(gs,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,B.jsxs)(hs,{children:[(0,B.jsx)(g,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,onClick:()=>t(!1),children:`Cancel`}),(0,B.jsx)(g,{variant:`destructiveOutline`,className:`rounded-full`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function Du({data:e,isModalOpen:t,closeModal:n}){let r=Ie(),{data:i}=Gr(wu({roleId:e.id,organizationId:e.organizationId})),a=Si(),o=a.user&&a.user?.roles?.[e.organizationId]?.role===e.roleName,{update:s,remove:c}=xa(e.organizationId),{mutate:l,isPending:u}=Cu(),{mutate:d,isPending:f}=xu(),p=_u(),[m,h]=(0,z.useState)(!1),_=L({resolver:N(gu),defaultValues:{name:e.roleName,update:i.organization.update||!1,delete:i.organization.delete||!1}}),v=(0,z.useCallback)(()=>{d({roleId:e.id},{onSuccess:()=>{R.success(`Role deleted successfully!`),n(!0),_.reset()},onError:e=>{R.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>R.dismiss()}})}})},[e.id,d,_,n]),[y,b]=(0,z.useState)(!0),[x,S]=(0,z.useState)(JSON.stringify({roles:{...i.organization.roles},clusters:{...i.organization.clusters}},null,2)),C=(0,z.useCallback)(e=>{b(e.length===0)},[b]),ee=(0,z.useCallback)(async t=>{if(!s)return;let i=Ji(x);if(!i)return;let a={...t,...i,organizationId:e.organizationId};x&&y&&l({roleId:e.id,updatedRoleInfo:a},{onSuccess:async()=>{R.success(`Role updated successfully!`),await r.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),n(!1),_.reset()},onError:e=>{R.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>R.dismiss()}})}})},[n,e.id,e.organizationId,_,y,r,i,s,x,l]);return(0,B.jsx)(Y,{onOpenChange:(0,z.useCallback)(()=>n(!1),[n]),open:t,children:(0,B.jsx)(X,{children:m?(0,B.jsx)(Eu,{onRoleDeleteClick:v,setIsConfirmingRoleDeletion:h,isRoleDeletionPending:f}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(Z,{children:[o||!s?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,B.jsx)(H,{..._,children:(0,B.jsxs)(`form`,{id:`org-edit-role-form`,name:`org-edit-role-form`,className:`grid grid-cols-2 gap-4 my-4`,onSubmit:_.handleSubmit(ee),children:[(0,B.jsx)(W,{control:_.control,name:`name`,render:({field:e})=>(0,B.jsxs)(G,{className:`col-span-2`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`Role Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:_.control,name:`update`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Update Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:_.control,name:`delete`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Can Delete Organization`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(`div`,{className:`col-span-2`,children:(0,B.jsx)(Rn,{theme:p,height:`300px`,defaultLanguage:`json`,onValidate:C,onChange:e=>{e&&S(e)},options:o||!s?{readOnly:!0}:void 0,defaultValue:x})}),!o&&(c||s)&&(0,B.jsx)(hs,{className:`col-span-2`,children:(0,B.jsxs)(`div`,{className:`flex justify-between w-full`,children:[c&&(0,B.jsx)(g,{type:`button`,variant:`destructiveOutline`,className:`rounded-full`,onClick:()=>h(!0),disabled:u,children:`Delete Role`}),s&&(0,B.jsx)(g,{variant:`submit`,className:`rounded-full`,disabled:!y||u||!_.formState.isValid||!_.formState.isDirty,children:`Save Changes`})]})})]})})]})})})}function Ou(){let e=ue(),t=Ie(),{organizationId:n,orgRoleId:r}=F({strict:!1}),{create:i}=xa(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=Gr(fu(n)),l=(0,z.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,z.useState)(!1),p=(0,z.useCallback)(async(i,a)=>{await e({to:[r?`..`:``,i].filter(Boolean).join(`/`)}),a&&await t.invalidateQueries({queryKey:[n,`roles`],refetchType:`active`})},[r,e,t]),m=(0,z.useCallback)(()=>{f(!0)},[f]),h=(0,z.useCallback)(e=>p(e.original.id,!1),[p]),_=(0,z.useCallback)(e=>p(void 0,e),[p]),v=ou(o);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,B.jsxs)(z.Suspense,{fallback:(0,B.jsx)(Fs,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,B.jsxs)(tu,{data:a,columns:pu,onRowClick:h,children:[(0,B.jsxs)(g,{variant:`defaultOutline`,onClick:v,accessKey:`r`,disabled:s||c,children:[(0,B.jsx)(wt,{}),(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,B.jsxs)(g,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,B.jsx)(Bt,{}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,B.jsx)(yu,{isModalOpen:d,setIsModalOpen:f}),u&&(0,B.jsx)(Du,{data:l,isModalOpen:u,closeModal:_})]})})]})}var ku=[{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},xr().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}],Au=k.object({email:uo.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:k.string().nonempty({error:`Please select a role.`})});async function ju(e){let{data:t}=await s.post(`/OrganizationRole/`,e);return t}function Mu(){return P({mutationFn:e=>ju(e)})}k.object({email:uo.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:k.string().nonempty({error:`Please select a role.`})});async function Nu(e){let{data:t}=await s.post(`/UserInvite/`,e);return t}function Pu(){return P({mutationFn:e=>Nu(e)})}function Fu({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=F({strict:!1}),{data:i}=Gr(fu(r)),[a,o]=(0,z.useState)(!1),s=L({resolver:N(Au),defaultValues:{email:``,roleId:``}}),{mutate:c,isPending:l}=Mu(),{mutate:u,isPending:d}=Pu(),f=(0,z.useCallback)(async e=>{e&&(a?u:c)(e,{onSuccess:()=>{let r=e.roleId;s.reset(),s.setValue(`roleId`,r),t(),R.success(`User invited successfully!`),n(!1),o(!1)},onError:e=>{e?.status===404&&o(!0)}})},[c,s,u,t,n,a]);return(0,B.jsx)(Y,{onOpenChange:()=>{n(!1),o(!1),s.reset()},open:e,children:(0,B.jsx)(X,{"aria-describedby":void 0,children:(0,B.jsx)(H,{...s,children:(0,B.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:s.handleSubmit(f),className:`grid gap-4 my-4`,children:[(0,B.jsx)(ms,{children:(0,B.jsx)(Z,{children:a?`Invite User`:`Add User`})}),(0,B.jsx)(W,{control:s.control,name:`email`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Email`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:s.control,name:`roleId`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Roles`}),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(zc,{}),children:(0,B.jsx)(U,{children:(0,B.jsxs)(Bc,{...e,onValueChange:t=>e.onChange(t),children:[(0,B.jsx)(Uc,{className:`w-full`,children:(0,B.jsx)(Hc,{placeholder:`Choose Role`})}),(0,B.jsx)(Wc,{children:(0,B.jsxs)(Vc,{children:[(0,B.jsx)(Gc,{children:`Role`}),i?.map(e=>(0,B.jsx)($,{value:e.id,children:e.roleName},e.id))]})})]})})}),(0,B.jsx)(q,{})]})}),a&&(0,B.jsxs)(gs,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,B.jsx)(Sn,{className:`inline-block size-12 pr-2`}),(0,B.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,B.jsx)(hs,{children:(0,B.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,B.jsxs)(g,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:l||d,children:[(0,B.jsx)(je,{}),` `,a?`Invite User`:`Add User`]})})})]})})})})}async function Iu({roleId:e,userId:t}){let{data:n}=await s.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function Lu(){return P({mutationFn:({roleId:e,userId:t})=>Iu({roleId:e,userId:t})})}function Ru(e){let[t,n]=(0,z.useState)(e||!1);return[t,(0,z.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function zu({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=Mu(),{mutate:c,isPending:l}=Lu(),u=!!i[r.roleName],[d,f]=(0,z.useState)(u),[p,m]=Ru(u);return(0,z.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),R.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),R.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,B.jsxs)(to,{className:`flex`,children:[(0,B.jsx)(J,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,B.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function Bu({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r}){let{organizationId:i}=F({strict:!1}),a=Si(),{update:o,remove:s}=xa(i),c=a.user?.email===t.email,{data:l}=Gr(fu(i)),u=(0,z.useMemo)(()=>t.roles?Js(t.roles,`roleName`):{},[t]),[d,f]=(0,z.useState)(!1);return(0,B.jsx)(Y,{onOpenChange:d?r:e,open:n,children:(0,B.jsxs)(X,{className:`sm:max-w-[750px]`,children:[(0,B.jsx)(ms,{children:(0,B.jsxs)(Z,{children:[o?`Edit `:`View `,` `,t.email,` `,c?`(yourself)`:``]})}),o&&(0,B.jsxs)(gs,{children:[`To remove `,c?`your self`:`this user`,` from the organization, uncheck all of the boxes below.`]}),l.map(e=>(0,B.jsx)(zu,{readOnly:!o,canRemove:s,data:t,orgRole:e,selectedRoles:u,setChangesMade:f},e.id))]})})}function Vu(e,t){return e.email>t.email?1:-1}function Hu(){let e=ue(),{organizationId:t,orgUserId:n}=F({strict:!1}),{update:r}=xa(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=Gr(fu(t)),c=(0,z.useMemo)(()=>{let e={};for(let t of i)if(t.users)for(let n of t.users)e[n.id]||(e[n.id]={...n,roles:[]}),e[n.id].roles.push(t);return Object.values(e).sort(Vu)},[i]),l=(0,z.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),u=(0,z.useCallback)(t=>{e({to:[n?`..`:``,t].filter(Boolean).join(`/`)})},[n,e]),d=!!n&&!!l,[f,p]=(0,z.useState)(!1),[m]=(0,z.useState)({attribute:`email`,descending:!1}),h=(0,z.useMemo)(()=>[{desc:m.descending,id:m.attribute}],[m]),_=(0,z.useCallback)(()=>{p(!0)},[p]),v=(0,z.useCallback)(()=>{a(),p(!1)},[a,p]),y=(0,z.useCallback)(e=>{u(e.original.id)},[u]),b=(0,z.useCallback)(()=>{u(void 0)},[u]),x=(0,z.useCallback)(()=>{a(),u(void 0)},[u,a]),S=ou(a);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,B.jsxs)(z.Suspense,{fallback:(0,B.jsx)(Fs,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,B.jsxs)(tu,{data:c,isFetching:o||s,columns:ku,onRowClick:y,sortingState:h,children:[(0,B.jsxs)(g,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,B.jsx)(wt,{}),` `,(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,B.jsxs)(g,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:f,children:[(0,B.jsx)(Bt,{}),` `,(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,B.jsx)(Fu,{isModalOpen:f,onChangesSaved:v,setIsModalOpen:p}),d&&(0,B.jsx)(Bu,{closeModal:b,data:l,isModalOpen:d,onUserUpdated:x})]})})]})}function Uu({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`skeleton`,className:d(`bg-primary/10 animate-pulse rounded-md`,e),...t})}function Wu({className:e,...t}){return(0,B.jsx)(wr,{"data-slot":`switch`,className:d(`peer data-[state=checked]:bg-green data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-grey-500 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,B.jsx)(ir,{"data-slot":`switch-thumb`,className:d(`bg-white dark:data-[state=unchecked]:bg-white dark:data-[state=checked]:bg-white pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}var Gu=O({couponId:w().nonempty({message:`Please enter a coupon ID.`}).trim()});async function Ku({organizationId:e,couponId:t}){let{data:n}=await s.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});return n}function qu(){return P({mutationFn:Ku})}function Ju({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=qu(),o=L({resolver:N(Gu),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,z.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,z.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?R.error(`Error`,{description:i||`Failed to add coupon.`}):(R.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,B.jsx)(Y,{open:n,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(X,{children:[(0,B.jsxs)(ms,{children:[(0,B.jsx)(Z,{children:`Add Coupon`}),(0,B.jsxs)(gs,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,B.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,B.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,B.jsx)(H,{...o,children:(0,B.jsxs)(`form`,{onSubmit:s(u),children:[(0,B.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,B.jsx)(W,{control:c,name:`couponId`,render:({field:e})=>(0,B.jsxs)(G,{className:`grid items-center gap-4`,children:[(0,B.jsx)(K,{children:`Coupon ID`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,B.jsx)(q,{})]})})}),(0,B.jsxs)(hs,{children:[(0,B.jsx)(g,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,B.jsx)(g,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function Yu({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=ba(n),s=o,{view:c}=xa(n),l=Ci(),[u,d]=(0,z.useState)(!1),f=(0,z.useCallback)(()=>{t(e)},[t,e]);return(0,B.jsxs)(Ei,{className:`relative h-full justify-between hover:shadow-lg transition-shadow duration-200`,children:[(0,B.jsxs)(Di,{children:[(0,B.jsxs)(ki,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`truncate`,children:n}),a&&(0,B.jsxs)(ys,{children:[(0,B.jsx)(bs,{className:`p-4 -m-4 -mr-6 hover:text-foreground`,children:(0,B.jsx)(de,{"aria-label":`Options`})}),(0,B.jsxs)(xs,{children:[(0,B.jsx)(ws,{className:`text-gray-600 text-xs`,children:`Options`}),(0,B.jsx)(Ts,{}),(0,B.jsx)(j,{to:`${n}`,children:(0,B.jsxs)(Ss,{children:[(0,B.jsx)(Un,{className:`size-4 mr-2 text-blue-500`}),`Clusters`]})}),c&&(0,B.jsx)(j,{to:`${n}/roles`,children:(0,B.jsxs)(Ss,{children:[(0,B.jsx)(Jn,{className:`size-4 mr-2 text-purple`}),`Roles`]})}),c&&(0,B.jsx)(j,{to:`${n}/users`,children:(0,B.jsxs)(Ss,{children:[(0,B.jsx)(Mn,{className:`size-4 mr-2 text-orange-500`}),`Users`]})}),s&&(0,B.jsx)(j,{to:`${n}/billing`,children:(0,B.jsxs)(Ss,{children:[(0,B.jsx)(at,{className:`size-4 mr-2 text-green-500`}),`Billing`]})}),l&&(0,B.jsxs)(Ss,{onClick:()=>d(!0),children:[(0,B.jsx)(kt,{className:`size-4 mr-2 text-pink-500`}),`Add Coupon`]}),(0,B.jsx)(Ts,{}),a&&(0,B.jsxs)(Ss,{className:`focus:bg-red/70 focus:text-white`,onClick:f,children:[(0,B.jsx)(Br,{className:`size-4 mr-2 text-red-500`}),`Delete`]})]})]})]}),(0,B.jsx)(Oi,{children:(0,B.jsx)(`h2`,{children:r})})]}),(0,B.jsxs)(Ai,{className:`flex justify-between`,children:[(0,B.jsx)(vs,{children:Ya(i)}),(0,B.jsx)(j,{to:n,className:`text-sm`,"aria-label":`View ${r}`,title:`View ${r}`,children:(0,B.jsxs)(`span`,{className:`py-2 transition-all duration-100 ease-in-out border-0 hover:border-b-2`,children:[`View `,(0,B.jsx)(Tn,{className:`inline-block`})]})})]}),(0,B.jsx)(Ju,{organizationId:n,organizationName:r,isOpen:u,onClose:()=>d(!1)})]})}async function Xu(e){let{data:t}=await s.delete(`/Organization/${e}`);return t}function Zu(){return P({mutationFn:e=>Xu(e)})}async function Qu(e){let{data:t}=await s.post(`/Organization/`,{...e});return t}function $u(){return P({mutationFn:e=>Qu(e)})}var ed=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.`}),td=O({name:w().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:ne([re(``),T(),ed]).optional()});function nd(){let{user:e}=Si(),t=ue(),n=L({resolver:N(td),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,z.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),u=(0,z.useMemo)(()=>{let e=fc(mc(o),ed.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:d,isPending:f}=$u(),p=Ie(),h=(0,z.useCallback)(async e=>{d({name:e.name||a,subdomain:e.subdomain||u.suggestedSubdomain},{onSuccess:e=>{p.invalidateQueries({queryKey:l,refetchType:`active`}),c.reloadUser(m),t({to:`/${e.id}`})}})},[u.suggestedSubdomain,p,d,a,t]);return(0,B.jsx)(B.Fragment,{children:(0,B.jsx)(H,{...n,children:(0,B.jsxs)(`form`,{id:`org-add-form`,name:`org-add-form`,onSubmit:n.handleSubmit(h),className:`grid gap-6 text-foreground max-w-xl`,children:[(0,B.jsx)(W,{control:n.control,name:`name`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,maxLength:td.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:n.control,name:`subdomain`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Subdomain`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,maxLength:ed.maxLength,autoCapitalize:`none`,placeholder:u.suggestedSubdomain,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{className:`pb-1`,children:`Full Host Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(`span`,{children:u.fullHostName})}),(0,B.jsx)(q,{})]}),(0,B.jsx)(hs,{children:(0,B.jsxs)(g,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:f,children:[`Create New Organization `,(0,B.jsx)(Tn,{})]})})]})})})}function rd(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{}),(0,B.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,B.jsx)(nd,{})})]})}function id(e,t){let n=e*12;return`/Admin/Organization/?${[...t?[`name=ct=${encodeURIComponent(t)}`]:[],`status=ne=DELETED`,`sort(name)`,`limit(${n},${n+12+1})`].join(`&`)}`}async function ad(e,t){let{data:n}=await s.get(id(e,t));return{organizations:n.slice(0,12),hasNextPage:n.length>12}}function od(e,t){return I({queryKey:[`admin-all-organizations`,t,e],queryFn:()=>ad(e,t),placeholderData:vt,retry:!1})}function sd(e,t=300,n){let[r,i]=(0,z.useState)(e);return(0,z.useEffect)(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[n?n(e):e,t]),r}function cd(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||e[i]!==t[i])return!1;return!0}function ld(e,t){let[n,r]=(0,z.useState)(t),[i,a]=(0,z.useState)(e);return(0,z.useEffect)(()=>{cd(n,t)||(r(t),a(e))},[n,t,e]),cd(n,t)?[i,a]:[e,a]}var ud={};function dd(e,t,n){let r=(0,z.useCallback)((e,n)=>t(e,n),[n]);(0,z.useEffect)(()=>(ud[e]||(ud[e]=[]),ud[e].push(r),function(){let t=ud[e].indexOf(r);t>=0&&ud[e].splice(t,1)}),[e,t,r])}function fd(e,t,n){let r=ud[e];if(r)for(let e of r)e(t,n)}function pd(e,t,n){return r=>fd(e,t,n??r)}function md(e,t,n){return(0,z.useCallback)(r=>fd(e,t,n??r),[e,t,n])}function hd(e,t){return Ji(sessionStorage.getItem(String(e)))??t}function gd(e,t){t==null?sessionStorage.removeItem(String(e)):sessionStorage.setItem(String(e),JSON.stringify(t))}function _d(e,t){let n=ld(hd(e,t),[e]),[r,i]=n;return(0,z.useEffect)(()=>{gd(e,r),fd(`Session:${e}`,r)},[e,r]),dd(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,z.useEffect)(function(){let n=n=>{n.key===e&&i(hd(e,t))};return window.addEventListener(`storage`,n),()=>{window.removeEventListener(`storage`,n)}},[e,i,t]),n}function vd(){let e=Ie(),{data:t}=Gr(i()),{mutate:n,isPending:r}=Zu(),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(``),d=(0,z.useCallback)(()=>u(``),[]),f=Ci(),[p,m]=_d(`ShowAllOrganizations`,!1),[h,_]=(0,z.useState)(0),v=f&&p,y=(0,z.useCallback)(e=>{m(e),_(0)},[m]),{data:b,isPending:x}=A({...od(h,sd(l,300)),enabled:v}),S=(0,z.useMemo)(()=>{let e=t?.roles||{},n=Object.values(e);return Object.keys(e).map((e,t)=>({organizationId:e,organizationName:n[t].organizationName,roleName:n[t].role})).filter(Fl([`organizationId`,`organizationName`],l)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1)||[]},[l,t?.roles]),C=(0,z.useMemo)(()=>{let e=t?.roles||{};return(b?.organizations||[]).map(t=>({organizationId:t.id,organizationName:t.name,roleName:e[t.id]?.role||`fabric admin`}))},[b?.organizations,t?.roles]),ee=v?C:S,w=(0,z.useCallback)(e=>{u(e.currentTarget.value||``),_(0)},[]),te=(0,z.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{R.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>R.dismiss()}}),e.invalidateQueries({queryKey:[]}),o(!1)},onError:()=>o(!1)})},[n,e,o]),ne=(0,z.useCallback)(e=>{c(e),o(!0)},[]),{createCluster:T}=Bn({strict:!1});return!v&&S.length===1&&!l.length&&T?(0,B.jsx)(Gn,{to:`/${S[0].organizationId}/new-cluster`,replace:!0}):!v&&!S.length&&!l.length?(0,B.jsx)(rd,{}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{children:(0,B.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[f&&(0,B.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 text-xs`,children:[(0,B.jsx)(Wu,{checked:p,onCheckedChange:y,"aria-label":`Show all organizations`}),(0,B.jsx)(`span`,{className:`hidden sm:inline-block`,children:`All Orgs`})]}),(0,B.jsx)(J,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:l,onChange:w}),(0,B.jsx)(j,{to:`/new-org`,children:(0,B.jsxs)(g,{variant:`positive`,accessKey:`n`,children:[(0,B.jsx)(Bt,{}),(0,B.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,B.jsx)(`u`,{children:`N`}),`ew `,(0,B.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,B.jsxs)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[v&&x?Array.from({length:12},(e,t)=>(0,B.jsx)(Uu,{className:`col-span-1 h-40 md:col-span-4 lg:col-span-3 2xl:col-span-2`},t)):ee.map(e=>(0,B.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,B.jsx)(Yu,{organizationRole:e,onDeleteOrgModal:ne})},e.organizationId)),!ee.length&&!(v&&x)&&(0,B.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,B.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,B.jsx)(g,{variant:`outline`,onClick:d,children:`Clear Filters`})]})]}),v&&(h>0||b?.hasNextPage)&&(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-4 py-6`,children:[(0,B.jsxs)(g,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:h===0,onClick:()=>_(e=>e-1),children:[(0,B.jsx)(lr,{}),`Previous`]}),(0,B.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[`Page `,h+1]}),(0,B.jsxs)(g,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:!b?.hasNextPage,onClick:()=>_(e=>e+1),children:[`Next`,(0,B.jsx)(Tn,{})]})]})]}),s&&(0,B.jsx)(_s,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:s.organizationName,isModalOpen:a,setIsModalOpen:()=>o(!1),deletionConfirmed:()=>te(s),deletionPending:r})]})}function yd(){let{isLoading:e}=xi(),{createCluster:t}=Bn({strict:!1}),[,n]=Zi($i.SavedClusterState,null);return(0,z.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,B.jsx)(Fs,{className:`fixed z-50 translate-1/2`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-gradient-to-r from-violet-100 to-white border-b border-violet-200 dark:from-purple-950 dark:to-zinc-900 dark:border-purple-950 md:px-12`,children:(0,B.jsx)(Aa,{})}),(0,B.jsx)(`main`,{children:(0,B.jsx)(Et,{})})]})}var bd=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function xd(){let e=Ll();return!bd.includes(e)&&{redirect:e}}var Sd=M({getParentRoute:()=>Gi,id:`_dashboardLayout`,component:yd,beforeLoad:({context:e})=>{let t=e.authentication[m];if(t&&!t.isLoading&&!t.user)throw Ve({to:`/sign-in`,search:xd()})}}),Cd=M({getParentRoute:()=>Sd,id:`_orgsLayout`});M({getParentRoute:()=>Cd,path:`/`,head:()=>({meta:[{title:`Organizations — Harper Fabric`}]}),component:vd}),M({getParentRoute:()=>Cd,path:`/new-org`,head:()=>({meta:[{title:`New Organization — Harper Fabric`}]}),component:rd});var wd=M({getParentRoute:()=>Cd,path:`$organizationId`,beforeLoad:async e=>{let{organizationId:t}=e.params;if(!cc(t))throw Ve({to:`/`});return{organization:await e.context.queryClient.ensureQueryData(uc(t))}}});M({getParentRoute:()=>wd,path:`/roles`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Ou}),M({getParentRoute:()=>wd,path:`/roles/$orgRoleId`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Ou}),M({getParentRoute:()=>wd,path:`/users`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:Hu}),M({getParentRoute:()=>wd,path:`/users/$orgUserId`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:Hu}),uu(wd);var Td=M({getParentRoute:()=>wd,id:`_clusterLayout`});M({getParentRoute:()=>Td,path:`/`,head:()=>({meta:[{title:`Clusters — Harper Fabric`}]}),component:Il}),M({getParentRoute:()=>wd,path:`/new-cluster`,head:()=>({meta:[{title:`New Cluster — Harper Fabric`}]}),component:jl}),M({getParentRoute:()=>Dd,path:`/edit`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:jl}),M({getParentRoute:()=>Dd,path:`/edit/$mode`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:jl});function Ed(){return(0,B.jsx)(Et,{})}var Dd=M({getParentRoute:()=>Td,path:`$clusterId`,component:Ed,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(lo(t.clusterId))})});function Od({children:e,className:t}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{}),(0,B.jsx)(`div`,{className:x(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}var kd=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function Ad(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&&kd.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function jd({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=Ad(t),[i,a,o]=Ms(r,e||``,n);return(0,B.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,B.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`This domain has been verified! Now to associate it with this cluster, add the following to your DNS registrar:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:r,onClick:i}),(0,B.jsx)(g,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,B.jsx)(mt,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:e,onClick:a}),(0,B.jsx)(g,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,B.jsx)(mt,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:n,onClick:o}),(0,B.jsx)(g,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,B.jsx)(mt,{className:`w-3 h-3`})})]})}),(0,B.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap italic text-sm`,children:`Select this domain using the checkbox to the left, then click "Bind" in the top right to finish associating it with this cluster.`})]})}function Md({certificate:e,domain:t,cluster:n}){let r=Ad(t.domain),[i,a,o]=Ms(r,n.fqdn||``,t.id),s=(0,z.useMemo)(()=>e.issueDate&&!e.inProgress?{width:`100%`,color:`bg-green/80`,pulse:!1,text:`Certificate Issued`}:e.inProgress?{width:`100%`,color:`bg-yellow/80`,pulse:!0,text:`Generating Certificate...`}:{width:`100%`,color:`bg-gray-600`,pulse:!1,text:`Pending Certificate Generation...`},[e]);return(0,B.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,B.jsx)(`div`,{style:{width:s.width},className:`grow transition-[width] duration-1000 ease-in-out motion-reduce:transition-none ${s.color} ${s.pulse?`animate-pulse`:``}`})}),(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,B.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,B.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,B.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,B.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,B.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,B.jsx)(mt,{className:`w-3 h-3`})})]}),(0,B.jsx)(Nd,{}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,B.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,B.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,B.jsx)(mt,{className:`w-3 h-3`})})]})]}),(0,B.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,B.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,B.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,B.jsx)(mt,{className:`w-2.5 h-2.5`})})]})})]})]})}function Nd(){return(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-3 h-3 text-muted-foreground`,children:[(0,B.jsx)(`path`,{d:`M5 12h14`}),(0,B.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function Pd(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l}=e;return I({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:()=>Fd(e)})}async function Fd({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 Id(e){return I({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await Fd({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},instanceClient:a({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:5e3})}function Ld(e){return A(Id(e))}function Rd({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=Ad(n),[o,s,c,l,u]=Ms(t,e,a,i||``,r);return(0,B.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,B.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`Prove that you own this domain by adding the following to your DNS registrar:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeName`,value:t,onClick:o}),(0,B.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,B.jsx)(mt,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeToken`,value:e,onClick:s}),(0,B.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,B.jsx)(mt,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-4`,children:`While you're at it, you should also add the CNAME record to point to this cluster:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:a,onClick:c}),(0,B.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,B.jsx)(mt,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,B.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:i,onClick:l}),(0,B.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,B.jsx)(mt,{className:`w-3.5 h-3.5`})})]})}),(0,B.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,B.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,B.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:r,onClick:u}),(0,B.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,B.jsx)(mt,{className:`w-3 h-3`})})]})}),(0,B.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-2`,children:`Then after your DNS TTL elapses, click the "Validate" button above.`})]})}async function zd({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await s.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function Bd(){return P({mutationFn:e=>zd(e)})}k.object({domainId:k.string()});async function Vd(e){let{data:t}=await s.delete(`/Domain/${e.domainId}`);return t}function Hd(){return P({mutationFn:e=>Vd(e)})}function Ud(e){return[...new Set(e)]}var Wd=xr();function Gd(e,t,n){let{data:r}=Ld(e.id),i=(0,z.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=Bd(),{mutate:s,isPending:c}=Hd(),l=o||c,u=(0,z.useCallback)((t,n)=>{if(!os(e.status)){R.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:Ud((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{Li.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),R.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,z.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{Li.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),R.success(`Domain removed!`)}})},[s]),f=(0,z.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{Li.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),R.success(`Domain unbound!`)}})},[s]);return(0,z.useMemo)(()=>[Wd.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!Es(e)?(0,B.jsx)(`label`,{className:`p-10 -m-10`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),Wd.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,B.jsxs)(Ga,{children:[(0,B.jsx)(Ka,{asChild:!0,children:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{children:t.domain}),(0,B.jsx)(g,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,B.jsx)(qa,{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!`})]})}}),Wd.display({header:`Next Steps`,enableSorting:!1,size:500,id:`nextSteps`,cell:t=>{let n=t.row.original,i=r?.find(e=>e.domain===n.domain);return n.status===`ACTIVE`&&n.clusterId?e.id===n.clusterId?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,B.jsx)(`div`,{className:`py-2`,children:(0,B.jsx)(Md,{certificate:i,domain:n,cluster:e})}),(0,B.jsx)(g,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l,onClick:()=>f(n.id),children:`Unbind Domain`})]}):`Bound to cluster ${n.clusterId}`:n.status===`PENDING_VALIDATION`?(0,B.jsx)(Rd,{domain:n,cluster:e}):Es(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,B.jsx)(jd,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var Kd=k.object({domain:k.string(),organizationId:k.string()});async function qd(e){let{data:t}=await s.post(`/Domain/`,e);return t}function Jd(){return P({mutationFn:e=>qd(e)})}async function Yd(e){let{data:t}=await s.post(`/Domain/${e}/validate`);return t}async function Xd(e){let{data:t}=await s.get(`/Domain/?organizationId=${e}`);return t}function Zd(e){return I({queryKey:[e,`domains`],queryFn:()=>Xd(e)})}function Qd(){let{organizationId:e,clusterId:t}=F({strict:!1}),{data:n}=Gr(lo(t,!0)),{update:r}=xa(e),{data:i,refetch:a,isFetching:o,isRefetching:s}=A(Zd(e)),c=(0,z.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[l]=(0,z.useState)({attribute:`domain`,descending:!1}),d=(0,z.useMemo)(()=>[{desc:l.descending,id:l.attribute}],[l]),f=ou(a),[p,m]=(0,z.useState)([]),h=(0,z.useCallback)(e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:_,isPending:v}=Bd(),y=(0,z.useCallback)(()=>{if(!os(n.status)){R.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}_({clusterId:n.id,domainIds:Ud((n.domainIds?.slice()||[]).concat(p)),generateDomainCerts:!0},{onSuccess:()=>{Li.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),R.success(`Domain(s) bound! Certificates are being generated in the background now.`),m([])}})},[n,p,_]),{mutateAsync:b,isPending:x}=Jd(),S=L({resolver:N(Kd),defaultValues:{domain:``,organizationId:e}}),C=(0,z.useCallback)(async e=>{if(e){let t=e.domain.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean);for(let n of t)await b({...e,domain:n});S.reset(),await a(),R.success(`${u(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[b,S,a]),ee=(0,z.useCallback)(async()=>{let e=`Validating ${u(c.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of c)try{R.loading(e,{description:`${n++} of ${c.length} checked`,id:t}),await Yd(i.id)}catch{r+=1}r>0?R.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(),R.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[c]),w=Gd(n,p,h),te=S.watch(`domain`),ne=(0,z.useMemo)(()=>typeof te==`string`?te.trim().split(`.`).length===2:!1,[te]),T=(0,z.useCallback)(()=>{typeof te==`string`&&S.setValue(`domain`,`${te.trim()}, www.${te.trim()}`)},[te,S]);return(0,B.jsx)(tu,{data:i||[],isFetching:o||s,columns:w,sortingState:d,children:(0,B.jsxs)(`div`,{className:`w-full flex flex-col md:flex-row items-center md:justify-between md:space-x-2 space-y-2 md:space-y-0`,children:[r&&(0,B.jsx)(H,{...S,children:(0,B.jsxs)(`form`,{id:`cluster-add-domain-form`,name:`cluster-add-domain-form`,onSubmit:S.handleSubmit(C),className:`flex gap-1 flex-col md:flex-row`,children:[(0,B.jsx)(W,{control:S.control,name:`domain`,render:({field:e})=>(0,B.jsxs)(G,{className:`flex-1`,children:[(0,B.jsx)(K,{className:`pb-1`,children:`New Domain Name`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),ne&&(0,B.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,B.jsx)(g,{variant:`positiveOutline`,type:`button`,onClick:T,children:`Add www as well`})]}),(0,B.jsx)(q,{children:(0,B.jsx)(`span`,{className:`text-muted-foreground italic`,children:`Type in a domain like example.com or your.example.com, and you'll be guided through validating and binding your cluster to it.`})})]})}),(0,B.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,B.jsxs)(g,{type:`submit`,variant:`submit`,disabled:x,children:[(0,B.jsx)(Bt,{}),` Add`]}),c.length>0&&(0,B.jsxs)(g,{variant:`positiveOutline`,onClick:ee,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,B.jsx)(or,{}),` `,(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,B.jsxs)(g,{variant:`defaultOutline`,onClick:f,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,B.jsx)(wt,{}),` `,(0,B.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,B.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),p.length>0&&(0,B.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,B.jsxs)(g,{variant:`submit`,onClick:y,disabled:v,children:[(0,B.jsx)(je,{}),` Bind `,u(p.length,`Domain`,`Domains`)]})})]})})}function $d(){return(0,B.jsx)(Od,{className:`flex flex-col justify-start max-w-4xl`,children:(0,B.jsx)(Qd,{})})}var ef=O({username:po,role:w().nonempty({error:`Please select a role.`}),password:fo.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 tf(e){await s.patch(`/ResetPasswordUpdater/${e}`)}async function nf(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function rf(){return P({mutationFn:nf})}async function af({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 of(){return P({mutationFn:af})}async function sf({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function cf(){return P({mutationFn:sf})}async function lf({clusterId:e,initialUsername:t,desiredUsername:n,newPassword:i,tempPassword:a,instanceClient:s}){if(!a)throw Error(`You may not have permission to set the password on this cluster.`);let c=s;try{let r=await ao({username:t,password:a,instanceClient:c,entityId:e});return r.instanceClient&&(c=r.instanceClient),n===`HDB_ADMIN`?await af({username:n,password:i,instanceClient:c}):(await nf({username:n,password:i,role:`super_user`,active:!0,instanceClient:c}),await ao({username:n,password:i,instanceClient:c,entityId:e}),await sf({username:o,instanceClient:c})),await tf(e),r}catch(t){throw await r({entityId:e,instanceClient:c}),t}}function uf(){return P({mutationFn:lf})}function df(){let{user:e}=Si(),{clusterId:t}=F({strict:!1}),{data:n}=A(lo(t,!0)),r=ue(),i=(0,z.useMemo)(()=>f(n),[n]),a=fa({operationsUrl:i}),{redirect:s}=Bn({strict:!1}),l=pt(),u=L({resolver:N(ef),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:d,control:p,handleSubmit:m}=u;(0,z.useEffect)(()=>{d(`password`)},[d]);let h=n?.instances?.find(e=>e.tempPassword)?.tempPassword,{mutate:_,isPending:v}=uf(),y=(0,z.useCallback)(async e=>{if(!i){R.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}_({instanceClient:a,clusterId:t,newPassword:e.password,tempPassword:h,initialUsername:o,desiredUsername:e.username},{onSuccess:async({message:e,user:t})=>{R.success(e),c.setUserForEntity(n,t),l.invalidate(),await r({to:s?.startsWith(`/`)?s:`../`})}})},[n,t,a,r,i,s,l,_,h]);return n&&!n.resetPassword?(0,B.jsx)(Gn,{to:`../sign-in`,replace:!0}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`fixed top-20 w-full h-12 z-39 px-4 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none flex items-center`,children:(0,B.jsx)(Za,{})}),(0,B.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,B.jsxs)(`div`,{className:`text-foreground w-xs`,children:[(0,B.jsx)(`h1`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,B.jsx)(`p`,{className:`text-muted-foreground`,children:`You are ready to create your first user in your new cluster. These credentials belong to you alone, and you can create more users and roles once you create this first one.`}),(0,B.jsx)(H,{...u,children:(0,B.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:m(y),className:`my-4`,children:[(0,B.jsx)(W,{control:p,name:`username`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Username`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{autoComplete:`username`,type:`text`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:p,name:`password`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,autoComplete:`new-password`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:p,name:`confirmPassword`,render:({field:e})=>(0,B.jsxs)(G,{className:`my-4`,children:[(0,B.jsx)(K,{children:`Confirm Password`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`password`,autoComplete:`new-password`,...e})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(g,{disabled:v,type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,children:`Create Admin User`})]})}),(0,B.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,B.jsx)(kn,{size:36,className:`flex-none`}),(0,B.jsx)(`span`,{children:`These credentials will be used to sign into your cluster directly, providing you a secure connection from your browser to your cluster.`})]})]})})]})}function ff({columns:e,data:t}){let n=sr({data:t,columns:e,getCoreRowModel:hn()});return(0,B.jsx)(`div`,{className:`bg-card dark:bg-black-dark rounded-md`,children:(0,B.jsxs)(Jl,{children:[(0,B.jsx)(Yl,{children:n.getHeaderGroups().map(e=>(0,B.jsx)(Zl,{className:`border-none`,children:e.headers.map(e=>(0,B.jsx)(Ql,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:sn(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,B.jsx)(Xl,{className:`bg-background dark:bg-black`,children:n.getRowModel().rows?.length?n.getRowModel().rows.map(e=>(0,B.jsx)(Zl,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,B.jsx)(eu,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:sn(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,B.jsx)(Zl,{children:(0,B.jsx)(eu,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function pf(){return(0,B.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,B.jsx)(`p`,{children:`No instances found.`})})}function mf({isSelfManaged:e,instance:t}){let{user:i,isLoading:a}=Ti(t.id),o=fa({operationsUrl:(0,z.useMemo)(()=>n(t),[t])}),{update:s}=wa(),l=c.checkForFabricConnect(t.id),u=(0,z.useCallback)(async()=>{await r({instanceClient:o,entityId:t.id}),c.setUserForEntity(t,null)},[t,o]);return a||!t.status||![`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`].includes(t.status)?(0,B.jsx)(on,{className:`animate-spin`,color:`gray`}):!i||l?(0,B.jsxs)(`span`,{className:`flex gap-4`,children:[s&&!e&&(0,B.jsx)(j,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,B.jsx)(g,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,B.jsx)(j,{to:`../instance/${t.id}/sign-in`,className:`text-sm`,"aria-label":`Sign in to ${t.name} instance`,title:`Sign in to ${t.name} instance`,children:(0,B.jsx)(g,{variant:s?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,B.jsxs)(`span`,{className:`flex gap-4`,children:[(0,B.jsx)(j,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,B.jsx)(g,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,B.jsx)(g,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:u,children:`Direct Sign Out`})]})}function hf({entityId:e,instanceClient:t},n){return I({queryKey:[e,`get_status`],staleTime:9e3,refetchInterval:1e4,retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function gf(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function _f({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function vf(){return P({mutationFn:_f,onSuccess:(e,t)=>Li.invalidateQueries({queryKey:[t.entityId,`get_status`]})})}function yf({instance:e,index:t}){let{update:r}=wa(),i=V({operationsUrl:(0,z.useMemo)(()=>n(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:a,isPending:o}=vf(),[s,c]=(0,z.useState)(!1);(0,z.useEffect)(()=>{let e=setTimeout(()=>c(!0),t*500);return()=>clearTimeout(e)},[t]);let{data:l,isLoading:u,isFetching:d}=A(hf(i,s&&r)),f=gf(l,`availability`)||`Unknown`,p=f===`Available`,m=f===`Unavailable`;return r?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsxs)(Ga,{children:[(0,B.jsx)(Ka,{asChild:!0,children:(0,B.jsx)(`div`,{className:`flex items-center`,children:u||!s||d&&!l?(0,B.jsx)(on,{className:`animate-spin size-5 text-muted-foreground`}):(0,B.jsx)(vs,{variant:p?`success`:m?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,B.jsx)(`span`,{className:`sr-only`,children:p?`Online`:`Offline`})})})}),(0,B.jsxs)(qa,{children:[d&&l?`Refreshing... `:``,f]})]}),r&&(0,B.jsxs)(`div`,{className:`flex gap-1`,children:[p&&(0,B.jsxs)(Ga,{children:[(0,B.jsx)(Ka,{asChild:!0,children:(0,B.jsx)(g,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>a({...i,id:`availability`,status:`Unavailable`}),disabled:o,children:o?(0,B.jsx)(on,{className:`animate-spin size-4`}):(0,B.jsx)(ft,{className:`size-4`})})}),(0,B.jsx)(qa,{children:`Bring out of rotation`})]}),m&&(0,B.jsxs)(Ga,{children:[(0,B.jsx)(Ka,{asChild:!0,children:(0,B.jsx)(g,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>a({...i,id:`availability`,status:`Available`}),disabled:o,children:o?(0,B.jsx)(on,{className:`animate-spin size-4`}):(0,B.jsx)(Jn,{className:`size-4`})})}),(0,B.jsx)(qa,{children:`Bring back into rotation`})]})]})]}):null}function bf(){let{clusterId:e}=F({strict:!1}),{data:t,isLoading:n}=A(lo(e,!0)),r=Es(t),i=(0,z.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,B.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,B.jsx)(mf,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>wl({secure:e.row.original.operationsApiSecure?`true`:`false`,port:e.row.original.operationsApiPort,fqdn:e.row.original.instanceFqdn})},!r&&{accessorKey:`name`,size:90,header:`Name`},{accessorKey:`status`,header:`Status`,size:1,minSize:1,cell:e=>{let t=e.getValue();return(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(yf,{instance:e.row.original,index:e.row.index}),t?(0,B.jsx)(vs,{variant:as(t),children:Ya(t)}):null]})}},!r&&{accessorKey:`version`,size:1,minSize:1,header:`Version`},!r&&{accessorKey:`storageGb`,size:1,minSize:1,header:`Storage`,cell:e=>`${e.getValue()} GB`},!r&&{accessorKey:`usedStorageGb`,size:1,minSize:1,header:`Used Storage`,cell:e=>{let t=e.getValue();return t===void 0?`-`:`${t} GB`}},!r&&{accessorKey:`cpuCores`,size:1,minSize:1,header:`Cores/Threads`,cell:e=>(0,B.jsxs)(B.Fragment,{children:[e.row.original.cpuCores,` / `,e.row.original.threads]})},!r&&{accessorKey:`memoryMb`,size:1,minSize:1,header:`Memory`,cell:e=>`${e.getValue()/1024} GB`}].filter(Ri),[r]),a=(0,z.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!ro.includes(e.status)).sort(Ks):[],[t]);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(is,{}),(0,B.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,B.jsx)(Ei,{className:`p-0 mt-4 min-h-96`,children:(0,B.jsx)(Ai,{className:`p-0 min-h-96`,children:n?(0,B.jsx)(zc,{}):a.length?(0,B.jsx)(ff,{data:a,columns:i}):(0,B.jsx)(pf,{})})})})]})}function xf(){let{clusterId:e}=F({strict:!1}),{data:t,isLoading:n}=A(lo(e,2e3)),r=t?.status,i=(0,z.useMemo)(()=>r&&no.includes(r),[r]);return n||!t?(0,B.jsx)(Od,{className:`flex justify-center`,children:(0,B.jsx)(zc,{})}):i?(0,B.jsx)(Od,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,B.jsx)(ks,{cluster:t,forceProgressBarVisible:!0}),(0,B.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,B.jsx)(`div`,{className:`text-center`,children:(0,B.jsx)(Ds,{cluster:t})})]})}):(0,B.jsx)(Od,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,B.jsx)(ks,{cluster:t,forceProgressBarVisible:!0}),(0,B.jsxs)(`p`,{children:[`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,B.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}function Sf(){let e=pt(),{clusterId:t}=F({strict:!1}),{data:n,isLoading:r}=A(lo(t,2e3)),i=n?.status,a=(0,z.useMemo)(()=>i&&no.includes(i),[i]),o=ss(i),[,s]=Zi($i.SavedClusterState,null),c=(0,z.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,B.jsx)(Od,{className:`flex justify-center`,children:(0,B.jsx)(zc,{})}):o?(0,B.jsx)(Od,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,B.jsx)(Kr,{className:`w-24 h-24`}),(0,B.jsxs)(`span`,{children:[`Your cluster failed to successfully start. This is usually caused by temporary communication problems. Would you like to try again? We also get notified about these failures. `,(0,B.jsx)(Ps,{}),` if you want more help.`]}),(0,B.jsx)(g,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,B.jsx)(Od,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,B.jsx)(ks,{cluster:n,forceProgressBarVisible:!0}),(0,B.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Did you know during this step, you connect straight to your cluster, providing a private secure connection? That's `,(0,B.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,B.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,B.jsx)(`div`,{className:`text-center`,children:(0,B.jsx)(Ds,{cluster:n})})]})}):(0,B.jsx)(Od,{className:`flex justify-center`,children:(0,B.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,B.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,B.jsx)(ks,{cluster:n,forceProgressBarVisible:!0}),(0,B.jsxs)(`p`,{children:[`Your cluster is spinning up with the latest changes, including your own DNS records and private connections. Please wait while we get everything going.`,` `,(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,B.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}M({getParentRoute:()=>Dd,path:`instances`,head:()=>({meta:[{title:`Instances — Harper Fabric`}]}),component:bf}),M({getParentRoute:()=>Dd,path:`starting-up`,head:()=>({meta:[{title:`Starting Up — Harper Fabric`}]}),component:Sf}),M({getParentRoute:()=>Dd,path:`scaling`,head:()=>({meta:[{title:`Scaling — Harper Fabric`}]}),component:xf}),M({getParentRoute:()=>Dd,path:`domains`,head:()=>({meta:[{title:`Domains — Harper Fabric`}]}),component:$d}),M({getParentRoute:()=>Dd,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:bo,beforeLoad:({context:e,location:t,params:n})=>{let r=c.checkForFabricConnect(n.clusterId);if(e.authentication[n.clusterId]?.user&&!r){let e=t?.search;throw Ve({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),M({getParentRoute:()=>Dd,path:`instance/$instanceId/sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:bo,beforeLoad:({context:e,location:t,params:n})=>{if(!(c.checkForFabricConnect(n.clusterId)||c.checkForFabricConnect(n.instanceId))&&e.authentication[n.instanceId]?.user){let e=t?.search;throw Ve({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),M({getParentRoute:()=>Dd,path:`finish-setup`,head:()=>({meta:[{title:`Create Admin User — Harper Fabric`}]}),component:df});function Cf(e){return M({getParentRoute:()=>e,path:`apis`,head:()=>({meta:[{title:`APIs — Harper Fabric`}]})}).lazy(()=>$r(()=>import(`./index.lazy-CTCt7C_C.js`).then(e=>e.route),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])))}function wf(e,t=!1){let[n,r]=_d(e,t),i=(0,z.useCallback)(e=>{e?.preventDefault?.(),r(e=>!e)},[r]),a=(0,z.useCallback)(e=>{e?.preventDefault?.(),r(!0)},[r]),o=(0,z.useCallback)(e=>{e?.preventDefault?.(),r(!1)},[r]);return(0,z.useMemo)(()=>({toggled:n,setToggled:r,toggle:i,toggleOn:a,toggleOff:o}),[i,r,o,a,n])}var Tf=(0,z.createContext)(null);function Ef(){return(0,z.useContext)(Tf)}async function Df({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 Of(e){let t=(e||``)?.split(`.`);return t.length>1?t.slice(-1)[0]:``}function kf(e){switch(Of(e).toLowerCase()){case`jpg`:case`jpeg`:case`gif`:case`png`:case`pneg`:case`webp`:return!0;default:return!1}}async function Af({instanceClient:e,file:t,project:n,encoding:r}){let{data:i}=await e.post(`/`,{operation:`get_component_file`,project:n,file:t,encoding:r??(kf(t)?`base64`:`utf8`)});return{project:n,file:t,...i}}function jf(e){return I({queryKey:Mf(e),queryFn:()=>Af(e),enabled:!!e.file&&!!e.project,retry:!1})}function Mf(e){return[e.entityId,`get_component_file`,e.project,e.file,e.encoding]}async function Nf({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 Pf(){return P({mutationFn:Nf})}function Ff(){let{reloadRootEntries:e,setFocusedItem:t,setSelectedItems:n}=Ef(),r=V();return(0,z.useCallback)(async i=>{let a=!1,o=i.filter(e=>e.from!==e.to);if(o.length===0)return;let s=`Renaming ${u(o.length,`File`,`Files`)}`,c={duration:6e4,action:{label:`Cancel`,onClick:()=>{a=!0}}};c.id=R.loading(s,{...c,description:(0,B.jsx)(nc,{animated:!0,width:`0%`})});let l=o.length*3,d=0;function f(){d+=1,R.loading(s,{...c,description:(0,B.jsx)(nc,{animated:!0,width:(d===0?0:d/l*100)+`%`})})}for(let e of o){let t=e.from.split(`/`),n=t.shift(),i=t.join(`/`),o=e.to.split(`/`),s=o.shift(),c=o.join(`/`),l=await Af({...r,file:i,project:n,encoding:`base64`});if(a||(f(),await Nf({...r,file:c,project:s,encoding:`base64`,payload:l.message}),a)||(f(),await Df({...r,file:i,project:n}),a))break;f()}d>=l?R.success(`Renamed ${u(o.length,`File`,`Files`)}`,{id:c.id,description:`All done!`,duration:3e3,action:{label:`OK`,onClick:()=>{}}}):R.warning(`Rename Cancelled`,{id:c.id,description:`${d} of ${l} steps completed.`,duration:1e4,action:{label:`OK`,onClick:()=>{}}}),e(),n(e=>{let t=e.slice();for(let e of o){let n=t.indexOf(e.from);n>=0?t.splice(n,1,e.to):t.push(e.to)}return t}),t(e=>{for(let t of o)if(e===t.from)return t.to;return e})},[r,e,t,n])}function If(e,t){return e[t]!==void 0}function Lf(e){return t=>If(t,e)}function Rf(e,t){let[n,r]=(0,z.useState)({value:t});return dd(e,(e,t)=>r({value:e,trigger:t}),[r]),n}function zf(e,t,n){fd(e,t,n)}function Bf(e,t,n){return r=>zf(e,t,n??r)}function Vf(e,t,n){return(0,z.useCallback)(r=>{zf(e,t,n??r)},[e,t,n])}var Hf=[{handleGlobal(e,t){if((t.cmd||t.ctrl)&&e===`Delete`)return zf(`ShowDeleteDirectoryOrFileModal`,!0),!0},addEditorAction(e){return{id:`delete-file`,label:`Delete File`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.Delete],run:Bf(`ShowDeleteDirectoryOrFileModal`,!0)}}},{handleGlobal(e,t){if(t.ctrl&&t.alt&&t.shift&&e===`˜`)return zf(`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:Bf(`ShowAddDirectoryOrFileModalType`,`directory`)}}},{handleGlobal(e,t){if(t.ctrl&&e===`n`)return zf(`ShowAddDirectoryOrFileModalType`,`file`),!0},addEditorAction(e){return{id:`new-file`,label:`New File`,keybindings:[e.KeyMod.WinCtrl|e.KeyCode.KeyN],run:Bf(`ShowAddDirectoryOrFileModalType`,`file`)}}},{handleGlobal(e){if(e===`F2`)return zf(`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:Bf(`ShowRenameFileModal`,!0)}}},{addEditorAction(){return{id:`revert-file`,label:`Revert File`,run:pd(`RevertChanges`,!0)}}},{handleGlobal(e,t){if(t.cmd&&e===`s`)return fd(`SaveFile`,!0),!0},addEditorAction(e){return{id:`save-file`,label:`Save Changes`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.KeyS],run:pd(`SaveFile`,!0)}}}],Uf=Hf.filter(Lf(`addEditorAction`)),Wf=Hf.filter(Lf(`handleGlobal`));function Gf(e){let[t,n]=e,r=Uf.map(e=>t.addAction(e.addEditorAction(n)));return()=>{for(let e of r)e?.dispose()}}function Kf(){(0,z.useEffect)(()=>(document.addEventListener(`keydown`,qf),()=>{document.removeEventListener(`keydown`,qf)}),[])}function qf(e){let t={cmd:e.getModifierState(`Meta`),alt:e.getModifierState(`Alt`),shift:e.getModifierState(`Shift`),ctrl:e.getModifierState(`Control`)};for(let n of Wf)if(n.handleGlobal(e.key,t)){e.preventDefault();return}}function Jf(e){return e.split(`/`).pop()}function Yf(...e){let t=e.flat(1);return t.map((e,n)=>typeof e==`string`?Xf(e,n!==0,n!==t.length-1):e).join(`/`)}function Xf(e,t=!0,n=!0){let r=t&&e[0]===`/`,i=n&&e[e.length-1]===`/`;return r&&i?e.slice(1,-1):r?e.slice(1):i?e.slice(0,-1):e}function Zf(e){return!!e?.entries}var Qf=`__root__`,$f=`importedApplications`,ep=`newApplication`;function tp(e){let t={},n=[],r=[],i=[];for(let a of e)Zf(a)?a.package?r.push(a.path):n.push(a.path):i.push(a.path),np(t,a);return t[Qf]={index:Qf,isFolder:!0,children:[ep,$f,...n,...i].filter(Ri),data:void 0,canMove:!1,canRename:!1},t[$f]={index:$f,isFolder:!0,children:r,data:{name:`Imported Applications`,path:$f,package:$f,project:``,entries:[]},canMove:!1,canRename:!1},t[ep]={index:ep,isFolder:!1,data:{name:`New Application`,path:ep,project:``},canMove:!1,canRename:!1},{items:t,rootId:Qf}}function np(e,t){let n=t.path;if(Zf(t)){let r=t,i=[],a=[];for(let e of r.entries)Zf(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)np(e,t)}else e[n]={index:n,isFolder:!1,data:t,canMove:!t.package,canRename:!t.package}}function rp(){let[e,t]=(0,z.useState)(!1),[n,r]=(0,z.useState)(void 0),i=(0,z.useCallback)(e=>{if(!e.dataTransfer?.types?.includes(`Files`))return;let n=e.target;if(n instanceof Element&&n.classList.contains(`rct-tree-item-button-isFolder`)){let e=n.getAttribute(`data-rct-item-id`);!n.querySelector(`.packageIsLocked`)&&e&&e!==`importedApplications`&&e!==`newApplication`&&r(e=>e===n?e:(e?.classList?.remove?.(`rct-tree-item-title-container-dragging-over`),n.classList.add(`rct-tree-item-title-container-dragging-over`),n))}t(!0)},[]),a=(0,z.useCallback)(()=>{t(!1),r(e=>{e&&e.classList.remove(`rct-tree-item-title-container-dragging-over`)})},[]),o=(0,z.useCallback)(e=>{if(!e.dataTransfer?.types?.includes(`Files`)||e.detail===1337)return;t(!1),n&&(n.classList.remove(`rct-tree-item-title-container-dragging-over`),r(void 0));let i=document.getElementById(`dropTarget`);return i?i.dispatchEvent(new DragEvent(`drop`,{bubbles:!0,detail:1337,cancelable:!0,dataTransfer:e.dataTransfer})):!1},[n]);return(0,z.useEffect)(()=>(document.addEventListener(`dragenter`,i),document.addEventListener(`dragover`,i),document.addEventListener(`dragleave`,a),document.addEventListener(`drop`,o),()=>{document.removeEventListener(`dragenter`,i),document.removeEventListener(`dragover`,i),document.removeEventListener(`dragleave`,a),document.removeEventListener(`drop`,o)}),[i,o,a]),(0,z.useMemo)(()=>({dragging:e,dragTarget:n}),[e,n])}function ip(e){return new Promise((t,n)=>{let r=new FileReader;r.onabort=n,r.onerror=n,r.onload=t,r.readAsDataURL(e)})}function ap(){let[e,t]=(0,z.useState)(``),{clusterId:n}=F({strict:!1}),{openedEntry:r,restrictPackageModification:i,reloadRootEntries:a,entryExists:o}=Ef(),s=!!r&&!r.package&&!i,l=V(),{dragging:d,dragTarget:f}=rp(),p=(f?.getAttribute?.(`data-rct-item-id`))?.split?.(`/`)?.pop?.(),m=r?.project,h=!1,g;if(r?.path){let e=r.path.split(`/`),t=Zf(r);h=s&&(t?e.slice(1):e.slice(1,-1)).join(`/`),g=e[e.length-(t?1:2)]}let _=(0,z.useCallback)(async(e,n)=>{let r=f?.getAttribute?.(`data-rct-item-id`)?.split?.(`/`),i=r?.length?r[0]:s?m:!1,c=r?.length?r.slice(1).join(`/`):s?h:!1;if(i===!1||i===void 0||c===!1||c===void 0)return;let d=[],p=n.slice();for(let t of e){let e=op(c,t);t.name.startsWith(`.`)||t.relativePath?.includes(`/.`)?p.push({file:t,errors:[{message:`Sensitive files and folders starting with . are skipped.`,code:`dot-ignored`}]}):o(`${i}/${e}`)?p.push({file:t,errors:[{message:`${e} already exists`,code:`duplicate`}]}):d.push(t)}let g=!1,_=`uploading-files`,v={label:`Cancel`,onClick:()=>{g=!0}},y={label:`OK`,onClick:()=>void 0};t(`Uploading ${u(d.length,`file`,`files`)}...`);let b=d.reduce((e,t)=>e+t.size,0),x=0,S=0;for(let e of d){S+=1,R.loading(`Upload in progress...`,{id:_,descriptionClassName:`whitespace-pre`,description:`${S} of ${u(d.length,`file`,`files`)}
12
12
  ${e.name}
13
13
  ${ll(x)} of ${ll(b)}`,action:v});let t=op(c,e),n=(await ip(e)).target.result,r=n.indexOf(`base64,`);g?p.push({file:e,errors:[{message:`${t} cancelled`,code:`cancelled`}]}):(await Nf({...l,file:t,project:i,encoding:`base64`,payload:n.slice(r+7)}),x+=e.size)}R.loading(`Reloading sidebar...`,{id:g?void 0:_,action:y,description:``}),await a(),p.length===0?e.length>0&&R.success(`Uploaded ${u(d.length,`file`,`files`)}!`,{id:_,action:y,description:``}):(console.log(p),R.error(g?`Cancelled uploads`:`Rejected uploads`,{id:g?void 0:_,action:y,descriptionClassName:`whitespace-pre overflow-y-auto`,description:p.slice(0,5).map(e=>e.errors.map(e=>e.message).join(`
14
14
  `)).join(`
@@ -48,5 +48,5 @@ Check the console for the full list.`:``)})),t(``)},[f,s,m,h,o,l,a]),{getRootPro
48
48
  focus-visible:ring-1
49
49
  focus-visible:outline-1
50
50
  focus-visible:ring-purple-200
51
- aria-invalid:focus-visible:ring-0`,{variants:{variant:{default:`bg-primary text-primary-foreground shadow-sm hover:bg-primary/90`,outline:`border bg-default border-primary border-2 text-foreground shadow-xs hover:-translate-y-1 transition duration-200 hover:bg-accent/60 dark:text-white dark:hover:bg-grey-700/40`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,sm:`h-8 px-1.5 min-w-8`,lg:`h-10 px-2.5 min-w-10`}},defaultVariants:{variant:`default`,size:`default`}});function U_({className:e,variant:t,size:n,...r}){return(0,B.jsx)(_t,{"data-slot":`toggle`,className:d(H_({variant:t,size:n,className:e})),...r})}function W_(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 G_=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],K_=0,q_=new Map,J_=e=>{if(q_.has(e))return q_.get(e);K_++;let t=G_[K_%G_.length];return q_.set(e,t),t};function Y_(e){switch(e){case`error`:case`stderr`:return`border-l-destructive`;case`warn`:return`border-l-yellow-500`;case`notify`:return`border-l-green-500`;default:return`border-l-transparent`}}function X_({columns:e,data:t,onRowClick:n}){let r=sr({data:t,columns:e,getCoreRowModel:hn()});return(0,B.jsx)(`div`,{className:`rounded-md bg-card dark:bg-black-dark logsTable overflow-hidden`,children:(0,B.jsxs)(Jl,{className:`text-xs`,children:[(0,B.jsx)(Yl,{children:r.getHeaderGroups().map(e=>(0,B.jsx)(Zl,{className:`border-b border-border`,children:e.headers.map(e=>(0,B.jsx)(Ql,{className:`p-4 max-w-96`,children:e.isPlaceholder?null:sn(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,B.jsx)(Xl,{className:`bg-background dark:bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>(0,B.jsx)(Zl,{"data-state":e.getIsSelected()&&`selected`,className:d(`hover:bg-muted/20 data-[state=selected]:bg-muted max-w-full border-l-2`,Y_(e.original.level),n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,B.jsx)(eu,{className:`p-2`,children:sn(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,B.jsx)(Zl,{children:(0,B.jsx)(eu,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function Z_(e){try{JSON.parse(e)}catch{return!1}return!0}function Q_({label:e,children:t}){return(0,B.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-border/50 last:border-0`,children:[(0,B.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground w-20 shrink-0 pt-0.5`,children:e}),(0,B.jsx)(`span`,{className:`text-xs`,children:t})]})}function $_({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?J_(n.node):`default`,i=_u();return(0,B.jsx)(Y,{onOpenChange:e,open:t,children:(0,B.jsxs)(X,{"aria-describedby":void 0,className:`max-w-2xl`,children:[(0,B.jsx)(ms,{children:(0,B.jsx)(Z,{children:`Log Entry`})}),n?(0,B.jsxs)(`div`,{className:`flex flex-col gap-2 text-popover-foreground`,children:[(0,B.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/20 px-3 py-1`,children:[(0,B.jsx)(Q_,{label:`Level`,children:(0,B.jsx)(vs,{variant:W_(n.level),children:Ya(n.level)})}),(0,B.jsx)(Q_,{label:`Timestamp`,children:(0,B.jsx)(`span`,{className:`tabular-nums`,children:new Date(n.timestamp).toLocaleString()})}),(0,B.jsx)(Q_,{label:`Thread`,children:(0,B.jsx)(`span`,{className:`tabular-nums font-mono`,children:n.thread})}),n.node&&(0,B.jsx)(Q_,{label:`Node`,children:(0,B.jsx)(vs,{variant:r,children:n.node})}),n.tags&&n.tags.length>0&&(0,B.jsx)(Q_,{label:`Tags`,children:(0,B.jsx)(`span`,{className:`font-mono`,children:n.tags})})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`Message`}),(0,B.jsx)(`div`,{className:`rounded-md overflow-hidden border border-border/50 h-72`,children:(0,B.jsx)(_r,{className:`w-full h-full`,language:Z_(n.message)?`json`:`text`,theme:i,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,padding:{top:12,bottom:12}}})})]})]}):(0,B.jsx)(Fs,{})]})})}var ev=O({limit:w().or(T()).or(ae()).optional(),level:D([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(T()).or(ae()).optional(),from:w().or(T()).or(ae()).optional(),until:w().or(T()).or(ae()).optional(),log_name:D([`hdb.log`,`system.log`]).or(T()).or(ae()).optional(),filter:w().or(T()).or(ae()).optional()});function tv({form:e,resetFilters:t,submitFilters:n,showLogName:r,showFilter:i}){let[a,o]=(0,z.useState)(!1);return(0,B.jsxs)(Ei,{children:[(0,B.jsx)(Di,{children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-controls":`logs-filters-content`,className:`flex w-full items-center justify-between md:pointer-events-none`,children:[(0,B.jsxs)(Oi,{className:`flex items-center gap-2 text-base`,children:[(0,B.jsx)(we,{className:`size-4 text-muted-foreground`}),`Filters`]}),(0,B.jsx)(Ge,{className:d(`size-4 text-muted-foreground transition-transform md:hidden`,a&&`rotate-180`)})]})}),(0,B.jsx)(Ai,{id:`logs-filters-content`,className:d(!a&&`hidden`,`md:block`),children:(0,B.jsx)(H,{...e,children:(0,B.jsxs)(`form`,{id:`instance-edit-log-filters-form`,name:`instance-edit-log-filters-form`,onSubmit:e.handleSubmit(n),className:`flex-col space-y-4`,children:[i&&(0,B.jsx)(W,{control:e.control,name:`filter`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(U,{children:(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(st,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,B.jsx)(J,{type:`search`,placeholder:`Search logs…`,className:`pl-9`,value:e.value??``,onChange:e.onChange})]})}),(0,B.jsx)(q,{})]})}),r&&(0,B.jsx)(W,{control:e.control,name:`log_name`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Log file`}),(0,B.jsxs)(Bc,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,B.jsx)(Uc,{className:`w-full bg-white dark:bg-grey-700`,children:(0,B.jsx)(Hc,{placeholder:`Select log file`})}),(0,B.jsx)(Wc,{children:(0,B.jsxs)(Vc,{children:[(0,B.jsx)($,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,B.jsx)($,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,B.jsx)(q,{})]})}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsx)(W,{control:e.control,name:`limit`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Limit`}),(0,B.jsxs)(Bc,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,B.jsx)(Uc,{className:`w-full bg-white dark:bg-grey-700`,children:(0,B.jsx)(Hc,{placeholder:`Limit`})}),(0,B.jsx)(Wc,{children:(0,B.jsxs)(Vc,{children:[(0,B.jsx)($,{value:`1000`,children:`1000`}),(0,B.jsx)($,{value:`500`,children:`500`}),(0,B.jsx)($,{value:`250`,children:`250`}),(0,B.jsx)($,{value:`100`,children:`100`}),(0,B.jsx)($,{value:`10`,children:`10`})]})})]}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e.control,name:`level`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Level`}),(0,B.jsxs)(Bc,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,B.jsx)(Uc,{className:`w-full bg-white dark:bg-grey-700`,children:(0,B.jsx)(Hc,{placeholder:`Level`})}),(0,B.jsx)(Wc,{children:(0,B.jsxs)(Vc,{children:[(0,B.jsx)($,{value:`undefined`,children:`All`}),(0,B.jsx)($,{value:`notify`,children:`Notify`}),(0,B.jsx)($,{value:`error`,children:`Error`}),(0,B.jsx)($,{value:`warn`,children:`Warn`}),(0,B.jsx)($,{value:`info`,children:`Info`}),(0,B.jsx)($,{value:`debug`,children:`Debug`}),(0,B.jsx)($,{value:`trace`,children:`Trace`})]})})]}),(0,B.jsx)(q,{})]})})]}),(0,B.jsx)(W,{control:e.control,name:`from`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Start date`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`datetime-local`,value:e.value??void 0,onChange:e.onChange})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e.control,name:`until`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`End date`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`datetime-local`,value:e.value??void 0,onChange:e.onChange})}),(0,B.jsx)(q,{})]})}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,B.jsx)(g,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,B.jsx)(g,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear`})]})]})})})]})}var nv={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``,filter:``},rv={error:(0,B.jsx)(Ye,{className:`size-3`}),stderr:(0,B.jsx)(Ye,{className:`size-3`}),warn:(0,B.jsx)(Wr,{className:`size-3`}),notify:(0,B.jsx)(yr,{className:`size-3`}),info:(0,B.jsx)(Xn,{className:`size-3`}),debug:(0,B.jsx)(xn,{className:`size-3`}),trace:(0,B.jsx)(kn,{className:`size-3`}),stdout:(0,B.jsx)(xe,{className:`size-3`})},iv=[{accessorKey:`level`,header:`Level`,cell:({row:e})=>{let{level:t}=e.original;return(0,B.jsxs)(vs,{variant:W_(t),children:[rv[t],Ya(t)]})}},{accessorKey:`timestamp`,header:`Timestamp`,cell:({row:e})=>{let{timestamp:t}=e.original,n=new Date(t);return(0,B.jsxs)(`span`,{className:`tabular-nums whitespace-nowrap text-muted-foreground`,children:[n.getFullYear()===new Date().getFullYear()?n.toLocaleDateString(void 0,{month:`numeric`,day:`2-digit`}):n.toLocaleDateString(),` `,n.toLocaleTimeString()]})}},{accessorKey:`message`,header:`Message`,cell:({row:e})=>{let{message:t}=e.original;return(0,B.jsx)(`span`,{className:`block max-w-xl truncate font-mono text-xs`,children:t})}},{accessorKey:`thread`,header:`Thread`,cell:({row:e})=>(0,B.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:e.original.thread})},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=J_(t);return(0,B.jsx)(B.Fragment,{children:t?(0,B.jsxs)(Ga,{children:[(0,B.jsx)(Ka,{asChild:!0,children:(0,B.jsxs)(vs,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,B.jsx)(qa,{className:`bg-popover text-popover-foreground border border-border`,arrowClassName:`bg-popover fill-popover`,children:t})]}):null})}},{accessorKey:`tags`,header:`Tags`,cell:({row:e})=>{let{tags:t}=e.original;return t&&t.length>0?(0,B.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null}}],av=(e,t)=>!e&&!t||!e||!t?!0:new Date(e)<=new Date(t);function ov(){return(0,B.jsxs)(`div`,{className:`rounded-md bg-card dark:bg-black-dark overflow-hidden`,children:[(0,B.jsx)(`div`,{className:`flex gap-4 p-4 border-b border-border`,children:[`w-14`,`w-32`,`w-14`,`w-24`,`w-16`,`flex-1`].map((e,t)=>(0,B.jsx)(Uu,{className:`h-4 ${e}`},t))}),Array.from({length:12}).map((e,t)=>(0,B.jsxs)(`div`,{className:`flex gap-4 p-3 border-b border-border/40 border-l-2 border-l-transparent`,children:[(0,B.jsx)(Uu,{className:`h-5 w-14`}),(0,B.jsx)(Uu,{className:`h-5 w-32`}),(0,B.jsx)(Uu,{className:`h-5 w-10`}),(0,B.jsx)(Uu,{className:`h-5 w-20`}),(0,B.jsx)(Uu,{className:`h-5 w-12`}),(0,B.jsx)(Uu,{className:`h-5 flex-1 max-w-xs`})]},t))]})}function sv(){let[e,t]=(0,z.useState)(nv),[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)(),[o,s]=(0,z.useState)(!1),c=V(),{data:l}=A(mh(c)),u=l?.version,d=!!u&&Xs(`4.7.16`,u),{data:f,isLoading:p,refetch:m,isFetching:h}=A(R_({logFilters:e,...c,replicated:c.entityType===`cluster`,isAutoRefreshEnabled:o})),_=L({resolver:N(ev),defaultValues:nv,mode:`onChange`}),v=e=>{a(e.original),r(!0)},y=async e=>{if(!av(e.from,e.until)){_.setError(`from`,{type:`onChange`,message:`Start date must be before end date`}),_.setError(`until`,{type:`onChange`,message:`End date must be after start date`});return}t(e)},b=async()=>{_.reset(),t(nv)},x=ou(m);return(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 pt-2 text-foreground md:grid-cols-12`,children:[(0,B.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pb-4 md:self-start md:sticky md:top-34 md:max-h-[calc(100vh-(--spacing(34)))] md:overflow-y-auto`,children:[(0,B.jsx)(tv,{form:_,resetFilters:b,submitFilters:y,showLogName:!1,showFilter:d}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,B.jsxs)(g,{variant:`defaultOutline`,onClick:x,disabled:h||p||o,className:`grow`,children:[(0,B.jsx)(wt,{}),`Refresh`]}),(0,B.jsxs)(Ga,{children:[(0,B.jsx)(Ka,{asChild:!0,children:(0,B.jsxs)(U_,{variant:`outline`,"aria-label":`Toggle Auto Refresh`,pressed:o,onPressedChange:s,className:`shrink-0`,children:[(0,B.jsx)(wt,{className:o?`animate-spin`:``}),`Auto`]})}),(0,B.jsx)(qa,{children:o?`Auto refresh on — click to disable`:`Enable auto refresh (every 5s)`})]})]})]}),(0,B.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:p?(0,B.jsx)(ov,{}):(0,B.jsx)(X_,{columns:iv,data:f||[],onRowClick:v})}),(0,B.jsx)($_,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function cv(e){return M({getParentRoute:()=>e,path:`logs`,head:()=>({meta:[{title:`Logs — Harper Fabric`}]}),component:sv})}function lv(e){return M({getParentRoute:()=>e,path:`status`,head:()=>({meta:[{title:`Status — Harper Fabric`}]}),component:ve(async()=>$r(()=>import(`./status-ChxVrrli.js`),__vite__mapDeps([14,1,3,2,4,5,6,7,8,9,10,11])),`StatusIndex`)})}function uv(e){let t=B_(e),n=[cv(t),...Vm(t),Cf(t),lv(t),Sg(t),O_(t)];return t.addChildren(n)}M({getParentRoute:()=>Sd,path:`profile`,head:()=>({meta:[{title:`Profile — Harper Fabric`}]}),component:ve(async()=>$r(()=>import(`./profile-D77bwywc.js`),__vite__mapDeps([15,1,4,3,2,5,6,7,8,9,10,11])),`ProfileIndex`)});var dv=Gi.addChildren([...rs,Sd.addChildren([uv(`local`)])]);function fv({routeTree:e=dv,authentication:t}){return Lr({routeTree:e,history:Oe(),defaultNotFoundComponent:Pi,defaultErrorComponent:Ni,defaultPreload:Fi()?!1:`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:Li,authentication:t||{}}})}function pv(){let e=bi(),t=fv({authentication:e});return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ln,{router:t,context:{authentication:e}}),(0,B.jsx)(ct,{router:t,position:`bottom-right`})]})}var mv=({...e})=>(0,B.jsx)(dr,{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}),hv=!1,gv=!1;function _v(){(0,z.useEffect)(()=>{hv||(hv=!0,gv&&(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 vv(){return za(),Hi(),_v(),(0,B.jsxs)(ta,{children:[(0,B.jsxs)(Rt,{client:Li,children:[(0,B.jsx)(pv,{}),(0,B.jsx)(rt,{buttonPosition:`bottom-right`})]}),(0,B.jsx)(mv,{richColors:!0})]})}(0,Wn().createRoot)(document.getElementById(`root`),{onUncaughtError:(e,t)=>{bn(e,t),console.error(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{bn(e,t),console.error(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{bn(e,t),console.warn(`Recoverable error:`,e,t)}}).render((0,B.jsx)(z.StrictMode,{children:(0,B.jsx)(vv,{})}));export{W as A,Ni as B,gs as C,q as D,J as E,Ka as F,Oi as G,Ai as H,_a as I,Si as K,V as L,H as M,Ga as N,K as O,qa as P,Qi as R,X as S,Z as T,ki as U,Ei as V,Di as W,Uc as _,fh as a,Fs as b,Op as c,hf as d,iu as f,$ as g,Wc as h,ph as i,U as j,G as k,Ep as l,Bc as m,F_ as n,dm as o,ll as p,mh as r,Tp as s,P_ as t,Dp as u,Hc as v,ms as w,Y as x,Xs as y,Ri as z};
52
- //# sourceMappingURL=index-BJjklK4V.js.map
51
+ aria-invalid:focus-visible:ring-0`,{variants:{variant:{default:`bg-primary text-primary-foreground shadow-sm hover:bg-primary/90`,outline:`border bg-default border-primary border-2 text-foreground shadow-xs hover:-translate-y-1 transition duration-200 hover:bg-accent/60 dark:text-white dark:hover:bg-grey-700/40`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,sm:`h-8 px-1.5 min-w-8`,lg:`h-10 px-2.5 min-w-10`}},defaultVariants:{variant:`default`,size:`default`}});function U_({className:e,variant:t,size:n,...r}){return(0,B.jsx)(_t,{"data-slot":`toggle`,className:d(H_({variant:t,size:n,className:e})),...r})}function W_(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 G_=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],K_=0,q_=new Map,J_=e=>{if(q_.has(e))return q_.get(e);K_++;let t=G_[K_%G_.length];return q_.set(e,t),t};function Y_(e){switch(e){case`error`:case`stderr`:return`border-l-destructive`;case`warn`:return`border-l-yellow-500`;case`notify`:return`border-l-green-500`;default:return`border-l-transparent`}}function X_({columns:e,data:t,onRowClick:n}){let r=sr({data:t,columns:e,getCoreRowModel:hn()});return(0,B.jsx)(`div`,{className:`rounded-md bg-card dark:bg-black-dark logsTable overflow-hidden`,children:(0,B.jsxs)(Jl,{className:`text-xs`,children:[(0,B.jsx)(Yl,{children:r.getHeaderGroups().map(e=>(0,B.jsx)(Zl,{className:`border-b border-border`,children:e.headers.map(e=>(0,B.jsx)(Ql,{className:`p-4 max-w-96`,children:e.isPlaceholder?null:sn(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,B.jsx)(Xl,{className:`bg-background dark:bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>(0,B.jsx)(Zl,{"data-state":e.getIsSelected()&&`selected`,className:d(`hover:bg-muted/20 data-[state=selected]:bg-muted max-w-full border-l-2`,Y_(e.original.level),n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,B.jsx)(eu,{className:`p-2`,children:sn(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,B.jsx)(Zl,{children:(0,B.jsx)(eu,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function Z_(e){try{JSON.parse(e)}catch{return!1}return!0}function Q_({label:e,children:t}){return(0,B.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-border/50 last:border-0`,children:[(0,B.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground w-20 shrink-0 pt-0.5`,children:e}),(0,B.jsx)(`span`,{className:`text-xs`,children:t})]})}function $_({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?J_(n.node):`default`,i=_u();return(0,B.jsx)(Y,{onOpenChange:e,open:t,children:(0,B.jsxs)(X,{"aria-describedby":void 0,className:`max-w-2xl`,children:[(0,B.jsx)(ms,{children:(0,B.jsx)(Z,{children:`Log Entry`})}),n?(0,B.jsxs)(`div`,{className:`flex flex-col gap-2 text-popover-foreground`,children:[(0,B.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/20 px-3 py-1`,children:[(0,B.jsx)(Q_,{label:`Level`,children:(0,B.jsx)(vs,{variant:W_(n.level),children:Ya(n.level)})}),(0,B.jsx)(Q_,{label:`Timestamp`,children:(0,B.jsx)(`span`,{className:`tabular-nums`,children:new Date(n.timestamp).toLocaleString()})}),(0,B.jsx)(Q_,{label:`Thread`,children:(0,B.jsx)(`span`,{className:`tabular-nums font-mono`,children:n.thread})}),n.node&&(0,B.jsx)(Q_,{label:`Node`,children:(0,B.jsx)(vs,{variant:r,children:n.node})}),n.tags&&n.tags.length>0&&(0,B.jsx)(Q_,{label:`Tags`,children:(0,B.jsx)(`span`,{className:`font-mono`,children:n.tags})})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`Message`}),(0,B.jsx)(`div`,{className:`rounded-md overflow-hidden border border-border/50 h-72`,children:(0,B.jsx)(_r,{className:`w-full h-full`,language:Z_(n.message)?`json`:`text`,theme:i,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,padding:{top:12,bottom:12}}})})]})]}):(0,B.jsx)(Fs,{})]})})}var ev=O({limit:w().or(T()).or(ae()).optional(),level:D([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(T()).or(ae()).optional(),from:w().or(T()).or(ae()).optional(),until:w().or(T()).or(ae()).optional(),log_name:D([`hdb.log`,`system.log`]).or(T()).or(ae()).optional(),filter:w().or(T()).or(ae()).optional()});function tv({form:e,resetFilters:t,submitFilters:n,showLogName:r,showFilter:i}){let[a,o]=(0,z.useState)(!1);return(0,B.jsxs)(Ei,{children:[(0,B.jsx)(Di,{children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-controls":`logs-filters-content`,className:`flex w-full items-center justify-between md:pointer-events-none`,children:[(0,B.jsxs)(Oi,{className:`flex items-center gap-2 text-base`,children:[(0,B.jsx)(we,{className:`size-4 text-muted-foreground`}),`Filters`]}),(0,B.jsx)(Ge,{className:d(`size-4 text-muted-foreground transition-transform md:hidden`,a&&`rotate-180`)})]})}),(0,B.jsx)(Ai,{id:`logs-filters-content`,className:d(!a&&`hidden`,`md:block`),children:(0,B.jsx)(H,{...e,children:(0,B.jsxs)(`form`,{id:`instance-edit-log-filters-form`,name:`instance-edit-log-filters-form`,onSubmit:e.handleSubmit(n),className:`flex-col space-y-4`,children:[i&&(0,B.jsx)(W,{control:e.control,name:`filter`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(U,{children:(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(st,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,B.jsx)(J,{type:`search`,placeholder:`Search logs…`,className:`pl-9`,value:e.value??``,onChange:e.onChange})]})}),(0,B.jsx)(q,{})]})}),r&&(0,B.jsx)(W,{control:e.control,name:`log_name`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Log file`}),(0,B.jsxs)(Bc,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,B.jsx)(Uc,{className:`w-full bg-white dark:bg-grey-700`,children:(0,B.jsx)(Hc,{placeholder:`Select log file`})}),(0,B.jsx)(Wc,{children:(0,B.jsxs)(Vc,{children:[(0,B.jsx)($,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,B.jsx)($,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,B.jsx)(q,{})]})}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsx)(W,{control:e.control,name:`limit`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Limit`}),(0,B.jsxs)(Bc,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,B.jsx)(Uc,{className:`w-full bg-white dark:bg-grey-700`,children:(0,B.jsx)(Hc,{placeholder:`Limit`})}),(0,B.jsx)(Wc,{children:(0,B.jsxs)(Vc,{children:[(0,B.jsx)($,{value:`1000`,children:`1000`}),(0,B.jsx)($,{value:`500`,children:`500`}),(0,B.jsx)($,{value:`250`,children:`250`}),(0,B.jsx)($,{value:`100`,children:`100`}),(0,B.jsx)($,{value:`10`,children:`10`})]})})]}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e.control,name:`level`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Level`}),(0,B.jsxs)(Bc,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,B.jsx)(Uc,{className:`w-full bg-white dark:bg-grey-700`,children:(0,B.jsx)(Hc,{placeholder:`Level`})}),(0,B.jsx)(Wc,{children:(0,B.jsxs)(Vc,{children:[(0,B.jsx)($,{value:`undefined`,children:`All`}),(0,B.jsx)($,{value:`notify`,children:`Notify`}),(0,B.jsx)($,{value:`error`,children:`Error`}),(0,B.jsx)($,{value:`warn`,children:`Warn`}),(0,B.jsx)($,{value:`info`,children:`Info`}),(0,B.jsx)($,{value:`debug`,children:`Debug`}),(0,B.jsx)($,{value:`trace`,children:`Trace`})]})})]}),(0,B.jsx)(q,{})]})})]}),(0,B.jsx)(W,{control:e.control,name:`from`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`Start date`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`datetime-local`,value:e.value??void 0,onChange:e.onChange})}),(0,B.jsx)(q,{})]})}),(0,B.jsx)(W,{control:e.control,name:`until`,render:({field:e})=>(0,B.jsxs)(G,{children:[(0,B.jsx)(K,{children:`End date`}),(0,B.jsx)(U,{children:(0,B.jsx)(J,{type:`datetime-local`,value:e.value??void 0,onChange:e.onChange})}),(0,B.jsx)(q,{})]})}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,B.jsx)(g,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,B.jsx)(g,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear`})]})]})})})]})}var nv={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``,filter:``},rv={error:(0,B.jsx)(Ye,{className:`size-3`}),stderr:(0,B.jsx)(Ye,{className:`size-3`}),warn:(0,B.jsx)(Wr,{className:`size-3`}),notify:(0,B.jsx)(yr,{className:`size-3`}),info:(0,B.jsx)(Xn,{className:`size-3`}),debug:(0,B.jsx)(xn,{className:`size-3`}),trace:(0,B.jsx)(kn,{className:`size-3`}),stdout:(0,B.jsx)(xe,{className:`size-3`})},iv=[{accessorKey:`level`,header:`Level`,cell:({row:e})=>{let{level:t}=e.original;return(0,B.jsxs)(vs,{variant:W_(t),children:[rv[t],Ya(t)]})}},{accessorKey:`timestamp`,header:`Timestamp`,cell:({row:e})=>{let{timestamp:t}=e.original,n=new Date(t);return(0,B.jsxs)(`span`,{className:`tabular-nums whitespace-nowrap text-muted-foreground`,children:[n.getFullYear()===new Date().getFullYear()?n.toLocaleDateString(void 0,{month:`numeric`,day:`2-digit`}):n.toLocaleDateString(),` `,n.toLocaleTimeString()]})}},{accessorKey:`message`,header:`Message`,cell:({row:e})=>{let{message:t}=e.original;return(0,B.jsx)(`span`,{className:`block max-w-xl truncate font-mono text-xs`,children:t})}},{accessorKey:`thread`,header:`Thread`,cell:({row:e})=>(0,B.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:e.original.thread})},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=J_(t);return(0,B.jsx)(B.Fragment,{children:t?(0,B.jsxs)(Ga,{children:[(0,B.jsx)(Ka,{asChild:!0,children:(0,B.jsxs)(vs,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,B.jsx)(qa,{className:`bg-popover text-popover-foreground border border-border`,arrowClassName:`bg-popover fill-popover`,children:t})]}):null})}},{accessorKey:`tags`,header:`Tags`,cell:({row:e})=>{let{tags:t}=e.original;return t&&t.length>0?(0,B.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null}}],av=(e,t)=>!e&&!t||!e||!t?!0:new Date(e)<=new Date(t);function ov(){return(0,B.jsxs)(`div`,{className:`rounded-md bg-card dark:bg-black-dark overflow-hidden`,children:[(0,B.jsx)(`div`,{className:`flex gap-4 p-4 border-b border-border`,children:[`w-14`,`w-32`,`w-14`,`w-24`,`w-16`,`flex-1`].map((e,t)=>(0,B.jsx)(Uu,{className:`h-4 ${e}`},t))}),Array.from({length:12}).map((e,t)=>(0,B.jsxs)(`div`,{className:`flex gap-4 p-3 border-b border-border/40 border-l-2 border-l-transparent`,children:[(0,B.jsx)(Uu,{className:`h-5 w-14`}),(0,B.jsx)(Uu,{className:`h-5 w-32`}),(0,B.jsx)(Uu,{className:`h-5 w-10`}),(0,B.jsx)(Uu,{className:`h-5 w-20`}),(0,B.jsx)(Uu,{className:`h-5 w-12`}),(0,B.jsx)(Uu,{className:`h-5 flex-1 max-w-xs`})]},t))]})}function sv(){let[e,t]=(0,z.useState)(nv),[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)(),[o,s]=(0,z.useState)(!1),c=V(),{data:l}=A(mh(c)),u=l?.version,d=!!u&&Xs(`4.7.16`,u),{data:f,isLoading:p,refetch:m,isFetching:h}=A(R_({logFilters:e,...c,replicated:c.entityType===`cluster`,isAutoRefreshEnabled:o})),_=L({resolver:N(ev),defaultValues:nv,mode:`onChange`}),v=e=>{a(e.original),r(!0)},y=async e=>{if(!av(e.from,e.until)){_.setError(`from`,{type:`onChange`,message:`Start date must be before end date`}),_.setError(`until`,{type:`onChange`,message:`End date must be after start date`});return}t(e)},b=async()=>{_.reset(),t(nv)},x=ou(m);return(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 pt-2 text-foreground md:grid-cols-12`,children:[(0,B.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pb-4 md:self-start md:sticky md:top-34 md:max-h-[calc(100vh-(--spacing(34)))] md:overflow-y-auto`,children:[(0,B.jsx)(tv,{form:_,resetFilters:b,submitFilters:y,showLogName:!1,showFilter:d}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,B.jsxs)(g,{variant:`defaultOutline`,onClick:x,disabled:h||p||o,className:`grow`,children:[(0,B.jsx)(wt,{}),`Refresh`]}),(0,B.jsxs)(Ga,{children:[(0,B.jsx)(Ka,{asChild:!0,children:(0,B.jsxs)(U_,{variant:`outline`,"aria-label":`Toggle Auto Refresh`,pressed:o,onPressedChange:s,className:`shrink-0`,children:[(0,B.jsx)(wt,{className:o?`animate-spin`:``}),`Auto`]})}),(0,B.jsx)(qa,{children:o?`Auto refresh on — click to disable`:`Enable auto refresh (every 5s)`})]})]})]}),(0,B.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:p?(0,B.jsx)(ov,{}):(0,B.jsx)(X_,{columns:iv,data:f||[],onRowClick:v})}),(0,B.jsx)($_,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function cv(e){return M({getParentRoute:()=>e,path:`logs`,head:()=>({meta:[{title:`Logs — Harper Fabric`}]}),component:sv})}function lv(e){return M({getParentRoute:()=>e,path:`status`,head:()=>({meta:[{title:`Status — Harper Fabric`}]}),component:ve(async()=>$r(()=>import(`./status-DQBR5qBd.js`),__vite__mapDeps([14,1,3,2,4,5,6,7,8,9,10,11])),`StatusIndex`)})}function uv(e){let t=B_(e),n=[cv(t),...Vm(t),Cf(t),lv(t),Sg(t),O_(t)];return t.addChildren(n)}M({getParentRoute:()=>Sd,path:`profile`,head:()=>({meta:[{title:`Profile — Harper Fabric`}]}),component:ve(async()=>$r(()=>import(`./profile-Dy4qT0vm.js`),__vite__mapDeps([15,1,4,3,2,5,6,7,8,9,10,11])),`ProfileIndex`)});var dv=Gi.addChildren([...rs,Sd.addChildren([uv(`local`)])]);function fv({routeTree:e=dv,authentication:t}){return Lr({routeTree:e,history:Oe(),defaultNotFoundComponent:Pi,defaultErrorComponent:Ni,defaultPreload:Fi()?!1:`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:Li,authentication:t||{}}})}function pv(){let e=bi(),t=fv({authentication:e});return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ln,{router:t,context:{authentication:e}}),(0,B.jsx)(ct,{router:t,position:`bottom-right`})]})}var mv=({...e})=>(0,B.jsx)(dr,{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}),hv=!1,gv=!1;function _v(){(0,z.useEffect)(()=>{hv||(hv=!0,gv&&(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 vv(){return za(),Hi(),_v(),(0,B.jsxs)(ta,{children:[(0,B.jsxs)(Rt,{client:Li,children:[(0,B.jsx)(pv,{}),(0,B.jsx)(rt,{buttonPosition:`bottom-right`})]}),(0,B.jsx)(mv,{richColors:!0})]})}(0,Wn().createRoot)(document.getElementById(`root`),{onUncaughtError:(e,t)=>{bn(e,t),console.error(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{bn(e,t),console.error(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{bn(e,t),console.warn(`Recoverable error:`,e,t)}}).render((0,B.jsx)(z.StrictMode,{children:(0,B.jsx)(vv,{})}));export{W as A,Ni as B,gs as C,q as D,J as E,Ka as F,Oi as G,Ai as H,_a as I,Si as K,V as L,H as M,Ga as N,K as O,qa as P,Qi as R,X as S,Z as T,ki as U,Ei as V,Di as W,Uc as _,fh as a,Fs as b,Op as c,hf as d,iu as f,$ as g,Wc as h,ph as i,U as j,G as k,Ep as l,Bc as m,F_ as n,dm as o,ll as p,mh as r,Tp as s,P_ as t,Dp as u,Hc as v,ms as w,Y as x,Xs as y,Ri as z};
52
+ //# sourceMappingURL=index-BFZovM68.js.map