@langwatch/server 3.1.0-beta.21 → 3.1.0-beta.23

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 (179) hide show
  1. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/__init__.py +36 -0
  2. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/_logger.py +165 -0
  3. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/batch_clustering.py +153 -0
  4. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/build_response.py +77 -0
  5. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/constants.py +7 -0
  6. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/incremental_clustering.py +325 -0
  7. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/topic_naming.py +432 -0
  8. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/types.py +42 -0
  9. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/utils.py +191 -0
  10. package/langevals/evaluators/topic_clustering/pyproject.toml +52 -0
  11. package/langevals/evaluators/topic_clustering/tests/test_topic_clustering.py +239 -0
  12. package/langevals/evaluators/topic_clustering/tests/test_topic_clustering_integration.py +97 -0
  13. package/langevals/evaluators/topic_clustering/tests/test_topic_naming.py +72 -0
  14. package/langevals/langevals/pytest_plugins/pass_rate_plugin.py +7 -1
  15. package/langevals/langevals/server.py +28 -0
  16. package/langevals/pyproject.toml +3 -0
  17. package/langevals/uv.lock +119 -20
  18. package/langwatch/dist/client/assets/{AnnotationsTable-BDAkYaz6.js → AnnotationsTable-uS_9SQ-g.js} +2 -2
  19. package/langwatch/dist/client/assets/{BatchEvaluationSummary-DMaQM_VB.js → BatchEvaluationSummary-DtFd8yKJ.js} +2 -2
  20. package/langwatch/dist/client/assets/{BudgetEditDrawer-CHaqmdIl.js → BudgetEditDrawer-CHEPz0hH.js} +2 -2
  21. package/langwatch/dist/client/assets/{ChartCard-D14PUg_d.js → ChartCard-s5fMPo7b.js} +2 -2
  22. package/langwatch/dist/client/assets/{ChatWindow-CRDnlP-Q.js → ChatWindow-C0XSteVJ.js} +2 -2
  23. package/langwatch/dist/client/assets/ChatWindow-DFEmNXQL.js +1 -0
  24. package/langwatch/dist/client/assets/{ConfirmDialog-CXIhncvW.js → ConfirmDialog-M94yLNvP.js} +2 -2
  25. package/langwatch/dist/client/assets/{ContactSalesBlock-CijLBwRC.js → ContactSalesBlock-CnnuZ8iI.js} +2 -2
  26. package/langwatch/dist/client/assets/{DSPyExperiment-B1YOL2m8.js → DSPyExperiment-CMA6lrlx.js} +2 -2
  27. package/langwatch/dist/client/assets/{FilterDisplay-BB0xWrLn.js → FilterDisplay-0S3NqCkq.js} +2 -2
  28. package/langwatch/dist/client/assets/{FormatMoney-w9vr_h0X.js → FormatMoney-CCygtAHg.js} +2 -2
  29. package/langwatch/dist/client/assets/{FoundryDrawer-CdJDXtpz.js → FoundryDrawer-B35xZ26C.js} +2 -2
  30. package/langwatch/dist/client/assets/{GatewayErrorPanel-DvE9U2dS.js → GatewayErrorPanel-BsaYQEie.js} +2 -2
  31. package/langwatch/dist/client/assets/{GatewayLayout-lv1p_6B5.js → GatewayLayout-LvwwrwMf.js} +2 -2
  32. package/langwatch/dist/client/assets/{GraphsLayout-BJ68J9e-.js → GraphsLayout-DJ-HI9N1.js} +2 -2
  33. package/langwatch/dist/client/assets/{GroupBindingInputRow-DebZBCnD.js → GroupBindingInputRow-CV-fBkX9.js} +2 -2
  34. package/langwatch/dist/client/assets/{MessagesTable-B6lYde-x.js → MessagesTable-9taaKCOZ.js} +2 -2
  35. package/langwatch/dist/client/assets/{NavigationFooter-CiOVzDUh.js → NavigationFooter-Dzvauw3l.js} +2 -2
  36. package/langwatch/dist/client/assets/{NoDataInfoBlock-quSW_MRm.js → NoDataInfoBlock-CLKl_wlX.js} +2 -2
  37. package/langwatch/dist/client/assets/{OpsPageShell-DJ1WlI6-.js → OpsPageShell-C_mTziRS.js} +2 -2
  38. package/langwatch/dist/client/assets/{OptimizationStudio-BlozXjcN.js → OptimizationStudio-D2zpsmJj.js} +8 -12
  39. package/langwatch/dist/client/assets/{PreconditionsField-BOfcWvmZ.js → PreconditionsField-WXB8kcTK.js} +2 -2
  40. package/langwatch/dist/client/assets/{SettingsLayout-CLCGxMAe.js → SettingsLayout--1gdEuhv.js} +2 -2
  41. package/langwatch/dist/client/assets/{SubscriptionPage-J8b2Zaj6.js → SubscriptionPage-B0ox_4kM.js} +2 -2
  42. package/langwatch/dist/client/assets/{VirtualKeySecretReveal-DR1VDLy7.js → VirtualKeySecretReveal-CRbI1dKQ.js} +2 -2
  43. package/langwatch/dist/client/assets/{WithPermissionGuard-DD8uo3UK.js → WithPermissionGuard-B4Jo8E5-.js} +2 -2
  44. package/langwatch/dist/client/assets/{__...path__-BZVaIayJ.js → __...path__-BF2zkD84.js} +2 -2
  45. package/langwatch/dist/client/assets/{_experiment_-B1aT-wS3.js → _experiment_-D02aoVQk.js} +2 -2
  46. package/langwatch/dist/client/assets/{_id_-oI_eq-I_.js → _id_-Ch8YmTiM.js} +2 -2
  47. package/langwatch/dist/client/assets/{_id_-DAqPuO73.js → _id_-D6ZvwHpH.js} +2 -2
  48. package/langwatch/dist/client/assets/{_id_-DUngklVb.js → _id_-DOC1ZkBm.js} +2 -2
  49. package/langwatch/dist/client/assets/{_id_-jFDAfbob.js → _id_-DfWwW6_N.js} +2 -2
  50. package/langwatch/dist/client/assets/{_id_-BKBrWGG0.js → _id_-DxUo4W7J.js} +2 -2
  51. package/langwatch/dist/client/assets/_not-found-COI3ShsR.js +1 -0
  52. package/langwatch/dist/client/assets/{_project_-Bt1tayHB.js → _project_-_UUt5Ar9.js} +2 -2
  53. package/langwatch/dist/client/assets/{_runId_-CfvnDt5H.js → _runId_-Dimwzp48.js} +2 -2
  54. package/langwatch/dist/client/assets/_slug_-BMvKBwS_.js +2 -0
  55. package/langwatch/dist/client/assets/{_slug_-DZAdl0QS.js → _slug_-CE6VoDSC.js} +2 -2
  56. package/langwatch/dist/client/assets/{_slug_-DmoWXjKT.js → _slug_-OiOLG1Mv.js} +2 -2
  57. package/langwatch/dist/client/assets/{_team_-DL_wKSWK.js → _team_-DKvmwO_5.js} +2 -2
  58. package/langwatch/dist/client/assets/{_workflow_-DcMXLPUe.js → _workflow_-FkilKiB-.js} +3 -3
  59. package/langwatch/dist/client/assets/{_workflow_-NI9bac7d.js → _workflow_-gJZppg3h.js} +2 -2
  60. package/langwatch/dist/client/assets/{access-audit-CFwNwusI.js → access-audit-xcUVYMMT.js} +2 -2
  61. package/langwatch/dist/client/assets/{agents-Di4XRwcn.js → agents-D32g91cu.js} +2 -2
  62. package/langwatch/dist/client/assets/{all-C273mlDB.js → all-vnREzDZj.js} +2 -2
  63. package/langwatch/dist/client/assets/{analytics-CEAcSf6B.js → analytics-DP6Y4Feh.js} +2 -2
  64. package/langwatch/dist/client/assets/{annotation-scores-CHfn4LQp.js → annotation-scores-CjD4CEB6.js} +2 -2
  65. package/langwatch/dist/client/assets/{annotations-CHZQrha6.js → annotations-1rVXiDRQ.js} +2 -2
  66. package/langwatch/dist/client/assets/{api-keys-BT7HExHM.js → api-keys-BJpKyuaz.js} +2 -2
  67. package/langwatch/dist/client/assets/{audit-log-BGk-51Dt.js → audit-log-BdUdZjxp.js} +2 -2
  68. package/langwatch/dist/client/assets/{authentication-DvwXfkp-.js → authentication-8mQB00CC.js} +2 -2
  69. package/langwatch/dist/client/assets/{authorize-tXpHrWyw.js → authorize-BpUueMNW.js} +2 -2
  70. package/langwatch/dist/client/assets/{authorize-CRu9xlpU.js → authorize-CbNBtmxW.js} +2 -2
  71. package/langwatch/dist/client/assets/{automations-CjDvz9Ak.js → automations-34KMkRxd.js} +2 -2
  72. package/langwatch/dist/client/assets/{billing-plans-FUqEPN62.js → billing-plans-BUQp08MI.js} +2 -2
  73. package/langwatch/dist/client/assets/{budgets-BV6_RHrs.js → budgets-CdelE8Hv.js} +2 -2
  74. package/langwatch/dist/client/assets/{cache-rules-CtYA79E_.js → cache-rules-D2m1QlNJ.js} +2 -2
  75. package/langwatch/dist/client/assets/choose-C0LdeUiH.js +2 -0
  76. package/langwatch/dist/client/assets/{command-bar-CaJygoez.js → command-bar-DUK45yin.js} +7 -9
  77. package/langwatch/dist/client/assets/custom-hBq2K4FJ.js +1 -0
  78. package/langwatch/dist/client/assets/{datasets-vLWpH84_.js → datasets-ErNNhmjg.js} +2 -2
  79. package/langwatch/dist/client/assets/{dejaview-DwVR3RGg.js → dejaview-BaD4_v90.js} +2 -2
  80. package/langwatch/dist/client/assets/{dist-SwV3YZv3.js → dist-Cds4Mqhj.js} +4 -6
  81. package/langwatch/dist/client/assets/{edit-CyxsmQmW.js → edit-DpT8ejBV.js} +2 -2
  82. package/langwatch/dist/client/assets/{evaluations-BfgeZMph.js → evaluations-BdQ2Dm2r.js} +2 -2
  83. package/langwatch/dist/client/assets/{evaluations-HSQIMvbX.js → evaluations-C90I4VAr.js} +2 -2
  84. package/langwatch/dist/client/assets/{evaluators-DLHVvnrh.js → evaluators-ig_ugRLt.js} +2 -2
  85. package/langwatch/dist/client/assets/{foundry-Ckq0WjPU.js → foundry-B-X_80pD.js} +2 -2
  86. package/langwatch/dist/client/assets/{gateway-CDSYPZ6w.js → gateway-CS_mtJx-.js} +2 -2
  87. package/langwatch/dist/client/assets/{groups-CCCRUqPj.js → groups-Bp90ChP3.js} +2 -2
  88. package/langwatch/dist/client/assets/{index-Bm6z2fM9.js → index-BEjGS0kI.js} +5 -5
  89. package/langwatch/dist/client/assets/{license-CHOarGWr.js → license-CgnlvyuI.js} +2 -2
  90. package/langwatch/dist/client/assets/{me-CBya_vXs.js → me-DEqhm_KC.js} +2 -2
  91. package/langwatch/dist/client/assets/{members-lIFLh-rh.js → members-CUJANDtH.js} +2 -2
  92. package/langwatch/dist/client/assets/{messages-CG9j8Dz8.js → messages-fQBfCjvp.js} +2 -2
  93. package/langwatch/dist/client/assets/{metrics-C9pzeaI6.js → metrics-DeIxebpD.js} +2 -2
  94. package/langwatch/dist/client/assets/{model-costs-Bc5uqjkl.js → model-costs-C1RbgK--.js} +2 -2
  95. package/langwatch/dist/client/assets/{model-providers-B5UjRgS_.js → model-providers-Pv3ML_-t.js} +2 -2
  96. package/langwatch/dist/client/assets/{my-queue-BkEfiWyR.js → my-queue-BLre2NMr.js} +2 -2
  97. package/langwatch/dist/client/assets/{ops-Cc-g-CMn.js → ops-CCw-FJaT.js} +2 -2
  98. package/langwatch/dist/client/assets/{organization-features-CoIKKHkQ.js → organization-features-rqg-75mI.js} +2 -2
  99. package/langwatch/dist/client/assets/{organizations-DWcQUTzi.js → organizations-DjCzIHVx.js} +2 -2
  100. package/langwatch/dist/client/assets/{persistence-CTQ44vGL.js → persistence-BPvHS0F6.js} +2 -2
  101. package/langwatch/dist/client/assets/{plans-Dq3eFg5K.js → plans-Ch2Ol-Fd.js} +2 -2
  102. package/langwatch/dist/client/assets/{projections-CTNj1QBM.js → projections-it4FOVjm.js} +2 -2
  103. package/langwatch/dist/client/assets/{projects-BxM7C87h.js → projects-CjWZFLfn.js} +2 -2
  104. package/langwatch/dist/client/assets/{prompts-DhXnJT6e.js → prompts-DilmFH_s.js} +2 -2
  105. package/langwatch/dist/client/assets/{providers-DW7VWdqq.js → providers-tlLT_lTF.js} +2 -2
  106. package/langwatch/dist/client/assets/{reports-D3QFKhNP.js → reports-vlrcTrLs.js} +2 -2
  107. package/langwatch/dist/client/assets/{roles-B_0t5DWA.js → roles-DNgi-NQ9.js} +2 -2
  108. package/langwatch/dist/client/assets/{scenarios-BX3XslU0.js → scenarios-BmG_wDkR.js} +2 -2
  109. package/langwatch/dist/client/assets/{scim-DDsLO39r.js → scim-BKr1_FHt.js} +2 -2
  110. package/langwatch/dist/client/assets/{secrets-BvEGwDCy.js → secrets-CU8ocTGv.js} +2 -2
  111. package/langwatch/dist/client/assets/{settings-9giNiAQQ.js → settings-CDzdoYVK.js} +2 -2
  112. package/langwatch/dist/client/assets/{setup-HxXKoVKG.js → setup-nEvn2rjN.js} +2 -2
  113. package/langwatch/dist/client/assets/{subscription-DhyswDze.js → subscription-BPNl_6jF.js} +3 -3
  114. package/langwatch/dist/client/assets/{subscriptions-Dyyau22a.js → subscriptions-D0G-OE5C.js} +2 -2
  115. package/langwatch/dist/client/assets/{teams-DRmeAxzf.js → teams-DThgDQvB.js} +2 -2
  116. package/langwatch/dist/client/assets/{textOverflowHeuristic-JibhpzDV.js → textOverflowHeuristic-DTC8-Ffx.js} +2 -2
  117. package/langwatch/dist/client/assets/{topic-clustering-Bllfw5rZ.js → topic-clustering-BR2Mbpao.js} +2 -2
  118. package/langwatch/dist/client/assets/{topics-CpiGYxqb.js → topics-CI8GoNqp.js} +2 -2
  119. package/langwatch/dist/client/assets/{traceExecutor-CiHXJB0V.js → traceExecutor-CDUGyUaw.js} +2 -2
  120. package/langwatch/dist/client/assets/{usage-BnsstwBY.js → usage-B4mR7ut_.js} +2 -2
  121. package/langwatch/dist/client/assets/{usage-CoyGtJoI.js → usage-C8fbffYi.js} +2 -2
  122. package/langwatch/dist/client/assets/{useAdminResource-SPC5iBHM.js → useAdminResource-SmnnHro6.js} +2 -2
  123. package/langwatch/dist/client/assets/{useAnnotationQueues-2DKZTC7r.js → useAnnotationQueues-CA6Vk--V.js} +2 -2
  124. package/langwatch/dist/client/assets/{useAvailableEvaluators-HndTl2LV.js → useAvailableEvaluators-hmbmcRQr.js} +2 -2
  125. package/langwatch/dist/client/assets/{useDeleteDatasetConfirmation-BgWN6Qqb.js → useDeleteDatasetConfirmation-BCK_zUUe.js} +2 -2
  126. package/langwatch/dist/client/assets/{useWorkflowStore-e1wFCvo2.js → useWorkflowStore-QUJ3J8X9.js} +2 -2
  127. package/langwatch/dist/client/assets/{users-C6wjliCC.js → users-CfhanCfR.js} +2 -2
  128. package/langwatch/dist/client/assets/{users-tF6ZKeV1.js → users-HjuN3o6k.js} +2 -2
  129. package/langwatch/dist/client/assets/{virtual-keys-BL-65S0B.js → virtual-keys-Bj-MhW66.js} +2 -2
  130. package/langwatch/dist/client/assets/{wizard-faGkpZDT.js → wizard-dRWCVVx6.js} +2 -2
  131. package/langwatch/dist/client/assets/{workbench-Oj0s_YR-.js → workbench-CuixH3G1.js} +2 -2
  132. package/langwatch/dist/client/assets/{workflows-Cu9k-Twu.js → workflows-BT6m4Yu9.js} +2 -2
  133. package/langwatch/dist/client/index.html +3 -3
  134. package/langwatch/dist/scenario-child-process.js +20 -10
  135. package/langwatch/package.json +2 -2
  136. package/langwatch/pnpm-lock.yaml +329 -328
  137. package/langwatch/scripts/seed-dogfood-password.ts +163 -0
  138. package/langwatch/src/app/api/workflows/post_event/__tests__/post-event-evaluator.integration.test.ts +458 -0
  139. package/langwatch/src/app/api/workflows/post_event/__tests__/post-event-routing.test.ts +188 -0
  140. package/langwatch/src/app/api/workflows/post_event/__tests__/post-event.integration.test.ts +274 -0
  141. package/langwatch/src/app/api/workflows/post_event/post-event.ts +29 -1
  142. package/langwatch/src/components/agents/AgentCodeEditorDrawer.tsx +4 -5
  143. package/langwatch/src/components/agents/__tests__/AgentCodeEditorDrawer.integration.test.tsx +40 -0
  144. package/langwatch/src/components/evaluations/wizard/hooks/evaluation-wizard-store/slices/factories/__tests__/code-execution-node.factory.unit.test.ts +47 -0
  145. package/langwatch/src/components/evaluations/wizard/hooks/evaluation-wizard-store/slices/factories/code-execution-node.factory.ts +2 -4
  146. package/langwatch/src/components/experiments/BatchEvaluationV2/BatchEvaluationV2EvaluationResults.tsx +6 -1
  147. package/langwatch/src/hooks/usePostHog.ts +11 -0
  148. package/langwatch/src/optimization_studio/__tests__/registry.test.ts +29 -1
  149. package/langwatch/src/optimization_studio/components/Optimize.tsx +17 -3
  150. package/langwatch/src/optimization_studio/components/properties/AgentPropertiesPanel.tsx +4 -5
  151. package/langwatch/src/optimization_studio/hooks/workflowStoreCore.ts +17 -6
  152. package/langwatch/src/optimization_studio/hooks/workflowStoreCore.unit.test.ts +42 -0
  153. package/langwatch/src/optimization_studio/registry.ts +2 -4
  154. package/langwatch/src/optimization_studio/server/lambda/index.ts +12 -2
  155. package/langwatch/src/server/api/routers/workflows.ts +18 -0
  156. package/langwatch/src/server/evaluations-v3/execution/workflowBuilder.ts +3 -2
  157. package/langwatch/src/server/evaluations-v3/services/__tests__/experiment-run.service.getRun-null.unit.test.ts +71 -0
  158. package/langwatch/src/server/evaluations-v3/services/experiment-run.service.ts +18 -9
  159. package/langwatch/src/server/modelProviders/utils.ts +11 -1
  160. package/langwatch/src/server/nlpgo/__tests__/nlpgoFetch.integration.test.ts +248 -0
  161. package/langwatch/src/server/nlpgo/nlpgoFetch.ts +155 -0
  162. package/langwatch/src/server/routes/__tests__/playground-proxy.integration.test.ts +242 -0
  163. package/langwatch/src/server/routes/playground.ts +11 -1
  164. package/langwatch/src/server/routes/workflows.ts +17 -0
  165. package/langwatch/src/server/topicClustering/topicClustering.ts +33 -8
  166. package/langwatch/src/server/workflows/runWorkflow.ts +10 -13
  167. package/langwatch_nlp/langwatch_nlp/studio/execute/execute_component.py +25 -1
  168. package/langwatch_nlp/langwatch_nlp/studio/parser.py +121 -16
  169. package/langwatch_nlp/langwatch_nlp/topic_clustering/topic_naming.py +39 -32
  170. package/langwatch_nlp/scripts/entrypoint.sh +67 -0
  171. package/langwatch_nlp/tests/studio/test_parse.py +198 -0
  172. package/mcp-server/pnpm-lock.yaml +15 -21
  173. package/package.json +1 -1
  174. package/packages/server/dist/cli.cjs +78 -94
  175. package/langwatch/dist/client/assets/ChatWindow-DzB-tNlQ.js +0 -1
  176. package/langwatch/dist/client/assets/_not-found-PEUaWdF3.js +0 -1
  177. package/langwatch/dist/client/assets/_slug_-C-8AjsjC.js +0 -2
  178. package/langwatch/dist/client/assets/choose--PBky27o.js +0 -2
  179. package/langwatch/dist/client/assets/custom-CSiS1liN.js +0 -1
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$s as n,Aa as r,Cn as i,Cs as a,La as o,Qs as s,Ss as c,Xr as l,Xs as u,Ys as d,Zn as f,Zs as p,_s as m,ao as h,ar as g,bs as _,er as v,io as y,ir as b,mn as x,mr as S,rr as C,tr as w,vr as T,vs as E,xs as D,ys as O}from"./command-bar-CaJygoez.js";import{j as ee,n as k,r as A}from"./stack-oJ9iWdbl.js";import{t as j}from"./box-BsM8YLGl.js";import{n as M}from"./toaster-C_DYALhL.js";import{an as N,f as P}from"./dist-SwV3YZv3.js";import{t as F}from"./text-CwTrMF8x.js";import{i as I}from"./code-FF_ibTVI.js";import{t as L}from"./input-C7emsUCL.js";import{t as R}from"./h-stack-BKLDJ2vg.js";import{r as z,t as B}from"./card-CMtKVPVl.js";import{t as te}from"./simple-grid-C3IW90zo.js";import{t as V}from"./spacer-2LJJGbo8.js";import{n as ne,r as re,t as ie}from"./stat-CHoKZ9Rr.js";import{a as H,c as U,i as ae,l as oe,n as se,o as W,r as ce,s as G,t as le}from"./ReplayStateBadge-ChyX1KUG.js";import{t as K}from"./v-stack-EOPQ57OZ.js";import{s as q}from"./auth-client-D3UhxhQi.js";import{t as ue}from"./createLucideIcon-BJKFyRLS.js";import{t as de}from"./arrow-up-right-Cmmi1ap5.js";import{t as J}from"./next-link-DuYeiiEe.js";import{t as fe}from"./OpsPageShell-DJ1WlI6-.js";var pe=ue(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Y=e(t()),X=ee();function me({data:e}){let t=se().data,n=t?.state===`running`,r=e.pausedKeys,i=r.length>0;return!n&&!i?null:(0,X.jsxs)(z,{overflow:`hidden`,children:[(0,X.jsx)(F,{textStyle:`xs`,fontWeight:`medium`,color:`fg.muted`,paddingX:4,paddingTop:3,paddingBottom:2,children:`Active Operations`}),(0,X.jsxs)(K,{align:`stretch`,gap:0,paddingX:4,paddingBottom:3,children:[n&&t&&(0,X.jsxs)(R,{gap:2,paddingY:2,borderBottom:i?`1px solid`:void 0,borderBottomColor:`border`,children:[(0,X.jsx)(oe,{colorPalette:`blue`,size:`sm`,children:(0,X.jsx)(U,{})}),(0,X.jsx)(F,{textStyle:`sm`,fontWeight:`medium`,children:`Replay running`}),t.currentProjection&&(0,X.jsx)(N,{size:`sm`,variant:`subtle`,colorPalette:`blue`,children:t.currentProjection}),(0,X.jsx)(V,{}),t.runId&&(0,X.jsx)(J,{href:`/ops/projections/${t.runId}`,style:{textDecoration:`none`},children:(0,X.jsx)(F,{textStyle:`xs`,color:`blue.500`,cursor:`pointer`,children:`View progress`})})]}),i&&(0,X.jsxs)(K,{align:`stretch`,gap:1,paddingY:2,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Paused pipelines`}),(0,X.jsx)(R,{gap:2,flexWrap:`wrap`,children:r.map(e=>(0,X.jsx)(N,{size:`sm`,colorPalette:`orange`,variant:`subtle`,children:e},e))})]})]})]})}function Z({label:e,value:t,sublabel:n,href:r,color:i}){let a=(0,X.jsxs)(ne,{cursor:r?`pointer`:void 0,_hover:r?{bg:`bg.subtle`}:void 0,borderRadius:`md`,padding:2,transition:`background 0.1s`,children:[(0,X.jsx)(ie,{children:(0,X.jsxs)(R,{gap:1,children:[(0,X.jsx)(F,{children:e}),r&&(0,X.jsx)(de,{size:10})]})}),(0,X.jsxs)(R,{gap:1.5,alignItems:`baseline`,children:[(0,X.jsx)(re,{color:i,children:t}),n&&(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,fontWeight:`normal`,children:n})]})]});return r?(0,X.jsx)(J,{href:r,style:{textDecoration:`none`},children:a}):a}function he(){let e=q.ops.getReplayHistory.useQuery(void 0,{refetchInterval:1e4}).data?.[0];return(0,X.jsxs)(z,{overflow:`hidden`,children:[(0,X.jsx)(J,{href:`/ops/projections`,style:{textDecoration:`none`},children:(0,X.jsxs)(R,{paddingX:4,paddingTop:3,paddingBottom:2,cursor:`pointer`,_hover:{color:`orange.500`},transition:`color 0.1s`,children:[(0,X.jsx)(F,{textStyle:`xs`,fontWeight:`medium`,color:`fg.muted`,children:`Latest Replay`}),(0,X.jsx)(de,{size:10})]})}),(0,X.jsx)(j,{paddingX:4,paddingBottom:4,children:e?(0,X.jsx)(J,{href:`/ops/projections/${e.runId}`,style:{textDecoration:`none`},children:(0,X.jsxs)(R,{gap:3,cursor:`pointer`,_hover:{opacity:.8},transition:`opacity 0.1s`,children:[(0,X.jsx)(N,{size:`sm`,variant:`subtle`,colorPalette:le(e.state),children:e.state}),(0,X.jsx)(F,{textStyle:`xs`,truncate:!0,maxWidth:`240px`,children:e.description||`—`}),(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:ae(e.startedAt,e.completedAt)}),(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,whiteSpace:`nowrap`,children:e.completedAt?new Date(e.completedAt).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`—`})]})}):(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`No replay history`})})]})}var Q={staged:{stroke:`#06b6d4`,fill:`#06b6d4`},completed:{stroke:`#22c55e`,fill:`#22c55e`},failed:{stroke:`#ef4444`,fill:`#ef4444`},pending:`#a78bfa`,blocked:`#f97316`},ge=[{label:`2s`,ms:0},{label:`5s`,ms:5e3},{label:`15s`,ms:15e3},{label:`30s`,ms:3e4},{label:`1m`,ms:6e4}];function _e(e,t){if(e.length===0)return[];if(t<=0)return e.map(e=>({timestamp:e.timestamp,staged:e.ingestedPerSec,completed:e.completedPerSec,failed:e.failedPerSec,pending:e.pendingCount,blocked:e.blockedCount}));let n=new Map;for(let r of e){let e=Math.floor(r.timestamp/t)*t,i=n.get(e);i?(i.sum.staged+=r.ingestedPerSec,i.sum.completed+=r.completedPerSec,i.sum.failed+=r.failedPerSec,i.sum.pending+=r.pendingCount,i.sum.blocked+=r.blockedCount,i.count++):n.set(e,{sum:{timestamp:e,staged:r.ingestedPerSec,completed:r.completedPerSec,failed:r.failedPerSec,pending:r.pendingCount,blocked:r.blockedCount},count:1})}let r=[];for(let[,{sum:e,count:t}]of n)r.push({timestamp:e.timestamp,staged:e.staged/t,completed:e.completed/t,failed:e.failed/t,pending:Math.round(e.pending/t),blocked:Math.round(e.blocked/t)});return r.sort((e,t)=>e.timestamp-t.timestamp),r}function ve(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function ye(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function be(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e===0?`0`:Number.isInteger(e)?e.toString():e.toFixed(1)}function xe(e){if(e.length<2)return[];let t=e[0].timestamp,n=e[e.length-1].timestamp,r=n-t,i=6e4;r>20*6e4?i=5*6e4:r>10*6e4&&(i=2*6e4);let a=Math.ceil(t/i)*i,o=[];for(let e=a;e<=n;e+=i)o.push(e);return o}function Se(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t,r;return r=n<=1?1:n<=2?2:n<=5?5:10,r*t}function Ce({active:e,payload:t,label:n}){if(!e||!t?.length||n==null)return null;let r=t.filter(e=>e.name!==`Pending`&&e.name!==`Blocked`),i=t.filter(e=>e.name===`Pending`||e.name===`Blocked`);return(0,X.jsxs)(j,{bg:`bg.panel`,borderWidth:`1px`,borderColor:`border`,borderRadius:`md`,padding:2,shadow:`md`,minWidth:`140px`,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:ye(n)}),r.map(e=>(0,X.jsxs)(R,{justify:`space-between`,gap:3,children:[(0,X.jsxs)(R,{gap:1.5,children:[(0,X.jsx)(j,{width:`6px`,height:`6px`,borderRadius:`full`,bg:e.color}),(0,X.jsx)(F,{textStyle:`xs`,children:e.name})]}),(0,X.jsxs)(F,{textStyle:`xs`,fontFamily:`mono`,fontWeight:`medium`,children:[e.value.toFixed(1),`/s`]})]},e.name)),i.length>0&&i.some(e=>e.value>0)&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{height:`1px`,bg:`border`,marginY:1}),i.map(e=>(0,X.jsxs)(R,{justify:`space-between`,gap:3,children:[(0,X.jsxs)(R,{gap:1.5,children:[(0,X.jsx)(j,{width:`6px`,height:`2px`,bg:e.color}),(0,X.jsx)(F,{textStyle:`xs`,children:e.name})]}),(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,children:e.value.toLocaleString()})]},e.name))]})]})}function we({showCounts:e}){return(0,X.jsx)(R,{gap:3,justify:`center`,paddingTop:2,children:[{name:`Staged/s`,color:Q.staged.stroke,type:`area`},{name:`Completed/s`,color:Q.completed.stroke,type:`area`},{name:`Failed/s`,color:Q.failed.stroke,type:`area`},...e?[{name:`Pending`,color:Q.pending,type:`line`},{name:`Blocked`,color:Q.blocked,type:`line`}]:[]].map(e=>(0,X.jsxs)(R,{gap:1,children:[e.type===`area`?(0,X.jsx)(j,{width:`6px`,height:`6px`,borderRadius:`full`,bg:e.color}):(0,X.jsx)(j,{width:`10px`,height:`2px`,bg:e.color,borderRadius:`full`,opacity:.7}),(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:e.name})]},e.name))})}function Te({data:e}){let t=(0,Y.useRef)(1),[n,r]=(0,Y.useState)(5e3),i=(0,Y.useMemo)(()=>_e(e.throughputHistory,n),[e.throughputHistory,n]),a=(0,Y.useMemo)(()=>xe(i),[i]),o=(0,Y.useMemo)(()=>{if(i.length===0)return 1;let e=0;for(let t of i)e=Math.max(e,t.staged,t.completed,t.failed);let n=Se(e*1.3);return(n>t.current*1.2||n<t.current*.5)&&(t.current=n),t.current},[i]),s=(0,Y.useMemo)(()=>i.some(e=>e.pending>0||e.blocked>0),[i]),c=(0,Y.useMemo)(()=>{if(!s)return 10;let e=0;for(let t of i)e=Math.max(e,t.pending,t.blocked);return e<=0?10:Se(e*1.3)},[i,s]);return i.length<2?(0,X.jsx)(I,{height:`280px`,children:(0,X.jsxs)(K,{gap:2,children:[(0,X.jsx)(A,{size:`sm`}),(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Collecting data...`})]})}):(0,X.jsxs)(K,{align:`stretch`,gap:0,children:[(0,X.jsxs)(R,{justify:`space-between`,paddingX:1,paddingBottom:1,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,fontStyle:`italic`,children:`events/s`}),(0,X.jsx)(R,{gap:.5,children:ge.map(e=>(0,X.jsx)(k,{size:`2xs`,variant:n===e.ms?`subtle`:`ghost`,colorPalette:n===e.ms?`orange`:`gray`,onClick:()=>r(e.ms),fontFamily:`mono`,minWidth:`auto`,paddingX:1.5,children:e.label},e.ms))}),s&&(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,fontStyle:`italic`,children:`count`})]}),(0,X.jsx)(T,{width:`100%`,height:280,children:(0,X.jsxs)(f,{data:i,margin:{top:8,right:s?4:12,bottom:4,left:-8},children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsxs)(`linearGradient`,{id:`gradStaged`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,X.jsx)(`stop`,{offset:`0%`,stopColor:Q.staged.fill,stopOpacity:.2}),(0,X.jsx)(`stop`,{offset:`100%`,stopColor:Q.staged.fill,stopOpacity:.02})]}),(0,X.jsxs)(`linearGradient`,{id:`gradCompleted`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,X.jsx)(`stop`,{offset:`0%`,stopColor:Q.completed.fill,stopOpacity:.2}),(0,X.jsx)(`stop`,{offset:`100%`,stopColor:Q.completed.fill,stopOpacity:.02})]}),(0,X.jsxs)(`linearGradient`,{id:`gradFailed`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,X.jsx)(`stop`,{offset:`0%`,stopColor:Q.failed.fill,stopOpacity:.25}),(0,X.jsx)(`stop`,{offset:`100%`,stopColor:Q.failed.fill,stopOpacity:.02})]})]}),(0,X.jsx)(g,{strokeDasharray:`3 3`,stroke:`var(--chakra-colors-border)`,strokeOpacity:.4,vertical:!1}),(0,X.jsx)(w,{dataKey:`timestamp`,type:`number`,domain:[`dataMin`,`dataMax`],scale:`time`,ticks:a,tickFormatter:ve,tick:{fontSize:10,fill:`var(--chakra-colors-fg-muted)`},axisLine:!1,tickLine:!1}),(0,X.jsx)(v,{yAxisId:`rate`,tick:{fontSize:10,fill:`var(--chakra-colors-fg-muted)`},axisLine:!1,tickLine:!1,width:40,domain:[0,o],allowDataOverflow:!0,tickFormatter:be}),s&&(0,X.jsx)(v,{yAxisId:`count`,orientation:`right`,tick:{fontSize:10,fill:`var(--chakra-colors-fg-muted)`},axisLine:!1,tickLine:!1,width:40,domain:[0,c],allowDataOverflow:!0,tickFormatter:be}),(0,X.jsx)(S,{content:(0,X.jsx)(Ce,{}),cursor:{stroke:`var(--chakra-colors-fg-muted)`,strokeWidth:1,strokeDasharray:`3 3`,strokeOpacity:.3}}),(0,X.jsx)(C,{yAxisId:`rate`,type:`monotone`,dataKey:`staged`,stroke:Q.staged.stroke,fill:`url(#gradStaged)`,strokeWidth:1.5,name:`Staged/s`,isAnimationActive:!1,dot:!1,activeDot:{r:3,strokeWidth:0}}),(0,X.jsx)(C,{yAxisId:`rate`,type:`monotone`,dataKey:`completed`,stroke:Q.completed.stroke,fill:`url(#gradCompleted)`,strokeWidth:1.5,name:`Completed/s`,isAnimationActive:!1,dot:!1,activeDot:{r:3,strokeWidth:0}}),(0,X.jsx)(C,{yAxisId:`rate`,type:`monotone`,dataKey:`failed`,stroke:Q.failed.stroke,fill:`url(#gradFailed)`,strokeWidth:1.5,name:`Failed/s`,isAnimationActive:!1,dot:!1,activeDot:{r:3,strokeWidth:0}}),(0,X.jsx)(b,{yAxisId:s?`count`:`rate`,type:`monotone`,dataKey:`pending`,stroke:Q.pending,strokeWidth:1,strokeOpacity:.6,strokeDasharray:`4 3`,dot:!1,activeDot:{r:2,strokeWidth:0},name:`Pending`,isAnimationActive:!1}),(0,X.jsx)(b,{yAxisId:s?`count`:`rate`,type:`monotone`,dataKey:`blocked`,stroke:Q.blocked,strokeWidth:1,strokeOpacity:.6,strokeDasharray:`4 3`,dot:!1,activeDot:{r:2,strokeWidth:0},name:`Blocked`,isAnimationActive:!1})]})}),(0,X.jsx)(we,{showCounts:s})]})}function Ee(e,t,n){let r=t?`${t}/${e.name}`:e.name;if(n.has(r))return!0;if(t){let e=t.split(`/`);for(let t=1;t<=e.length;t++){let r=e.slice(0,t).join(`/`);if(n.has(r))return!0}}return!1}function De(e,t){return t.has(e)}function Oe(e,t){if(!t.trim())return e;let n=t.toLowerCase();function r(e){if(e.name.toLowerCase().includes(n))return e;let t=e.children.map(r).filter(e=>e!==null);return t.length>0?{...e,children:t}:null}let i=e.map(r).filter(e=>e!==null);return i.length>0?i:null}function ke(e){return e===null?!1:Date.now()-e>300*1e3}function Ae(e,t){switch(t){case`all`:return!0;case`ok`:return!e.isBlocked&&!e.isStaleBlock;case`blocked`:return e.isBlocked&&!e.isStaleBlock;case`stale`:return e.isStaleBlock;case`active`:return e.hasActiveJob&&!e.isBlocked}}function je({node:e,parentPath:t,depth:n,pausedKeys:r,expandedPaths:i,onToggleExpand:a,onPause:s,onUnpause:c,hasAccess:l,queueNames:u}){let d=t?`${t}/${e.name}`:e.name,f=e.children.length>0,p=i.has(d),m=Ee(e,t,r),g=De(d,r),_=!f;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(R,{paddingY:1,paddingX:3,paddingLeft:`${n*20+12}px`,cursor:f?`pointer`:`default`,_hover:{bg:`bg.subtle`},onClick:()=>f&&a(d),borderBottom:`1px solid`,borderBottomColor:`border`,gap:2,opacity:m?.6:1,children:[(0,X.jsx)(j,{width:`14px`,flexShrink:0,children:f?p?(0,X.jsx)(h,{size:12}):(0,X.jsx)(y,{size:12}):null}),(0,X.jsx)(F,{textStyle:`xs`,fontWeight:n===0?`semibold`:`medium`,fontFamily:_?`mono`:void 0,flex:1,color:m?`orange.500`:void 0,children:e.name}),m&&(0,X.jsx)(N,{size:`xs`,colorPalette:`orange`,variant:`subtle`,children:`Paused`}),(0,X.jsxs)(R,{gap:1,flexShrink:0,children:[e.pending>0&&(0,X.jsx)(N,{size:`xs`,colorPalette:`blue`,variant:`subtle`,children:e.pending}),e.active>0&&(0,X.jsx)(N,{size:`xs`,colorPalette:`green`,variant:`subtle`,children:e.active}),e.blocked>0&&(0,X.jsx)(N,{size:`xs`,colorPalette:`red`,variant:`subtle`,children:e.blocked})]}),l&&(0,X.jsx)(j,{flexShrink:0,onClick:e=>e.stopPropagation(),children:g?(0,X.jsx)(k,{variant:`ghost`,size:`2xs`,colorPalette:`green`,onClick:()=>c(d),children:(0,X.jsx)(o,{size:10})}):m?null:(0,X.jsx)(k,{variant:`ghost`,size:`2xs`,colorPalette:`orange`,onClick:()=>s(d),children:(0,X.jsx)(pe,{size:10})})})]}),f&&p&&e.children.map(e=>(0,X.jsx)(je,{node:e,parentPath:d,depth:n+1,pausedKeys:r,expandedPaths:i,onToggleExpand:a,onPause:s,onUnpause:c,hasAccess:l,queueNames:u},e.name))]})}function Me({pipelineTree:e,pausedKeys:t,queueNames:n}){let{hasAccess:a}=i(),o=q.useContext(),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(()=>new Set),d=(0,Y.useMemo)(()=>new Set(t),[t]),f=(0,Y.useMemo)(()=>Oe(e,s),[e,s]),p=q.ops.pausePipeline.useMutation({onSuccess:()=>{M.create({title:`Pipeline paused`,type:`success`}),o.ops.invalidate()},onError:e=>{M.create({title:`Failed to pause`,description:e.message,type:`error`})}}),m=q.ops.unpausePipeline.useMutation({onSuccess:()=>{M.create({title:`Pipeline unpaused`,type:`success`}),o.ops.invalidate()},onError:e=>{M.create({title:`Failed to unpause`,description:e.message,type:`error`})}});function h(e){u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function g(){let t=new Set;function n(e,r){for(let i of e){let e=r?`${r}/${i.name}`:i.name;t.add(e),n(i.children,e)}}n(e,``),u(t)}let _=n[0];function v(e){_&&p.mutate({queueName:_,key:e})}function y(e){_&&m.mutate({queueName:_,key:e})}return(0,X.jsx)(z,{children:(0,X.jsxs)(B,{padding:0,children:[(0,X.jsxs)(R,{paddingX:4,paddingY:2.5,borderBottom:`1px solid`,borderBottomColor:`border`,children:[(0,X.jsx)(F,{textStyle:`sm`,fontWeight:`medium`,children:`Pipeline Tree`}),(0,X.jsx)(V,{}),e.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(j,{position:`relative`,width:`200px`,children:[(0,X.jsx)(j,{position:`absolute`,left:2.5,top:`50%`,transform:`translateY(-50%)`,zIndex:1,children:(0,X.jsx)(r,{size:11,color:`var(--chakra-colors-fg-muted)`})}),(0,X.jsx)(L,{size:`xs`,placeholder:`Filter...`,value:s,onChange:e=>c(e.target.value),paddingLeft:7})]}),(0,X.jsx)(k,{variant:`ghost`,size:`2xs`,onClick:g,children:`Expand all`}),(0,X.jsx)(k,{variant:`ghost`,size:`2xs`,onClick:()=>u(new Set),children:`Collapse`})]})]}),e.length===0?(0,X.jsx)(j,{padding:4,children:(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`No pipelines discovered yet.`})}):f===null?(0,X.jsx)(j,{padding:4,children:(0,X.jsxs)(F,{textStyle:`xs`,color:`fg.muted`,children:[`No pipelines match "`,s,`"`]})}):f.map(e=>(0,X.jsx)(je,{node:e,parentPath:``,depth:0,pausedKeys:d,expandedPaths:l,onToggleExpand:h,onPause:v,onUnpause:y,hasAccess:a,queueNames:n},e.name))]})})}function $({open:e,onClose:t,onConfirm:n,title:r,description:i,isLoading:a}){return(0,X.jsx)(P.Root,{open:e,onOpenChange:e=>!e.open&&t(),children:(0,X.jsxs)(P.Content,{children:[(0,X.jsx)(P.Header,{children:(0,X.jsx)(P.Title,{children:r})}),(0,X.jsx)(P.Body,{children:(0,X.jsx)(F,{textStyle:`sm`,children:i})}),(0,X.jsxs)(P.Footer,{children:[(0,X.jsx)(k,{variant:`outline`,size:`sm`,onClick:t,children:`Cancel`}),(0,X.jsx)(k,{colorPalette:`red`,size:`sm`,onClick:n,loading:a,children:`Confirm`})]}),(0,X.jsx)(P.CloseTrigger,{})]})})}function Ne({queueNames:e}){let{hasAccess:t}=i(),n=q.useContext(),r=q.ops.getBlockedSummary.useQuery(),o=q.ops.listQueues.useQuery(),[s,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(5),b=q.ops.unblockAll.useMutation({onSuccess:e=>{M.create({title:`Unblocked ${e.unblockedCount} groups`,type:`success`}),l(null),n.ops.invalidate()},onError:e=>{M.create({title:`Unblock failed`,description:e.message,type:`error`})}}),x=q.ops.drainGroup.useMutation({onSuccess:e=>{M.create({title:`Drained, removed ${e.jobsRemoved} jobs`,type:`success`}),d(null),n.ops.invalidate()},onError:e=>{M.create({title:`Drain failed`,description:e.message,type:`error`})}}),S=q.ops.moveAllBlockedToDlq.useMutation({onSuccess:e=>{M.create({title:`Moved ${e.movedCount} groups to DLQ`,type:`success`}),p(null),n.ops.invalidate()},onError:e=>{M.create({title:`Move to DLQ failed`,description:e.message,type:`error`})}}),C=q.ops.canaryUnblock.useMutation({onSuccess:e=>{M.create({title:`Canary unblocked ${e.unblockedCount}`,type:`success`}),g(null),n.ops.invalidate()},onError:e=>{M.create({title:`Canary failed`,description:e.message,type:`error`})}}),w=(o.data??[]).filter(e=>e.blockedGroupCount>0);return r.isLoading||!r.data||r.data.clusters.length===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{children:(0,X.jsxs)(B,{padding:0,children:[(0,X.jsxs)(R,{paddingX:4,paddingY:2.5,borderBottom:`1px solid`,borderBottomColor:`border`,gap:2,flexWrap:`wrap`,children:[(0,X.jsxs)(F,{textStyle:`sm`,fontWeight:`medium`,color:`red.500`,children:[`Blocked — `,r.data.totalBlocked,` groups, `,r.data.clusters.length,` error patterns`]}),(0,X.jsx)(V,{}),t&&(0,X.jsxs)(R,{gap:1.5,flexWrap:`wrap`,children:[w.map(e=>(0,X.jsxs)(k,{variant:`outline`,size:`2xs`,colorPalette:`orange`,onClick:()=>l(e.name),children:[`Unblock All (`,e.blockedGroupCount,`)`]},e.name)),w.map(e=>(0,X.jsx)(k,{variant:`outline`,size:`2xs`,colorPalette:`red`,onClick:()=>p(e.name),children:`→ DLQ`},`dlq-${e.name}`)),(0,X.jsxs)(R,{gap:1,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Canary:`}),(0,X.jsx)(L,{size:`xs`,type:`number`,value:v,onChange:e=>y(Math.max(1,Math.min(100,parseInt(e.target.value)||5))),width:`50px`}),w.map(e=>(0,X.jsx)(k,{variant:`ghost`,size:`2xs`,onClick:()=>g(e.name),children:`Go`},`c-${e.name}`))]})]})]}),(0,X.jsx)(a,{children:(0,X.jsxs)(D,{size:`sm`,variant:`line`,css:{"& tr:last-child td":{borderBottom:`none`}},children:[(0,X.jsx)(_,{children:(0,X.jsxs)(c,{children:[(0,X.jsx)(O,{width:`60px`,textAlign:`end`,children:`Count`}),(0,X.jsx)(O,{children:`Error`}),(0,X.jsx)(O,{children:`Pipeline`}),(0,X.jsx)(O,{children:`Sample Groups`}),(0,X.jsx)(O,{width:`60px`,children:`Actions`})]})}),(0,X.jsx)(m,{children:r.data.clusters.map((e,t)=>(0,X.jsxs)(c,{children:[(0,X.jsx)(E,{textAlign:`end`,children:(0,X.jsx)(F,{color:`red.500`,fontWeight:`medium`,textStyle:`xs`,children:e.count})}),(0,X.jsx)(E,{children:(0,X.jsx)(F,{textStyle:`xs`,truncate:!0,maxWidth:`300px`,title:e.sampleMessage,children:e.sampleMessage})}),(0,X.jsx)(E,{children:(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:e.pipelineName??`—`})}),(0,X.jsx)(E,{children:(0,X.jsxs)(F,{textStyle:`xs`,fontFamily:`mono`,truncate:!0,maxWidth:`160px`,children:[e.sampleGroupIds.slice(0,2).join(`, `),e.sampleGroupIds.length>2?` +${e.sampleGroupIds.length-2}`:``]})}),(0,X.jsx)(E,{children:e.sampleGroupIds[0]&&(0,X.jsx)(k,{variant:`outline`,size:`2xs`,colorPalette:`red`,onClick:()=>d({queueName:e.queueName,groupId:e.sampleGroupIds[0]}),children:`Drain`})})]},t))})]})})]})}),(0,X.jsx)($,{open:!!s,onClose:()=>l(null),onConfirm:()=>{s&&b.mutate({queueName:s})},title:`Unblock All`,description:`Unblock all blocked groups in "${s}". They will retry immediately.`,isLoading:b.isPending}),(0,X.jsx)($,{open:!!u,onClose:()=>d(null),onConfirm:()=>{u&&x.mutate(u)},title:`Drain Group`,description:`Permanently remove all jobs from "${u?.groupId}". Cannot be undone.`,isLoading:x.isPending}),(0,X.jsx)($,{open:!!f,onClose:()=>p(null),onConfirm:()=>{f&&S.mutate({queueName:f})},title:`Move All to DLQ`,description:`Move all blocked groups in "${f}" to DLQ. They can be replayed later.`,isLoading:S.isPending}),(0,X.jsx)($,{open:!!h,onClose:()=>g(null),onConfirm:()=>{h&&C.mutate({queueName:h,count:v})},title:`Canary Unblock`,description:`Unblock ${v} random groups in "${h}" as a canary test.`,isLoading:C.isPending})]})}function Pe({queueNames:e}){let{hasAccess:t}=i(),n=q.useContext(),r=q.ops.listAllDlqGroups.useQuery(void 0,{refetchInterval:1e4}),[o,s]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),[p,h]=(0,Y.useState)(5),g=q.ops.replayFromDlq.useMutation({onSuccess:e=>{M.create({title:`Replayed ${e.jobsReplayed} jobs`,type:`success`}),s(null),n.ops.invalidate()},onError:e=>{M.create({title:`Replay failed`,description:e.message,type:`error`})}}),v=q.ops.replayAllFromDlq.useMutation({onSuccess:e=>{M.create({title:`Replayed ${e.replayedCount} groups`,type:`success`}),u(null),n.ops.invalidate()},onError:e=>{M.create({title:`Replay all failed`,description:e.message,type:`error`})}}),y=q.ops.canaryRedrive.useMutation({onSuccess:e=>{M.create({title:`Canary redrove ${e.redrivenCount}`,type:`success`}),f(null),n.ops.invalidate()},onError:e=>{M.create({title:`Canary failed`,description:e.message,type:`error`})}}),b=r.data??[],x=[...new Set(b.map(e=>e.queueName))];return r.isLoading||b.length===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{children:(0,X.jsxs)(B,{padding:0,children:[(0,X.jsxs)(R,{paddingX:4,paddingY:2.5,borderBottom:`1px solid`,borderBottomColor:`border`,gap:2,flexWrap:`wrap`,children:[(0,X.jsxs)(F,{textStyle:`sm`,fontWeight:`medium`,color:`orange.500`,children:[`Dead Letter Queue — `,b.length,` group`,b.length===1?``:`s`]}),(0,X.jsx)(V,{}),t&&(0,X.jsxs)(R,{gap:1.5,flexWrap:`wrap`,children:[x.map(e=>{let t=b.filter(t=>t.queueName===e).length;return(0,X.jsxs)(k,{variant:`outline`,size:`2xs`,colorPalette:`green`,onClick:()=>u(e),children:[`Replay All `,b.find(t=>t.queueName===e)?.queueDisplayName??e,` (`,t,`)`]},e)}),(0,X.jsxs)(R,{gap:1,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Canary:`}),(0,X.jsx)(L,{size:`xs`,type:`number`,value:p,onChange:e=>h(Math.max(1,Math.min(100,parseInt(e.target.value)||5))),width:`50px`}),x.map(e=>(0,X.jsx)(k,{variant:`ghost`,size:`2xs`,onClick:()=>f(e),children:`Go`},`c-${e}`))]})]})]}),(0,X.jsx)(a,{children:(0,X.jsxs)(D,{size:`sm`,variant:`line`,css:{"& tr:last-child td":{borderBottom:`none`}},children:[(0,X.jsx)(_,{children:(0,X.jsxs)(c,{children:[(0,X.jsx)(O,{children:`Queue`}),(0,X.jsx)(O,{children:`Group ID`}),(0,X.jsx)(O,{children:`Pipeline`}),(0,X.jsx)(O,{children:`Error`}),(0,X.jsx)(O,{textAlign:`end`,width:`50px`,children:`Jobs`}),t&&(0,X.jsx)(O,{width:`70px`,children:`Actions`})]})}),(0,X.jsx)(m,{children:b.map(e=>(0,X.jsxs)(c,{children:[(0,X.jsx)(E,{children:(0,X.jsx)(N,{size:`xs`,variant:`subtle`,children:e.queueDisplayName})}),(0,X.jsx)(E,{children:(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,truncate:!0,maxWidth:`160px`,children:e.groupId})}),(0,X.jsx)(E,{children:(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:e.pipelineName??`—`})}),(0,X.jsx)(E,{children:(0,X.jsx)(F,{textStyle:`xs`,color:`red.500`,truncate:!0,maxWidth:`220px`,title:e.error??void 0,children:e.error??``})}),(0,X.jsx)(E,{textAlign:`end`,children:(0,X.jsx)(F,{textStyle:`xs`,children:e.jobCount})}),t&&(0,X.jsx)(E,{children:(0,X.jsx)(k,{variant:`outline`,size:`2xs`,colorPalette:`green`,onClick:()=>s({queueName:e.queueName,groupId:e.groupId}),children:`Replay`})})]},`${e.queueName}:${e.groupId}`))})]})})]})}),(0,X.jsx)($,{open:!!o,onClose:()=>s(null),onConfirm:()=>{o&&g.mutate(o)},title:`Replay from DLQ`,description:`Move "${o?.groupId}" back to main queue for reprocessing.`,isLoading:g.isPending}),(0,X.jsx)($,{open:!!l,onClose:()=>u(null),onConfirm:()=>{l&&v.mutate({queueName:l})},title:`Replay All from DLQ`,description:`Move all DLQ groups in "${l}" back to main queue.`,isLoading:v.isPending}),(0,X.jsx)($,{open:!!d,onClose:()=>f(null),onConfirm:()=>{d&&y.mutate({queueName:d,count:p})},title:`Canary Redrive`,description:`Replay ${p} random DLQ groups from "${d}" as canary.`,isLoading:y.isPending})]})}function Fe({group:e,onClose:t}){let n=q.ops.getGroupDetail.useQuery({queueName:e?.queueName??``,groupId:e?.groupId??``},{enabled:!!e}),r=q.ops.getGroupJobs.useQuery({queueName:e?.queueName??``,groupId:e?.groupId??``,page:1,pageSize:20},{enabled:!!e}),i=n.data,a=r.data;return(0,X.jsx)(P.Root,{open:!!e,onOpenChange:e=>!e.open&&t(),size:`lg`,children:(0,X.jsxs)(P.Content,{children:[(0,X.jsx)(P.Header,{children:(0,X.jsx)(P.Title,{children:(0,X.jsx)(F,{textStyle:`sm`,fontFamily:`mono`,wordBreak:`break-all`,children:e?.groupId})})}),(0,X.jsx)(P.Body,{children:n.isLoading?(0,X.jsx)(I,{paddingY:6,children:(0,X.jsx)(A,{size:`sm`})}):i?(0,X.jsxs)(K,{align:`stretch`,gap:4,children:[(0,X.jsxs)(R,{gap:4,flexWrap:`wrap`,children:[(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Status`}),i.isStaleBlock?(0,X.jsx)(N,{size:`sm`,colorPalette:`orange`,variant:`subtle`,children:`Stale`}):i.isBlocked?(0,X.jsx)(N,{size:`sm`,colorPalette:`red`,variant:`subtle`,children:`Blocked`}):i.hasActiveJob?(0,X.jsx)(N,{size:`sm`,colorPalette:`green`,variant:`subtle`,children:`Active`}):(0,X.jsx)(N,{size:`sm`,colorPalette:`gray`,variant:`subtle`,children:`OK`})]}),(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Pipeline`}),(0,X.jsx)(F,{textStyle:`sm`,children:i.pipelineName??`—`})]}),(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Pending`}),(0,X.jsx)(F,{textStyle:`sm`,fontFamily:`mono`,children:i.pendingJobs})]}),(i.retryCount??0)>0&&(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Retries`}),(0,X.jsx)(F,{textStyle:`sm`,fontFamily:`mono`,color:`orange.500`,children:i.retryCount})]}),i.activeJobId&&(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Active Job`}),(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,color:`green.500`,children:i.activeJobId})]})]}),(0,X.jsxs)(R,{gap:4,children:[(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Oldest Job`}),(0,X.jsx)(F,{textStyle:`sm`,children:G(i.oldestJobMs)})]}),(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Newest Job`}),(0,X.jsx)(F,{textStyle:`sm`,children:G(i.newestJobMs)})]}),i.processingDurationMs!=null&&(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Processing`}),(0,X.jsxs)(F,{textStyle:`sm`,children:[i.processingDurationMs,`ms`]})]})]}),i.errorMessage&&(0,X.jsxs)(K,{align:`stretch`,gap:1,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Error`}),(0,X.jsx)(z,{borderColor:`red.500/20`,children:(0,X.jsxs)(B,{padding:3,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`red.500`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,children:i.errorMessage}),i.errorStack&&(0,X.jsx)(j,{marginTop:2,maxHeight:`200px`,overflow:`auto`,bg:`bg.subtle`,borderRadius:`sm`,padding:2,children:(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,color:`fg.muted`,whiteSpace:`pre`,fontSize:`10px`,children:i.errorStack})})]})})]}),(0,X.jsxs)(K,{align:`stretch`,gap:1,children:[(0,X.jsxs)(F,{textStyle:`xs`,color:`fg.muted`,children:[`Jobs `,a?`(${a.total})`:``]}),r.isLoading?(0,X.jsx)(A,{size:`xs`}):a&&a.jobs.length>0?(0,X.jsx)(K,{align:`stretch`,gap:2,children:a.jobs.map(e=>(0,X.jsx)(z,{variant:`outline`,children:(0,X.jsxs)(B,{padding:3,children:[(0,X.jsxs)(R,{gap:3,marginBottom:e.data?2:0,children:[(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Job ID`}),(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,wordBreak:`break-all`,children:e.jobId})]}),(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Score`}),(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,children:e.score})]})]}),e.data&&(0,X.jsx)(j,{bg:`bg.subtle`,borderRadius:`sm`,padding:2,maxHeight:`200px`,overflow:`auto`,children:(0,X.jsx)(F,{as:`pre`,textStyle:`xs`,fontFamily:`mono`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,fontSize:`11px`,children:JSON.stringify(e.data,null,2)})})]})},e.jobId))}):(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`No jobs in queue.`})]})]}):null}),(0,X.jsx)(P.CloseTrigger,{})]})})}function Ie({queueNames:e}){let{hasAccess:t}=i(),n=q.useContext(),[o,s]=(0,Y.useState)(`all`),[l,u]=(0,Y.useState)(``),d=e[0],f=q.ops.listGroups.useQuery({queueName:d??``,page:1,pageSize:200},{refetchInterval:1e4,enabled:!!d}),p=(0,Y.useMemo)(()=>{let e=[];if(f.data&&d)for(let t of f.data.groups)e.push({...t,queueName:d});return e},[f.data,d]),h=(0,Y.useMemo)(()=>{let e=p;if(o!==`all`&&(e=e.filter(e=>Ae(e,o))),l.trim()){let t=l.toLowerCase();e=e.filter(e=>e.groupId.toLowerCase().includes(t)||e.pipelineName?.toLowerCase().includes(t)||e.errorMessage?.toLowerCase().includes(t))}return e},[p,o,l]),g=(0,Y.useMemo)(()=>{let e=0,t=0,n=0,r=0;for(let i of p)i.isStaleBlock?n++:i.isBlocked?t++:e++,i.hasActiveJob&&!i.isBlocked&&r++;return{all:p.length,ok:e,blocked:t,stale:n,active:r}},[p]),v=!!d&&f.isLoading,[y,b]=(0,Y.useState)(null),[x,S]=(0,Y.useState)(null),C=q.ops.drainGroup.useMutation({onSuccess:e=>{M.create({title:`Drained, removed ${e.jobsRemoved} jobs`,type:`success`}),S(null),n.ops.invalidate()},onError:e=>{M.create({title:`Failed to drain`,description:e.message,type:`error`})}}),w=q.ops.unblockGroup.useMutation({onSuccess:()=>{M.create({title:`Group unblocked`,type:`success`}),n.ops.invalidate()},onError:e=>{M.create({title:`Failed to unblock`,description:e.message,type:`error`})}}),T=[{value:`all`,label:`All`,count:g.all,color:`gray`},{value:`ok`,label:`OK`,count:g.ok,color:`green`},{value:`blocked`,label:`Blocked`,count:g.blocked,color:`red`},{value:`stale`,label:`Stale`,count:g.stale,color:`orange`},{value:`active`,label:`Active`,count:g.active,color:`blue`}];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{children:(0,X.jsxs)(B,{padding:0,children:[(0,X.jsxs)(R,{paddingX:4,paddingY:2.5,borderBottom:`1px solid`,borderBottomColor:`border`,gap:2,flexWrap:`wrap`,children:[(0,X.jsx)(F,{textStyle:`sm`,fontWeight:`medium`,children:`Groups`}),(0,X.jsx)(V,{}),p.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R,{gap:1,children:T.map(e=>(0,X.jsxs)(k,{size:`2xs`,variant:o===e.value?`solid`:`ghost`,colorPalette:e.color,onClick:()=>s(e.value),children:[e.label,` `,e.count>0?`(${e.count})`:``]},e.value))}),(0,X.jsxs)(j,{position:`relative`,width:`200px`,children:[(0,X.jsx)(j,{position:`absolute`,left:2.5,top:`50%`,transform:`translateY(-50%)`,zIndex:1,children:(0,X.jsx)(r,{size:11,color:`var(--chakra-colors-fg-muted)`})}),(0,X.jsx)(L,{size:`xs`,placeholder:`Search...`,value:l,onChange:e=>u(e.target.value),paddingLeft:7})]})]})]}),v?(0,X.jsx)(I,{paddingY:6,children:(0,X.jsx)(A,{size:`sm`})}):p.length===0?(0,X.jsx)(j,{padding:4,children:(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`No groups — queues are idle.`})}):h.length===0?(0,X.jsx)(j,{padding:4,children:(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`No groups match current filters.`})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(a,{children:(0,X.jsxs)(D,{size:`sm`,variant:`line`,css:{"& tr:last-child td":{borderBottom:`none`}},children:[(0,X.jsx)(_,{children:(0,X.jsxs)(c,{children:[(0,X.jsx)(O,{children:`Group ID`}),(0,X.jsx)(O,{width:`140px`,children:`Pipeline`}),(0,X.jsx)(O,{textAlign:`end`,width:`50px`,children:`Pend.`}),(0,X.jsx)(O,{textAlign:`end`,width:`45px`,children:`Retry`}),(0,X.jsx)(O,{width:`75px`,children:`Oldest`}),(0,X.jsx)(O,{width:`65px`,children:`Status`}),t&&(0,X.jsx)(O,{width:`100px`,children:`Actions`})]})}),(0,X.jsx)(m,{children:h.slice(0,100).map(e=>{let n=!e.isBlocked&&ke(e.oldestJobMs);return(0,X.jsxs)(c,{cursor:`pointer`,_hover:{bg:`bg.subtle`},onClick:()=>b({queueName:e.queueName,groupId:e.groupId}),children:[(0,X.jsx)(E,{children:(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,truncate:!0,title:e.groupId,children:e.groupId})}),(0,X.jsx)(E,{children:(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,truncate:!0,children:e.pipelineName??`—`})}),(0,X.jsx)(E,{textAlign:`end`,children:(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,children:e.pendingJobs})}),(0,X.jsx)(E,{textAlign:`end`,children:(e.retryCount??0)>0?(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,color:`orange.500`,children:e.retryCount}):(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,color:`fg.muted`,children:`—`})}),(0,X.jsx)(E,{children:(0,X.jsxs)(F,{textStyle:`xs`,color:n?`orange.500`:`fg.muted`,fontWeight:n?`medium`:void 0,children:[G(e.oldestJobMs),n?` ⚠`:``]})}),(0,X.jsx)(E,{children:e.isStaleBlock?(0,X.jsx)(N,{size:`xs`,colorPalette:`orange`,variant:`subtle`,children:`Stale`}):e.isBlocked?(0,X.jsx)(N,{size:`xs`,colorPalette:`red`,variant:`subtle`,children:`Blocked`}):e.hasActiveJob?(0,X.jsx)(N,{size:`xs`,colorPalette:`green`,variant:`subtle`,children:`Active`}):(0,X.jsx)(N,{size:`xs`,colorPalette:`gray`,variant:`subtle`,children:`OK`})}),t&&(0,X.jsx)(E,{onClick:e=>e.stopPropagation(),children:(0,X.jsxs)(R,{gap:1,children:[e.isBlocked&&(0,X.jsx)(k,{variant:`outline`,size:`2xs`,colorPalette:`green`,onClick:()=>w.mutate({queueName:e.queueName,groupId:e.groupId}),loading:w.isPending,children:`Retry`}),(0,X.jsx)(k,{variant:`outline`,size:`2xs`,colorPalette:`red`,onClick:()=>S({queueName:e.queueName,groupId:e.groupId}),children:`Drain`})]})})]},`${e.queueName}:${e.groupId}`)})})]})}),h.length>100&&(0,X.jsx)(j,{padding:3,borderTop:`1px solid`,borderTopColor:`border`,children:(0,X.jsxs)(F,{textStyle:`xs`,color:`fg.muted`,textAlign:`center`,children:[`Showing 100 of `,h.length]})})]})]})}),(0,X.jsx)(Fe,{group:y,onClose:()=>b(null)}),(0,X.jsx)($,{open:!!x,onClose:()=>S(null),onConfirm:()=>{x&&C.mutate(x)},title:`Drain Group`,description:`Permanently remove all jobs from "${x?.groupId}". Cannot be undone.`,isLoading:C.isPending})]})}function Le({data:e}){let t=e.queues.reduce((e,t)=>e+t.blockedGroupCount,0),n=e.queues.reduce((e,t)=>e+t.dlqCount,0),r=q.ops.listQueues.useQuery(void 0,{refetchInterval:1e4}),i=(0,Y.useMemo)(()=>(r.data??[]).map(e=>e.name),[r.data]);return(0,X.jsxs)(K,{align:`stretch`,gap:5,width:`full`,children:[(0,X.jsx)(me,{data:e}),(0,X.jsxs)(te,{columns:{base:2,md:4,lg:7},gap:1,children:[(0,X.jsx)(Z,{label:`Staged/s`,value:W(e.throughputIngestedPerSec),sublabel:`peak ${W(e.peakIngestedPerSec)}`}),(0,X.jsx)(Z,{label:`Completed/s`,value:W(e.completedPerSec),sublabel:`${ce(e.totalCompleted)} total`}),(0,X.jsx)(Z,{label:`Failed/s`,value:W(e.failedPerSec),sublabel:e.totalFailed>0?`${ce(e.totalFailed)} total`:void 0,color:e.failedPerSec>0?`red.500`:void 0}),(0,X.jsx)(Z,{label:`Blocked`,value:t.toString(),sublabel:`${e.totalGroups} groups`,color:t>0?`red.500`:void 0}),(0,X.jsx)(Z,{label:`P50`,value:H(e.latencyP50Ms),sublabel:`peak ${H(e.peakLatencyP50Ms)}`}),(0,X.jsx)(Z,{label:`P99`,value:H(e.latencyP99Ms),sublabel:`peak ${H(e.peakLatencyP99Ms)}`}),(0,X.jsx)(Z,{label:`DLQ`,value:n.toString(),sublabel:e.redisMemoryUsed,color:n>0?`orange.500`:void 0})]}),(0,X.jsx)(z,{overflow:`hidden`,children:(0,X.jsxs)(B,{padding:4,children:[(0,X.jsx)(F,{textStyle:`xs`,fontWeight:`medium`,color:`fg.muted`,marginBottom:2,children:`Throughput`}),(0,X.jsx)(Te,{data:e})]})}),(0,X.jsx)(Me,{pipelineTree:e.pipelineTree,pausedKeys:e.pausedKeys,queueNames:i}),(0,X.jsxs)(z,{overflow:`hidden`,children:[(0,X.jsx)(R,{paddingX:4,paddingTop:3,paddingBottom:2,children:(0,X.jsx)(F,{textStyle:`xs`,fontWeight:`medium`,color:`fg.muted`,children:`Top Errors`})}),e.topErrors.length>0?(0,X.jsx)(a,{children:(0,X.jsxs)(D,{size:`sm`,variant:`line`,css:{"& tr:last-child td":{borderBottom:`none`}},children:[(0,X.jsx)(_,{children:(0,X.jsxs)(c,{children:[(0,X.jsx)(O,{width:`60px`,children:`Count`}),(0,X.jsx)(O,{children:`Error`}),(0,X.jsx)(O,{children:`Pipeline`})]})}),(0,X.jsx)(m,{children:e.topErrors.slice(0,5).map((e,t)=>(0,X.jsxs)(c,{children:[(0,X.jsx)(E,{children:(0,X.jsx)(F,{color:`red.500`,fontWeight:`medium`,children:e.count})}),(0,X.jsx)(E,{children:(0,X.jsx)(F,{truncate:!0,maxWidth:`400px`,children:e.sampleMessage})}),(0,X.jsx)(E,{color:`fg.muted`,children:e.pipelineName??`—`})]},t))})]})}):(0,X.jsx)(j,{paddingX:4,paddingBottom:4,children:(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:t>0?`0 errors`:`No errors`})})]}),(0,X.jsx)(Ne,{queueNames:i}),(0,X.jsx)(Pe,{queueNames:i}),(0,X.jsx)(Ie,{queueNames:i}),(0,X.jsx)(he,{})]})}var Re={connected:`green`,connecting:`orange`,disconnected:`red`},ze={connected:`Live`,connecting:`Connecting`,disconnected:`Disconnected`};function Be({status:e}){return(0,X.jsxs)(oe,{size:`sm`,colorPalette:Re[e],children:[(0,X.jsx)(U,{}),ze[e]]})}var Ve=300*1e3;function He(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(`connecting`),i=(0,Y.useRef)(1e3),a=(0,Y.useCallback)((e,n)=>{e===`dashboard`&&t(n)},[]),o=(0,Y.useRef)(a);return o.current=a,(0,Y.useEffect)(()=>{let e=null,t=!1,n=null;function a(){t||(r(`connecting`),e=new EventSource(`/api/ops/sse`),e.onopen=()=>{r(`connected`),i.current=1e3,n=setTimeout(()=>{!t&&e&&(e.close(),a())},Ve)},e.addEventListener(`dashboard`,e=>{try{o.current(`dashboard`,JSON.parse(e.data))}catch{}}),e.addEventListener(`heartbeat`,()=>{}),e.onerror=()=>{r(`disconnected`),e?.close(),n&&=(clearTimeout(n),null);let t=Math.min(i.current,3e4);i.current=t*2,setTimeout(a,t)})}return a(),()=>{t=!0,n&&clearTimeout(n),e?.close()}},[]),{data:e,status:n}}function Ue(){let{data:e,status:t}=He(),r=q.ops.getDashboardSnapshot.useQuery(void 0,{enabled:!e,refetchInterval:e?!1:5e3}),i=e??r.data??null;return(0,X.jsx)(fe,{children:(0,X.jsxs)(x,{children:[(0,X.jsxs)(l.Header,{children:[(0,X.jsx)(l.Heading,{children:`Ops Dashboard`}),(0,X.jsx)(V,{}),(0,X.jsx)(Be,{status:t})]}),(0,X.jsx)(l.Container,{children:i?(0,X.jsx)(Le,{data:i}):(0,X.jsx)(I,{paddingY:20,children:(0,X.jsx)(s,{children:(0,X.jsxs)(d,{children:[(0,X.jsx)(p,{children:(0,X.jsx)(A,{size:`lg`})}),(0,X.jsx)(n,{children:`Loading metrics`}),(0,X.jsx)(u,{children:`Waiting for the first collection cycle...`})]})})})})]})})}export{Ue as default};
2
- //# sourceMappingURL=ops-Cc-g-CMn.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$s as n,Aa as r,Cn as i,Cs as a,La as o,Qs as s,Ss as c,Xr as l,Xs as u,Ys as d,Zn as f,Zs as p,_s as m,ao as h,ar as g,bs as _,er as v,io as y,ir as b,mn as x,mr as S,rr as C,tr as w,vr as T,vs as E,xs as D,ys as O}from"./command-bar-DUK45yin.js";import{j as ee,n as k,r as A}from"./stack-oJ9iWdbl.js";import{t as j}from"./box-BsM8YLGl.js";import{n as M}from"./toaster-C_DYALhL.js";import{an as N,f as P}from"./dist-Cds4Mqhj.js";import{t as F}from"./text-CwTrMF8x.js";import{i as I}from"./code-FF_ibTVI.js";import{t as L}from"./input-C7emsUCL.js";import{t as R}from"./h-stack-BKLDJ2vg.js";import{r as z,t as B}from"./card-CMtKVPVl.js";import{t as te}from"./simple-grid-C3IW90zo.js";import{t as V}from"./spacer-2LJJGbo8.js";import{n as ne,r as re,t as ie}from"./stat-CHoKZ9Rr.js";import{a as H,c as U,i as ae,l as oe,n as se,o as W,r as ce,s as G,t as le}from"./ReplayStateBadge-ChyX1KUG.js";import{t as K}from"./v-stack-EOPQ57OZ.js";import{s as q}from"./auth-client-D3UhxhQi.js";import{t as ue}from"./createLucideIcon-BJKFyRLS.js";import{t as de}from"./arrow-up-right-Cmmi1ap5.js";import{t as J}from"./next-link-DuYeiiEe.js";import{t as fe}from"./OpsPageShell-C_mTziRS.js";var pe=ue(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Y=e(t()),X=ee();function me({data:e}){let t=se().data,n=t?.state===`running`,r=e.pausedKeys,i=r.length>0;return!n&&!i?null:(0,X.jsxs)(z,{overflow:`hidden`,children:[(0,X.jsx)(F,{textStyle:`xs`,fontWeight:`medium`,color:`fg.muted`,paddingX:4,paddingTop:3,paddingBottom:2,children:`Active Operations`}),(0,X.jsxs)(K,{align:`stretch`,gap:0,paddingX:4,paddingBottom:3,children:[n&&t&&(0,X.jsxs)(R,{gap:2,paddingY:2,borderBottom:i?`1px solid`:void 0,borderBottomColor:`border`,children:[(0,X.jsx)(oe,{colorPalette:`blue`,size:`sm`,children:(0,X.jsx)(U,{})}),(0,X.jsx)(F,{textStyle:`sm`,fontWeight:`medium`,children:`Replay running`}),t.currentProjection&&(0,X.jsx)(N,{size:`sm`,variant:`subtle`,colorPalette:`blue`,children:t.currentProjection}),(0,X.jsx)(V,{}),t.runId&&(0,X.jsx)(J,{href:`/ops/projections/${t.runId}`,style:{textDecoration:`none`},children:(0,X.jsx)(F,{textStyle:`xs`,color:`blue.500`,cursor:`pointer`,children:`View progress`})})]}),i&&(0,X.jsxs)(K,{align:`stretch`,gap:1,paddingY:2,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Paused pipelines`}),(0,X.jsx)(R,{gap:2,flexWrap:`wrap`,children:r.map(e=>(0,X.jsx)(N,{size:`sm`,colorPalette:`orange`,variant:`subtle`,children:e},e))})]})]})]})}function Z({label:e,value:t,sublabel:n,href:r,color:i}){let a=(0,X.jsxs)(ne,{cursor:r?`pointer`:void 0,_hover:r?{bg:`bg.subtle`}:void 0,borderRadius:`md`,padding:2,transition:`background 0.1s`,children:[(0,X.jsx)(ie,{children:(0,X.jsxs)(R,{gap:1,children:[(0,X.jsx)(F,{children:e}),r&&(0,X.jsx)(de,{size:10})]})}),(0,X.jsxs)(R,{gap:1.5,alignItems:`baseline`,children:[(0,X.jsx)(re,{color:i,children:t}),n&&(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,fontWeight:`normal`,children:n})]})]});return r?(0,X.jsx)(J,{href:r,style:{textDecoration:`none`},children:a}):a}function he(){let e=q.ops.getReplayHistory.useQuery(void 0,{refetchInterval:1e4}).data?.[0];return(0,X.jsxs)(z,{overflow:`hidden`,children:[(0,X.jsx)(J,{href:`/ops/projections`,style:{textDecoration:`none`},children:(0,X.jsxs)(R,{paddingX:4,paddingTop:3,paddingBottom:2,cursor:`pointer`,_hover:{color:`orange.500`},transition:`color 0.1s`,children:[(0,X.jsx)(F,{textStyle:`xs`,fontWeight:`medium`,color:`fg.muted`,children:`Latest Replay`}),(0,X.jsx)(de,{size:10})]})}),(0,X.jsx)(j,{paddingX:4,paddingBottom:4,children:e?(0,X.jsx)(J,{href:`/ops/projections/${e.runId}`,style:{textDecoration:`none`},children:(0,X.jsxs)(R,{gap:3,cursor:`pointer`,_hover:{opacity:.8},transition:`opacity 0.1s`,children:[(0,X.jsx)(N,{size:`sm`,variant:`subtle`,colorPalette:le(e.state),children:e.state}),(0,X.jsx)(F,{textStyle:`xs`,truncate:!0,maxWidth:`240px`,children:e.description||`—`}),(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:ae(e.startedAt,e.completedAt)}),(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,whiteSpace:`nowrap`,children:e.completedAt?new Date(e.completedAt).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`—`})]})}):(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`No replay history`})})]})}var Q={staged:{stroke:`#06b6d4`,fill:`#06b6d4`},completed:{stroke:`#22c55e`,fill:`#22c55e`},failed:{stroke:`#ef4444`,fill:`#ef4444`},pending:`#a78bfa`,blocked:`#f97316`},ge=[{label:`2s`,ms:0},{label:`5s`,ms:5e3},{label:`15s`,ms:15e3},{label:`30s`,ms:3e4},{label:`1m`,ms:6e4}];function _e(e,t){if(e.length===0)return[];if(t<=0)return e.map(e=>({timestamp:e.timestamp,staged:e.ingestedPerSec,completed:e.completedPerSec,failed:e.failedPerSec,pending:e.pendingCount,blocked:e.blockedCount}));let n=new Map;for(let r of e){let e=Math.floor(r.timestamp/t)*t,i=n.get(e);i?(i.sum.staged+=r.ingestedPerSec,i.sum.completed+=r.completedPerSec,i.sum.failed+=r.failedPerSec,i.sum.pending+=r.pendingCount,i.sum.blocked+=r.blockedCount,i.count++):n.set(e,{sum:{timestamp:e,staged:r.ingestedPerSec,completed:r.completedPerSec,failed:r.failedPerSec,pending:r.pendingCount,blocked:r.blockedCount},count:1})}let r=[];for(let[,{sum:e,count:t}]of n)r.push({timestamp:e.timestamp,staged:e.staged/t,completed:e.completed/t,failed:e.failed/t,pending:Math.round(e.pending/t),blocked:Math.round(e.blocked/t)});return r.sort((e,t)=>e.timestamp-t.timestamp),r}function ve(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function ye(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function be(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e===0?`0`:Number.isInteger(e)?e.toString():e.toFixed(1)}function xe(e){if(e.length<2)return[];let t=e[0].timestamp,n=e[e.length-1].timestamp,r=n-t,i=6e4;r>20*6e4?i=5*6e4:r>10*6e4&&(i=2*6e4);let a=Math.ceil(t/i)*i,o=[];for(let e=a;e<=n;e+=i)o.push(e);return o}function Se(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t,r;return r=n<=1?1:n<=2?2:n<=5?5:10,r*t}function Ce({active:e,payload:t,label:n}){if(!e||!t?.length||n==null)return null;let r=t.filter(e=>e.name!==`Pending`&&e.name!==`Blocked`),i=t.filter(e=>e.name===`Pending`||e.name===`Blocked`);return(0,X.jsxs)(j,{bg:`bg.panel`,borderWidth:`1px`,borderColor:`border`,borderRadius:`md`,padding:2,shadow:`md`,minWidth:`140px`,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:ye(n)}),r.map(e=>(0,X.jsxs)(R,{justify:`space-between`,gap:3,children:[(0,X.jsxs)(R,{gap:1.5,children:[(0,X.jsx)(j,{width:`6px`,height:`6px`,borderRadius:`full`,bg:e.color}),(0,X.jsx)(F,{textStyle:`xs`,children:e.name})]}),(0,X.jsxs)(F,{textStyle:`xs`,fontFamily:`mono`,fontWeight:`medium`,children:[e.value.toFixed(1),`/s`]})]},e.name)),i.length>0&&i.some(e=>e.value>0)&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{height:`1px`,bg:`border`,marginY:1}),i.map(e=>(0,X.jsxs)(R,{justify:`space-between`,gap:3,children:[(0,X.jsxs)(R,{gap:1.5,children:[(0,X.jsx)(j,{width:`6px`,height:`2px`,bg:e.color}),(0,X.jsx)(F,{textStyle:`xs`,children:e.name})]}),(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,children:e.value.toLocaleString()})]},e.name))]})]})}function we({showCounts:e}){return(0,X.jsx)(R,{gap:3,justify:`center`,paddingTop:2,children:[{name:`Staged/s`,color:Q.staged.stroke,type:`area`},{name:`Completed/s`,color:Q.completed.stroke,type:`area`},{name:`Failed/s`,color:Q.failed.stroke,type:`area`},...e?[{name:`Pending`,color:Q.pending,type:`line`},{name:`Blocked`,color:Q.blocked,type:`line`}]:[]].map(e=>(0,X.jsxs)(R,{gap:1,children:[e.type===`area`?(0,X.jsx)(j,{width:`6px`,height:`6px`,borderRadius:`full`,bg:e.color}):(0,X.jsx)(j,{width:`10px`,height:`2px`,bg:e.color,borderRadius:`full`,opacity:.7}),(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:e.name})]},e.name))})}function Te({data:e}){let t=(0,Y.useRef)(1),[n,r]=(0,Y.useState)(5e3),i=(0,Y.useMemo)(()=>_e(e.throughputHistory,n),[e.throughputHistory,n]),a=(0,Y.useMemo)(()=>xe(i),[i]),o=(0,Y.useMemo)(()=>{if(i.length===0)return 1;let e=0;for(let t of i)e=Math.max(e,t.staged,t.completed,t.failed);let n=Se(e*1.3);return(n>t.current*1.2||n<t.current*.5)&&(t.current=n),t.current},[i]),s=(0,Y.useMemo)(()=>i.some(e=>e.pending>0||e.blocked>0),[i]),c=(0,Y.useMemo)(()=>{if(!s)return 10;let e=0;for(let t of i)e=Math.max(e,t.pending,t.blocked);return e<=0?10:Se(e*1.3)},[i,s]);return i.length<2?(0,X.jsx)(I,{height:`280px`,children:(0,X.jsxs)(K,{gap:2,children:[(0,X.jsx)(A,{size:`sm`}),(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Collecting data...`})]})}):(0,X.jsxs)(K,{align:`stretch`,gap:0,children:[(0,X.jsxs)(R,{justify:`space-between`,paddingX:1,paddingBottom:1,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,fontStyle:`italic`,children:`events/s`}),(0,X.jsx)(R,{gap:.5,children:ge.map(e=>(0,X.jsx)(k,{size:`2xs`,variant:n===e.ms?`subtle`:`ghost`,colorPalette:n===e.ms?`orange`:`gray`,onClick:()=>r(e.ms),fontFamily:`mono`,minWidth:`auto`,paddingX:1.5,children:e.label},e.ms))}),s&&(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,fontStyle:`italic`,children:`count`})]}),(0,X.jsx)(T,{width:`100%`,height:280,children:(0,X.jsxs)(f,{data:i,margin:{top:8,right:s?4:12,bottom:4,left:-8},children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsxs)(`linearGradient`,{id:`gradStaged`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,X.jsx)(`stop`,{offset:`0%`,stopColor:Q.staged.fill,stopOpacity:.2}),(0,X.jsx)(`stop`,{offset:`100%`,stopColor:Q.staged.fill,stopOpacity:.02})]}),(0,X.jsxs)(`linearGradient`,{id:`gradCompleted`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,X.jsx)(`stop`,{offset:`0%`,stopColor:Q.completed.fill,stopOpacity:.2}),(0,X.jsx)(`stop`,{offset:`100%`,stopColor:Q.completed.fill,stopOpacity:.02})]}),(0,X.jsxs)(`linearGradient`,{id:`gradFailed`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,X.jsx)(`stop`,{offset:`0%`,stopColor:Q.failed.fill,stopOpacity:.25}),(0,X.jsx)(`stop`,{offset:`100%`,stopColor:Q.failed.fill,stopOpacity:.02})]})]}),(0,X.jsx)(g,{strokeDasharray:`3 3`,stroke:`var(--chakra-colors-border)`,strokeOpacity:.4,vertical:!1}),(0,X.jsx)(w,{dataKey:`timestamp`,type:`number`,domain:[`dataMin`,`dataMax`],scale:`time`,ticks:a,tickFormatter:ve,tick:{fontSize:10,fill:`var(--chakra-colors-fg-muted)`},axisLine:!1,tickLine:!1}),(0,X.jsx)(v,{yAxisId:`rate`,tick:{fontSize:10,fill:`var(--chakra-colors-fg-muted)`},axisLine:!1,tickLine:!1,width:40,domain:[0,o],allowDataOverflow:!0,tickFormatter:be}),s&&(0,X.jsx)(v,{yAxisId:`count`,orientation:`right`,tick:{fontSize:10,fill:`var(--chakra-colors-fg-muted)`},axisLine:!1,tickLine:!1,width:40,domain:[0,c],allowDataOverflow:!0,tickFormatter:be}),(0,X.jsx)(S,{content:(0,X.jsx)(Ce,{}),cursor:{stroke:`var(--chakra-colors-fg-muted)`,strokeWidth:1,strokeDasharray:`3 3`,strokeOpacity:.3}}),(0,X.jsx)(C,{yAxisId:`rate`,type:`monotone`,dataKey:`staged`,stroke:Q.staged.stroke,fill:`url(#gradStaged)`,strokeWidth:1.5,name:`Staged/s`,isAnimationActive:!1,dot:!1,activeDot:{r:3,strokeWidth:0}}),(0,X.jsx)(C,{yAxisId:`rate`,type:`monotone`,dataKey:`completed`,stroke:Q.completed.stroke,fill:`url(#gradCompleted)`,strokeWidth:1.5,name:`Completed/s`,isAnimationActive:!1,dot:!1,activeDot:{r:3,strokeWidth:0}}),(0,X.jsx)(C,{yAxisId:`rate`,type:`monotone`,dataKey:`failed`,stroke:Q.failed.stroke,fill:`url(#gradFailed)`,strokeWidth:1.5,name:`Failed/s`,isAnimationActive:!1,dot:!1,activeDot:{r:3,strokeWidth:0}}),(0,X.jsx)(b,{yAxisId:s?`count`:`rate`,type:`monotone`,dataKey:`pending`,stroke:Q.pending,strokeWidth:1,strokeOpacity:.6,strokeDasharray:`4 3`,dot:!1,activeDot:{r:2,strokeWidth:0},name:`Pending`,isAnimationActive:!1}),(0,X.jsx)(b,{yAxisId:s?`count`:`rate`,type:`monotone`,dataKey:`blocked`,stroke:Q.blocked,strokeWidth:1,strokeOpacity:.6,strokeDasharray:`4 3`,dot:!1,activeDot:{r:2,strokeWidth:0},name:`Blocked`,isAnimationActive:!1})]})}),(0,X.jsx)(we,{showCounts:s})]})}function Ee(e,t,n){let r=t?`${t}/${e.name}`:e.name;if(n.has(r))return!0;if(t){let e=t.split(`/`);for(let t=1;t<=e.length;t++){let r=e.slice(0,t).join(`/`);if(n.has(r))return!0}}return!1}function De(e,t){return t.has(e)}function Oe(e,t){if(!t.trim())return e;let n=t.toLowerCase();function r(e){if(e.name.toLowerCase().includes(n))return e;let t=e.children.map(r).filter(e=>e!==null);return t.length>0?{...e,children:t}:null}let i=e.map(r).filter(e=>e!==null);return i.length>0?i:null}function ke(e){return e===null?!1:Date.now()-e>300*1e3}function Ae(e,t){switch(t){case`all`:return!0;case`ok`:return!e.isBlocked&&!e.isStaleBlock;case`blocked`:return e.isBlocked&&!e.isStaleBlock;case`stale`:return e.isStaleBlock;case`active`:return e.hasActiveJob&&!e.isBlocked}}function je({node:e,parentPath:t,depth:n,pausedKeys:r,expandedPaths:i,onToggleExpand:a,onPause:s,onUnpause:c,hasAccess:l,queueNames:u}){let d=t?`${t}/${e.name}`:e.name,f=e.children.length>0,p=i.has(d),m=Ee(e,t,r),g=De(d,r),_=!f;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(R,{paddingY:1,paddingX:3,paddingLeft:`${n*20+12}px`,cursor:f?`pointer`:`default`,_hover:{bg:`bg.subtle`},onClick:()=>f&&a(d),borderBottom:`1px solid`,borderBottomColor:`border`,gap:2,opacity:m?.6:1,children:[(0,X.jsx)(j,{width:`14px`,flexShrink:0,children:f?p?(0,X.jsx)(h,{size:12}):(0,X.jsx)(y,{size:12}):null}),(0,X.jsx)(F,{textStyle:`xs`,fontWeight:n===0?`semibold`:`medium`,fontFamily:_?`mono`:void 0,flex:1,color:m?`orange.500`:void 0,children:e.name}),m&&(0,X.jsx)(N,{size:`xs`,colorPalette:`orange`,variant:`subtle`,children:`Paused`}),(0,X.jsxs)(R,{gap:1,flexShrink:0,children:[e.pending>0&&(0,X.jsx)(N,{size:`xs`,colorPalette:`blue`,variant:`subtle`,children:e.pending}),e.active>0&&(0,X.jsx)(N,{size:`xs`,colorPalette:`green`,variant:`subtle`,children:e.active}),e.blocked>0&&(0,X.jsx)(N,{size:`xs`,colorPalette:`red`,variant:`subtle`,children:e.blocked})]}),l&&(0,X.jsx)(j,{flexShrink:0,onClick:e=>e.stopPropagation(),children:g?(0,X.jsx)(k,{variant:`ghost`,size:`2xs`,colorPalette:`green`,onClick:()=>c(d),children:(0,X.jsx)(o,{size:10})}):m?null:(0,X.jsx)(k,{variant:`ghost`,size:`2xs`,colorPalette:`orange`,onClick:()=>s(d),children:(0,X.jsx)(pe,{size:10})})})]}),f&&p&&e.children.map(e=>(0,X.jsx)(je,{node:e,parentPath:d,depth:n+1,pausedKeys:r,expandedPaths:i,onToggleExpand:a,onPause:s,onUnpause:c,hasAccess:l,queueNames:u},e.name))]})}function Me({pipelineTree:e,pausedKeys:t,queueNames:n}){let{hasAccess:a}=i(),o=q.useContext(),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(()=>new Set),d=(0,Y.useMemo)(()=>new Set(t),[t]),f=(0,Y.useMemo)(()=>Oe(e,s),[e,s]),p=q.ops.pausePipeline.useMutation({onSuccess:()=>{M.create({title:`Pipeline paused`,type:`success`}),o.ops.invalidate()},onError:e=>{M.create({title:`Failed to pause`,description:e.message,type:`error`})}}),m=q.ops.unpausePipeline.useMutation({onSuccess:()=>{M.create({title:`Pipeline unpaused`,type:`success`}),o.ops.invalidate()},onError:e=>{M.create({title:`Failed to unpause`,description:e.message,type:`error`})}});function h(e){u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function g(){let t=new Set;function n(e,r){for(let i of e){let e=r?`${r}/${i.name}`:i.name;t.add(e),n(i.children,e)}}n(e,``),u(t)}let _=n[0];function v(e){_&&p.mutate({queueName:_,key:e})}function y(e){_&&m.mutate({queueName:_,key:e})}return(0,X.jsx)(z,{children:(0,X.jsxs)(B,{padding:0,children:[(0,X.jsxs)(R,{paddingX:4,paddingY:2.5,borderBottom:`1px solid`,borderBottomColor:`border`,children:[(0,X.jsx)(F,{textStyle:`sm`,fontWeight:`medium`,children:`Pipeline Tree`}),(0,X.jsx)(V,{}),e.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(j,{position:`relative`,width:`200px`,children:[(0,X.jsx)(j,{position:`absolute`,left:2.5,top:`50%`,transform:`translateY(-50%)`,zIndex:1,children:(0,X.jsx)(r,{size:11,color:`var(--chakra-colors-fg-muted)`})}),(0,X.jsx)(L,{size:`xs`,placeholder:`Filter...`,value:s,onChange:e=>c(e.target.value),paddingLeft:7})]}),(0,X.jsx)(k,{variant:`ghost`,size:`2xs`,onClick:g,children:`Expand all`}),(0,X.jsx)(k,{variant:`ghost`,size:`2xs`,onClick:()=>u(new Set),children:`Collapse`})]})]}),e.length===0?(0,X.jsx)(j,{padding:4,children:(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`No pipelines discovered yet.`})}):f===null?(0,X.jsx)(j,{padding:4,children:(0,X.jsxs)(F,{textStyle:`xs`,color:`fg.muted`,children:[`No pipelines match "`,s,`"`]})}):f.map(e=>(0,X.jsx)(je,{node:e,parentPath:``,depth:0,pausedKeys:d,expandedPaths:l,onToggleExpand:h,onPause:v,onUnpause:y,hasAccess:a,queueNames:n},e.name))]})})}function $({open:e,onClose:t,onConfirm:n,title:r,description:i,isLoading:a}){return(0,X.jsx)(P.Root,{open:e,onOpenChange:e=>!e.open&&t(),children:(0,X.jsxs)(P.Content,{children:[(0,X.jsx)(P.Header,{children:(0,X.jsx)(P.Title,{children:r})}),(0,X.jsx)(P.Body,{children:(0,X.jsx)(F,{textStyle:`sm`,children:i})}),(0,X.jsxs)(P.Footer,{children:[(0,X.jsx)(k,{variant:`outline`,size:`sm`,onClick:t,children:`Cancel`}),(0,X.jsx)(k,{colorPalette:`red`,size:`sm`,onClick:n,loading:a,children:`Confirm`})]}),(0,X.jsx)(P.CloseTrigger,{})]})})}function Ne({queueNames:e}){let{hasAccess:t}=i(),n=q.useContext(),r=q.ops.getBlockedSummary.useQuery(),o=q.ops.listQueues.useQuery(),[s,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(5),b=q.ops.unblockAll.useMutation({onSuccess:e=>{M.create({title:`Unblocked ${e.unblockedCount} groups`,type:`success`}),l(null),n.ops.invalidate()},onError:e=>{M.create({title:`Unblock failed`,description:e.message,type:`error`})}}),x=q.ops.drainGroup.useMutation({onSuccess:e=>{M.create({title:`Drained, removed ${e.jobsRemoved} jobs`,type:`success`}),d(null),n.ops.invalidate()},onError:e=>{M.create({title:`Drain failed`,description:e.message,type:`error`})}}),S=q.ops.moveAllBlockedToDlq.useMutation({onSuccess:e=>{M.create({title:`Moved ${e.movedCount} groups to DLQ`,type:`success`}),p(null),n.ops.invalidate()},onError:e=>{M.create({title:`Move to DLQ failed`,description:e.message,type:`error`})}}),C=q.ops.canaryUnblock.useMutation({onSuccess:e=>{M.create({title:`Canary unblocked ${e.unblockedCount}`,type:`success`}),g(null),n.ops.invalidate()},onError:e=>{M.create({title:`Canary failed`,description:e.message,type:`error`})}}),w=(o.data??[]).filter(e=>e.blockedGroupCount>0);return r.isLoading||!r.data||r.data.clusters.length===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{children:(0,X.jsxs)(B,{padding:0,children:[(0,X.jsxs)(R,{paddingX:4,paddingY:2.5,borderBottom:`1px solid`,borderBottomColor:`border`,gap:2,flexWrap:`wrap`,children:[(0,X.jsxs)(F,{textStyle:`sm`,fontWeight:`medium`,color:`red.500`,children:[`Blocked — `,r.data.totalBlocked,` groups, `,r.data.clusters.length,` error patterns`]}),(0,X.jsx)(V,{}),t&&(0,X.jsxs)(R,{gap:1.5,flexWrap:`wrap`,children:[w.map(e=>(0,X.jsxs)(k,{variant:`outline`,size:`2xs`,colorPalette:`orange`,onClick:()=>l(e.name),children:[`Unblock All (`,e.blockedGroupCount,`)`]},e.name)),w.map(e=>(0,X.jsx)(k,{variant:`outline`,size:`2xs`,colorPalette:`red`,onClick:()=>p(e.name),children:`→ DLQ`},`dlq-${e.name}`)),(0,X.jsxs)(R,{gap:1,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Canary:`}),(0,X.jsx)(L,{size:`xs`,type:`number`,value:v,onChange:e=>y(Math.max(1,Math.min(100,parseInt(e.target.value)||5))),width:`50px`}),w.map(e=>(0,X.jsx)(k,{variant:`ghost`,size:`2xs`,onClick:()=>g(e.name),children:`Go`},`c-${e.name}`))]})]})]}),(0,X.jsx)(a,{children:(0,X.jsxs)(D,{size:`sm`,variant:`line`,css:{"& tr:last-child td":{borderBottom:`none`}},children:[(0,X.jsx)(_,{children:(0,X.jsxs)(c,{children:[(0,X.jsx)(O,{width:`60px`,textAlign:`end`,children:`Count`}),(0,X.jsx)(O,{children:`Error`}),(0,X.jsx)(O,{children:`Pipeline`}),(0,X.jsx)(O,{children:`Sample Groups`}),(0,X.jsx)(O,{width:`60px`,children:`Actions`})]})}),(0,X.jsx)(m,{children:r.data.clusters.map((e,t)=>(0,X.jsxs)(c,{children:[(0,X.jsx)(E,{textAlign:`end`,children:(0,X.jsx)(F,{color:`red.500`,fontWeight:`medium`,textStyle:`xs`,children:e.count})}),(0,X.jsx)(E,{children:(0,X.jsx)(F,{textStyle:`xs`,truncate:!0,maxWidth:`300px`,title:e.sampleMessage,children:e.sampleMessage})}),(0,X.jsx)(E,{children:(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:e.pipelineName??`—`})}),(0,X.jsx)(E,{children:(0,X.jsxs)(F,{textStyle:`xs`,fontFamily:`mono`,truncate:!0,maxWidth:`160px`,children:[e.sampleGroupIds.slice(0,2).join(`, `),e.sampleGroupIds.length>2?` +${e.sampleGroupIds.length-2}`:``]})}),(0,X.jsx)(E,{children:e.sampleGroupIds[0]&&(0,X.jsx)(k,{variant:`outline`,size:`2xs`,colorPalette:`red`,onClick:()=>d({queueName:e.queueName,groupId:e.sampleGroupIds[0]}),children:`Drain`})})]},t))})]})})]})}),(0,X.jsx)($,{open:!!s,onClose:()=>l(null),onConfirm:()=>{s&&b.mutate({queueName:s})},title:`Unblock All`,description:`Unblock all blocked groups in "${s}". They will retry immediately.`,isLoading:b.isPending}),(0,X.jsx)($,{open:!!u,onClose:()=>d(null),onConfirm:()=>{u&&x.mutate(u)},title:`Drain Group`,description:`Permanently remove all jobs from "${u?.groupId}". Cannot be undone.`,isLoading:x.isPending}),(0,X.jsx)($,{open:!!f,onClose:()=>p(null),onConfirm:()=>{f&&S.mutate({queueName:f})},title:`Move All to DLQ`,description:`Move all blocked groups in "${f}" to DLQ. They can be replayed later.`,isLoading:S.isPending}),(0,X.jsx)($,{open:!!h,onClose:()=>g(null),onConfirm:()=>{h&&C.mutate({queueName:h,count:v})},title:`Canary Unblock`,description:`Unblock ${v} random groups in "${h}" as a canary test.`,isLoading:C.isPending})]})}function Pe({queueNames:e}){let{hasAccess:t}=i(),n=q.useContext(),r=q.ops.listAllDlqGroups.useQuery(void 0,{refetchInterval:1e4}),[o,s]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),[p,h]=(0,Y.useState)(5),g=q.ops.replayFromDlq.useMutation({onSuccess:e=>{M.create({title:`Replayed ${e.jobsReplayed} jobs`,type:`success`}),s(null),n.ops.invalidate()},onError:e=>{M.create({title:`Replay failed`,description:e.message,type:`error`})}}),v=q.ops.replayAllFromDlq.useMutation({onSuccess:e=>{M.create({title:`Replayed ${e.replayedCount} groups`,type:`success`}),u(null),n.ops.invalidate()},onError:e=>{M.create({title:`Replay all failed`,description:e.message,type:`error`})}}),y=q.ops.canaryRedrive.useMutation({onSuccess:e=>{M.create({title:`Canary redrove ${e.redrivenCount}`,type:`success`}),f(null),n.ops.invalidate()},onError:e=>{M.create({title:`Canary failed`,description:e.message,type:`error`})}}),b=r.data??[],x=[...new Set(b.map(e=>e.queueName))];return r.isLoading||b.length===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{children:(0,X.jsxs)(B,{padding:0,children:[(0,X.jsxs)(R,{paddingX:4,paddingY:2.5,borderBottom:`1px solid`,borderBottomColor:`border`,gap:2,flexWrap:`wrap`,children:[(0,X.jsxs)(F,{textStyle:`sm`,fontWeight:`medium`,color:`orange.500`,children:[`Dead Letter Queue — `,b.length,` group`,b.length===1?``:`s`]}),(0,X.jsx)(V,{}),t&&(0,X.jsxs)(R,{gap:1.5,flexWrap:`wrap`,children:[x.map(e=>{let t=b.filter(t=>t.queueName===e).length;return(0,X.jsxs)(k,{variant:`outline`,size:`2xs`,colorPalette:`green`,onClick:()=>u(e),children:[`Replay All `,b.find(t=>t.queueName===e)?.queueDisplayName??e,` (`,t,`)`]},e)}),(0,X.jsxs)(R,{gap:1,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Canary:`}),(0,X.jsx)(L,{size:`xs`,type:`number`,value:p,onChange:e=>h(Math.max(1,Math.min(100,parseInt(e.target.value)||5))),width:`50px`}),x.map(e=>(0,X.jsx)(k,{variant:`ghost`,size:`2xs`,onClick:()=>f(e),children:`Go`},`c-${e}`))]})]})]}),(0,X.jsx)(a,{children:(0,X.jsxs)(D,{size:`sm`,variant:`line`,css:{"& tr:last-child td":{borderBottom:`none`}},children:[(0,X.jsx)(_,{children:(0,X.jsxs)(c,{children:[(0,X.jsx)(O,{children:`Queue`}),(0,X.jsx)(O,{children:`Group ID`}),(0,X.jsx)(O,{children:`Pipeline`}),(0,X.jsx)(O,{children:`Error`}),(0,X.jsx)(O,{textAlign:`end`,width:`50px`,children:`Jobs`}),t&&(0,X.jsx)(O,{width:`70px`,children:`Actions`})]})}),(0,X.jsx)(m,{children:b.map(e=>(0,X.jsxs)(c,{children:[(0,X.jsx)(E,{children:(0,X.jsx)(N,{size:`xs`,variant:`subtle`,children:e.queueDisplayName})}),(0,X.jsx)(E,{children:(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,truncate:!0,maxWidth:`160px`,children:e.groupId})}),(0,X.jsx)(E,{children:(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:e.pipelineName??`—`})}),(0,X.jsx)(E,{children:(0,X.jsx)(F,{textStyle:`xs`,color:`red.500`,truncate:!0,maxWidth:`220px`,title:e.error??void 0,children:e.error??``})}),(0,X.jsx)(E,{textAlign:`end`,children:(0,X.jsx)(F,{textStyle:`xs`,children:e.jobCount})}),t&&(0,X.jsx)(E,{children:(0,X.jsx)(k,{variant:`outline`,size:`2xs`,colorPalette:`green`,onClick:()=>s({queueName:e.queueName,groupId:e.groupId}),children:`Replay`})})]},`${e.queueName}:${e.groupId}`))})]})})]})}),(0,X.jsx)($,{open:!!o,onClose:()=>s(null),onConfirm:()=>{o&&g.mutate(o)},title:`Replay from DLQ`,description:`Move "${o?.groupId}" back to main queue for reprocessing.`,isLoading:g.isPending}),(0,X.jsx)($,{open:!!l,onClose:()=>u(null),onConfirm:()=>{l&&v.mutate({queueName:l})},title:`Replay All from DLQ`,description:`Move all DLQ groups in "${l}" back to main queue.`,isLoading:v.isPending}),(0,X.jsx)($,{open:!!d,onClose:()=>f(null),onConfirm:()=>{d&&y.mutate({queueName:d,count:p})},title:`Canary Redrive`,description:`Replay ${p} random DLQ groups from "${d}" as canary.`,isLoading:y.isPending})]})}function Fe({group:e,onClose:t}){let n=q.ops.getGroupDetail.useQuery({queueName:e?.queueName??``,groupId:e?.groupId??``},{enabled:!!e}),r=q.ops.getGroupJobs.useQuery({queueName:e?.queueName??``,groupId:e?.groupId??``,page:1,pageSize:20},{enabled:!!e}),i=n.data,a=r.data;return(0,X.jsx)(P.Root,{open:!!e,onOpenChange:e=>!e.open&&t(),size:`lg`,children:(0,X.jsxs)(P.Content,{children:[(0,X.jsx)(P.Header,{children:(0,X.jsx)(P.Title,{children:(0,X.jsx)(F,{textStyle:`sm`,fontFamily:`mono`,wordBreak:`break-all`,children:e?.groupId})})}),(0,X.jsx)(P.Body,{children:n.isLoading?(0,X.jsx)(I,{paddingY:6,children:(0,X.jsx)(A,{size:`sm`})}):i?(0,X.jsxs)(K,{align:`stretch`,gap:4,children:[(0,X.jsxs)(R,{gap:4,flexWrap:`wrap`,children:[(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Status`}),i.isStaleBlock?(0,X.jsx)(N,{size:`sm`,colorPalette:`orange`,variant:`subtle`,children:`Stale`}):i.isBlocked?(0,X.jsx)(N,{size:`sm`,colorPalette:`red`,variant:`subtle`,children:`Blocked`}):i.hasActiveJob?(0,X.jsx)(N,{size:`sm`,colorPalette:`green`,variant:`subtle`,children:`Active`}):(0,X.jsx)(N,{size:`sm`,colorPalette:`gray`,variant:`subtle`,children:`OK`})]}),(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Pipeline`}),(0,X.jsx)(F,{textStyle:`sm`,children:i.pipelineName??`—`})]}),(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Pending`}),(0,X.jsx)(F,{textStyle:`sm`,fontFamily:`mono`,children:i.pendingJobs})]}),(i.retryCount??0)>0&&(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Retries`}),(0,X.jsx)(F,{textStyle:`sm`,fontFamily:`mono`,color:`orange.500`,children:i.retryCount})]}),i.activeJobId&&(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Active Job`}),(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,color:`green.500`,children:i.activeJobId})]})]}),(0,X.jsxs)(R,{gap:4,children:[(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Oldest Job`}),(0,X.jsx)(F,{textStyle:`sm`,children:G(i.oldestJobMs)})]}),(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Newest Job`}),(0,X.jsx)(F,{textStyle:`sm`,children:G(i.newestJobMs)})]}),i.processingDurationMs!=null&&(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Processing`}),(0,X.jsxs)(F,{textStyle:`sm`,children:[i.processingDurationMs,`ms`]})]})]}),i.errorMessage&&(0,X.jsxs)(K,{align:`stretch`,gap:1,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Error`}),(0,X.jsx)(z,{borderColor:`red.500/20`,children:(0,X.jsxs)(B,{padding:3,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`red.500`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,children:i.errorMessage}),i.errorStack&&(0,X.jsx)(j,{marginTop:2,maxHeight:`200px`,overflow:`auto`,bg:`bg.subtle`,borderRadius:`sm`,padding:2,children:(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,color:`fg.muted`,whiteSpace:`pre`,fontSize:`10px`,children:i.errorStack})})]})})]}),(0,X.jsxs)(K,{align:`stretch`,gap:1,children:[(0,X.jsxs)(F,{textStyle:`xs`,color:`fg.muted`,children:[`Jobs `,a?`(${a.total})`:``]}),r.isLoading?(0,X.jsx)(A,{size:`xs`}):a&&a.jobs.length>0?(0,X.jsx)(K,{align:`stretch`,gap:2,children:a.jobs.map(e=>(0,X.jsx)(z,{variant:`outline`,children:(0,X.jsxs)(B,{padding:3,children:[(0,X.jsxs)(R,{gap:3,marginBottom:e.data?2:0,children:[(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Job ID`}),(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,wordBreak:`break-all`,children:e.jobId})]}),(0,X.jsxs)(K,{align:`start`,gap:0,children:[(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`Score`}),(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,children:e.score})]})]}),e.data&&(0,X.jsx)(j,{bg:`bg.subtle`,borderRadius:`sm`,padding:2,maxHeight:`200px`,overflow:`auto`,children:(0,X.jsx)(F,{as:`pre`,textStyle:`xs`,fontFamily:`mono`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,fontSize:`11px`,children:JSON.stringify(e.data,null,2)})})]})},e.jobId))}):(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`No jobs in queue.`})]})]}):null}),(0,X.jsx)(P.CloseTrigger,{})]})})}function Ie({queueNames:e}){let{hasAccess:t}=i(),n=q.useContext(),[o,s]=(0,Y.useState)(`all`),[l,u]=(0,Y.useState)(``),d=e[0],f=q.ops.listGroups.useQuery({queueName:d??``,page:1,pageSize:200},{refetchInterval:1e4,enabled:!!d}),p=(0,Y.useMemo)(()=>{let e=[];if(f.data&&d)for(let t of f.data.groups)e.push({...t,queueName:d});return e},[f.data,d]),h=(0,Y.useMemo)(()=>{let e=p;if(o!==`all`&&(e=e.filter(e=>Ae(e,o))),l.trim()){let t=l.toLowerCase();e=e.filter(e=>e.groupId.toLowerCase().includes(t)||e.pipelineName?.toLowerCase().includes(t)||e.errorMessage?.toLowerCase().includes(t))}return e},[p,o,l]),g=(0,Y.useMemo)(()=>{let e=0,t=0,n=0,r=0;for(let i of p)i.isStaleBlock?n++:i.isBlocked?t++:e++,i.hasActiveJob&&!i.isBlocked&&r++;return{all:p.length,ok:e,blocked:t,stale:n,active:r}},[p]),v=!!d&&f.isLoading,[y,b]=(0,Y.useState)(null),[x,S]=(0,Y.useState)(null),C=q.ops.drainGroup.useMutation({onSuccess:e=>{M.create({title:`Drained, removed ${e.jobsRemoved} jobs`,type:`success`}),S(null),n.ops.invalidate()},onError:e=>{M.create({title:`Failed to drain`,description:e.message,type:`error`})}}),w=q.ops.unblockGroup.useMutation({onSuccess:()=>{M.create({title:`Group unblocked`,type:`success`}),n.ops.invalidate()},onError:e=>{M.create({title:`Failed to unblock`,description:e.message,type:`error`})}}),T=[{value:`all`,label:`All`,count:g.all,color:`gray`},{value:`ok`,label:`OK`,count:g.ok,color:`green`},{value:`blocked`,label:`Blocked`,count:g.blocked,color:`red`},{value:`stale`,label:`Stale`,count:g.stale,color:`orange`},{value:`active`,label:`Active`,count:g.active,color:`blue`}];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{children:(0,X.jsxs)(B,{padding:0,children:[(0,X.jsxs)(R,{paddingX:4,paddingY:2.5,borderBottom:`1px solid`,borderBottomColor:`border`,gap:2,flexWrap:`wrap`,children:[(0,X.jsx)(F,{textStyle:`sm`,fontWeight:`medium`,children:`Groups`}),(0,X.jsx)(V,{}),p.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R,{gap:1,children:T.map(e=>(0,X.jsxs)(k,{size:`2xs`,variant:o===e.value?`solid`:`ghost`,colorPalette:e.color,onClick:()=>s(e.value),children:[e.label,` `,e.count>0?`(${e.count})`:``]},e.value))}),(0,X.jsxs)(j,{position:`relative`,width:`200px`,children:[(0,X.jsx)(j,{position:`absolute`,left:2.5,top:`50%`,transform:`translateY(-50%)`,zIndex:1,children:(0,X.jsx)(r,{size:11,color:`var(--chakra-colors-fg-muted)`})}),(0,X.jsx)(L,{size:`xs`,placeholder:`Search...`,value:l,onChange:e=>u(e.target.value),paddingLeft:7})]})]})]}),v?(0,X.jsx)(I,{paddingY:6,children:(0,X.jsx)(A,{size:`sm`})}):p.length===0?(0,X.jsx)(j,{padding:4,children:(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`No groups — queues are idle.`})}):h.length===0?(0,X.jsx)(j,{padding:4,children:(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:`No groups match current filters.`})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(a,{children:(0,X.jsxs)(D,{size:`sm`,variant:`line`,css:{"& tr:last-child td":{borderBottom:`none`}},children:[(0,X.jsx)(_,{children:(0,X.jsxs)(c,{children:[(0,X.jsx)(O,{children:`Group ID`}),(0,X.jsx)(O,{width:`140px`,children:`Pipeline`}),(0,X.jsx)(O,{textAlign:`end`,width:`50px`,children:`Pend.`}),(0,X.jsx)(O,{textAlign:`end`,width:`45px`,children:`Retry`}),(0,X.jsx)(O,{width:`75px`,children:`Oldest`}),(0,X.jsx)(O,{width:`65px`,children:`Status`}),t&&(0,X.jsx)(O,{width:`100px`,children:`Actions`})]})}),(0,X.jsx)(m,{children:h.slice(0,100).map(e=>{let n=!e.isBlocked&&ke(e.oldestJobMs);return(0,X.jsxs)(c,{cursor:`pointer`,_hover:{bg:`bg.subtle`},onClick:()=>b({queueName:e.queueName,groupId:e.groupId}),children:[(0,X.jsx)(E,{children:(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,truncate:!0,title:e.groupId,children:e.groupId})}),(0,X.jsx)(E,{children:(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,truncate:!0,children:e.pipelineName??`—`})}),(0,X.jsx)(E,{textAlign:`end`,children:(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,children:e.pendingJobs})}),(0,X.jsx)(E,{textAlign:`end`,children:(e.retryCount??0)>0?(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,color:`orange.500`,children:e.retryCount}):(0,X.jsx)(F,{textStyle:`xs`,fontFamily:`mono`,color:`fg.muted`,children:`—`})}),(0,X.jsx)(E,{children:(0,X.jsxs)(F,{textStyle:`xs`,color:n?`orange.500`:`fg.muted`,fontWeight:n?`medium`:void 0,children:[G(e.oldestJobMs),n?` ⚠`:``]})}),(0,X.jsx)(E,{children:e.isStaleBlock?(0,X.jsx)(N,{size:`xs`,colorPalette:`orange`,variant:`subtle`,children:`Stale`}):e.isBlocked?(0,X.jsx)(N,{size:`xs`,colorPalette:`red`,variant:`subtle`,children:`Blocked`}):e.hasActiveJob?(0,X.jsx)(N,{size:`xs`,colorPalette:`green`,variant:`subtle`,children:`Active`}):(0,X.jsx)(N,{size:`xs`,colorPalette:`gray`,variant:`subtle`,children:`OK`})}),t&&(0,X.jsx)(E,{onClick:e=>e.stopPropagation(),children:(0,X.jsxs)(R,{gap:1,children:[e.isBlocked&&(0,X.jsx)(k,{variant:`outline`,size:`2xs`,colorPalette:`green`,onClick:()=>w.mutate({queueName:e.queueName,groupId:e.groupId}),loading:w.isPending,children:`Retry`}),(0,X.jsx)(k,{variant:`outline`,size:`2xs`,colorPalette:`red`,onClick:()=>S({queueName:e.queueName,groupId:e.groupId}),children:`Drain`})]})})]},`${e.queueName}:${e.groupId}`)})})]})}),h.length>100&&(0,X.jsx)(j,{padding:3,borderTop:`1px solid`,borderTopColor:`border`,children:(0,X.jsxs)(F,{textStyle:`xs`,color:`fg.muted`,textAlign:`center`,children:[`Showing 100 of `,h.length]})})]})]})}),(0,X.jsx)(Fe,{group:y,onClose:()=>b(null)}),(0,X.jsx)($,{open:!!x,onClose:()=>S(null),onConfirm:()=>{x&&C.mutate(x)},title:`Drain Group`,description:`Permanently remove all jobs from "${x?.groupId}". Cannot be undone.`,isLoading:C.isPending})]})}function Le({data:e}){let t=e.queues.reduce((e,t)=>e+t.blockedGroupCount,0),n=e.queues.reduce((e,t)=>e+t.dlqCount,0),r=q.ops.listQueues.useQuery(void 0,{refetchInterval:1e4}),i=(0,Y.useMemo)(()=>(r.data??[]).map(e=>e.name),[r.data]);return(0,X.jsxs)(K,{align:`stretch`,gap:5,width:`full`,children:[(0,X.jsx)(me,{data:e}),(0,X.jsxs)(te,{columns:{base:2,md:4,lg:7},gap:1,children:[(0,X.jsx)(Z,{label:`Staged/s`,value:W(e.throughputIngestedPerSec),sublabel:`peak ${W(e.peakIngestedPerSec)}`}),(0,X.jsx)(Z,{label:`Completed/s`,value:W(e.completedPerSec),sublabel:`${ce(e.totalCompleted)} total`}),(0,X.jsx)(Z,{label:`Failed/s`,value:W(e.failedPerSec),sublabel:e.totalFailed>0?`${ce(e.totalFailed)} total`:void 0,color:e.failedPerSec>0?`red.500`:void 0}),(0,X.jsx)(Z,{label:`Blocked`,value:t.toString(),sublabel:`${e.totalGroups} groups`,color:t>0?`red.500`:void 0}),(0,X.jsx)(Z,{label:`P50`,value:H(e.latencyP50Ms),sublabel:`peak ${H(e.peakLatencyP50Ms)}`}),(0,X.jsx)(Z,{label:`P99`,value:H(e.latencyP99Ms),sublabel:`peak ${H(e.peakLatencyP99Ms)}`}),(0,X.jsx)(Z,{label:`DLQ`,value:n.toString(),sublabel:e.redisMemoryUsed,color:n>0?`orange.500`:void 0})]}),(0,X.jsx)(z,{overflow:`hidden`,children:(0,X.jsxs)(B,{padding:4,children:[(0,X.jsx)(F,{textStyle:`xs`,fontWeight:`medium`,color:`fg.muted`,marginBottom:2,children:`Throughput`}),(0,X.jsx)(Te,{data:e})]})}),(0,X.jsx)(Me,{pipelineTree:e.pipelineTree,pausedKeys:e.pausedKeys,queueNames:i}),(0,X.jsxs)(z,{overflow:`hidden`,children:[(0,X.jsx)(R,{paddingX:4,paddingTop:3,paddingBottom:2,children:(0,X.jsx)(F,{textStyle:`xs`,fontWeight:`medium`,color:`fg.muted`,children:`Top Errors`})}),e.topErrors.length>0?(0,X.jsx)(a,{children:(0,X.jsxs)(D,{size:`sm`,variant:`line`,css:{"& tr:last-child td":{borderBottom:`none`}},children:[(0,X.jsx)(_,{children:(0,X.jsxs)(c,{children:[(0,X.jsx)(O,{width:`60px`,children:`Count`}),(0,X.jsx)(O,{children:`Error`}),(0,X.jsx)(O,{children:`Pipeline`})]})}),(0,X.jsx)(m,{children:e.topErrors.slice(0,5).map((e,t)=>(0,X.jsxs)(c,{children:[(0,X.jsx)(E,{children:(0,X.jsx)(F,{color:`red.500`,fontWeight:`medium`,children:e.count})}),(0,X.jsx)(E,{children:(0,X.jsx)(F,{truncate:!0,maxWidth:`400px`,children:e.sampleMessage})}),(0,X.jsx)(E,{color:`fg.muted`,children:e.pipelineName??`—`})]},t))})]})}):(0,X.jsx)(j,{paddingX:4,paddingBottom:4,children:(0,X.jsx)(F,{textStyle:`xs`,color:`fg.muted`,children:t>0?`0 errors`:`No errors`})})]}),(0,X.jsx)(Ne,{queueNames:i}),(0,X.jsx)(Pe,{queueNames:i}),(0,X.jsx)(Ie,{queueNames:i}),(0,X.jsx)(he,{})]})}var Re={connected:`green`,connecting:`orange`,disconnected:`red`},ze={connected:`Live`,connecting:`Connecting`,disconnected:`Disconnected`};function Be({status:e}){return(0,X.jsxs)(oe,{size:`sm`,colorPalette:Re[e],children:[(0,X.jsx)(U,{}),ze[e]]})}var Ve=300*1e3;function He(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(`connecting`),i=(0,Y.useRef)(1e3),a=(0,Y.useCallback)((e,n)=>{e===`dashboard`&&t(n)},[]),o=(0,Y.useRef)(a);return o.current=a,(0,Y.useEffect)(()=>{let e=null,t=!1,n=null;function a(){t||(r(`connecting`),e=new EventSource(`/api/ops/sse`),e.onopen=()=>{r(`connected`),i.current=1e3,n=setTimeout(()=>{!t&&e&&(e.close(),a())},Ve)},e.addEventListener(`dashboard`,e=>{try{o.current(`dashboard`,JSON.parse(e.data))}catch{}}),e.addEventListener(`heartbeat`,()=>{}),e.onerror=()=>{r(`disconnected`),e?.close(),n&&=(clearTimeout(n),null);let t=Math.min(i.current,3e4);i.current=t*2,setTimeout(a,t)})}return a(),()=>{t=!0,n&&clearTimeout(n),e?.close()}},[]),{data:e,status:n}}function Ue(){let{data:e,status:t}=He(),r=q.ops.getDashboardSnapshot.useQuery(void 0,{enabled:!e,refetchInterval:e?!1:5e3}),i=e??r.data??null;return(0,X.jsx)(fe,{children:(0,X.jsxs)(x,{children:[(0,X.jsxs)(l.Header,{children:[(0,X.jsx)(l.Heading,{children:`Ops Dashboard`}),(0,X.jsx)(V,{}),(0,X.jsx)(Be,{status:t})]}),(0,X.jsx)(l.Container,{children:i?(0,X.jsx)(Le,{data:i}):(0,X.jsx)(I,{paddingY:20,children:(0,X.jsx)(s,{children:(0,X.jsxs)(d,{children:[(0,X.jsx)(p,{children:(0,X.jsx)(A,{size:`lg`})}),(0,X.jsx)(n,{children:`Loading metrics`}),(0,X.jsx)(u,{children:`Waiting for the first collection cycle...`})]})})})})]})})}export{Ue as default};
2
+ //# sourceMappingURL=ops-CCw-FJaT.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Do as n,Ra as r,Ss as i,Xa as a,_s as o,bs as s,ga as c,qi as l,vs as u,xs as d,ys as f}from"./command-bar-CaJygoez.js";import{j as p,n as m}from"./stack-oJ9iWdbl.js";import{t as h}from"./box-BsM8YLGl.js";import{n as g}from"./toaster-C_DYALhL.js";import{n as _,r as v,t as y}from"./native-select-B51i56CE.js";import{t as b}from"./text-CwTrMF8x.js";import{a as x,n as S,r as C}from"./field-CnUiixMS.js";import{t as w}from"./input-C7emsUCL.js";import{t as T}from"./h-stack-BKLDJ2vg.js";import{t as E}from"./spacer-2LJJGbo8.js";import{t as D}from"./v-stack-EOPQ57OZ.js";import{a as O,c as k,n as A,o as j,r as M,s as N,t as P,u as F}from"./useAdminResource-SPC5iBHM.js";var I=e(t()),L=p(),R=25;function z(){let[e,t]=(0,I.useState)(1),[n,p]=(0,I.useState)(``),[m]=c(n,300),[g,_]=(0,I.useState)(null),[v,y]=(0,I.useState)(!1),x=A(`organizationFeature`,{pagination:{page:e,perPage:R},sort:{field:`createdAt`,order:`DESC`},filter:m?{query:m}:{}}),S=A(`organization`,{pagination:{page:1,perPage:200},sort:{field:`name`,order:`ASC`},filter:{}}),C=(0,I.useMemo)(()=>{let e=new Map;for(let t of S.data?.data??[])e.set(t.id,t.name);return e},[S.data]);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(O,{title:`Organization Features`,searchValue:n,onSearchChange:e=>{p(e),t(1)},searchPlaceholder:`Search by ID, feature, or organization`,isLoading:x.isLoading,isFetching:x.isFetching,error:x.error,pagination:{page:e,perPage:R,total:x.data?.total??0,onPageChange:t},onCreate:()=>y(!0),createLabel:`Grant feature`,children:(0,L.jsxs)(d,{variant:`line`,size:`md`,width:`full`,children:[(0,L.jsx)(s,{children:(0,L.jsxs)(i,{children:[(0,L.jsx)(f,{children:`Feature`}),(0,L.jsx)(f,{children:`Organization`}),(0,L.jsx)(f,{children:`Trial ends`}),(0,L.jsx)(f,{children:`Created`}),(0,L.jsx)(f,{width:`60px`,textAlign:`right`})]})}),(0,L.jsxs)(o,{children:[x.data?.data.length===0&&(0,L.jsx)(i,{children:(0,L.jsx)(u,{colSpan:5,children:(0,L.jsx)(b,{color:`fg.muted`,textAlign:`center`,paddingY:6,children:`No organization features yet.`})})}),x.data?.data.map(e=>{let t=e.organization?.name??C.get(e.organizationId);return(0,L.jsxs)(i,{children:[(0,L.jsx)(u,{children:e.feature}),(0,L.jsx)(u,{children:t??(0,L.jsx)(b,{fontSize:`xs`,color:`fg.muted`,children:e.organizationId})}),(0,L.jsx)(u,{children:e.trialEndDate?k(e.trialEndDate):(0,L.jsx)(j,{children:`Permanent`})}),(0,L.jsx)(u,{children:k(e.createdAt)}),(0,L.jsx)(u,{textAlign:`right`,children:(0,L.jsx)(h,{width:`full`,height:`full`,display:`flex`,justifyContent:`end`,children:(0,L.jsxs)(l.Root,{children:[(0,L.jsx)(l.Trigger,{children:(0,L.jsx)(a,{size:16})}),(0,L.jsx)(l.Content,{children:(0,L.jsxs)(l.Item,{value:`edit`,onClick:()=>_(e),children:[(0,L.jsx)(r,{size:16}),`Edit`]})})]})})})]},e.id)})]})]})}),(0,L.jsx)(V,{mode:`edit`,item:g,onClose:()=>_(null)}),(0,L.jsx)(V,{mode:`create`,item:v?null:void 0,onClose:()=>y(!1)})]})}function B(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,10)}function V({mode:e,item:t,onClose:r}){let i=M(`organizationFeature`),a=P(`organizationFeature`),o=e===`edit`?i:a,[s,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),[f,p]=(0,I.useState)(``),[h,O]=(0,I.useState)(``),[k]=c(h,250),j=e===`edit`?!!t:t!==void 0;(0,I.useEffect)(()=>{j&&(e===`edit`&&t?(l(t.feature),d(t.organizationId),p(B(t.trialEndDate))):e===`create`&&(l(``),d(``),p(``),O(``)))},[j,e,t]);let F=A(`organization`,{pagination:{page:1,perPage:50},sort:{field:`name`,order:`ASC`},filter:k?{query:k}:{}},{enabled:j}),R=(0,I.useMemo)(()=>F.data?.data??[],[F.data]),z=()=>{if(!s.trim()){g.create({title:`Feature is required`,type:`error`,duration:3e3,meta:{closable:!0}});return}if(!u){g.create({title:`Organization is required`,type:`error`,duration:3e3,meta:{closable:!0}});return}let n={feature:s.trim(),organizationId:u,trialEndDate:N(f)},o=()=>{g.create({title:e===`edit`?`Feature updated`:`Feature granted`,type:`success`,duration:3e3,meta:{closable:!0}}),r()},c=t=>g.create({title:e===`edit`?`Update failed`:`Grant failed`,description:t.message,type:`error`,duration:5e3,meta:{closable:!0}});e===`edit`&&t?i.mutate({id:t.id,data:n},{onSuccess:o,onError:c}):a.mutate(n,{onSuccess:o,onError:c})},V=e===`edit`?`Edit Organization Feature`:`Grant Feature`;return(0,L.jsx)(n.Root,{open:j,onOpenChange:({open:e})=>{e||r()},size:`md`,children:(0,L.jsxs)(n.Content,{children:[(0,L.jsx)(n.Header,{children:(0,L.jsx)(n.Title,{children:V})}),(0,L.jsx)(n.CloseTrigger,{}),(0,L.jsx)(n.Body,{children:(0,L.jsxs)(D,{gap:4,align:`stretch`,children:[(0,L.jsxs)(x,{required:!0,children:[(0,L.jsx)(C,{children:`Feature`}),(0,L.jsx)(w,{value:s,onChange:e=>l(e.target.value),placeholder:`e.g. CUSTOM_EMBEDDINGS`}),(0,L.jsx)(S,{children:`Free-form feature key consumed by the entitlement checker.`})]}),(0,L.jsxs)(x,{required:!0,children:[(0,L.jsx)(C,{children:`Organization`}),e===`edit`&&t?.organization?.name&&!h&&(0,L.jsxs)(b,{fontSize:`xs`,color:`fg.muted`,children:[`Currently: `,t.organization.name]}),(0,L.jsx)(w,{placeholder:`Type to search organizations`,value:h,onChange:e=>O(e.target.value)}),(0,L.jsxs)(v,{size:`sm`,width:`full`,mt:1,children:[(0,L.jsxs)(y,{value:u,onChange:e=>d(e.target.value),children:[(0,L.jsx)(`option`,{value:``,children:`Select organization…`}),R.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.slug,`)`]},e.id))]}),(0,L.jsx)(_,{})]})]}),(0,L.jsxs)(x,{children:[(0,L.jsx)(C,{children:`Trial end date`}),(0,L.jsx)(w,{type:`date`,value:f,onChange:e=>p(e.target.value)}),(0,L.jsx)(S,{children:`Leave empty to grant the feature permanently.`})]})]})}),(0,L.jsx)(n.Footer,{children:(0,L.jsxs)(T,{width:`full`,children:[(0,L.jsx)(E,{}),(0,L.jsx)(m,{variant:`ghost`,onClick:r,children:`Cancel`}),(0,L.jsx)(m,{loading:o.isPending,onClick:z,children:e===`edit`?`Save`:`Grant`})]})})]})})}function H(){return(0,L.jsx)(F,{children:(0,L.jsx)(z,{})})}export{H as default};
2
- //# sourceMappingURL=organization-features-CoIKKHkQ.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Do as n,Ra as r,Ss as i,Xa as a,_s as o,bs as s,ga as c,qi as l,vs as u,xs as d,ys as f}from"./command-bar-DUK45yin.js";import{j as p,n as m}from"./stack-oJ9iWdbl.js";import{t as h}from"./box-BsM8YLGl.js";import{n as g}from"./toaster-C_DYALhL.js";import{n as _,r as v,t as y}from"./native-select-B51i56CE.js";import{t as b}from"./text-CwTrMF8x.js";import{a as x,n as S,r as C}from"./field-CnUiixMS.js";import{t as w}from"./input-C7emsUCL.js";import{t as T}from"./h-stack-BKLDJ2vg.js";import{t as E}from"./spacer-2LJJGbo8.js";import{t as D}from"./v-stack-EOPQ57OZ.js";import{a as O,c as k,n as A,o as j,r as M,s as N,t as P,u as F}from"./useAdminResource-SmnnHro6.js";var I=e(t()),L=p(),R=25;function z(){let[e,t]=(0,I.useState)(1),[n,p]=(0,I.useState)(``),[m]=c(n,300),[g,_]=(0,I.useState)(null),[v,y]=(0,I.useState)(!1),x=A(`organizationFeature`,{pagination:{page:e,perPage:R},sort:{field:`createdAt`,order:`DESC`},filter:m?{query:m}:{}}),S=A(`organization`,{pagination:{page:1,perPage:200},sort:{field:`name`,order:`ASC`},filter:{}}),C=(0,I.useMemo)(()=>{let e=new Map;for(let t of S.data?.data??[])e.set(t.id,t.name);return e},[S.data]);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(O,{title:`Organization Features`,searchValue:n,onSearchChange:e=>{p(e),t(1)},searchPlaceholder:`Search by ID, feature, or organization`,isLoading:x.isLoading,isFetching:x.isFetching,error:x.error,pagination:{page:e,perPage:R,total:x.data?.total??0,onPageChange:t},onCreate:()=>y(!0),createLabel:`Grant feature`,children:(0,L.jsxs)(d,{variant:`line`,size:`md`,width:`full`,children:[(0,L.jsx)(s,{children:(0,L.jsxs)(i,{children:[(0,L.jsx)(f,{children:`Feature`}),(0,L.jsx)(f,{children:`Organization`}),(0,L.jsx)(f,{children:`Trial ends`}),(0,L.jsx)(f,{children:`Created`}),(0,L.jsx)(f,{width:`60px`,textAlign:`right`})]})}),(0,L.jsxs)(o,{children:[x.data?.data.length===0&&(0,L.jsx)(i,{children:(0,L.jsx)(u,{colSpan:5,children:(0,L.jsx)(b,{color:`fg.muted`,textAlign:`center`,paddingY:6,children:`No organization features yet.`})})}),x.data?.data.map(e=>{let t=e.organization?.name??C.get(e.organizationId);return(0,L.jsxs)(i,{children:[(0,L.jsx)(u,{children:e.feature}),(0,L.jsx)(u,{children:t??(0,L.jsx)(b,{fontSize:`xs`,color:`fg.muted`,children:e.organizationId})}),(0,L.jsx)(u,{children:e.trialEndDate?k(e.trialEndDate):(0,L.jsx)(j,{children:`Permanent`})}),(0,L.jsx)(u,{children:k(e.createdAt)}),(0,L.jsx)(u,{textAlign:`right`,children:(0,L.jsx)(h,{width:`full`,height:`full`,display:`flex`,justifyContent:`end`,children:(0,L.jsxs)(l.Root,{children:[(0,L.jsx)(l.Trigger,{children:(0,L.jsx)(a,{size:16})}),(0,L.jsx)(l.Content,{children:(0,L.jsxs)(l.Item,{value:`edit`,onClick:()=>_(e),children:[(0,L.jsx)(r,{size:16}),`Edit`]})})]})})})]},e.id)})]})]})}),(0,L.jsx)(V,{mode:`edit`,item:g,onClose:()=>_(null)}),(0,L.jsx)(V,{mode:`create`,item:v?null:void 0,onClose:()=>y(!1)})]})}function B(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,10)}function V({mode:e,item:t,onClose:r}){let i=M(`organizationFeature`),a=P(`organizationFeature`),o=e===`edit`?i:a,[s,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),[f,p]=(0,I.useState)(``),[h,O]=(0,I.useState)(``),[k]=c(h,250),j=e===`edit`?!!t:t!==void 0;(0,I.useEffect)(()=>{j&&(e===`edit`&&t?(l(t.feature),d(t.organizationId),p(B(t.trialEndDate))):e===`create`&&(l(``),d(``),p(``),O(``)))},[j,e,t]);let F=A(`organization`,{pagination:{page:1,perPage:50},sort:{field:`name`,order:`ASC`},filter:k?{query:k}:{}},{enabled:j}),R=(0,I.useMemo)(()=>F.data?.data??[],[F.data]),z=()=>{if(!s.trim()){g.create({title:`Feature is required`,type:`error`,duration:3e3,meta:{closable:!0}});return}if(!u){g.create({title:`Organization is required`,type:`error`,duration:3e3,meta:{closable:!0}});return}let n={feature:s.trim(),organizationId:u,trialEndDate:N(f)},o=()=>{g.create({title:e===`edit`?`Feature updated`:`Feature granted`,type:`success`,duration:3e3,meta:{closable:!0}}),r()},c=t=>g.create({title:e===`edit`?`Update failed`:`Grant failed`,description:t.message,type:`error`,duration:5e3,meta:{closable:!0}});e===`edit`&&t?i.mutate({id:t.id,data:n},{onSuccess:o,onError:c}):a.mutate(n,{onSuccess:o,onError:c})},V=e===`edit`?`Edit Organization Feature`:`Grant Feature`;return(0,L.jsx)(n.Root,{open:j,onOpenChange:({open:e})=>{e||r()},size:`md`,children:(0,L.jsxs)(n.Content,{children:[(0,L.jsx)(n.Header,{children:(0,L.jsx)(n.Title,{children:V})}),(0,L.jsx)(n.CloseTrigger,{}),(0,L.jsx)(n.Body,{children:(0,L.jsxs)(D,{gap:4,align:`stretch`,children:[(0,L.jsxs)(x,{required:!0,children:[(0,L.jsx)(C,{children:`Feature`}),(0,L.jsx)(w,{value:s,onChange:e=>l(e.target.value),placeholder:`e.g. CUSTOM_EMBEDDINGS`}),(0,L.jsx)(S,{children:`Free-form feature key consumed by the entitlement checker.`})]}),(0,L.jsxs)(x,{required:!0,children:[(0,L.jsx)(C,{children:`Organization`}),e===`edit`&&t?.organization?.name&&!h&&(0,L.jsxs)(b,{fontSize:`xs`,color:`fg.muted`,children:[`Currently: `,t.organization.name]}),(0,L.jsx)(w,{placeholder:`Type to search organizations`,value:h,onChange:e=>O(e.target.value)}),(0,L.jsxs)(v,{size:`sm`,width:`full`,mt:1,children:[(0,L.jsxs)(y,{value:u,onChange:e=>d(e.target.value),children:[(0,L.jsx)(`option`,{value:``,children:`Select organization…`}),R.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.slug,`)`]},e.id))]}),(0,L.jsx)(_,{})]})]}),(0,L.jsxs)(x,{children:[(0,L.jsx)(C,{children:`Trial end date`}),(0,L.jsx)(w,{type:`date`,value:f,onChange:e=>p(e.target.value)}),(0,L.jsx)(S,{children:`Leave empty to grant the feature permanently.`})]})]})}),(0,L.jsx)(n.Footer,{children:(0,L.jsxs)(T,{width:`full`,children:[(0,L.jsx)(E,{}),(0,L.jsx)(m,{variant:`ghost`,onClick:r,children:`Cancel`}),(0,L.jsx)(m,{loading:o.isPending,onClick:z,children:e===`edit`?`Save`:`Grant`})]})})]})})}function H(){return(0,L.jsx)(F,{children:(0,L.jsx)(z,{})})}export{H as default};
2
+ //# sourceMappingURL=organization-features-rqg-75mI.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Do as n,Ra as r,Ss as i,Xa as a,_s as o,bs as s,fa as c,ga as l,gs as u,qi as d,vs as f,xs as p,ys as m}from"./command-bar-CaJygoez.js";import{j as h,n as g}from"./stack-oJ9iWdbl.js";import{t as _}from"./box-BsM8YLGl.js";import{n as v}from"./toaster-C_DYALhL.js";import{h as y}from"./terminal-CfM0q99k.js";import{n as b,r as x,t as S}from"./native-select-B51i56CE.js";import{t as C}from"./heading-D90dlSnH.js";import{t as w}from"./text-CwTrMF8x.js";import{a as T,n as E,r as D}from"./field-CnUiixMS.js";import{t as O}from"./input-C7emsUCL.js";import{t as k}from"./h-stack-BKLDJ2vg.js";import{t as A}from"./spacer-2LJJGbo8.js";import{t as j}from"./v-stack-EOPQ57OZ.js";import{r as M}from"./next-router-C6sliiV7.js";import{c as N}from"./useOrganizationTeamProject-DC0iozx2.js";import{a as P,c as F,n as I,o as L,r as R,s as z,u as B}from"./useAdminResource-SPC5iBHM.js";var V=N(),H=e(t()),U=h(),W=25;function G(){let e=M(),t=(0,H.useRef)(typeof e.query.q==`string`?e.query.q:``),[n,c]=(0,H.useState)(1),[u,h]=(0,H.useState)(t.current),[g]=l(u,300),[v,y]=(0,H.useState)(null),b=I(`organization`,{pagination:{page:n,perPage:W},sort:{field:`createdAt`,order:`DESC`},filter:g?{query:g}:{}});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(P,{title:`Organizations`,searchValue:u,onSearchChange:e=>{h(e),c(1)},searchPlaceholder:`Search by ID, name, or slug`,isLoading:b.isLoading,isFetching:b.isFetching,error:b.error,pagination:{page:n,perPage:W,total:b.data?.total??0,onPageChange:c},children:(0,U.jsxs)(p,{variant:`line`,size:`md`,width:`full`,children:[(0,U.jsx)(s,{children:(0,U.jsxs)(i,{children:[(0,U.jsx)(m,{children:`ID`}),(0,U.jsx)(m,{children:`Name`}),(0,U.jsx)(m,{children:`Slug`}),(0,U.jsx)(m,{children:`Plan model`}),(0,U.jsx)(m,{children:`Currency`}),(0,U.jsx)(m,{children:`SSO domain`}),(0,U.jsx)(m,{children:`Created`}),(0,U.jsx)(m,{width:`60px`,textAlign:`right`})]})}),(0,U.jsxs)(o,{children:[b.data?.data.length===0&&(0,U.jsx)(i,{children:(0,U.jsx)(f,{colSpan:8,children:(0,U.jsx)(w,{color:`fg.muted`,textAlign:`center`,paddingY:6,children:`No organizations match your search.`})})}),b.data?.data.map(e=>(0,U.jsxs)(i,{children:[(0,U.jsx)(f,{fontSize:`xs`,color:`fg.muted`,children:e.id}),(0,U.jsx)(f,{children:e.name}),(0,U.jsx)(f,{children:e.slug}),(0,U.jsx)(f,{children:e.pricingModel}),(0,U.jsx)(f,{children:e.currency}),(0,U.jsx)(f,{children:e.ssoDomain??(0,U.jsx)(L,{})}),(0,U.jsx)(f,{children:F(e.createdAt)}),(0,U.jsx)(f,{textAlign:`right`,children:(0,U.jsx)(_,{width:`full`,height:`full`,display:`flex`,justifyContent:`end`,children:(0,U.jsxs)(d.Root,{children:[(0,U.jsx)(d.Trigger,{children:(0,U.jsx)(a,{size:16})}),(0,U.jsx)(d.Content,{children:(0,U.jsxs)(d.Item,{value:`edit`,onClick:()=>y(e),children:[(0,U.jsx)(r,{size:16}),`Edit`]})})]})})})]},e.id))]})]})}),(0,U.jsx)(Y,{organization:v,onClose:()=>y(null)})]})}function K(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,10)}function q(e){if(e===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}function J(e){return e.trim()===``?null:e}function Y({organization:e,onClose:t}){let r=R(`organization`),[i,a]=(0,H.useState)(null);(0,H.useEffect)(()=>{e&&a({name:e.name??``,slug:e.slug??``,phoneNumber:e.phoneNumber??``,ssoDomain:e.ssoDomain??``,ssoProvider:e.ssoProvider??``,usageSpendingMaxLimit:e.usageSpendingMaxLimit?.toString()??``,signedDPA:!!e.signedDPA,promoCode:e.promoCode??``,stripeCustomerId:e.stripeCustomerId??``,currency:e.currency,pricingModel:e.pricingModel,license:e.license??``,licenseExpiresAt:K(e.licenseExpiresAt),useCustomElasticsearch:!!e.useCustomElasticsearch,useCustomS3:!!e.useCustomS3,elasticsearchNodeUrl:``,elasticsearchApiKey:``,s3Endpoint:``,s3AccessKeyId:``,s3SecretAccessKey:``,s3Bucket:``})},[e]);let o=(e,t)=>a(n=>n&&{...n,[e]:t});return(0,U.jsx)(n.Root,{open:!!e,onOpenChange:({open:e})=>{e||t()},size:`md`,children:(0,U.jsxs)(n.Content,{children:[(0,U.jsx)(n.Header,{children:(0,U.jsx)(n.Title,{children:`Edit Organization`})}),(0,U.jsx)(n.CloseTrigger,{}),(0,U.jsx)(n.Body,{children:e&&i&&(0,U.jsxs)(j,{gap:4,align:`stretch`,children:[(0,U.jsx)(X,{children:`Identity`}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Name`}),(0,U.jsx)(O,{value:i.name,onChange:e=>o(`name`,e.target.value)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Slug`}),(0,U.jsx)(O,{value:i.slug,onChange:e=>o(`slug`,e.target.value)}),(0,U.jsx)(E,{children:`URL-safe identifier. Changing this can break existing links.`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Phone number`}),(0,U.jsx)(O,{type:`tel`,value:i.phoneNumber,onChange:e=>o(`phoneNumber`,e.target.value)})]}),(0,U.jsx)(X,{children:`Billing`}),(0,U.jsxs)(k,{gap:3,align:`start`,children:[(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Currency`}),(0,U.jsx)(Z,{value:i.currency,options:Object.values(V.Currency),onChange:e=>o(`currency`,e)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Pricing model`}),(0,U.jsx)(Z,{value:i.pricingModel,options:Object.values(V.PricingModel),onChange:e=>o(`pricingModel`,e)})]})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Stripe customer ID`}),(0,U.jsx)(O,{value:i.stripeCustomerId,onChange:e=>o(`stripeCustomerId`,e.target.value)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Promo code`}),(0,U.jsx)(O,{value:i.promoCode,onChange:e=>o(`promoCode`,e.target.value)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Usage spending max limit`}),(0,U.jsx)(O,{type:`number`,value:i.usageSpendingMaxLimit,onChange:e=>o(`usageSpendingMaxLimit`,e.target.value),placeholder:`Leave empty for no cap`})]}),(0,U.jsx)(Q,{label:`Signed DPA`,hint:`Enterprise data processing agreement on file.`,checked:i.signedDPA,onChange:e=>o(`signedDPA`,e)}),(0,U.jsx)(X,{children:`Authentication`}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`SSO domain`}),(0,U.jsx)(O,{value:i.ssoDomain,onChange:e=>o(`ssoDomain`,e.target.value),placeholder:`e.g. acme.com`}),(0,U.jsx)(E,{children:`Lowercased server-side. Users with this email domain can sign in via SSO.`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`SSO provider`}),(0,U.jsx)(O,{value:i.ssoProvider,onChange:e=>o(`ssoProvider`,e.target.value)})]}),(0,U.jsx)(X,{children:`License`}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`License key`}),(0,U.jsx)(u,{rows:4,value:i.license,onChange:e=>o(`license`,e.target.value),fontFamily:`mono`,fontSize:`xs`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`License expires at`}),(0,U.jsx)(O,{type:`date`,value:i.licenseExpiresAt,onChange:e=>o(`licenseExpiresAt`,e.target.value)})]}),(0,U.jsx)(X,{children:`Custom Elasticsearch`}),(0,U.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:`Credentials below are write-only — the server never reads them back. Leave blank to keep the stored value; type to replace.`}),(0,U.jsx)(Q,{label:`Use custom Elasticsearch`,hint:`Override the platform-managed ClickHouse/ES cluster for this tenant.`,checked:i.useCustomElasticsearch,onChange:e=>o(`useCustomElasticsearch`,e)}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Node URL`}),(0,U.jsx)(O,{type:`url`,value:i.elasticsearchNodeUrl,onChange:e=>o(`elasticsearchNodeUrl`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomElasticsearch})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`API key`}),(0,U.jsx)(O,{type:`password`,value:i.elasticsearchApiKey,onChange:e=>o(`elasticsearchApiKey`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomElasticsearch,autoComplete:`new-password`})]}),(0,U.jsx)(X,{children:`Custom S3`}),(0,U.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:`Credentials below are write-only — the server never reads them back. Leave blank to keep the stored value; type to replace.`}),(0,U.jsx)(Q,{label:`Use custom S3`,hint:`Store large blobs (datasets, uploads) in the tenant's own bucket.`,checked:i.useCustomS3,onChange:e=>o(`useCustomS3`,e)}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Endpoint`}),(0,U.jsx)(O,{type:`url`,value:i.s3Endpoint,onChange:e=>o(`s3Endpoint`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomS3})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Bucket`}),(0,U.jsx)(O,{value:i.s3Bucket,onChange:e=>o(`s3Bucket`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomS3})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Access key ID`}),(0,U.jsx)(O,{type:`password`,value:i.s3AccessKeyId,onChange:e=>o(`s3AccessKeyId`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomS3,autoComplete:`new-password`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Secret access key`}),(0,U.jsx)(O,{type:`password`,value:i.s3SecretAccessKey,onChange:e=>o(`s3SecretAccessKey`,e.target.value),placeholder:`Leave blank to keep current`,autoComplete:`new-password`,disabled:!i.useCustomS3})]}),(0,U.jsx)(y,{my:2}),(0,U.jsxs)(j,{align:`start`,gap:0,children:[(0,U.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`Organization ID: `,e.id]}),(0,U.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`Created: `,F(e.createdAt)]})]})]})}),(0,U.jsx)(n.Footer,{children:(0,U.jsxs)(k,{width:`full`,children:[(0,U.jsx)(A,{}),(0,U.jsx)(g,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,U.jsx)(g,{loading:r.isPending,onClick:()=>{if(!e||!i)return;let n={};i.name!==e.name&&(n.name=i.name),i.slug!==e.slug&&(n.slug=i.slug),i.phoneNumber!==(e.phoneNumber??``)&&(n.phoneNumber=J(i.phoneNumber)),i.ssoDomain!==(e.ssoDomain??``)&&(n.ssoDomain=J(i.ssoDomain)),i.ssoProvider!==(e.ssoProvider??``)&&(n.ssoProvider=J(i.ssoProvider));let a=q(i.usageSpendingMaxLimit);a!==e.usageSpendingMaxLimit&&(n.usageSpendingMaxLimit=a),i.signedDPA!==!!e.signedDPA&&(n.signedDPA=i.signedDPA),i.promoCode!==(e.promoCode??``)&&(n.promoCode=J(i.promoCode)),i.stripeCustomerId!==(e.stripeCustomerId??``)&&(n.stripeCustomerId=J(i.stripeCustomerId)),i.currency!==e.currency&&(n.currency=i.currency),i.pricingModel!==e.pricingModel&&(n.pricingModel=i.pricingModel),i.license!==(e.license??``)&&(n.license=J(i.license));let o=z(i.licenseExpiresAt);if(o!==e.licenseExpiresAt&&(n.licenseExpiresAt=o),i.useCustomElasticsearch!==!!e.useCustomElasticsearch&&(n.useCustomElasticsearch=i.useCustomElasticsearch),i.useCustomS3!==!!e.useCustomS3&&(n.useCustomS3=i.useCustomS3),i.elasticsearchNodeUrl.trim()!==``&&(n.elasticsearchNodeUrl=i.elasticsearchNodeUrl),i.elasticsearchApiKey.trim()!==``&&(n.elasticsearchApiKey=i.elasticsearchApiKey),i.s3Endpoint.trim()!==``&&(n.s3Endpoint=i.s3Endpoint),i.s3AccessKeyId.trim()!==``&&(n.s3AccessKeyId=i.s3AccessKeyId),i.s3SecretAccessKey.trim()!==``&&(n.s3SecretAccessKey=i.s3SecretAccessKey),i.s3Bucket.trim()!==``&&(n.s3Bucket=i.s3Bucket),Object.keys(n).length===0){t();return}r.mutate({id:e.id,data:n},{onSuccess:()=>{v.create({title:`Organization updated`,type:`success`,duration:3e3,meta:{closable:!0}}),t()},onError:e=>v.create({title:`Update failed`,description:e.message,type:`error`,duration:5e3,meta:{closable:!0}})})},children:`Save`})]})})]})})}function X({children:e}){return(0,U.jsx)(C,{as:`h3`,size:`xs`,color:`fg.muted`,textTransform:`uppercase`,letterSpacing:`wider`,pt:2,children:e})}function Z({value:e,options:t,onChange:n}){return(0,U.jsxs)(x,{size:`sm`,width:`full`,children:[(0,U.jsx)(S,{value:e,onChange:e=>n(e.target.value),children:t.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))}),(0,U.jsx)(b,{})]})}function Q({label:e,hint:t,checked:n,onChange:r}){return(0,U.jsx)(T,{children:(0,U.jsxs)(k,{width:`full`,children:[(0,U.jsxs)(j,{align:`start`,gap:0,children:[(0,U.jsx)(D,{children:e}),t&&(0,U.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:t})]}),(0,U.jsx)(A,{}),(0,U.jsx)(c,{checked:n,onCheckedChange:e=>r(e.checked)})]})})}function $(){return(0,U.jsx)(B,{children:(0,U.jsx)(G,{})})}export{$ as default};
2
- //# sourceMappingURL=organizations-DWcQUTzi.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Do as n,Ra as r,Ss as i,Xa as a,_s as o,bs as s,fa as c,ga as l,gs as u,qi as d,vs as f,xs as p,ys as m}from"./command-bar-DUK45yin.js";import{j as h,n as g}from"./stack-oJ9iWdbl.js";import{t as _}from"./box-BsM8YLGl.js";import{n as v}from"./toaster-C_DYALhL.js";import{h as y}from"./terminal-CfM0q99k.js";import{n as b,r as x,t as S}from"./native-select-B51i56CE.js";import{t as C}from"./heading-D90dlSnH.js";import{t as w}from"./text-CwTrMF8x.js";import{a as T,n as E,r as D}from"./field-CnUiixMS.js";import{t as O}from"./input-C7emsUCL.js";import{t as k}from"./h-stack-BKLDJ2vg.js";import{t as A}from"./spacer-2LJJGbo8.js";import{t as j}from"./v-stack-EOPQ57OZ.js";import{r as M}from"./next-router-C6sliiV7.js";import{c as N}from"./useOrganizationTeamProject-DC0iozx2.js";import{a as P,c as F,n as I,o as L,r as R,s as z,u as B}from"./useAdminResource-SmnnHro6.js";var V=N(),H=e(t()),U=h(),W=25;function G(){let e=M(),t=(0,H.useRef)(typeof e.query.q==`string`?e.query.q:``),[n,c]=(0,H.useState)(1),[u,h]=(0,H.useState)(t.current),[g]=l(u,300),[v,y]=(0,H.useState)(null),b=I(`organization`,{pagination:{page:n,perPage:W},sort:{field:`createdAt`,order:`DESC`},filter:g?{query:g}:{}});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(P,{title:`Organizations`,searchValue:u,onSearchChange:e=>{h(e),c(1)},searchPlaceholder:`Search by ID, name, or slug`,isLoading:b.isLoading,isFetching:b.isFetching,error:b.error,pagination:{page:n,perPage:W,total:b.data?.total??0,onPageChange:c},children:(0,U.jsxs)(p,{variant:`line`,size:`md`,width:`full`,children:[(0,U.jsx)(s,{children:(0,U.jsxs)(i,{children:[(0,U.jsx)(m,{children:`ID`}),(0,U.jsx)(m,{children:`Name`}),(0,U.jsx)(m,{children:`Slug`}),(0,U.jsx)(m,{children:`Plan model`}),(0,U.jsx)(m,{children:`Currency`}),(0,U.jsx)(m,{children:`SSO domain`}),(0,U.jsx)(m,{children:`Created`}),(0,U.jsx)(m,{width:`60px`,textAlign:`right`})]})}),(0,U.jsxs)(o,{children:[b.data?.data.length===0&&(0,U.jsx)(i,{children:(0,U.jsx)(f,{colSpan:8,children:(0,U.jsx)(w,{color:`fg.muted`,textAlign:`center`,paddingY:6,children:`No organizations match your search.`})})}),b.data?.data.map(e=>(0,U.jsxs)(i,{children:[(0,U.jsx)(f,{fontSize:`xs`,color:`fg.muted`,children:e.id}),(0,U.jsx)(f,{children:e.name}),(0,U.jsx)(f,{children:e.slug}),(0,U.jsx)(f,{children:e.pricingModel}),(0,U.jsx)(f,{children:e.currency}),(0,U.jsx)(f,{children:e.ssoDomain??(0,U.jsx)(L,{})}),(0,U.jsx)(f,{children:F(e.createdAt)}),(0,U.jsx)(f,{textAlign:`right`,children:(0,U.jsx)(_,{width:`full`,height:`full`,display:`flex`,justifyContent:`end`,children:(0,U.jsxs)(d.Root,{children:[(0,U.jsx)(d.Trigger,{children:(0,U.jsx)(a,{size:16})}),(0,U.jsx)(d.Content,{children:(0,U.jsxs)(d.Item,{value:`edit`,onClick:()=>y(e),children:[(0,U.jsx)(r,{size:16}),`Edit`]})})]})})})]},e.id))]})]})}),(0,U.jsx)(Y,{organization:v,onClose:()=>y(null)})]})}function K(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,10)}function q(e){if(e===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}function J(e){return e.trim()===``?null:e}function Y({organization:e,onClose:t}){let r=R(`organization`),[i,a]=(0,H.useState)(null);(0,H.useEffect)(()=>{e&&a({name:e.name??``,slug:e.slug??``,phoneNumber:e.phoneNumber??``,ssoDomain:e.ssoDomain??``,ssoProvider:e.ssoProvider??``,usageSpendingMaxLimit:e.usageSpendingMaxLimit?.toString()??``,signedDPA:!!e.signedDPA,promoCode:e.promoCode??``,stripeCustomerId:e.stripeCustomerId??``,currency:e.currency,pricingModel:e.pricingModel,license:e.license??``,licenseExpiresAt:K(e.licenseExpiresAt),useCustomElasticsearch:!!e.useCustomElasticsearch,useCustomS3:!!e.useCustomS3,elasticsearchNodeUrl:``,elasticsearchApiKey:``,s3Endpoint:``,s3AccessKeyId:``,s3SecretAccessKey:``,s3Bucket:``})},[e]);let o=(e,t)=>a(n=>n&&{...n,[e]:t});return(0,U.jsx)(n.Root,{open:!!e,onOpenChange:({open:e})=>{e||t()},size:`md`,children:(0,U.jsxs)(n.Content,{children:[(0,U.jsx)(n.Header,{children:(0,U.jsx)(n.Title,{children:`Edit Organization`})}),(0,U.jsx)(n.CloseTrigger,{}),(0,U.jsx)(n.Body,{children:e&&i&&(0,U.jsxs)(j,{gap:4,align:`stretch`,children:[(0,U.jsx)(X,{children:`Identity`}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Name`}),(0,U.jsx)(O,{value:i.name,onChange:e=>o(`name`,e.target.value)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Slug`}),(0,U.jsx)(O,{value:i.slug,onChange:e=>o(`slug`,e.target.value)}),(0,U.jsx)(E,{children:`URL-safe identifier. Changing this can break existing links.`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Phone number`}),(0,U.jsx)(O,{type:`tel`,value:i.phoneNumber,onChange:e=>o(`phoneNumber`,e.target.value)})]}),(0,U.jsx)(X,{children:`Billing`}),(0,U.jsxs)(k,{gap:3,align:`start`,children:[(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Currency`}),(0,U.jsx)(Z,{value:i.currency,options:Object.values(V.Currency),onChange:e=>o(`currency`,e)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Pricing model`}),(0,U.jsx)(Z,{value:i.pricingModel,options:Object.values(V.PricingModel),onChange:e=>o(`pricingModel`,e)})]})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Stripe customer ID`}),(0,U.jsx)(O,{value:i.stripeCustomerId,onChange:e=>o(`stripeCustomerId`,e.target.value)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Promo code`}),(0,U.jsx)(O,{value:i.promoCode,onChange:e=>o(`promoCode`,e.target.value)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Usage spending max limit`}),(0,U.jsx)(O,{type:`number`,value:i.usageSpendingMaxLimit,onChange:e=>o(`usageSpendingMaxLimit`,e.target.value),placeholder:`Leave empty for no cap`})]}),(0,U.jsx)(Q,{label:`Signed DPA`,hint:`Enterprise data processing agreement on file.`,checked:i.signedDPA,onChange:e=>o(`signedDPA`,e)}),(0,U.jsx)(X,{children:`Authentication`}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`SSO domain`}),(0,U.jsx)(O,{value:i.ssoDomain,onChange:e=>o(`ssoDomain`,e.target.value),placeholder:`e.g. acme.com`}),(0,U.jsx)(E,{children:`Lowercased server-side. Users with this email domain can sign in via SSO.`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`SSO provider`}),(0,U.jsx)(O,{value:i.ssoProvider,onChange:e=>o(`ssoProvider`,e.target.value)})]}),(0,U.jsx)(X,{children:`License`}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`License key`}),(0,U.jsx)(u,{rows:4,value:i.license,onChange:e=>o(`license`,e.target.value),fontFamily:`mono`,fontSize:`xs`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`License expires at`}),(0,U.jsx)(O,{type:`date`,value:i.licenseExpiresAt,onChange:e=>o(`licenseExpiresAt`,e.target.value)})]}),(0,U.jsx)(X,{children:`Custom Elasticsearch`}),(0,U.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:`Credentials below are write-only — the server never reads them back. Leave blank to keep the stored value; type to replace.`}),(0,U.jsx)(Q,{label:`Use custom Elasticsearch`,hint:`Override the platform-managed ClickHouse/ES cluster for this tenant.`,checked:i.useCustomElasticsearch,onChange:e=>o(`useCustomElasticsearch`,e)}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Node URL`}),(0,U.jsx)(O,{type:`url`,value:i.elasticsearchNodeUrl,onChange:e=>o(`elasticsearchNodeUrl`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomElasticsearch})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`API key`}),(0,U.jsx)(O,{type:`password`,value:i.elasticsearchApiKey,onChange:e=>o(`elasticsearchApiKey`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomElasticsearch,autoComplete:`new-password`})]}),(0,U.jsx)(X,{children:`Custom S3`}),(0,U.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:`Credentials below are write-only — the server never reads them back. Leave blank to keep the stored value; type to replace.`}),(0,U.jsx)(Q,{label:`Use custom S3`,hint:`Store large blobs (datasets, uploads) in the tenant's own bucket.`,checked:i.useCustomS3,onChange:e=>o(`useCustomS3`,e)}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Endpoint`}),(0,U.jsx)(O,{type:`url`,value:i.s3Endpoint,onChange:e=>o(`s3Endpoint`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomS3})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Bucket`}),(0,U.jsx)(O,{value:i.s3Bucket,onChange:e=>o(`s3Bucket`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomS3})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Access key ID`}),(0,U.jsx)(O,{type:`password`,value:i.s3AccessKeyId,onChange:e=>o(`s3AccessKeyId`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomS3,autoComplete:`new-password`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Secret access key`}),(0,U.jsx)(O,{type:`password`,value:i.s3SecretAccessKey,onChange:e=>o(`s3SecretAccessKey`,e.target.value),placeholder:`Leave blank to keep current`,autoComplete:`new-password`,disabled:!i.useCustomS3})]}),(0,U.jsx)(y,{my:2}),(0,U.jsxs)(j,{align:`start`,gap:0,children:[(0,U.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`Organization ID: `,e.id]}),(0,U.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`Created: `,F(e.createdAt)]})]})]})}),(0,U.jsx)(n.Footer,{children:(0,U.jsxs)(k,{width:`full`,children:[(0,U.jsx)(A,{}),(0,U.jsx)(g,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,U.jsx)(g,{loading:r.isPending,onClick:()=>{if(!e||!i)return;let n={};i.name!==e.name&&(n.name=i.name),i.slug!==e.slug&&(n.slug=i.slug),i.phoneNumber!==(e.phoneNumber??``)&&(n.phoneNumber=J(i.phoneNumber)),i.ssoDomain!==(e.ssoDomain??``)&&(n.ssoDomain=J(i.ssoDomain)),i.ssoProvider!==(e.ssoProvider??``)&&(n.ssoProvider=J(i.ssoProvider));let a=q(i.usageSpendingMaxLimit);a!==e.usageSpendingMaxLimit&&(n.usageSpendingMaxLimit=a),i.signedDPA!==!!e.signedDPA&&(n.signedDPA=i.signedDPA),i.promoCode!==(e.promoCode??``)&&(n.promoCode=J(i.promoCode)),i.stripeCustomerId!==(e.stripeCustomerId??``)&&(n.stripeCustomerId=J(i.stripeCustomerId)),i.currency!==e.currency&&(n.currency=i.currency),i.pricingModel!==e.pricingModel&&(n.pricingModel=i.pricingModel),i.license!==(e.license??``)&&(n.license=J(i.license));let o=z(i.licenseExpiresAt);if(o!==e.licenseExpiresAt&&(n.licenseExpiresAt=o),i.useCustomElasticsearch!==!!e.useCustomElasticsearch&&(n.useCustomElasticsearch=i.useCustomElasticsearch),i.useCustomS3!==!!e.useCustomS3&&(n.useCustomS3=i.useCustomS3),i.elasticsearchNodeUrl.trim()!==``&&(n.elasticsearchNodeUrl=i.elasticsearchNodeUrl),i.elasticsearchApiKey.trim()!==``&&(n.elasticsearchApiKey=i.elasticsearchApiKey),i.s3Endpoint.trim()!==``&&(n.s3Endpoint=i.s3Endpoint),i.s3AccessKeyId.trim()!==``&&(n.s3AccessKeyId=i.s3AccessKeyId),i.s3SecretAccessKey.trim()!==``&&(n.s3SecretAccessKey=i.s3SecretAccessKey),i.s3Bucket.trim()!==``&&(n.s3Bucket=i.s3Bucket),Object.keys(n).length===0){t();return}r.mutate({id:e.id,data:n},{onSuccess:()=>{v.create({title:`Organization updated`,type:`success`,duration:3e3,meta:{closable:!0}}),t()},onError:e=>v.create({title:`Update failed`,description:e.message,type:`error`,duration:5e3,meta:{closable:!0}})})},children:`Save`})]})})]})})}function X({children:e}){return(0,U.jsx)(C,{as:`h3`,size:`xs`,color:`fg.muted`,textTransform:`uppercase`,letterSpacing:`wider`,pt:2,children:e})}function Z({value:e,options:t,onChange:n}){return(0,U.jsxs)(x,{size:`sm`,width:`full`,children:[(0,U.jsx)(S,{value:e,onChange:e=>n(e.target.value),children:t.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))}),(0,U.jsx)(b,{})]})}function Q({label:e,hint:t,checked:n,onChange:r}){return(0,U.jsx)(T,{children:(0,U.jsxs)(k,{width:`full`,children:[(0,U.jsxs)(j,{align:`start`,gap:0,children:[(0,U.jsx)(D,{children:e}),t&&(0,U.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:t})]}),(0,U.jsx)(A,{}),(0,U.jsx)(c,{checked:n,onCheckedChange:e=>r(e.checked)})]})})}function $(){return(0,U.jsx)(B,{children:(0,U.jsx)(G,{})})}export{$ as default};
2
+ //# sourceMappingURL=organizations-DjCzIHVx.js.map
@@ -1,2 +1,2 @@
1
- import{_t as e,gt as t,ht as n,vt as r}from"./command-bar-CaJygoez.js";import{A as i,D as a,E as o,P as s,j as c,m as l}from"./types-B5pOLKPA.js";var u=a({runId:c().optional(),versionId:c().optional(),targetOutputs:i(l(s())),targetMetadata:i(l(r.nullish())),evaluatorResults:i(i(l(s()))),errors:i(l(c().nullish()))});a({experimentId:c().optional(),experimentSlug:c().optional(),name:c(),datasets:l(n),activeDatasetId:c(),evaluators:l(t),targets:l(e),results:u.optional(),hiddenColumns:l(c()).optional(),concurrency:o().min(1).max(24).optional()});var d=e=>{if(Object.keys(e.targetOutputs).length>0||Object.keys(e.targetMetadata).length>0||Object.keys(e.evaluatorResults).length>0||Object.keys(e.errors).length>0)return{runId:e.runId,versionId:e.versionId,targetOutputs:e.targetOutputs,targetMetadata:e.targetMetadata,evaluatorResults:e.evaluatorResults,errors:e.errors}},f=e=>{let{ui:t,results:n,datasets:r,...i}=e,a=d(n),o=r.map(e=>{if(e.type===`saved`){let{savedRecords:t,...n}=e;return n}return e});return{...i,datasets:o,results:a,hiddenColumns:Array.from(t.hiddenColumns),concurrency:t.concurrency}};export{f as t};
2
- //# sourceMappingURL=persistence-CTQ44vGL.js.map
1
+ import{_t as e,gt as t,ht as n,vt as r}from"./command-bar-DUK45yin.js";import{A as i,D as a,E as o,P as s,j as c,m as l}from"./types-B5pOLKPA.js";var u=a({runId:c().optional(),versionId:c().optional(),targetOutputs:i(l(s())),targetMetadata:i(l(r.nullish())),evaluatorResults:i(i(l(s()))),errors:i(l(c().nullish()))});a({experimentId:c().optional(),experimentSlug:c().optional(),name:c(),datasets:l(n),activeDatasetId:c(),evaluators:l(t),targets:l(e),results:u.optional(),hiddenColumns:l(c()).optional(),concurrency:o().min(1).max(24).optional()});var d=e=>{if(Object.keys(e.targetOutputs).length>0||Object.keys(e.targetMetadata).length>0||Object.keys(e.evaluatorResults).length>0||Object.keys(e.errors).length>0)return{runId:e.runId,versionId:e.versionId,targetOutputs:e.targetOutputs,targetMetadata:e.targetMetadata,evaluatorResults:e.evaluatorResults,errors:e.errors}},f=e=>{let{ui:t,results:n,datasets:r,...i}=e,a=d(n),o=r.map(e=>{if(e.type===`saved`){let{savedRecords:t,...n}=e;return n}return e});return{...i,datasets:o,results:a,hiddenColumns:Array.from(t.hiddenColumns),concurrency:t.concurrency}};export{f as t};
2
+ //# sourceMappingURL=persistence-BPvHS0F6.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Za as n}from"./command-bar-CaJygoez.js";import{j as r,n as i,r as a}from"./stack-oJ9iWdbl.js";import{t as o}from"./box-BsM8YLGl.js";import{an as s,in as c}from"./dist-SwV3YZv3.js";import{o as l}from"./terminal-CfM0q99k.js";import{t as u}from"./heading-D90dlSnH.js";import{t as d}from"./text-CwTrMF8x.js";import{n as f,r as p}from"./code-FF_ibTVI.js";import{t as m}from"./h-stack-BKLDJ2vg.js";import{r as h,t as g}from"./card-CMtKVPVl.js";import{t as _}from"./link-CwZhwOLq.js";import{t as v}from"./simple-grid-C3IW90zo.js";import{t as y}from"./v-stack-EOPQ57OZ.js";import{s as b}from"./auth-client-D3UhxhQi.js";import{c as x,t as S}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as C}from"./createLucideIcon-BJKFyRLS.js";import{t as w}from"./SettingsLayout-CLCGxMAe.js";import{i as T,l as E,n as D,o as O,s as k,t as A,u as j}from"./billing-plans-FUqEPN62.js";import{t as M}from"./constants-BT2q4NNM.js";import{t as N}from"./WithPermissionGuard-DD8uo3UK.js";var P=C(`euro`,[[`path`,{d:`M4 10h12`,key:`1y6xl8`}],[`path`,{d:`M4 14h9`,key:`1loblj`}],[`path`,{d:`M19 6a7.7 7.7 0 0 0-5.2-2A7.9 7.9 0 0 0 6 12c0 4.4 3.5 8 7.8 8 2 0 3.8-.8 5.2-2`,key:`1j6lzo`}]]),F=e(t()),I=x();function L(e){if(!e)return null;let t=e.type?.toUpperCase();return e.free||t===`FREE`?`free`:t===`GROWTH`||t&&j(t)?`growth`:t===`ENTERPRISE`?`enterprise`:null}var R=r(),z=e=>[{id:`free`,name:`Free`,subtitle:`For teams getting started`,actionLabel:`Get Started`,actionHref:`/settings/subscription`,actionColor:`blue`,features:D},{id:`growth`,name:`Growth`,subtitle:`Seat and usage pricing for growing teams`,actionLabel:`Get Started`,actionHref:`/settings/subscription`,actionColor:`orange`,features:O(e)},{id:`enterprise`,name:`Enterprise`,subtitle:`Regulated and high-volume deployments`,actionLabel:`Contact Sales`,actionHref:M,actionColor:`blue`,features:A}];function B(e,t,n){if(e===`free`)return`${T[t]}0 per user/month`;if(e===`growth`){let e=E();return`${k({cents:n===`annual`?Math.round(e[t].annual/12):e[t].monthly,currency:t})} per seat/month`}return`Custom pricing`}function V({plan:e,currentPlan:t}){return e.id===`free`?null:e.id===`growth`?t===`growth`?(0,R.jsx)(y,{width:`full`,gap:2,children:(0,R.jsx)(i,{asChild:!0,width:`full`,color:`bg.emphasized`,backgroundColor:`orange.600`,variant:`solid`,children:(0,R.jsx)(_,{href:`/settings/members`,children:`Add Members`})})}):(0,R.jsx)(i,{asChild:!0,width:`full`,colorPalette:`orange`,variant:`solid`,children:(0,R.jsx)(_,{color:`white`,href:`/settings/subscription`,children:`Upgrade Now`})}):e.id===`enterprise`&&t!==`enterprise`?(0,R.jsx)(i,{asChild:!0,width:`full`,colorPalette:`muted`,variant:`outline`,children:(0,R.jsx)(_,{href:M,isExternal:!0,children:`Contact Sales`})}):null}function H({plan:e,isCurrent:t,currentPlan:n,currency:r,billingPeriod:i}){return(0,R.jsx)(h,{"data-testid":`plan-column-${e.id}`,borderWidth:1,borderColor:`border.emphasized`,bg:`bg.panel`,borderRadius:`2xl`,height:`full`,transition:`all 0.2s ease-in-out`,_hover:{transform:`scale(1.02)`,boxShadow:`lg`},children:(0,R.jsx)(g,{paddingY:6,paddingX:6,children:(0,R.jsxs)(y,{align:`stretch`,gap:5,height:`full`,children:[(0,R.jsxs)(y,{align:`start`,gap:1,children:[(0,R.jsxs)(m,{gap:2,children:[(0,R.jsx)(u,{as:`h2`,size:`xl`,children:e.name}),t&&(0,R.jsx)(s,{colorPalette:`green`,variant:`surface`,size:`lg`,children:`Current`})]}),(0,R.jsx)(d,{color:`fg`,fontSize:`md`,fontWeight:`medium`,children:B(e.id,r,i)}),(0,R.jsx)(d,{color:`fg.muted`,fontSize:`sm`,children:e.subtitle})]}),(0,R.jsx)(y,{align:`start`,gap:2,flex:1,children:e.features.map(e=>(0,R.jsxs)(m,{align:`start`,gap:2,children:[(0,R.jsx)(f,{size:14,style:{marginTop:`4px`,flexShrink:0},color:`var(--chakra-colors-blue-500)`}),(0,R.jsx)(d,{fontSize:`sm`,color:`fg.muted`,children:e})]},e))}),(0,R.jsx)(y,{width:`full`,marginTop:`auto`,paddingTop:4,children:(0,R.jsx)(V,{plan:e,currentPlan:n})})]})})})}function U({activePlan:e,pricingModel:t}){let r=L(e),s=t===`TIERED`&&!e?.free,f=b.currency.detectCurrency.useQuery({}),[h,g]=(0,F.useState)(null),x=h??f.data?.currency??I.Currency.EUR,[S,C]=(0,F.useState)(`monthly`);return f.isLoading?(0,R.jsx)(a,{}):(0,R.jsxs)(y,{gap:6,width:`full`,align:`stretch`,maxWidth:`900px`,marginX:`auto`,children:[(0,R.jsxs)(c,{justifyContent:`space-between`,alignItems:`flex-start`,children:[(0,R.jsx)(o,{flex:1,children:(0,R.jsx)(_,{href:`/settings/subscription`,children:(0,R.jsxs)(i,{variant:`ghost`,size:`sm`,color:`gray.600`,children:[(0,R.jsx)(p,{size:14}),` Subscription`]})})}),(0,R.jsxs)(y,{align:`center`,gap:1,flex:2,children:[(0,R.jsx)(u,{size:`xl`,as:`h2`,children:`Plans`}),(0,R.jsx)(d,{color:`fg.muted`,children:`Compare plans and choose the right tier for your organization.`})]}),(0,R.jsx)(o,{flex:1})]}),(0,R.jsxs)(m,{width:`full`,justifyContent:{base:`center`,md:`center`},flexWrap:`wrap`,gap:3,children:[(0,R.jsx)(o,{flex:{md:1}}),(0,R.jsx)(m,{gap:0,bg:`bg.muted`,borderRadius:`full`,padding:`1`,"data-testid":`billing-period-toggle`,children:[{label:`Monthly`,value:`monthly`},{label:`Annually`,value:`annual`}].map(e=>(0,R.jsx)(o,{as:`button`,"aria-pressed":S===e.value,onClick:()=>C(e.value),paddingX:4,paddingY:1.5,borderRadius:`full`,fontSize:`sm`,fontWeight:S===e.value?`semibold`:`normal`,color:S===e.value?`orange.500`:`fg.muted`,bg:S===e.value?`bg.panel`:`transparent`,boxShadow:S===e.value?`xs`:`none`,transition:`all 0.15s ease-in-out`,cursor:`pointer`,_hover:{color:S===e.value?`orange.500`:`fg`},children:e.label},e.value))}),(0,R.jsx)(o,{flex:{md:1},display:`flex`,justifyContent:`flex-end`,children:(0,R.jsxs)(i,{"data-testid":`currency-toggle`,variant:`subtle`,size:`sm`,_hover:{bgColor:`orange.400`,color:`bg.muted`},onClick:()=>g(x===I.Currency.EUR?I.Currency.USD:I.Currency.EUR),children:[x===I.Currency.EUR?(0,R.jsx)(P,{size:14}):(0,R.jsx)(n,{size:14}),x]})})]}),s&&(0,R.jsx)(o,{"data-testid":`tiered-discontinued-notice`,backgroundColor:`orange.50`,borderWidth:1,borderColor:`orange.200`,borderRadius:`md`,padding:4,children:(0,R.jsxs)(m,{gap:2,alignItems:`start`,children:[(0,R.jsx)(l,{size:16,color:`var(--chakra-colors-orange-500)`}),(0,R.jsxs)(d,{fontSize:`sm`,color:`orange.900`,children:[`Your current pricing model has been discontinued.`,` `,(0,R.jsx)(_,{href:`/settings/subscription`,fontWeight:`semibold`,color:`orange.700`,_hover:{color:`orange.900`},children:`Update your plan`}),` `,`to move to seat and usage billing.`]})]})}),(0,R.jsx)(v,{columns:{base:1,md:3},gap:4,children:z(x).map(e=>(0,R.jsx)(H,{plan:e,isCurrent:r===e.id,currentPlan:r,currency:x,billingPeriod:S},e.id))})]})}function W(){let{organization:e}=S(),t=b.plan.getActivePlan.useQuery({organizationId:e?.id??``},{enabled:!!e?.id,refetchOnWindowFocus:!1,refetchOnMount:!1});return t.isLoading&&!t.data?(0,R.jsx)(w,{children:(0,R.jsx)(a,{})}):(0,R.jsx)(w,{children:(0,R.jsx)(U,{activePlan:t.data,pricingModel:e?.pricingModel})})}var G=N(`organization:view`,{layoutComponent:w})(W);export{G as default};
2
- //# sourceMappingURL=plans-Dq3eFg5K.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Za as n}from"./command-bar-DUK45yin.js";import{j as r,n as i,r as a}from"./stack-oJ9iWdbl.js";import{t as o}from"./box-BsM8YLGl.js";import{an as s,in as c}from"./dist-Cds4Mqhj.js";import{o as l}from"./terminal-CfM0q99k.js";import{t as u}from"./heading-D90dlSnH.js";import{t as d}from"./text-CwTrMF8x.js";import{n as f,r as p}from"./code-FF_ibTVI.js";import{t as m}from"./h-stack-BKLDJ2vg.js";import{r as h,t as g}from"./card-CMtKVPVl.js";import{t as _}from"./link-CwZhwOLq.js";import{t as v}from"./simple-grid-C3IW90zo.js";import{t as y}from"./v-stack-EOPQ57OZ.js";import{s as b}from"./auth-client-D3UhxhQi.js";import{c as x,t as S}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as C}from"./createLucideIcon-BJKFyRLS.js";import{t as w}from"./SettingsLayout--1gdEuhv.js";import{i as T,l as E,n as D,o as O,s as k,t as A,u as j}from"./billing-plans-BUQp08MI.js";import{t as M}from"./constants-BT2q4NNM.js";import{t as N}from"./WithPermissionGuard-B4Jo8E5-.js";var P=C(`euro`,[[`path`,{d:`M4 10h12`,key:`1y6xl8`}],[`path`,{d:`M4 14h9`,key:`1loblj`}],[`path`,{d:`M19 6a7.7 7.7 0 0 0-5.2-2A7.9 7.9 0 0 0 6 12c0 4.4 3.5 8 7.8 8 2 0 3.8-.8 5.2-2`,key:`1j6lzo`}]]),F=e(t()),I=x();function L(e){if(!e)return null;let t=e.type?.toUpperCase();return e.free||t===`FREE`?`free`:t===`GROWTH`||t&&j(t)?`growth`:t===`ENTERPRISE`?`enterprise`:null}var R=r(),z=e=>[{id:`free`,name:`Free`,subtitle:`For teams getting started`,actionLabel:`Get Started`,actionHref:`/settings/subscription`,actionColor:`blue`,features:D},{id:`growth`,name:`Growth`,subtitle:`Seat and usage pricing for growing teams`,actionLabel:`Get Started`,actionHref:`/settings/subscription`,actionColor:`orange`,features:O(e)},{id:`enterprise`,name:`Enterprise`,subtitle:`Regulated and high-volume deployments`,actionLabel:`Contact Sales`,actionHref:M,actionColor:`blue`,features:A}];function B(e,t,n){if(e===`free`)return`${T[t]}0 per user/month`;if(e===`growth`){let e=E();return`${k({cents:n===`annual`?Math.round(e[t].annual/12):e[t].monthly,currency:t})} per seat/month`}return`Custom pricing`}function V({plan:e,currentPlan:t}){return e.id===`free`?null:e.id===`growth`?t===`growth`?(0,R.jsx)(y,{width:`full`,gap:2,children:(0,R.jsx)(i,{asChild:!0,width:`full`,color:`bg.emphasized`,backgroundColor:`orange.600`,variant:`solid`,children:(0,R.jsx)(_,{href:`/settings/members`,children:`Add Members`})})}):(0,R.jsx)(i,{asChild:!0,width:`full`,colorPalette:`orange`,variant:`solid`,children:(0,R.jsx)(_,{color:`white`,href:`/settings/subscription`,children:`Upgrade Now`})}):e.id===`enterprise`&&t!==`enterprise`?(0,R.jsx)(i,{asChild:!0,width:`full`,colorPalette:`muted`,variant:`outline`,children:(0,R.jsx)(_,{href:M,isExternal:!0,children:`Contact Sales`})}):null}function H({plan:e,isCurrent:t,currentPlan:n,currency:r,billingPeriod:i}){return(0,R.jsx)(h,{"data-testid":`plan-column-${e.id}`,borderWidth:1,borderColor:`border.emphasized`,bg:`bg.panel`,borderRadius:`2xl`,height:`full`,transition:`all 0.2s ease-in-out`,_hover:{transform:`scale(1.02)`,boxShadow:`lg`},children:(0,R.jsx)(g,{paddingY:6,paddingX:6,children:(0,R.jsxs)(y,{align:`stretch`,gap:5,height:`full`,children:[(0,R.jsxs)(y,{align:`start`,gap:1,children:[(0,R.jsxs)(m,{gap:2,children:[(0,R.jsx)(u,{as:`h2`,size:`xl`,children:e.name}),t&&(0,R.jsx)(s,{colorPalette:`green`,variant:`surface`,size:`lg`,children:`Current`})]}),(0,R.jsx)(d,{color:`fg`,fontSize:`md`,fontWeight:`medium`,children:B(e.id,r,i)}),(0,R.jsx)(d,{color:`fg.muted`,fontSize:`sm`,children:e.subtitle})]}),(0,R.jsx)(y,{align:`start`,gap:2,flex:1,children:e.features.map(e=>(0,R.jsxs)(m,{align:`start`,gap:2,children:[(0,R.jsx)(f,{size:14,style:{marginTop:`4px`,flexShrink:0},color:`var(--chakra-colors-blue-500)`}),(0,R.jsx)(d,{fontSize:`sm`,color:`fg.muted`,children:e})]},e))}),(0,R.jsx)(y,{width:`full`,marginTop:`auto`,paddingTop:4,children:(0,R.jsx)(V,{plan:e,currentPlan:n})})]})})})}function U({activePlan:e,pricingModel:t}){let r=L(e),s=t===`TIERED`&&!e?.free,f=b.currency.detectCurrency.useQuery({}),[h,g]=(0,F.useState)(null),x=h??f.data?.currency??I.Currency.EUR,[S,C]=(0,F.useState)(`monthly`);return f.isLoading?(0,R.jsx)(a,{}):(0,R.jsxs)(y,{gap:6,width:`full`,align:`stretch`,maxWidth:`900px`,marginX:`auto`,children:[(0,R.jsxs)(c,{justifyContent:`space-between`,alignItems:`flex-start`,children:[(0,R.jsx)(o,{flex:1,children:(0,R.jsx)(_,{href:`/settings/subscription`,children:(0,R.jsxs)(i,{variant:`ghost`,size:`sm`,color:`gray.600`,children:[(0,R.jsx)(p,{size:14}),` Subscription`]})})}),(0,R.jsxs)(y,{align:`center`,gap:1,flex:2,children:[(0,R.jsx)(u,{size:`xl`,as:`h2`,children:`Plans`}),(0,R.jsx)(d,{color:`fg.muted`,children:`Compare plans and choose the right tier for your organization.`})]}),(0,R.jsx)(o,{flex:1})]}),(0,R.jsxs)(m,{width:`full`,justifyContent:{base:`center`,md:`center`},flexWrap:`wrap`,gap:3,children:[(0,R.jsx)(o,{flex:{md:1}}),(0,R.jsx)(m,{gap:0,bg:`bg.muted`,borderRadius:`full`,padding:`1`,"data-testid":`billing-period-toggle`,children:[{label:`Monthly`,value:`monthly`},{label:`Annually`,value:`annual`}].map(e=>(0,R.jsx)(o,{as:`button`,"aria-pressed":S===e.value,onClick:()=>C(e.value),paddingX:4,paddingY:1.5,borderRadius:`full`,fontSize:`sm`,fontWeight:S===e.value?`semibold`:`normal`,color:S===e.value?`orange.500`:`fg.muted`,bg:S===e.value?`bg.panel`:`transparent`,boxShadow:S===e.value?`xs`:`none`,transition:`all 0.15s ease-in-out`,cursor:`pointer`,_hover:{color:S===e.value?`orange.500`:`fg`},children:e.label},e.value))}),(0,R.jsx)(o,{flex:{md:1},display:`flex`,justifyContent:`flex-end`,children:(0,R.jsxs)(i,{"data-testid":`currency-toggle`,variant:`subtle`,size:`sm`,_hover:{bgColor:`orange.400`,color:`bg.muted`},onClick:()=>g(x===I.Currency.EUR?I.Currency.USD:I.Currency.EUR),children:[x===I.Currency.EUR?(0,R.jsx)(P,{size:14}):(0,R.jsx)(n,{size:14}),x]})})]}),s&&(0,R.jsx)(o,{"data-testid":`tiered-discontinued-notice`,backgroundColor:`orange.50`,borderWidth:1,borderColor:`orange.200`,borderRadius:`md`,padding:4,children:(0,R.jsxs)(m,{gap:2,alignItems:`start`,children:[(0,R.jsx)(l,{size:16,color:`var(--chakra-colors-orange-500)`}),(0,R.jsxs)(d,{fontSize:`sm`,color:`orange.900`,children:[`Your current pricing model has been discontinued.`,` `,(0,R.jsx)(_,{href:`/settings/subscription`,fontWeight:`semibold`,color:`orange.700`,_hover:{color:`orange.900`},children:`Update your plan`}),` `,`to move to seat and usage billing.`]})]})}),(0,R.jsx)(v,{columns:{base:1,md:3},gap:4,children:z(x).map(e=>(0,R.jsx)(H,{plan:e,isCurrent:r===e.id,currentPlan:r,currency:x,billingPeriod:S},e.id))})]})}function W(){let{organization:e}=S(),t=b.plan.getActivePlan.useQuery({organizationId:e?.id??``},{enabled:!!e?.id,refetchOnWindowFocus:!1,refetchOnMount:!1});return t.isLoading&&!t.data?(0,R.jsx)(w,{children:(0,R.jsx)(a,{})}):(0,R.jsx)(w,{children:(0,R.jsx)(U,{activePlan:t.data,pricingModel:e?.pricingModel})})}var G=N(`organization:view`,{layoutComponent:w})(W);export{G as default};
2
+ //# sourceMappingURL=plans-Ch2Ol-Fd.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$ as n,D as r,M as i,Q as a,Tt as o,U as s,W as c,X as l,Y as u,_ as d,a as f,et as p,i as m,k as h,l as ee,m as g,o as _,p as te,r as v,rt as y,wt as b}from"./prop-types-DifpXm68.js";import{$s as x,Aa as ne,Ao as re,Bs as ie,Cn as S,Cs as ae,Gs as C,Mo as oe,No as se,Oo as ce,Po as le,Qs as ue,Ss as de,Vs as fe,Xr as pe,Xs as me,Ys as he,_s as ge,ao as _e,bs as ve,ec as ye,gs as be,jo as xe,ko as Se,mn as Ce,nc as we,tc as Te,vs as w,xs as Ee,yo as De,ys as T,zs as Oe}from"./command-bar-CaJygoez.js";import{j as ke,n as E,r as Ae}from"./stack-oJ9iWdbl.js";import{t as D}from"./box-BsM8YLGl.js";import{m as je}from"./tabs-DwV1cIZB.js";import{m as Me}from"./tooltip-AEm0YeiF.js";import{m as O,n as k,o as Ne}from"./toaster-C_DYALhL.js";import{c as Pe,i as Fe,l as Ie}from"./radio-group.anatomy-1s_fCJ3y.js";import{an as A}from"./dist-SwV3YZv3.js";import{h as Le}from"./terminal-CfM0q99k.js";import{a as Re,d as ze,l as Be,s as Ve,u as He}from"./dist-frWhjLir.js";import{t as j}from"./text-CwTrMF8x.js";import{i as Ue}from"./code-FF_ibTVI.js";import{r as We,t as Ge}from"./input-C7emsUCL.js";import{n as M}from"./tags-input.anatomy-BFbwdDIO.js";import{t as Ke}from"./create-slot-recipe-context-B6DU0msX.js";import{c as qe,t as N}from"./h-stack-BKLDJ2vg.js";import{r as P,t as F}from"./card-CMtKVPVl.js";import{n as I,r as L,t as R}from"./stat-CHoKZ9Rr.js";import{c as Je,i as Ye,l as Xe,n as z,t as Ze}from"./ReplayStateBadge-ChyX1KUG.js";import{t as B}from"./v-stack-EOPQ57OZ.js";import{s as V}from"./auth-client-D3UhxhQi.js";import{r as Qe}from"./next-router-C6sliiV7.js";import{t as $e}from"./arrow-right-B3ZN8yal.js";import{t as et}from"./OpsPageShell-DJ1WlI6-.js";import{n as tt,r as nt,t as rt}from"./PhaseTimeline-DXfTjBZX.js";function it(e){if(!e)return!1;try{return e.selectionStart===0&&e.selectionEnd===0}catch{return e.value===``}}var H=`__live-region__`;function at(e={}){let{level:t=`polite`,document:n=document,root:r,delay:i=0}=e,a=n.defaultView??window,o=r??n.body;function s(e,r){n.getElementById(H)?.remove(),r??=i;let s=n.createElement(`span`);s.id=H,s.dataset.liveAnnouncer=`true`;let c=t===`assertive`?`alert`:`status`;s.setAttribute(`aria-live`,t),s.setAttribute(`role`,c),Object.assign(s.style,{border:`0`,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:`0`,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`}),o.appendChild(s),a.setTimeout(()=>{s.textContent=e},r)}function c(){n.getElementById(H)?.remove()}return{announce:s,destroy:c,toJSON(){return H}}}function ot(e){if(!e)return;let t=Me(e);return`box-sizing:`+t.boxSizing+`;border-left:`+t.borderLeftWidth+` solid red;border-right:`+t.borderRightWidth+` solid red;font-family:`+t.fontFamily+`;font-feature-settings:`+t.fontFeatureSettings+`;font-kerning:`+t.fontKerning+`;font-size:`+t.fontSize+`;font-stretch:`+t.fontStretch+`;font-style:`+t.fontStyle+`;font-variant:`+t.fontVariant+`;font-variant-caps:`+t.fontVariantCaps+`;font-variant-ligatures:`+t.fontVariantLigatures+`;font-variant-numeric:`+t.fontVariantNumeric+`;font-weight:`+t.fontWeight+`;letter-spacing:`+t.letterSpacing+`;margin-left:`+t.marginLeft+`;margin-right:`+t.marginRight+`;padding-left:`+t.paddingLeft+`;padding-right:`+t.paddingRight+`;text-indent:`+t.textIndent+`;text-transform:`+t.textTransform}function st(e){let t=e.createElement(`div`);return t.id=`ghost`,t.style.cssText=`display:inline-block;height:0;overflow:hidden;position:absolute;top:0;visibility:hidden;white-space:nowrap;`,e.body.appendChild(t),t}function ct(e){if(!e)return;let t=h(e),n=i(e),r=st(t),a=ot(e);a&&(r.style.cssText+=a);function o(){n.requestAnimationFrame(()=>{r.innerHTML=e.value;let t=n.getComputedStyle(r);e?.style.setProperty(`width`,t.width)})}return o(),e?.addEventListener(`input`,o),e?.addEventListener(`change`,o),()=>{t.body.removeChild(r),e?.removeEventListener(`input`,o),e?.removeEventListener(`change`,o)}}var[lt,U]=p({name:`TagsInputContext`,hookName:`useTagsInputContext`,providerName:`<TagsInputProvider />`}),W=ke(),G=e(t(),1),ut=(0,G.forwardRef)((e,t)=>{let n=a(U().getClearTriggerProps(),e);return(0,W.jsx)(_.button,{...n,ref:t})});ut.displayName=`TagsInputClearTrigger`;var dt=(0,G.forwardRef)((e,t)=>{let n=a(U().getControlProps(),e);return(0,W.jsx)(_.div,{...n,ref:t})});dt.displayName=`TagsInputControl`;var ft=(0,G.forwardRef)((e,t)=>{let n=a(U().getHiddenInputProps(),e),r=We();return(0,W.jsx)(_.input,{"aria-describedby":r?.ariaDescribedby,...n,ref:t})});ft.displayName=`TagsInputHiddenInput`;var pt=(0,G.forwardRef)((e,t)=>{let n=a(U().getInputProps(),e);return(0,W.jsx)(_.input,{...n,ref:t})});pt.displayName=`TagsInputInput`;var[mt,ht]=p({name:`TagsInputItemContext`,hookName:`useTagsInputItemContext`,providerName:`<TagsInputItemProvider />`}),[gt,K]=p({name:`TagsInputItemPropsContext`,hookName:`useTagsInputItemPropsContext`,providerName:`<TagsInputItemPropsProvider />`}),_t=Re(),vt=(0,G.forwardRef)((e,t)=>{let[n,r]=_t(e,[`index`,`disabled`,`value`]),i=U(),o=a(i.getItemProps(n),r);return(0,W.jsx)(gt,{value:n,children:(0,W.jsx)(mt,{value:i.getItemState(n),children:(0,W.jsx)(_.div,{...o,ref:t})})})});vt.displayName=`TagsInputItem`;var yt=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemDeleteTriggerProps(r),e);return(0,W.jsx)(_.button,{...i,ref:t})});yt.displayName=`TagsInputItemDeleteTrigger`;var bt=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemInputProps(r),e);return(0,W.jsx)(_.input,{...i,ref:t})});bt.displayName=`TagsInputItemInput`;var xt=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemPreviewProps(r),e);return(0,W.jsx)(_.div,{...i,ref:t})});xt.displayName=`TagsInputItemPreview`;var St=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemTextProps(r),e);return(0,W.jsx)(_.span,{...i,ref:t})});St.displayName=`TagsInputItemText`;var Ct=(0,G.forwardRef)((e,t)=>{let n=a(U().getLabelProps(),e);return(0,W.jsx)(_.label,{...n,ref:t})});Ct.displayName=`TagsInputLabel`;var wt=e=>e.ids?.root??`tags-input:${e.id}`,Tt=e=>e.ids?.input??`tags-input:${e.id}:input`,Et=e=>e.ids?.clearBtn??`tags-input:${e.id}:clear-btn`,Dt=e=>e.ids?.hiddenInput??`tags-input:${e.id}:hidden-input`,Ot=e=>e.ids?.label??`tags-input:${e.id}:label`,kt=e=>e.ids?.control??`tags-input:${e.id}:control`,q=(e,t)=>e.ids?.item?.(t)??`tags-input:${e.id}:tag:${t.value}:${t.index}`,At=(e,t)=>e.ids?.itemDeleteTrigger?.(t)??`${q(e,t)}:delete-btn`,jt=(e,t)=>e.ids?.itemInput?.(t)??`${q(e,t)}:input`,Mt=e=>`${e}:input`,Nt=(e,t)=>e.getById(Mt(t)),Pt=e=>ze(It(e),`[data-part=item]`),Ft=(e,t)=>e.getById(jt(e,t)),It=e=>e.getById(wt(e)),J=e=>e.getById(Tt(e)),Lt=e=>e.getById(Dt(e)),Y=e=>ze(It(e),`[data-part=item-preview]:not([data-disabled])`),Rt=e=>Y(e)[0],zt=e=>Y(e)[Y(e).length-1],Bt=(e,t)=>He(Y(e),t,!1),Vt=(e,t)=>Be(Y(e),t,!1),Ht=(e,t)=>Y(e)[t],X=(e,t)=>Ve(Y(e),t),Ut=e=>{let t=e.closest(`[data-part=item-preview]`);t&&(t.dataset.deleteIntent=``)},Wt=e=>{let t=e.closest(`[data-part=item-preview]`);t&&delete t.dataset.deleteIntent},Gt=(e,t)=>{let n=Lt(e);n&&Fe(n,{value:t})};function Kt(e,t){let{state:n,send:r,computed:i,prop:a,scope:o,context:l}=e,u=i(`isInteractive`),f=!!a(`disabled`),p=!!a(`readOnly`),m=!!a(`required`),h=a(`invalid`)||i(`isOverflowing`),_=a(`translations`),v=n.hasTag(`focused`),y=n.matches(`editing:tag`),b=i(`count`)===0;function x(e){let t=q(o,e),n=l.get(`editedTagId`),r=l.get(`highlightedTagId`);return{id:t,editing:y&&n===t,highlighted:t===r,disabled:!!(e.disabled||f)}}return{empty:b,inputValue:l.get(`inputValue`),value:l.get(`value`),valueAsString:i(`valueAsString`),count:i(`count`),atMax:i(`isAtMax`),setValue(e){r({type:`SET_VALUE`,value:e})},clearValue(e){r(e?{type:`CLEAR_TAG`,id:e}:{type:`CLEAR_VALUE`})},addValue(e){r({type:`ADD_TAG`,value:e})},setValueAtIndex(e,t){r({type:`SET_VALUE_AT_INDEX`,index:e,value:t})},setInputValue(e){r({type:`SET_INPUT_VALUE`,value:e})},clearInputValue(){r({type:`SET_INPUT_VALUE`,value:``})},focus(){J(o)?.focus()},getItemState:x,getRootProps(){return t.element({dir:a(`dir`),...M.root.attrs,"data-invalid":c(h),"data-readonly":c(p),"data-disabled":c(f),"data-focus":c(v),"data-empty":c(b),id:wt(o),onPointerDown(){u&&r({type:`POINTER_DOWN`})}})},getLabelProps(){return t.label({...M.label.attrs,"data-disabled":c(f),"data-invalid":c(h),"data-readonly":c(p),"data-required":c(m),id:Ot(o),dir:a(`dir`),htmlFor:Tt(o)})},getControlProps(){return t.element({id:kt(o),...M.control.attrs,dir:a(`dir`),tabIndex:p?0:void 0,"data-disabled":c(f),"data-readonly":c(p),"data-invalid":c(h),"data-focus":c(v)})},getInputProps(){return t.input({...M.input.attrs,dir:a(`dir`),"data-invalid":c(h),"aria-invalid":s(h),"data-readonly":c(p),"data-empty":c(b),maxLength:a(`maxLength`),id:Tt(o),defaultValue:l.get(`inputValue`),autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,enterKeyHint:`done`,disabled:f||p,placeholder:b?a(`placeholder`):void 0,onInput(e){let t=te(e),n=e.currentTarget.value;if(t.inputType===`insertFromPaste`){r({type:`PASTE`,value:n});return}if(qt(n,a(`delimiter`))){r({type:`DELIMITER_KEY`});return}r({type:`TYPE`,value:n,key:t.inputType})},onFocus(){queueMicrotask(()=>{r({type:`FOCUS`})})},onKeyDown(e){if(e.defaultPrevented||g(e))return;let t=e.currentTarget,n=t.getAttribute(`role`)===`combobox`,i=t.ariaExpanded===`true`,o={ArrowDown(){r({type:`ARROW_DOWN`})},ArrowLeft(){n&&i||r({type:`ARROW_LEFT`})},ArrowRight(e){l.get(`highlightedTagId`)&&e.preventDefault(),!(n&&i)&&r({type:`ARROW_RIGHT`})},Escape(e){e.preventDefault(),r({type:`ESCAPE`})},Backspace(){r({type:`BACKSPACE`})},Delete(){r({type:`DELETE`})},Enter(e){let a=t.getAttribute(`aria-activedescendant`);n&&i&&a||(r({type:`ENTER`}),e.preventDefault())}}[ee(e,{dir:a(`dir`)})];if(o){o(e);return}}})},getHiddenInputProps(){return t.input({type:`text`,hidden:!0,name:a(`name`),form:a(`form`),disabled:f,readOnly:p,required:a(`required`),id:Dt(o),defaultValue:i(`valueAsString`)})},getItemProps(e){return t.element({...M.item.attrs,dir:a(`dir`),"data-value":e.value,"data-disabled":c(f)})},getItemPreviewProps(e){let n=x(e);return t.element({...M.itemPreview.attrs,id:n.id,dir:a(`dir`),hidden:n.editing,"data-value":e.value,"data-disabled":c(f),"data-highlighted":c(n.highlighted),onPointerDown(e){!u||n.disabled||d(e)&&(e.preventDefault(),r({type:`POINTER_DOWN_TAG`,id:n.id}))},onDoubleClick(){!u||n.disabled||r({type:`DOUBLE_CLICK_TAG`,id:n.id})}})},getItemTextProps(e){let n=x(e);return t.element({...M.itemText.attrs,dir:a(`dir`),"data-disabled":c(f),"data-highlighted":c(n.highlighted)})},getItemInputProps(e){let n=x(e);return t.input({...M.itemInput.attrs,dir:a(`dir`),"aria-label":_?.tagEdited?.(e.value),disabled:f,id:jt(o,e),tabIndex:-1,hidden:!n.editing,maxLength:a(`maxLength`),defaultValue:n.editing?l.get(`editedTagValue`):``,onInput(e){r({type:`TAG_INPUT_TYPE`,value:e.currentTarget.value})},onBlur(e){queueMicrotask(()=>{r({type:`TAG_INPUT_BLUR`,target:e.relatedTarget,id:n.id})})},onKeyDown(e){if(e.defaultPrevented||g(e))return;let t={Enter(){r({type:`TAG_INPUT_ENTER`})},Escape(){r({type:`TAG_INPUT_ESCAPE`})}}[e.key];t&&(e.preventDefault(),t(e))}})},getItemDeleteTriggerProps(e){let n=x(e);return t.button({...M.itemDeleteTrigger.attrs,dir:a(`dir`),"data-disabled":c(n.disabled),"aria-disabled":n.disabled,"data-highlighted":c(n.highlighted),id:At(o,e),type:`button`,disabled:n.disabled,"aria-label":_?.deleteTagTriggerLabel?.(e.value),tabIndex:-1,onPointerDown(e){d(e)&&(u||e.preventDefault())},onPointerMove(e){u&&Ut(e.currentTarget)},onPointerLeave(e){u&&Wt(e.currentTarget)},onClick(e){e.defaultPrevented||u&&r({type:`CLICK_DELETE_TAG`,id:n.id})}})},getClearTriggerProps(){return t.button({...M.clearTrigger.attrs,dir:a(`dir`),id:Et(o),type:`button`,"data-readonly":c(p),disabled:f,"aria-label":_?.clearTriggerLabel,hidden:b,onClick(){u&&r({type:`CLEAR_VALUE`})}})}}}function qt(e,t){return t?typeof t==`string`?e.endsWith(t):RegExp(`${t.source}$`).test(e):!1}var{and:Z,not:Q,or:Jt}=u(),Yt=l({props({props:e}){return{dir:`ltr`,addOnPaste:!1,editable:!0,validate:()=>!0,allowDuplicates:!1,delimiter:`,`,defaultValue:[],defaultInputValue:``,max:1/0,sanitizeValue:e=>e.trim(),...e,translations:{clearTriggerLabel:`Clear all tags`,deleteTagTriggerLabel:e=>`Delete tag ${e}`,tagAdded:e=>`Added tag ${e}`,tagsPasted:e=>`Pasted ${e.length} tags`,tagEdited:e=>`Editing tag ${e}. Press enter to save or escape to cancel.`,tagUpdated:e=>`Tag update to ${e}`,tagDeleted:e=>`Tag ${e} deleted`,tagSelected:e=>`Tag ${e} selected. Press enter to edit, delete or backspace to remove.`,...e.translations}}},initialState({prop:e}){return e(`autoFocus`)?`focused:input`:`idle`},refs(){return{liveRegion:null,log:{current:null,prev:null}}},context({bindable:e,prop:t}){return{value:e(()=>({defaultValue:t(`defaultValue`),value:t(`value`),isEqual:je,hash(e){return e.join(`, `)},onChange(e){t(`onValueChange`)?.({value:e})}})),inputValue:e(()=>({sync:!0,defaultValue:t(`defaultInputValue`),value:t(`inputValue`),onChange(e){t(`onInputValueChange`)?.({inputValue:e})}})),fieldsetDisabled:e(()=>({defaultValue:!1})),editedTagValue:e(()=>({defaultValue:``})),editedTagId:e(()=>({defaultValue:null})),editedTagIndex:e(()=>({defaultValue:null,sync:!0})),highlightedTagId:e(()=>({defaultValue:null,sync:!0,onChange(e){t(`onHighlightChange`)?.({highlightedValue:e})}}))}},computed:{count:({context:e})=>e.get(`value`).length,valueAsString:({context:e})=>e.hash(`value`),sanitizedInputValue:({context:e,prop:t})=>t(`sanitizeValue`)(e.get(`inputValue`)),isDisabled:({prop:e})=>!!e(`disabled`),isInteractive:({prop:e})=>!(e(`readOnly`)||e(`disabled`)),isAtMax:({context:e,prop:t})=>e.get(`value`).length===t(`max`),isOverflowing:({context:e,prop:t})=>e.get(`value`).length>t(`max`)},watch({track:e,context:t,action:n,computed:r,refs:i}){e([()=>t.get(`editedTagValue`)],()=>{n([`syncEditedTagInputValue`])}),e([()=>t.get(`inputValue`)],()=>{n([`syncInputValue`])}),e([()=>t.get(`highlightedTagId`)],()=>{n([`logHighlightedTag`])}),e([()=>r(`isOverflowing`)],()=>{n([`invokeOnInvalid`])}),e([()=>JSON.stringify(i.get(`log`))],()=>{n([`announceLog`])})},effects:[`trackLiveRegion`,`trackFormControlState`],exit:[`clearLog`],on:{DOUBLE_CLICK_TAG:{guard:`isTagEditable`,target:`editing:tag`,actions:[`setEditedId`]},POINTER_DOWN_TAG:{target:`navigating:tag`,actions:[`highlightTag`,`focusInput`]},CLICK_DELETE_TAG:{target:`focused:input`,actions:[`deleteTag`]},SET_INPUT_VALUE:{actions:[`setInputValue`]},SET_VALUE:{actions:[`setValue`]},CLEAR_TAG:{actions:[`deleteTag`]},SET_VALUE_AT_INDEX:{actions:[`setValueAtIndex`]},CLEAR_VALUE:{actions:[`clearTags`,`clearInputValue`,`focusInput`]},ADD_TAG:{actions:[`addTag`]},INSERT_TAG:{guard:Z(Jt(Q(`isAtMax`),`allowOverflow`),Q(`isInputValueEmpty`)),actions:[`addTag`,`clearInputValue`]},EXTERNAL_BLUR:[{guard:`addOnBlur`,actions:[`raiseInsertTagEvent`]},{guard:`clearOnBlur`,actions:[`clearInputValue`]}]},states:{idle:{on:{FOCUS:{target:`focused:input`},POINTER_DOWN:{guard:Q(`hasHighlightedTag`),target:`focused:input`}}},"focused:input":{tags:[`focused`],entry:[`focusInput`,`clearHighlightedId`],effects:[`trackInteractOutside`],on:{TYPE:{actions:[`setInputValue`]},BLUR:[{guard:`addOnBlur`,target:`idle`,actions:[`raiseInsertTagEvent`]},{guard:`clearOnBlur`,target:`idle`,actions:[`clearInputValue`]},{target:`idle`}],ENTER:{actions:[`raiseInsertTagEvent`]},DELIMITER_KEY:{actions:[`raiseInsertTagEvent`]},ARROW_LEFT:{guard:Z(`hasTags`,`isCaretAtStart`),target:`navigating:tag`,actions:[`highlightLastTag`]},BACKSPACE:{target:`navigating:tag`,guard:Z(`hasTags`,`isCaretAtStart`),actions:[`highlightLastTag`]},DELETE:{guard:`hasHighlightedTag`,actions:[`deleteHighlightedTag`,`highlightTagAtIndex`]},PASTE:[{guard:`addOnPaste`,actions:[`setInputValue`,`addTagFromPaste`]},{actions:[`setInputValue`]}]}},"navigating:tag":{tags:[`focused`],effects:[`trackInteractOutside`],on:{ARROW_RIGHT:[{guard:Z(`hasTags`,`isCaretAtStart`,Q(`isLastTagHighlighted`)),actions:[`highlightNextTag`]},{target:`focused:input`}],ARROW_LEFT:[{guard:Q(`isCaretAtStart`),target:`focused:input`},{actions:[`highlightPrevTag`]}],BLUR:{target:`idle`,actions:[`clearHighlightedId`]},ENTER:{guard:Z(`isTagEditable`,`hasHighlightedTag`),target:`editing:tag`,actions:[`setEditedId`,`focusEditedTagInput`]},ARROW_DOWN:{target:`focused:input`},ESCAPE:{target:`focused:input`},TYPE:{target:`focused:input`,actions:[`setInputValue`]},BACKSPACE:[{guard:Q(`isCaretAtStart`),target:`focused:input`},{guard:`isFirstTagHighlighted`,actions:[`deleteHighlightedTag`,`highlightFirstTag`]},{guard:`hasHighlightedTag`,actions:[`deleteHighlightedTag`,`highlightPrevTag`]},{actions:[`highlightLastTag`]}],DELETE:[{guard:Q(`isCaretAtStart`),target:`focused:input`},{target:`focused:input`,actions:[`deleteHighlightedTag`,`highlightTagAtIndex`]}],PASTE:[{guard:`addOnPaste`,target:`focused:input`,actions:[`setInputValue`,`addTagFromPaste`]},{target:`focused:input`,actions:[`setInputValue`]}]}},"editing:tag":{tags:[`editing`,`focused`],entry:[`focusEditedTagInput`],effects:[`autoResize`],on:{TAG_INPUT_TYPE:{actions:[`setEditedTagValue`]},TAG_INPUT_ESCAPE:{target:`navigating:tag`,actions:[`clearEditedTagValue`,`focusInput`,`clearEditedId`,`highlightTagAtIndex`]},TAG_INPUT_BLUR:[{guard:`isInputRelatedTarget`,target:`navigating:tag`,actions:[`clearEditedTagValue`,`clearHighlightedId`,`clearEditedId`]},{target:`idle`,actions:[`clearEditedTagValue`,`clearHighlightedId`,`clearEditedId`,`raiseExternalBlurEvent`]}],TAG_INPUT_ENTER:[{guard:`isEditedTagEmpty`,target:`navigating:tag`,actions:[`deleteHighlightedTag`,`focusInput`,`clearEditedId`,`highlightTagAtIndex`]},{target:`navigating:tag`,actions:[`submitEditedTagValue`,`focusInput`,`clearEditedId`,`highlightTagAtIndex`]}]}}},implementations:{guards:{isInputRelatedTarget:({scope:e,event:t})=>t.relatedTarget===J(e),isAtMax:({computed:e})=>e(`isAtMax`),hasHighlightedTag:({context:e})=>e.get(`highlightedTagId`)!=null,isFirstTagHighlighted:({context:e,scope:t})=>q(t,{value:e.get(`value`)[0],index:0})===e.get(`highlightedTagId`),isEditedTagEmpty:({context:e,prop:t})=>t(`sanitizeValue`)(e.get(`editedTagValue`))===``,isLastTagHighlighted:({context:e,scope:t})=>{let n=e.get(`value`),r=n.length-1;return q(t,{value:n[r],index:r})===e.get(`highlightedTagId`)},isInputValueEmpty:({context:e,prop:t})=>t(`sanitizeValue`)(e.get(`inputValue`)).length===0,hasTags:({context:e})=>e.get(`value`).length>0,allowOverflow:({prop:e})=>!!e(`allowOverflow`),autoFocus:({prop:e})=>!!e(`autoFocus`),addOnBlur:({prop:e})=>e(`blurBehavior`)===`add`,clearOnBlur:({prop:e})=>e(`blurBehavior`)===`clear`,addOnPaste:({prop:e})=>!!e(`addOnPaste`),isTagEditable:({prop:e})=>!!e(`editable`),isCaretAtStart:({scope:e})=>it(J(e))},effects:{trackInteractOutside({scope:e,prop:t,send:n}){return Ne(J(e),{exclude(t){return Pt(e).some(e=>r(e,t))},onFocusOutside:t(`onFocusOutside`),onPointerDownOutside:t(`onPointerDownOutside`),onInteractOutside(e){t(`onInteractOutside`)?.(e),!e.defaultPrevented&&n({type:`BLUR`,src:`interact-outside`})}})},trackFormControlState({context:e,send:t,scope:n}){return Ie(Lt(n),{onFieldsetDisabledChange(t){e.set(`fieldsetDisabled`,t)},onFormReset(){t({type:`SET_VALUE`,value:e.initial(`value`),src:`form-reset`})}})},autoResize({context:e,prop:t,scope:n}){let r;return queueMicrotask(()=>{let i=e.get(`editedTagValue`),a=e.get(`editedTagIndex`);!i||a==null||!t(`editable`)||(r=ct(Ft(n,{value:i,index:a})))}),()=>{r?.()}},trackLiveRegion({scope:e,refs:t}){let n=at({level:`assertive`,document:e.getDoc()});return t.set(`liveRegion`,n),()=>n.destroy()}},actions:{raiseInsertTagEvent({send:e}){e({type:`INSERT_TAG`})},raiseExternalBlurEvent({send:e,event:t}){e({type:`EXTERNAL_BLUR`,id:t.id})},dispatchChangeEvent({scope:e,computed:t}){Gt(e,t(`valueAsString`))},highlightNextTag({context:e,scope:t}){let n=e.get(`highlightedTagId`);if(n==null)return;let r=Vt(t,n);e.set(`highlightedTagId`,r?.id??null)},highlightFirstTag({context:e,scope:t}){O(()=>{let n=Rt(t);e.set(`highlightedTagId`,n?.id??null)})},highlightLastTag({context:e,scope:t}){let n=zt(t);e.set(`highlightedTagId`,n?.id??null)},highlightPrevTag({context:e,scope:t}){let n=e.get(`highlightedTagId`);if(n==null)return;let r=Bt(t,n);e.set(`highlightedTagId`,r?.id??null)},highlightTag({context:e,event:t}){e.set(`highlightedTagId`,t.id)},highlightTagAtIndex({context:e,scope:t}){O(()=>{let n=e.get(`editedTagIndex`);if(n==null)return;let r=Ht(t,n);r!=null&&(e.set(`highlightedTagId`,r.id),e.set(`editedTagIndex`,null))})},deleteTag({context:e,scope:t,event:n,refs:r}){let i=X(t,n.id),a=e.get(`value`)[i],o=r.get(`log`);r.set(`log`,{prev:o.current,current:{type:`delete`,value:a}}),e.set(`value`,e=>b(e,i))},deleteHighlightedTag({context:e,scope:t,refs:n}){let r=e.get(`highlightedTagId`);if(r==null)return;let i=X(t,r);e.set(`editedTagIndex`,i);let a=e.get(`value`),o=n.get(`log`);n.set(`log`,{prev:o.current,current:{type:`delete`,value:a[i]}}),e.set(`value`,e=>b(e,i))},setEditedId({context:e,event:t,scope:n}){let r=e.get(`highlightedTagId`),i=t.id??r;e.set(`editedTagId`,i);let a=X(n,i),o=e.get(`value`)[a];e.set(`editedTagIndex`,a),e.set(`editedTagValue`,o)},clearEditedId({context:e}){e.set(`editedTagId`,null)},clearEditedTagValue({context:e}){e.set(`editedTagValue`,``)},setEditedTagValue({context:e,event:t}){e.set(`editedTagValue`,t.value)},submitEditedTagValue({context:e,scope:t,refs:n,prop:r}){let i=e.get(`editedTagId`);if(!i)return;let a=X(t,i),o=e.get(`editedTagValue`),s=e.get(`value`),c=s.some((e,t)=>t!==a&&e===o);if(!r(`allowDuplicates`)&&c||s[a]===o)return;e.set(`value`,e=>{let t=e.slice();return t[a]=o,t});let l=n.get(`log`);n.set(`log`,{prev:l.current,current:{type:`update`,value:o}})},setValueAtIndex({context:e,event:t,refs:n,prop:r}){if(t.value){let i=e.get(`value`),a=i.some((e,n)=>n!==t.index&&e===t.value);if(!r(`allowDuplicates`)&&a||i[t.index]===t.value)return;e.set(`value`,e=>{let n=e.slice();return n[t.index]=t.value,n});let o=n.get(`log`);n.set(`log`,{prev:o.current,current:{type:`update`,value:t.value}})}else y(`You need to provide a value for the tag`)},focusEditedTagInput({context:e,scope:t}){O(()=>{let n=e.get(`editedTagId`);n&&Nt(t,n)?.select()})},setInputValue({context:e,event:t}){e.set(`inputValue`,t.value)},clearHighlightedId({context:e}){e.set(`highlightedTagId`,null)},focusInput({scope:e}){O(()=>{J(e)?.focus()})},clearInputValue({context:e}){O(()=>{e.set(`inputValue`,``)})},syncInputValue({context:e,scope:t}){let n=J(t);n&&Pe(n,e.get(`inputValue`))},syncEditedTagInputValue({context:e,event:t,scope:n}){let r=e.get(`editedTagId`)||e.get(`highlightedTagId`)||t.id;if(r==null)return;let i=Nt(n,r);i&&Pe(i,e.get(`editedTagValue`))},addTag({context:e,event:t,computed:n,prop:r,refs:i}){let a=t.value??n(`sanitizedInputValue`),s=e.get(`value`);if(r(`validate`)?.({inputValue:a,value:Array.from(s)})){let t=r(`allowDuplicates`)?s.concat(a):o(s.concat(a));e.set(`value`,t);let n=i.get(`log`);i.set(`log`,{prev:n.current,current:{type:`add`,value:a}})}else r(`onValueInvalid`)?.({reason:`invalidTag`})},addTagFromPaste({context:e,computed:t,prop:n,refs:r}){O(()=>{let i=t(`sanitizedInputValue`),a=e.get(`value`),s=n(`sanitizeValue`);if(n(`validate`)?.({inputValue:i,value:Array.from(a)})){let t=n(`delimiter`),c=t?i.split(t).map(s):[i],l=n(`allowDuplicates`)?a.concat(...c):o(a.concat(...c));e.set(`value`,l);let u=r.get(`log`);r.set(`log`,{prev:u.current,current:{type:`paste`,values:c}})}else n(`onValueInvalid`)?.({reason:`invalidTag`});e.set(`inputValue`,``)})},clearTags({context:e,refs:t}){e.set(`value`,[]);let n=t.get(`log`);t.set(`log`,{prev:n.current,current:{type:`clear`}})},setValue({context:e,event:t}){e.set(`value`,t.value)},invokeOnInvalid({prop:e,computed:t}){t(`isOverflowing`)&&e(`onValueInvalid`)?.({reason:`rangeOverflow`})},clearLog({refs:e}){let t=e.get(`log`);t.prev=t.current=null},logHighlightedTag({refs:e,context:t,scope:n}){let r=t.get(`highlightedTagId`),i=e.get(`log`);if(r==null||!i.current)return;let a=X(n,r),o=t.get(`value`)[a],s=e.get(`log`);e.set(`log`,{prev:s.current,current:{type:`select`,value:o}})},announceLog({refs:e,prop:t}){let n=e.get(`liveRegion`),r=t(`translations`),i=e.get(`log`);if(!i.current||n==null)return;let a=n,{current:o,prev:s}=i,c;switch(o.type){case`add`:c=r.tagAdded(o.value);break;case`delete`:c=r.tagDeleted(o.value);break;case`update`:c=r.tagUpdated(o.value);break;case`paste`:c=r.tagsPasted(o.values);break;case`select`:c=r.tagSelected(o.value),s?.type===`delete`?c=`${r.tagDeleted(s.value)}. ${c}`:s?.type===`update`&&(c=`${r.tagUpdated(s.value)}. ${c}`);break;default:break}c&&a.announce(c)}}}}),Xt=e=>{let t=(0,G.useId)(),{getRootNode:r}=n(),{dir:i}=f(),a=We();return Kt(m(Yt,{id:t,ids:{label:a?.ids.label,hiddenInput:a?.ids.control},dir:i,disabled:a?.disabled,invalid:a?.invalid,readOnly:a?.readOnly,required:a?.required,getRootNode:r,...e}),v)},Zt=Re(),Qt=(0,G.forwardRef)((e,t)=>{let[n,r]=Zt(e,`addOnPaste.allowDuplicates.allowOverflow.autoFocus.blurBehavior.defaultInputValue.defaultValue.delimiter.disabled.editable.form.id.ids.inputValue.invalid.max.maxLength.name.onFocusOutside.onHighlightChange.onInputValueChange.onInteractOutside.onPointerDownOutside.onValueChange.onValueInvalid.placeholder.readOnly.required.sanitizeValue.translations.validate.value`.split(`.`)),i=Xt(n),o=a(i.getRootProps(),r);return(0,W.jsx)(lt,{value:i,children:(0,W.jsx)(_.div,{...o,ref:t})})});Qt.displayName=`TagsInputRoot`;var $t=Re(),en=(0,G.forwardRef)((e,t)=>{let[{value:n},r]=$t(e,[`value`]),i=a(n.getRootProps(),r);return(0,W.jsx)(lt,{value:n,children:(0,W.jsx)(_.div,{...i,ref:t})})});en.displayName=`TagsInputRootProvider`;var{withProvider:tn,withContext:$,useStyles:nn,PropsProvider:rn}=Ke({key:`tagsInput`});tn(en,`root`,{forwardAsChild:!0});var an=tn(Qt,`root`,{forwardAsChild:!0,defaultProps:{editable:!1}}),on=$(Ct,`label`,{forwardAsChild:!0}),sn=$(dt,`control`,{forwardAsChild:!0}),cn=$(pt,`input`,{forwardAsChild:!0}),ln=$(vt,`item`,{forwardAsChild:!0}),un=$(St,`itemText`,{forwardAsChild:!0}),dn=$(yt,`itemDeleteTrigger`,{forwardAsChild:!0,defaultProps:{children:(0,W.jsx)(qe,{})}}),fn=$(xt,`itemPreview`,{forwardAsChild:!0}),pn=$(bt,`itemInput`,{forwardAsChild:!0}),mn=$(ut,`clearTrigger`,{forwardAsChild:!0,defaultProps:{children:(0,W.jsx)(qe,{})}}),hn=e=>(0,W.jsx)(C,{each:U().value,children:(t,n)=>(0,W.jsxs)(ln,{index:n,value:t,...e,children:[(0,W.jsxs)(fn,{children:[(0,W.jsx)(un,{children:t}),(0,W.jsx)(dn,{})]}),(0,W.jsx)(pn,{})]},n)});function gn({open:e,onClose:t}){let n=Qe(),{hasAccess:r}=S(),i=z({refetchInterval:e?1e3:!1}),a=V.ops.cancelReplay.useMutation({onSuccess:()=>void i.refetch()}),o=i.data,s=o?.state===`running`,c=o?.state===`completed`?`green`:o?.state===`failed`?`red`:o?.state===`cancelled`?`orange`:`blue`,l=o&&o.aggregatesTotal>0?Math.round(o.aggregatesProcessed/o.aggregatesTotal*100):0,u=(0,G.useMemo)(()=>{if(!o?.startedAt||!o.eventsProcessed)return null;let e=(Date.now()-new Date(o.startedAt).getTime())/1e3;return e<1?null:Math.round(o.eventsProcessed/e)},[o?.startedAt,o?.eventsProcessed]);return(0,W.jsx)(se,{open:e,onOpenChange:e=>{e.open||t()},placement:`end`,size:`sm`,children:(0,W.jsxs)(re,{children:[(0,W.jsxs)(oe,{children:[(0,W.jsx)(le,{children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(Xe,{colorPalette:c,size:`sm`,children:(0,W.jsx)(Je,{})}),`Replay `,o?.state??`idle`]})}),(0,W.jsx)(Se,{})]}),(0,W.jsx)(ce,{children:!o||o.state===`idle`?(0,W.jsx)(j,{textStyle:`sm`,color:`fg.muted`,children:`No replay is currently running.`}):(0,W.jsxs)(B,{align:`stretch`,gap:4,children:[(0,W.jsx)(nt,{currentPhase:o.currentPhase,completedState:o.state===`running`?null:o.state}),o.currentPhase&&(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(j,{textStyle:`lg`,children:rt[o.currentPhase]??`·`}),(0,W.jsxs)(B,{align:`start`,gap:0,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:tt[o.currentPhase]??o.currentPhase}),o.currentProjection&&(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:o.currentProjection})]})]}),o.aggregatesTotal>0&&(0,W.jsxs)(B,{align:`stretch`,gap:1,children:[(0,W.jsxs)(N,{justify:`space-between`,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Aggregates`}),(0,W.jsxs)(j,{textStyle:`xs`,fontWeight:`medium`,children:[o.aggregatesProcessed.toLocaleString(),` / `,o.aggregatesTotal.toLocaleString(),` (`,l,`%)`]})]}),(0,W.jsx)(ie,{value:l,size:`sm`,colorPalette:c,children:(0,W.jsx)(fe,{children:(0,W.jsx)(Oe,{})})})]}),(0,W.jsx)(Le,{}),(0,W.jsxs)(N,{gap:4,flexWrap:`wrap`,children:[(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Events`}),(0,W.jsx)(L,{textStyle:`lg`,children:o.eventsProcessed.toLocaleString()})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Projections`}),(0,W.jsx)(L,{textStyle:`lg`,children:o.projectionNames.length})]}),u!==null&&(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Events/s`}),(0,W.jsx)(L,{textStyle:`lg`,children:u.toLocaleString()})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Elapsed`}),(0,W.jsx)(L,{textStyle:`lg`,children:o.startedAt?Ye(o.startedAt):`—`})]})]}),(0,W.jsxs)(B,{align:`stretch`,gap:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Projections`}),(0,W.jsx)(N,{gap:1,flexWrap:`wrap`,children:o.projectionNames.map(e=>(0,W.jsx)(A,{size:`sm`,variant:e===o.currentProjection?`solid`:`subtle`,colorPalette:e===o.currentProjection?`orange`:`gray`,children:e},e))})]}),o.description&&(0,W.jsxs)(B,{align:`stretch`,gap:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Description`}),(0,W.jsx)(j,{textStyle:`sm`,children:o.description})]}),o.error&&(0,W.jsxs)(D,{padding:3,borderRadius:`md`,bg:`red.subtle`,borderWidth:`1px`,borderColor:`red.200`,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,color:`red.fg`,marginBottom:1,children:`Error`}),(0,W.jsx)(j,{textStyle:`xs`,color:`red.fg`,children:o.error})]})]})}),(0,W.jsx)(xe,{children:(0,W.jsxs)(N,{gap:2,width:`full`,children:[o?.runId&&(0,W.jsx)(E,{size:`sm`,variant:`outline`,flex:1,onClick:()=>{n.push(`/ops/projections/${o.runId}`),t()},children:`Full Page View`}),s&&r&&(0,W.jsx)(E,{size:`sm`,colorPalette:`red`,variant:`outline`,loading:a.isPending,onClick:()=>a.mutate(),children:`Cancel`})]})})]})})}function _n(){let e=Qe(),t=z(),n=V.ops.cancelReplay.useMutation({onSuccess:()=>void t.refetch()}),{hasAccess:r}=S(),i=t.data;return!i||i.state!==`running`?null:(0,W.jsx)(P,{borderColor:`blue.200`,borderWidth:`1px`,children:(0,W.jsx)(F,{padding:4,children:(0,W.jsxs)(N,{justify:`space-between`,children:[(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(Xe,{colorPalette:`blue`,children:(0,W.jsx)(Je,{})}),(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`semibold`,children:`Replay running`}),i.currentProjection&&(0,W.jsx)(A,{size:`sm`,variant:`subtle`,children:i.currentProjection})]}),(0,W.jsxs)(N,{gap:2,children:[i.runId&&(0,W.jsx)(E,{size:`xs`,variant:`outline`,onClick:()=>void e.push(`/ops/projections/${i.runId}`),children:`View Progress`}),r&&(0,W.jsx)(E,{size:`xs`,colorPalette:`red`,variant:`outline`,loading:n.isPending,onClick:()=>n.mutate(),children:`Cancel`})]})]})})})}function vn(){let e=Qe(),t=V.ops.getReplayHistory.useQuery(void 0,{refetchInterval:1e4}).data;return!t||t.length===0?null:(0,W.jsx)(P,{overflow:`hidden`,children:(0,W.jsxs)(F,{padding:0,children:[(0,W.jsx)(N,{paddingX:4,paddingY:3,children:(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:`Replay History`})}),(0,W.jsx)(ae,{children:(0,W.jsxs)(Ee,{size:`sm`,variant:`line`,css:{"& tr:last-child td":{borderBottom:`none`}},children:[(0,W.jsx)(ve,{children:(0,W.jsxs)(de,{children:[(0,W.jsx)(T,{children:`Status`}),(0,W.jsx)(T,{children:`Description`}),(0,W.jsx)(T,{children:`Projections`}),(0,W.jsx)(T,{textAlign:`end`,children:`Duration`}),(0,W.jsx)(T,{textAlign:`end`,children:`Aggregates`}),(0,W.jsx)(T,{textAlign:`end`,children:`Events`}),(0,W.jsx)(T,{children:`When`}),(0,W.jsx)(T,{width:`40px`})]})}),(0,W.jsx)(ge,{children:t.map(t=>{let n=Ze(t.state);return(0,W.jsxs)(de,{cursor:`pointer`,_hover:{bg:`bg.subtle`},onClick:()=>void e.push(`/ops/projections/${t.runId}`),children:[(0,W.jsx)(w,{children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(Xe,{colorPalette:n,children:(0,W.jsx)(Je,{})}),(0,W.jsx)(A,{size:`sm`,variant:`subtle`,colorPalette:n,children:t.state})]})}),(0,W.jsx)(w,{children:(0,W.jsx)(j,{textStyle:`xs`,truncate:!0,maxW:`300px`,children:t.description??`—`})}),(0,W.jsx)(w,{children:(0,W.jsxs)(j,{textStyle:`xs`,color:`fg.muted`,children:[t.projectionNames?.length??0,` projection`,(t.projectionNames?.length??0)===1?``:`s`]})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{textStyle:`xs`,children:Ye(t.startedAt,t.completedAt)})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{textStyle:`xs`,children:(t.aggregatesProcessed??0).toLocaleString()})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{textStyle:`xs`,children:(t.eventsProcessed??0).toLocaleString()})}),(0,W.jsx)(w,{children:(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,whiteSpace:`nowrap`,children:t.startedAt?new Date(t.startedAt).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`—`})}),(0,W.jsx)(w,{children:(0,W.jsx)($e,{size:12,style:{opacity:.5}})})]},t.runId)})})]})})]})})}function yn({tenantIds:e,onTenantIdsChange:t}){let[n,r]=(0,G.useState)(``),i=V.ops.searchTenants.useQuery({query:n},{enabled:n.length>=2});return(0,W.jsxs)(B,{align:`stretch`,gap:2,children:[(0,W.jsxs)(an,{size:`sm`,value:e,onValueChange:e=>t(e.value),addOnPaste:!0,delimiter:`,`,blurBehavior:`add`,validate:e=>e.inputValue.trim().length>0,children:[(0,W.jsx)(on,{children:(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Tenants`})}),(0,W.jsxs)(sn,{children:[(0,W.jsx)(hn,{}),(0,W.jsx)(cn,{placeholder:`Type tenant ID and press Enter...`}),(0,W.jsx)(mn,{})]})]}),(0,W.jsxs)(D,{position:`relative`,children:[(0,W.jsxs)(N,{gap:2,borderWidth:`1px`,borderRadius:`md`,paddingX:3,paddingY:1.5,children:[(0,W.jsx)(ne,{size:12,color:`var(--chakra-colors-fg-muted)`}),(0,W.jsx)(`input`,{style:{flex:1,background:`transparent`,border:`none`,outline:`none`,fontSize:`12px`,color:`inherit`},placeholder:`Search tenants by name or ID...`,value:n,onChange:e=>r(e.target.value)})]}),i.data&&i.data.length>0&&(0,W.jsx)(D,{position:`absolute`,zIndex:10,width:`full`,borderWidth:`1px`,borderRadius:`md`,bg:`bg.panel`,shadow:`md`,maxHeight:`200px`,overflowY:`auto`,marginTop:1,children:i.data.map(n=>(0,W.jsx)(D,{paddingX:3,paddingY:2,cursor:`pointer`,_hover:{bg:`bg.subtle`},onClick:()=>{e.includes(n.id)||t([...e,n.id]),r(``)},children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,children:n.name}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,fontFamily:`mono`,children:n.id}),e.includes(n.id)&&(0,W.jsx)(A,{size:`sm`,colorPalette:`green`,children:`added`})]})},n.id))})]})]})}function bn({onReplayStarted:e}){let{hasAccess:t}=S(),[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(new Set),[u,d]=(0,G.useState)(``),f=V.ops.listProjections.useQuery(),p=z(),m=i||n.length>0,h=o.length>0,ee=m&&h,g=V.ops.discoverAggregates.useQuery({projectionNames:f.data?.projections.map(e=>e.projectionName)??[],since:o,tenantIds:i?[]:n},{enabled:!1}),_=(0,G.useRef)(``);(0,G.useEffect)(()=>{if(!ee)return;let e=JSON.stringify({tenantIds:i?[]:n,since:o});e!==_.current&&(_.current=e,g.refetch().then(e=>{e.data&&l(new Set(e.data.projections.filter(e=>e.aggregateCount>0).map(e=>e.projectionName)))}))},[ee,i,n,o]);let te=!!g.data,v=new Set(g.data?.projections.filter(e=>e.aggregateCount>0).map(e=>e.projectionName)??[]),y=V.ops.startReplay.useMutation({onSuccess:()=>{p.refetch(),k.create({title:`Projection replay started`,description:`Replaying ${c.size} projection${c.size===1?``:`s`}...`,type:`success`}),e()},onError:e=>{k.create({title:`Failed to start replay`,description:e.message,type:`error`})}}),[b,ne]=(0,G.useState)(null),re=V.ops.dryRunReplay.useMutation({onSuccess:e=>{ne(e),k.create({title:`Dry run complete`,description:e.message,type:`info`})},onError:e=>{k.create({title:`Dry run failed`,description:e.message,type:`error`})}});function ie(e){v.has(e)&&l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function ae(){l(new Set(v))}let C=g.data?.projections.filter(e=>c.has(e.projectionName)).reduce((e,t)=>e+t.aggregateCount,0)??0,oe=p.data?.state===`running`;function se(){y.mutate({projectionNames:[...c],since:o,tenantIds:i?[]:n,description:u||`Manual replay`})}function ce(){re.mutate({projectionNames:[...c],since:o,tenantIds:i?[]:n})}return f.isLoading?(0,W.jsx)(Ue,{paddingY:20,children:(0,W.jsx)(Ae,{size:`lg`})}):f.data&&f.data.projections.length===0?(0,W.jsx)(Ue,{paddingY:20,children:(0,W.jsx)(ue,{children:(0,W.jsxs)(he,{children:[(0,W.jsx)(x,{children:`No projections registered`}),(0,W.jsx)(me,{children:`No fold projections were found in the pipeline registry.`})]})})}):f.data?(0,W.jsxs)(B,{align:`stretch`,gap:4,children:[(0,W.jsx)(P,{children:(0,W.jsxs)(F,{padding:4,children:[(0,W.jsxs)(N,{marginBottom:3,justify:`space-between`,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:`1. Select tenants`}),(0,W.jsx)(De,{size:`sm`,checked:i,onCheckedChange:e=>{a(!!e.checked),e.checked&&r([])},children:(0,W.jsx)(j,{textStyle:`xs`,children:`All tenants`})})]}),(0,W.jsx)(D,{opacity:i?.4:1,pointerEvents:i?`none`:`auto`,children:(0,W.jsx)(yn,{tenantIds:n,onTenantIdsChange:r})}),!m&&!i&&(0,W.jsx)(j,{textStyle:`xs`,color:`orange.500`,marginTop:2,children:`At least 1 tenant is required to proceed`})]})}),(0,W.jsx)(P,{opacity:m?1:.5,pointerEvents:m?`auto`:`none`,children:(0,W.jsxs)(F,{padding:4,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,marginBottom:3,children:`2. Choose date range`}),(0,W.jsxs)(N,{gap:3,alignItems:`end`,flexWrap:`wrap`,children:[(0,W.jsxs)(D,{maxWidth:`220px`,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Replay events since`}),(0,W.jsx)(Ge,{type:`date`,size:`sm`,value:o,onChange:e=>s(e.target.value)})]}),(0,W.jsx)(N,{gap:1,children:[{label:`This month`,months:0},{label:`2 months`,months:2},{label:`3 months`,months:3},{label:`6 months`,months:6}].map(({label:e,months:t})=>{let n=new Date;t===0?n.setDate(1):n.setMonth(n.getMonth()-t);let r=n.toISOString().slice(0,10);return(0,W.jsx)(E,{size:`sm`,height:`36px`,variant:o===r?`solid`:`outline`,onClick:()=>s(r),children:e},e)})})]}),ee&&g.isFetching&&(0,W.jsxs)(N,{gap:2,marginTop:3,children:[(0,W.jsx)(Ae,{size:`xs`}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Discovering aggregates...`})]})]})}),te&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(P,{children:(0,W.jsxs)(F,{padding:0,overflowX:`auto`,children:[(0,W.jsxs)(N,{paddingX:4,paddingY:3,justify:`space-between`,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:`3. Select projections to replay`}),(0,W.jsx)(E,{variant:`ghost`,size:`xs`,onClick:ae,children:`Select all with data`})]}),(0,W.jsxs)(Ee,{size:`sm`,variant:`line`,children:[(0,W.jsx)(ve,{children:(0,W.jsxs)(de,{children:[(0,W.jsx)(T,{width:`40px`}),(0,W.jsx)(T,{children:`Projection`}),(0,W.jsx)(T,{children:`Pipeline`}),(0,W.jsx)(T,{textAlign:`end`,children:`Aggregates`}),(0,W.jsx)(T,{children:`Tenants`})]})}),(0,W.jsx)(ge,{children:g.data.projections.map(e=>{let t=e.aggregateCount>0,n=c.has(e.projectionName);return(0,W.jsxs)(de,{cursor:t?`pointer`:`default`,opacity:t?1:.4,onClick:()=>ie(e.projectionName),_hover:t?{bg:`bg.subtle`}:void 0,bg:n?`bg.subtle`:void 0,children:[(0,W.jsx)(w,{children:(0,W.jsx)(De,{checked:n,disabled:!t,onCheckedChange:()=>ie(e.projectionName)})}),(0,W.jsx)(w,{children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(j,{textStyle:`sm`,children:e.projectionName}),!t&&(0,W.jsx)(A,{size:`sm`,variant:`subtle`,colorPalette:`gray`,children:`no data`})]})}),(0,W.jsx)(w,{children:(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:f.data?.projections.find(t=>t.projectionName===e.projectionName)?.pipelineName??`—`})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{fontWeight:`medium`,children:e.aggregateCount})}),(0,W.jsx)(w,{children:(0,W.jsxs)(j,{textStyle:`xs`,color:`fg.muted`,children:[e.tenantBreakdown.length,` tenant`,e.tenantBreakdown.length===1?``:`s`]})})]},e.projectionName)})})]})]})}),c.size>0&&(0,W.jsx)(P,{children:(0,W.jsxs)(F,{padding:4,children:[(0,W.jsxs)(N,{gap:6,marginBottom:4,children:[(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Selected Aggregates`}),(0,W.jsx)(L,{children:C})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Projections`}),(0,W.jsx)(L,{children:c.size})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Tenants`}),(0,W.jsx)(L,{children:i?`All`:n.length})]})]}),t&&(0,W.jsxs)(B,{align:`stretch`,gap:3,children:[(0,W.jsxs)(D,{children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Description (for audit log)`}),(0,W.jsx)(be,{size:`sm`,placeholder:`Describe the reason for this replay...`,value:u,onChange:e=>d(e.target.value),rows:2})]}),(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(E,{size:`sm`,colorPalette:`orange`,disabled:oe||C===0,loading:y.isPending,onClick:se,children:`Start Full Replay`}),(0,W.jsx)(E,{size:`sm`,variant:`outline`,disabled:oe||C===0,loading:re.isPending,onClick:ce,children:`Dry Run (5 aggregates)`}),oe&&(0,W.jsx)(j,{textStyle:`xs`,color:`orange.500`,children:`A replay is already running`})]}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Full replay pauses projections, drains active jobs, replays events from ClickHouse, then unpauses. Dry run processes 5 sample aggregates in memory without writing.`}),b&&(0,W.jsx)(P,{borderColor:`blue.200`,borderWidth:`1px`,children:(0,W.jsxs)(F,{padding:3,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,color:`blue.500`,marginBottom:1,children:`Dry Run Result`}),(0,W.jsx)(j,{textStyle:`sm`,children:b.message}),(0,W.jsxs)(j,{textStyle:`xs`,color:`fg.muted`,marginTop:1,children:[`Projections:`,` `,b.projectionNames.join(`, `),` | Sample size: `,b.sampleSize]})]})})]})]})})]})]}):null}function xn({projections:e,onReplayStarted:t}){let n=z(),r=n.data?.state===`running`,[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(new Set),[u]=(0,G.useState)(()=>{let e=new Date;return e.setMonth(e.getMonth()-3),e.toISOString().slice(0,10)}),d=V.ops.startReplay.useMutation({onSuccess:()=>{n.refetch(),k.create({title:`Single aggregate replay started`,type:`success`}),t()},onError:e=>{k.create({title:`Failed to start replay`,description:e.message,type:`error`})}});function f(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,W.jsxs)(B,{align:`stretch`,gap:2,children:[(0,W.jsxs)(N,{gap:2,children:[(0,W.jsxs)(D,{flex:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Aggregate ID`}),(0,W.jsx)(Ge,{size:`sm`,placeholder:`e.g. trace_abc123`,value:i,onChange:e=>a(e.target.value),fontFamily:`mono`})]}),(0,W.jsxs)(D,{flex:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Tenant ID`}),(0,W.jsx)(Ge,{size:`sm`,placeholder:`e.g. project_xyz`,value:o,onChange:e=>s(e.target.value),fontFamily:`mono`})]})]}),(0,W.jsxs)(D,{children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Projections`}),(0,W.jsx)(N,{gap:1,flexWrap:`wrap`,children:e.map(e=>(0,W.jsx)(A,{size:`sm`,variant:c.has(e.projectionName)?`solid`:`outline`,colorPalette:c.has(e.projectionName)?`orange`:`gray`,cursor:`pointer`,onClick:()=>f(e.projectionName),children:e.projectionName},e.projectionName))})]}),(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(E,{size:`sm`,variant:`outline`,disabled:!i.trim()||!o.trim()||c.size===0||r,loading:d.isPending,onClick:()=>{d.mutate({projectionNames:[...c],since:u,tenantIds:[o.trim()],aggregateIds:[i.trim()],description:`Single aggregate replay: ${i.trim()}`})},children:`Replay Single`}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Replays selected projections for a single tenant (events from last 3 months)`})]})]})}function Sn(){let{hasAccess:e}=S(),[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(!1),a=V.ops.listProjections.useQuery().data?.projections??[];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(B,{align:`stretch`,gap:4,children:[(0,W.jsx)(_n,{}),(0,W.jsx)(bn,{onReplayStarted:()=>n(!0)}),e&&a.length>0&&(0,W.jsxs)(Te,{open:r,onOpenChange:e=>i(e.open),children:[(0,W.jsx)(we,{asChild:!0,children:(0,W.jsx)(D,{cursor:`pointer`,userSelect:`none`,children:(0,W.jsxs)(N,{gap:2,paddingY:1,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,color:`fg.muted`,children:`Advanced: Single Aggregate Replay`}),(0,W.jsx)(_e,{size:12,style:{transform:r?`rotate(180deg)`:`none`,transition:`transform 0.15s`}})]})})}),(0,W.jsx)(ye,{children:(0,W.jsx)(P,{marginTop:2,children:(0,W.jsx)(F,{padding:4,children:(0,W.jsx)(xn,{projections:a,onReplayStarted:()=>n(!0)})})})})]}),(0,W.jsx)(vn,{})]}),(0,W.jsx)(gn,{open:t,onClose:()=>n(!1)})]})}function Cn(){return(0,W.jsx)(et,{children:(0,W.jsxs)(Ce,{children:[(0,W.jsx)(pe.Header,{children:(0,W.jsx)(pe.Heading,{children:`Projection Replay`})}),(0,W.jsx)(pe.Container,{children:(0,W.jsx)(Sn,{})})]})})}export{Cn as default};
2
- //# sourceMappingURL=projections-CTNj1QBM.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$ as n,D as r,M as i,Q as a,Tt as o,U as s,W as c,X as l,Y as u,_ as d,a as f,et as p,i as m,k as h,l as ee,m as g,o as _,p as te,r as v,rt as y,wt as b}from"./prop-types-DifpXm68.js";import{$s as x,Aa as ne,Ao as re,Bs as ie,Cn as S,Cs as ae,Gs as C,Mo as oe,No as se,Oo as ce,Po as le,Qs as ue,Ss as de,Vs as fe,Xr as pe,Xs as me,Ys as he,_s as ge,ao as _e,bs as ve,ec as ye,gs as be,jo as xe,ko as Se,mn as Ce,nc as we,tc as Te,vs as w,xs as Ee,yo as De,ys as T,zs as Oe}from"./command-bar-DUK45yin.js";import{j as ke,n as E,r as Ae}from"./stack-oJ9iWdbl.js";import{t as D}from"./box-BsM8YLGl.js";import{m as je}from"./tabs-DwV1cIZB.js";import{m as Me}from"./tooltip-AEm0YeiF.js";import{m as O,n as k,o as Ne}from"./toaster-C_DYALhL.js";import{c as Pe,i as Fe,l as Ie}from"./radio-group.anatomy-1s_fCJ3y.js";import{an as A}from"./dist-Cds4Mqhj.js";import{h as Le}from"./terminal-CfM0q99k.js";import{a as Re,d as ze,l as Be,s as Ve,u as He}from"./dist-frWhjLir.js";import{t as j}from"./text-CwTrMF8x.js";import{i as Ue}from"./code-FF_ibTVI.js";import{r as We,t as Ge}from"./input-C7emsUCL.js";import{n as M}from"./tags-input.anatomy-BFbwdDIO.js";import{t as Ke}from"./create-slot-recipe-context-B6DU0msX.js";import{c as qe,t as N}from"./h-stack-BKLDJ2vg.js";import{r as P,t as F}from"./card-CMtKVPVl.js";import{n as I,r as L,t as R}from"./stat-CHoKZ9Rr.js";import{c as Je,i as Ye,l as Xe,n as z,t as Ze}from"./ReplayStateBadge-ChyX1KUG.js";import{t as B}from"./v-stack-EOPQ57OZ.js";import{s as V}from"./auth-client-D3UhxhQi.js";import{r as Qe}from"./next-router-C6sliiV7.js";import{t as $e}from"./arrow-right-B3ZN8yal.js";import{t as et}from"./OpsPageShell-C_mTziRS.js";import{n as tt,r as nt,t as rt}from"./PhaseTimeline-DXfTjBZX.js";function it(e){if(!e)return!1;try{return e.selectionStart===0&&e.selectionEnd===0}catch{return e.value===``}}var H=`__live-region__`;function at(e={}){let{level:t=`polite`,document:n=document,root:r,delay:i=0}=e,a=n.defaultView??window,o=r??n.body;function s(e,r){n.getElementById(H)?.remove(),r??=i;let s=n.createElement(`span`);s.id=H,s.dataset.liveAnnouncer=`true`;let c=t===`assertive`?`alert`:`status`;s.setAttribute(`aria-live`,t),s.setAttribute(`role`,c),Object.assign(s.style,{border:`0`,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:`0`,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`}),o.appendChild(s),a.setTimeout(()=>{s.textContent=e},r)}function c(){n.getElementById(H)?.remove()}return{announce:s,destroy:c,toJSON(){return H}}}function ot(e){if(!e)return;let t=Me(e);return`box-sizing:`+t.boxSizing+`;border-left:`+t.borderLeftWidth+` solid red;border-right:`+t.borderRightWidth+` solid red;font-family:`+t.fontFamily+`;font-feature-settings:`+t.fontFeatureSettings+`;font-kerning:`+t.fontKerning+`;font-size:`+t.fontSize+`;font-stretch:`+t.fontStretch+`;font-style:`+t.fontStyle+`;font-variant:`+t.fontVariant+`;font-variant-caps:`+t.fontVariantCaps+`;font-variant-ligatures:`+t.fontVariantLigatures+`;font-variant-numeric:`+t.fontVariantNumeric+`;font-weight:`+t.fontWeight+`;letter-spacing:`+t.letterSpacing+`;margin-left:`+t.marginLeft+`;margin-right:`+t.marginRight+`;padding-left:`+t.paddingLeft+`;padding-right:`+t.paddingRight+`;text-indent:`+t.textIndent+`;text-transform:`+t.textTransform}function st(e){let t=e.createElement(`div`);return t.id=`ghost`,t.style.cssText=`display:inline-block;height:0;overflow:hidden;position:absolute;top:0;visibility:hidden;white-space:nowrap;`,e.body.appendChild(t),t}function ct(e){if(!e)return;let t=h(e),n=i(e),r=st(t),a=ot(e);a&&(r.style.cssText+=a);function o(){n.requestAnimationFrame(()=>{r.innerHTML=e.value;let t=n.getComputedStyle(r);e?.style.setProperty(`width`,t.width)})}return o(),e?.addEventListener(`input`,o),e?.addEventListener(`change`,o),()=>{t.body.removeChild(r),e?.removeEventListener(`input`,o),e?.removeEventListener(`change`,o)}}var[lt,U]=p({name:`TagsInputContext`,hookName:`useTagsInputContext`,providerName:`<TagsInputProvider />`}),W=ke(),G=e(t(),1),ut=(0,G.forwardRef)((e,t)=>{let n=a(U().getClearTriggerProps(),e);return(0,W.jsx)(_.button,{...n,ref:t})});ut.displayName=`TagsInputClearTrigger`;var dt=(0,G.forwardRef)((e,t)=>{let n=a(U().getControlProps(),e);return(0,W.jsx)(_.div,{...n,ref:t})});dt.displayName=`TagsInputControl`;var ft=(0,G.forwardRef)((e,t)=>{let n=a(U().getHiddenInputProps(),e),r=We();return(0,W.jsx)(_.input,{"aria-describedby":r?.ariaDescribedby,...n,ref:t})});ft.displayName=`TagsInputHiddenInput`;var pt=(0,G.forwardRef)((e,t)=>{let n=a(U().getInputProps(),e);return(0,W.jsx)(_.input,{...n,ref:t})});pt.displayName=`TagsInputInput`;var[mt,ht]=p({name:`TagsInputItemContext`,hookName:`useTagsInputItemContext`,providerName:`<TagsInputItemProvider />`}),[gt,K]=p({name:`TagsInputItemPropsContext`,hookName:`useTagsInputItemPropsContext`,providerName:`<TagsInputItemPropsProvider />`}),_t=Re(),vt=(0,G.forwardRef)((e,t)=>{let[n,r]=_t(e,[`index`,`disabled`,`value`]),i=U(),o=a(i.getItemProps(n),r);return(0,W.jsx)(gt,{value:n,children:(0,W.jsx)(mt,{value:i.getItemState(n),children:(0,W.jsx)(_.div,{...o,ref:t})})})});vt.displayName=`TagsInputItem`;var yt=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemDeleteTriggerProps(r),e);return(0,W.jsx)(_.button,{...i,ref:t})});yt.displayName=`TagsInputItemDeleteTrigger`;var bt=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemInputProps(r),e);return(0,W.jsx)(_.input,{...i,ref:t})});bt.displayName=`TagsInputItemInput`;var xt=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemPreviewProps(r),e);return(0,W.jsx)(_.div,{...i,ref:t})});xt.displayName=`TagsInputItemPreview`;var St=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemTextProps(r),e);return(0,W.jsx)(_.span,{...i,ref:t})});St.displayName=`TagsInputItemText`;var Ct=(0,G.forwardRef)((e,t)=>{let n=a(U().getLabelProps(),e);return(0,W.jsx)(_.label,{...n,ref:t})});Ct.displayName=`TagsInputLabel`;var wt=e=>e.ids?.root??`tags-input:${e.id}`,Tt=e=>e.ids?.input??`tags-input:${e.id}:input`,Et=e=>e.ids?.clearBtn??`tags-input:${e.id}:clear-btn`,Dt=e=>e.ids?.hiddenInput??`tags-input:${e.id}:hidden-input`,Ot=e=>e.ids?.label??`tags-input:${e.id}:label`,kt=e=>e.ids?.control??`tags-input:${e.id}:control`,q=(e,t)=>e.ids?.item?.(t)??`tags-input:${e.id}:tag:${t.value}:${t.index}`,At=(e,t)=>e.ids?.itemDeleteTrigger?.(t)??`${q(e,t)}:delete-btn`,jt=(e,t)=>e.ids?.itemInput?.(t)??`${q(e,t)}:input`,Mt=e=>`${e}:input`,Nt=(e,t)=>e.getById(Mt(t)),Pt=e=>ze(It(e),`[data-part=item]`),Ft=(e,t)=>e.getById(jt(e,t)),It=e=>e.getById(wt(e)),J=e=>e.getById(Tt(e)),Lt=e=>e.getById(Dt(e)),Y=e=>ze(It(e),`[data-part=item-preview]:not([data-disabled])`),Rt=e=>Y(e)[0],zt=e=>Y(e)[Y(e).length-1],Bt=(e,t)=>He(Y(e),t,!1),Vt=(e,t)=>Be(Y(e),t,!1),Ht=(e,t)=>Y(e)[t],X=(e,t)=>Ve(Y(e),t),Ut=e=>{let t=e.closest(`[data-part=item-preview]`);t&&(t.dataset.deleteIntent=``)},Wt=e=>{let t=e.closest(`[data-part=item-preview]`);t&&delete t.dataset.deleteIntent},Gt=(e,t)=>{let n=Lt(e);n&&Fe(n,{value:t})};function Kt(e,t){let{state:n,send:r,computed:i,prop:a,scope:o,context:l}=e,u=i(`isInteractive`),f=!!a(`disabled`),p=!!a(`readOnly`),m=!!a(`required`),h=a(`invalid`)||i(`isOverflowing`),_=a(`translations`),v=n.hasTag(`focused`),y=n.matches(`editing:tag`),b=i(`count`)===0;function x(e){let t=q(o,e),n=l.get(`editedTagId`),r=l.get(`highlightedTagId`);return{id:t,editing:y&&n===t,highlighted:t===r,disabled:!!(e.disabled||f)}}return{empty:b,inputValue:l.get(`inputValue`),value:l.get(`value`),valueAsString:i(`valueAsString`),count:i(`count`),atMax:i(`isAtMax`),setValue(e){r({type:`SET_VALUE`,value:e})},clearValue(e){r(e?{type:`CLEAR_TAG`,id:e}:{type:`CLEAR_VALUE`})},addValue(e){r({type:`ADD_TAG`,value:e})},setValueAtIndex(e,t){r({type:`SET_VALUE_AT_INDEX`,index:e,value:t})},setInputValue(e){r({type:`SET_INPUT_VALUE`,value:e})},clearInputValue(){r({type:`SET_INPUT_VALUE`,value:``})},focus(){J(o)?.focus()},getItemState:x,getRootProps(){return t.element({dir:a(`dir`),...M.root.attrs,"data-invalid":c(h),"data-readonly":c(p),"data-disabled":c(f),"data-focus":c(v),"data-empty":c(b),id:wt(o),onPointerDown(){u&&r({type:`POINTER_DOWN`})}})},getLabelProps(){return t.label({...M.label.attrs,"data-disabled":c(f),"data-invalid":c(h),"data-readonly":c(p),"data-required":c(m),id:Ot(o),dir:a(`dir`),htmlFor:Tt(o)})},getControlProps(){return t.element({id:kt(o),...M.control.attrs,dir:a(`dir`),tabIndex:p?0:void 0,"data-disabled":c(f),"data-readonly":c(p),"data-invalid":c(h),"data-focus":c(v)})},getInputProps(){return t.input({...M.input.attrs,dir:a(`dir`),"data-invalid":c(h),"aria-invalid":s(h),"data-readonly":c(p),"data-empty":c(b),maxLength:a(`maxLength`),id:Tt(o),defaultValue:l.get(`inputValue`),autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,enterKeyHint:`done`,disabled:f||p,placeholder:b?a(`placeholder`):void 0,onInput(e){let t=te(e),n=e.currentTarget.value;if(t.inputType===`insertFromPaste`){r({type:`PASTE`,value:n});return}if(qt(n,a(`delimiter`))){r({type:`DELIMITER_KEY`});return}r({type:`TYPE`,value:n,key:t.inputType})},onFocus(){queueMicrotask(()=>{r({type:`FOCUS`})})},onKeyDown(e){if(e.defaultPrevented||g(e))return;let t=e.currentTarget,n=t.getAttribute(`role`)===`combobox`,i=t.ariaExpanded===`true`,o={ArrowDown(){r({type:`ARROW_DOWN`})},ArrowLeft(){n&&i||r({type:`ARROW_LEFT`})},ArrowRight(e){l.get(`highlightedTagId`)&&e.preventDefault(),!(n&&i)&&r({type:`ARROW_RIGHT`})},Escape(e){e.preventDefault(),r({type:`ESCAPE`})},Backspace(){r({type:`BACKSPACE`})},Delete(){r({type:`DELETE`})},Enter(e){let a=t.getAttribute(`aria-activedescendant`);n&&i&&a||(r({type:`ENTER`}),e.preventDefault())}}[ee(e,{dir:a(`dir`)})];if(o){o(e);return}}})},getHiddenInputProps(){return t.input({type:`text`,hidden:!0,name:a(`name`),form:a(`form`),disabled:f,readOnly:p,required:a(`required`),id:Dt(o),defaultValue:i(`valueAsString`)})},getItemProps(e){return t.element({...M.item.attrs,dir:a(`dir`),"data-value":e.value,"data-disabled":c(f)})},getItemPreviewProps(e){let n=x(e);return t.element({...M.itemPreview.attrs,id:n.id,dir:a(`dir`),hidden:n.editing,"data-value":e.value,"data-disabled":c(f),"data-highlighted":c(n.highlighted),onPointerDown(e){!u||n.disabled||d(e)&&(e.preventDefault(),r({type:`POINTER_DOWN_TAG`,id:n.id}))},onDoubleClick(){!u||n.disabled||r({type:`DOUBLE_CLICK_TAG`,id:n.id})}})},getItemTextProps(e){let n=x(e);return t.element({...M.itemText.attrs,dir:a(`dir`),"data-disabled":c(f),"data-highlighted":c(n.highlighted)})},getItemInputProps(e){let n=x(e);return t.input({...M.itemInput.attrs,dir:a(`dir`),"aria-label":_?.tagEdited?.(e.value),disabled:f,id:jt(o,e),tabIndex:-1,hidden:!n.editing,maxLength:a(`maxLength`),defaultValue:n.editing?l.get(`editedTagValue`):``,onInput(e){r({type:`TAG_INPUT_TYPE`,value:e.currentTarget.value})},onBlur(e){queueMicrotask(()=>{r({type:`TAG_INPUT_BLUR`,target:e.relatedTarget,id:n.id})})},onKeyDown(e){if(e.defaultPrevented||g(e))return;let t={Enter(){r({type:`TAG_INPUT_ENTER`})},Escape(){r({type:`TAG_INPUT_ESCAPE`})}}[e.key];t&&(e.preventDefault(),t(e))}})},getItemDeleteTriggerProps(e){let n=x(e);return t.button({...M.itemDeleteTrigger.attrs,dir:a(`dir`),"data-disabled":c(n.disabled),"aria-disabled":n.disabled,"data-highlighted":c(n.highlighted),id:At(o,e),type:`button`,disabled:n.disabled,"aria-label":_?.deleteTagTriggerLabel?.(e.value),tabIndex:-1,onPointerDown(e){d(e)&&(u||e.preventDefault())},onPointerMove(e){u&&Ut(e.currentTarget)},onPointerLeave(e){u&&Wt(e.currentTarget)},onClick(e){e.defaultPrevented||u&&r({type:`CLICK_DELETE_TAG`,id:n.id})}})},getClearTriggerProps(){return t.button({...M.clearTrigger.attrs,dir:a(`dir`),id:Et(o),type:`button`,"data-readonly":c(p),disabled:f,"aria-label":_?.clearTriggerLabel,hidden:b,onClick(){u&&r({type:`CLEAR_VALUE`})}})}}}function qt(e,t){return t?typeof t==`string`?e.endsWith(t):RegExp(`${t.source}$`).test(e):!1}var{and:Z,not:Q,or:Jt}=u(),Yt=l({props({props:e}){return{dir:`ltr`,addOnPaste:!1,editable:!0,validate:()=>!0,allowDuplicates:!1,delimiter:`,`,defaultValue:[],defaultInputValue:``,max:1/0,sanitizeValue:e=>e.trim(),...e,translations:{clearTriggerLabel:`Clear all tags`,deleteTagTriggerLabel:e=>`Delete tag ${e}`,tagAdded:e=>`Added tag ${e}`,tagsPasted:e=>`Pasted ${e.length} tags`,tagEdited:e=>`Editing tag ${e}. Press enter to save or escape to cancel.`,tagUpdated:e=>`Tag update to ${e}`,tagDeleted:e=>`Tag ${e} deleted`,tagSelected:e=>`Tag ${e} selected. Press enter to edit, delete or backspace to remove.`,...e.translations}}},initialState({prop:e}){return e(`autoFocus`)?`focused:input`:`idle`},refs(){return{liveRegion:null,log:{current:null,prev:null}}},context({bindable:e,prop:t}){return{value:e(()=>({defaultValue:t(`defaultValue`),value:t(`value`),isEqual:je,hash(e){return e.join(`, `)},onChange(e){t(`onValueChange`)?.({value:e})}})),inputValue:e(()=>({sync:!0,defaultValue:t(`defaultInputValue`),value:t(`inputValue`),onChange(e){t(`onInputValueChange`)?.({inputValue:e})}})),fieldsetDisabled:e(()=>({defaultValue:!1})),editedTagValue:e(()=>({defaultValue:``})),editedTagId:e(()=>({defaultValue:null})),editedTagIndex:e(()=>({defaultValue:null,sync:!0})),highlightedTagId:e(()=>({defaultValue:null,sync:!0,onChange(e){t(`onHighlightChange`)?.({highlightedValue:e})}}))}},computed:{count:({context:e})=>e.get(`value`).length,valueAsString:({context:e})=>e.hash(`value`),sanitizedInputValue:({context:e,prop:t})=>t(`sanitizeValue`)(e.get(`inputValue`)),isDisabled:({prop:e})=>!!e(`disabled`),isInteractive:({prop:e})=>!(e(`readOnly`)||e(`disabled`)),isAtMax:({context:e,prop:t})=>e.get(`value`).length===t(`max`),isOverflowing:({context:e,prop:t})=>e.get(`value`).length>t(`max`)},watch({track:e,context:t,action:n,computed:r,refs:i}){e([()=>t.get(`editedTagValue`)],()=>{n([`syncEditedTagInputValue`])}),e([()=>t.get(`inputValue`)],()=>{n([`syncInputValue`])}),e([()=>t.get(`highlightedTagId`)],()=>{n([`logHighlightedTag`])}),e([()=>r(`isOverflowing`)],()=>{n([`invokeOnInvalid`])}),e([()=>JSON.stringify(i.get(`log`))],()=>{n([`announceLog`])})},effects:[`trackLiveRegion`,`trackFormControlState`],exit:[`clearLog`],on:{DOUBLE_CLICK_TAG:{guard:`isTagEditable`,target:`editing:tag`,actions:[`setEditedId`]},POINTER_DOWN_TAG:{target:`navigating:tag`,actions:[`highlightTag`,`focusInput`]},CLICK_DELETE_TAG:{target:`focused:input`,actions:[`deleteTag`]},SET_INPUT_VALUE:{actions:[`setInputValue`]},SET_VALUE:{actions:[`setValue`]},CLEAR_TAG:{actions:[`deleteTag`]},SET_VALUE_AT_INDEX:{actions:[`setValueAtIndex`]},CLEAR_VALUE:{actions:[`clearTags`,`clearInputValue`,`focusInput`]},ADD_TAG:{actions:[`addTag`]},INSERT_TAG:{guard:Z(Jt(Q(`isAtMax`),`allowOverflow`),Q(`isInputValueEmpty`)),actions:[`addTag`,`clearInputValue`]},EXTERNAL_BLUR:[{guard:`addOnBlur`,actions:[`raiseInsertTagEvent`]},{guard:`clearOnBlur`,actions:[`clearInputValue`]}]},states:{idle:{on:{FOCUS:{target:`focused:input`},POINTER_DOWN:{guard:Q(`hasHighlightedTag`),target:`focused:input`}}},"focused:input":{tags:[`focused`],entry:[`focusInput`,`clearHighlightedId`],effects:[`trackInteractOutside`],on:{TYPE:{actions:[`setInputValue`]},BLUR:[{guard:`addOnBlur`,target:`idle`,actions:[`raiseInsertTagEvent`]},{guard:`clearOnBlur`,target:`idle`,actions:[`clearInputValue`]},{target:`idle`}],ENTER:{actions:[`raiseInsertTagEvent`]},DELIMITER_KEY:{actions:[`raiseInsertTagEvent`]},ARROW_LEFT:{guard:Z(`hasTags`,`isCaretAtStart`),target:`navigating:tag`,actions:[`highlightLastTag`]},BACKSPACE:{target:`navigating:tag`,guard:Z(`hasTags`,`isCaretAtStart`),actions:[`highlightLastTag`]},DELETE:{guard:`hasHighlightedTag`,actions:[`deleteHighlightedTag`,`highlightTagAtIndex`]},PASTE:[{guard:`addOnPaste`,actions:[`setInputValue`,`addTagFromPaste`]},{actions:[`setInputValue`]}]}},"navigating:tag":{tags:[`focused`],effects:[`trackInteractOutside`],on:{ARROW_RIGHT:[{guard:Z(`hasTags`,`isCaretAtStart`,Q(`isLastTagHighlighted`)),actions:[`highlightNextTag`]},{target:`focused:input`}],ARROW_LEFT:[{guard:Q(`isCaretAtStart`),target:`focused:input`},{actions:[`highlightPrevTag`]}],BLUR:{target:`idle`,actions:[`clearHighlightedId`]},ENTER:{guard:Z(`isTagEditable`,`hasHighlightedTag`),target:`editing:tag`,actions:[`setEditedId`,`focusEditedTagInput`]},ARROW_DOWN:{target:`focused:input`},ESCAPE:{target:`focused:input`},TYPE:{target:`focused:input`,actions:[`setInputValue`]},BACKSPACE:[{guard:Q(`isCaretAtStart`),target:`focused:input`},{guard:`isFirstTagHighlighted`,actions:[`deleteHighlightedTag`,`highlightFirstTag`]},{guard:`hasHighlightedTag`,actions:[`deleteHighlightedTag`,`highlightPrevTag`]},{actions:[`highlightLastTag`]}],DELETE:[{guard:Q(`isCaretAtStart`),target:`focused:input`},{target:`focused:input`,actions:[`deleteHighlightedTag`,`highlightTagAtIndex`]}],PASTE:[{guard:`addOnPaste`,target:`focused:input`,actions:[`setInputValue`,`addTagFromPaste`]},{target:`focused:input`,actions:[`setInputValue`]}]}},"editing:tag":{tags:[`editing`,`focused`],entry:[`focusEditedTagInput`],effects:[`autoResize`],on:{TAG_INPUT_TYPE:{actions:[`setEditedTagValue`]},TAG_INPUT_ESCAPE:{target:`navigating:tag`,actions:[`clearEditedTagValue`,`focusInput`,`clearEditedId`,`highlightTagAtIndex`]},TAG_INPUT_BLUR:[{guard:`isInputRelatedTarget`,target:`navigating:tag`,actions:[`clearEditedTagValue`,`clearHighlightedId`,`clearEditedId`]},{target:`idle`,actions:[`clearEditedTagValue`,`clearHighlightedId`,`clearEditedId`,`raiseExternalBlurEvent`]}],TAG_INPUT_ENTER:[{guard:`isEditedTagEmpty`,target:`navigating:tag`,actions:[`deleteHighlightedTag`,`focusInput`,`clearEditedId`,`highlightTagAtIndex`]},{target:`navigating:tag`,actions:[`submitEditedTagValue`,`focusInput`,`clearEditedId`,`highlightTagAtIndex`]}]}}},implementations:{guards:{isInputRelatedTarget:({scope:e,event:t})=>t.relatedTarget===J(e),isAtMax:({computed:e})=>e(`isAtMax`),hasHighlightedTag:({context:e})=>e.get(`highlightedTagId`)!=null,isFirstTagHighlighted:({context:e,scope:t})=>q(t,{value:e.get(`value`)[0],index:0})===e.get(`highlightedTagId`),isEditedTagEmpty:({context:e,prop:t})=>t(`sanitizeValue`)(e.get(`editedTagValue`))===``,isLastTagHighlighted:({context:e,scope:t})=>{let n=e.get(`value`),r=n.length-1;return q(t,{value:n[r],index:r})===e.get(`highlightedTagId`)},isInputValueEmpty:({context:e,prop:t})=>t(`sanitizeValue`)(e.get(`inputValue`)).length===0,hasTags:({context:e})=>e.get(`value`).length>0,allowOverflow:({prop:e})=>!!e(`allowOverflow`),autoFocus:({prop:e})=>!!e(`autoFocus`),addOnBlur:({prop:e})=>e(`blurBehavior`)===`add`,clearOnBlur:({prop:e})=>e(`blurBehavior`)===`clear`,addOnPaste:({prop:e})=>!!e(`addOnPaste`),isTagEditable:({prop:e})=>!!e(`editable`),isCaretAtStart:({scope:e})=>it(J(e))},effects:{trackInteractOutside({scope:e,prop:t,send:n}){return Ne(J(e),{exclude(t){return Pt(e).some(e=>r(e,t))},onFocusOutside:t(`onFocusOutside`),onPointerDownOutside:t(`onPointerDownOutside`),onInteractOutside(e){t(`onInteractOutside`)?.(e),!e.defaultPrevented&&n({type:`BLUR`,src:`interact-outside`})}})},trackFormControlState({context:e,send:t,scope:n}){return Ie(Lt(n),{onFieldsetDisabledChange(t){e.set(`fieldsetDisabled`,t)},onFormReset(){t({type:`SET_VALUE`,value:e.initial(`value`),src:`form-reset`})}})},autoResize({context:e,prop:t,scope:n}){let r;return queueMicrotask(()=>{let i=e.get(`editedTagValue`),a=e.get(`editedTagIndex`);!i||a==null||!t(`editable`)||(r=ct(Ft(n,{value:i,index:a})))}),()=>{r?.()}},trackLiveRegion({scope:e,refs:t}){let n=at({level:`assertive`,document:e.getDoc()});return t.set(`liveRegion`,n),()=>n.destroy()}},actions:{raiseInsertTagEvent({send:e}){e({type:`INSERT_TAG`})},raiseExternalBlurEvent({send:e,event:t}){e({type:`EXTERNAL_BLUR`,id:t.id})},dispatchChangeEvent({scope:e,computed:t}){Gt(e,t(`valueAsString`))},highlightNextTag({context:e,scope:t}){let n=e.get(`highlightedTagId`);if(n==null)return;let r=Vt(t,n);e.set(`highlightedTagId`,r?.id??null)},highlightFirstTag({context:e,scope:t}){O(()=>{let n=Rt(t);e.set(`highlightedTagId`,n?.id??null)})},highlightLastTag({context:e,scope:t}){let n=zt(t);e.set(`highlightedTagId`,n?.id??null)},highlightPrevTag({context:e,scope:t}){let n=e.get(`highlightedTagId`);if(n==null)return;let r=Bt(t,n);e.set(`highlightedTagId`,r?.id??null)},highlightTag({context:e,event:t}){e.set(`highlightedTagId`,t.id)},highlightTagAtIndex({context:e,scope:t}){O(()=>{let n=e.get(`editedTagIndex`);if(n==null)return;let r=Ht(t,n);r!=null&&(e.set(`highlightedTagId`,r.id),e.set(`editedTagIndex`,null))})},deleteTag({context:e,scope:t,event:n,refs:r}){let i=X(t,n.id),a=e.get(`value`)[i],o=r.get(`log`);r.set(`log`,{prev:o.current,current:{type:`delete`,value:a}}),e.set(`value`,e=>b(e,i))},deleteHighlightedTag({context:e,scope:t,refs:n}){let r=e.get(`highlightedTagId`);if(r==null)return;let i=X(t,r);e.set(`editedTagIndex`,i);let a=e.get(`value`),o=n.get(`log`);n.set(`log`,{prev:o.current,current:{type:`delete`,value:a[i]}}),e.set(`value`,e=>b(e,i))},setEditedId({context:e,event:t,scope:n}){let r=e.get(`highlightedTagId`),i=t.id??r;e.set(`editedTagId`,i);let a=X(n,i),o=e.get(`value`)[a];e.set(`editedTagIndex`,a),e.set(`editedTagValue`,o)},clearEditedId({context:e}){e.set(`editedTagId`,null)},clearEditedTagValue({context:e}){e.set(`editedTagValue`,``)},setEditedTagValue({context:e,event:t}){e.set(`editedTagValue`,t.value)},submitEditedTagValue({context:e,scope:t,refs:n,prop:r}){let i=e.get(`editedTagId`);if(!i)return;let a=X(t,i),o=e.get(`editedTagValue`),s=e.get(`value`),c=s.some((e,t)=>t!==a&&e===o);if(!r(`allowDuplicates`)&&c||s[a]===o)return;e.set(`value`,e=>{let t=e.slice();return t[a]=o,t});let l=n.get(`log`);n.set(`log`,{prev:l.current,current:{type:`update`,value:o}})},setValueAtIndex({context:e,event:t,refs:n,prop:r}){if(t.value){let i=e.get(`value`),a=i.some((e,n)=>n!==t.index&&e===t.value);if(!r(`allowDuplicates`)&&a||i[t.index]===t.value)return;e.set(`value`,e=>{let n=e.slice();return n[t.index]=t.value,n});let o=n.get(`log`);n.set(`log`,{prev:o.current,current:{type:`update`,value:t.value}})}else y(`You need to provide a value for the tag`)},focusEditedTagInput({context:e,scope:t}){O(()=>{let n=e.get(`editedTagId`);n&&Nt(t,n)?.select()})},setInputValue({context:e,event:t}){e.set(`inputValue`,t.value)},clearHighlightedId({context:e}){e.set(`highlightedTagId`,null)},focusInput({scope:e}){O(()=>{J(e)?.focus()})},clearInputValue({context:e}){O(()=>{e.set(`inputValue`,``)})},syncInputValue({context:e,scope:t}){let n=J(t);n&&Pe(n,e.get(`inputValue`))},syncEditedTagInputValue({context:e,event:t,scope:n}){let r=e.get(`editedTagId`)||e.get(`highlightedTagId`)||t.id;if(r==null)return;let i=Nt(n,r);i&&Pe(i,e.get(`editedTagValue`))},addTag({context:e,event:t,computed:n,prop:r,refs:i}){let a=t.value??n(`sanitizedInputValue`),s=e.get(`value`);if(r(`validate`)?.({inputValue:a,value:Array.from(s)})){let t=r(`allowDuplicates`)?s.concat(a):o(s.concat(a));e.set(`value`,t);let n=i.get(`log`);i.set(`log`,{prev:n.current,current:{type:`add`,value:a}})}else r(`onValueInvalid`)?.({reason:`invalidTag`})},addTagFromPaste({context:e,computed:t,prop:n,refs:r}){O(()=>{let i=t(`sanitizedInputValue`),a=e.get(`value`),s=n(`sanitizeValue`);if(n(`validate`)?.({inputValue:i,value:Array.from(a)})){let t=n(`delimiter`),c=t?i.split(t).map(s):[i],l=n(`allowDuplicates`)?a.concat(...c):o(a.concat(...c));e.set(`value`,l);let u=r.get(`log`);r.set(`log`,{prev:u.current,current:{type:`paste`,values:c}})}else n(`onValueInvalid`)?.({reason:`invalidTag`});e.set(`inputValue`,``)})},clearTags({context:e,refs:t}){e.set(`value`,[]);let n=t.get(`log`);t.set(`log`,{prev:n.current,current:{type:`clear`}})},setValue({context:e,event:t}){e.set(`value`,t.value)},invokeOnInvalid({prop:e,computed:t}){t(`isOverflowing`)&&e(`onValueInvalid`)?.({reason:`rangeOverflow`})},clearLog({refs:e}){let t=e.get(`log`);t.prev=t.current=null},logHighlightedTag({refs:e,context:t,scope:n}){let r=t.get(`highlightedTagId`),i=e.get(`log`);if(r==null||!i.current)return;let a=X(n,r),o=t.get(`value`)[a],s=e.get(`log`);e.set(`log`,{prev:s.current,current:{type:`select`,value:o}})},announceLog({refs:e,prop:t}){let n=e.get(`liveRegion`),r=t(`translations`),i=e.get(`log`);if(!i.current||n==null)return;let a=n,{current:o,prev:s}=i,c;switch(o.type){case`add`:c=r.tagAdded(o.value);break;case`delete`:c=r.tagDeleted(o.value);break;case`update`:c=r.tagUpdated(o.value);break;case`paste`:c=r.tagsPasted(o.values);break;case`select`:c=r.tagSelected(o.value),s?.type===`delete`?c=`${r.tagDeleted(s.value)}. ${c}`:s?.type===`update`&&(c=`${r.tagUpdated(s.value)}. ${c}`);break;default:break}c&&a.announce(c)}}}}),Xt=e=>{let t=(0,G.useId)(),{getRootNode:r}=n(),{dir:i}=f(),a=We();return Kt(m(Yt,{id:t,ids:{label:a?.ids.label,hiddenInput:a?.ids.control},dir:i,disabled:a?.disabled,invalid:a?.invalid,readOnly:a?.readOnly,required:a?.required,getRootNode:r,...e}),v)},Zt=Re(),Qt=(0,G.forwardRef)((e,t)=>{let[n,r]=Zt(e,`addOnPaste.allowDuplicates.allowOverflow.autoFocus.blurBehavior.defaultInputValue.defaultValue.delimiter.disabled.editable.form.id.ids.inputValue.invalid.max.maxLength.name.onFocusOutside.onHighlightChange.onInputValueChange.onInteractOutside.onPointerDownOutside.onValueChange.onValueInvalid.placeholder.readOnly.required.sanitizeValue.translations.validate.value`.split(`.`)),i=Xt(n),o=a(i.getRootProps(),r);return(0,W.jsx)(lt,{value:i,children:(0,W.jsx)(_.div,{...o,ref:t})})});Qt.displayName=`TagsInputRoot`;var $t=Re(),en=(0,G.forwardRef)((e,t)=>{let[{value:n},r]=$t(e,[`value`]),i=a(n.getRootProps(),r);return(0,W.jsx)(lt,{value:n,children:(0,W.jsx)(_.div,{...i,ref:t})})});en.displayName=`TagsInputRootProvider`;var{withProvider:tn,withContext:$,useStyles:nn,PropsProvider:rn}=Ke({key:`tagsInput`});tn(en,`root`,{forwardAsChild:!0});var an=tn(Qt,`root`,{forwardAsChild:!0,defaultProps:{editable:!1}}),on=$(Ct,`label`,{forwardAsChild:!0}),sn=$(dt,`control`,{forwardAsChild:!0}),cn=$(pt,`input`,{forwardAsChild:!0}),ln=$(vt,`item`,{forwardAsChild:!0}),un=$(St,`itemText`,{forwardAsChild:!0}),dn=$(yt,`itemDeleteTrigger`,{forwardAsChild:!0,defaultProps:{children:(0,W.jsx)(qe,{})}}),fn=$(xt,`itemPreview`,{forwardAsChild:!0}),pn=$(bt,`itemInput`,{forwardAsChild:!0}),mn=$(ut,`clearTrigger`,{forwardAsChild:!0,defaultProps:{children:(0,W.jsx)(qe,{})}}),hn=e=>(0,W.jsx)(C,{each:U().value,children:(t,n)=>(0,W.jsxs)(ln,{index:n,value:t,...e,children:[(0,W.jsxs)(fn,{children:[(0,W.jsx)(un,{children:t}),(0,W.jsx)(dn,{})]}),(0,W.jsx)(pn,{})]},n)});function gn({open:e,onClose:t}){let n=Qe(),{hasAccess:r}=S(),i=z({refetchInterval:e?1e3:!1}),a=V.ops.cancelReplay.useMutation({onSuccess:()=>void i.refetch()}),o=i.data,s=o?.state===`running`,c=o?.state===`completed`?`green`:o?.state===`failed`?`red`:o?.state===`cancelled`?`orange`:`blue`,l=o&&o.aggregatesTotal>0?Math.round(o.aggregatesProcessed/o.aggregatesTotal*100):0,u=(0,G.useMemo)(()=>{if(!o?.startedAt||!o.eventsProcessed)return null;let e=(Date.now()-new Date(o.startedAt).getTime())/1e3;return e<1?null:Math.round(o.eventsProcessed/e)},[o?.startedAt,o?.eventsProcessed]);return(0,W.jsx)(se,{open:e,onOpenChange:e=>{e.open||t()},placement:`end`,size:`sm`,children:(0,W.jsxs)(re,{children:[(0,W.jsxs)(oe,{children:[(0,W.jsx)(le,{children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(Xe,{colorPalette:c,size:`sm`,children:(0,W.jsx)(Je,{})}),`Replay `,o?.state??`idle`]})}),(0,W.jsx)(Se,{})]}),(0,W.jsx)(ce,{children:!o||o.state===`idle`?(0,W.jsx)(j,{textStyle:`sm`,color:`fg.muted`,children:`No replay is currently running.`}):(0,W.jsxs)(B,{align:`stretch`,gap:4,children:[(0,W.jsx)(nt,{currentPhase:o.currentPhase,completedState:o.state===`running`?null:o.state}),o.currentPhase&&(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(j,{textStyle:`lg`,children:rt[o.currentPhase]??`·`}),(0,W.jsxs)(B,{align:`start`,gap:0,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:tt[o.currentPhase]??o.currentPhase}),o.currentProjection&&(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:o.currentProjection})]})]}),o.aggregatesTotal>0&&(0,W.jsxs)(B,{align:`stretch`,gap:1,children:[(0,W.jsxs)(N,{justify:`space-between`,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Aggregates`}),(0,W.jsxs)(j,{textStyle:`xs`,fontWeight:`medium`,children:[o.aggregatesProcessed.toLocaleString(),` / `,o.aggregatesTotal.toLocaleString(),` (`,l,`%)`]})]}),(0,W.jsx)(ie,{value:l,size:`sm`,colorPalette:c,children:(0,W.jsx)(fe,{children:(0,W.jsx)(Oe,{})})})]}),(0,W.jsx)(Le,{}),(0,W.jsxs)(N,{gap:4,flexWrap:`wrap`,children:[(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Events`}),(0,W.jsx)(L,{textStyle:`lg`,children:o.eventsProcessed.toLocaleString()})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Projections`}),(0,W.jsx)(L,{textStyle:`lg`,children:o.projectionNames.length})]}),u!==null&&(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Events/s`}),(0,W.jsx)(L,{textStyle:`lg`,children:u.toLocaleString()})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Elapsed`}),(0,W.jsx)(L,{textStyle:`lg`,children:o.startedAt?Ye(o.startedAt):`—`})]})]}),(0,W.jsxs)(B,{align:`stretch`,gap:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Projections`}),(0,W.jsx)(N,{gap:1,flexWrap:`wrap`,children:o.projectionNames.map(e=>(0,W.jsx)(A,{size:`sm`,variant:e===o.currentProjection?`solid`:`subtle`,colorPalette:e===o.currentProjection?`orange`:`gray`,children:e},e))})]}),o.description&&(0,W.jsxs)(B,{align:`stretch`,gap:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Description`}),(0,W.jsx)(j,{textStyle:`sm`,children:o.description})]}),o.error&&(0,W.jsxs)(D,{padding:3,borderRadius:`md`,bg:`red.subtle`,borderWidth:`1px`,borderColor:`red.200`,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,color:`red.fg`,marginBottom:1,children:`Error`}),(0,W.jsx)(j,{textStyle:`xs`,color:`red.fg`,children:o.error})]})]})}),(0,W.jsx)(xe,{children:(0,W.jsxs)(N,{gap:2,width:`full`,children:[o?.runId&&(0,W.jsx)(E,{size:`sm`,variant:`outline`,flex:1,onClick:()=>{n.push(`/ops/projections/${o.runId}`),t()},children:`Full Page View`}),s&&r&&(0,W.jsx)(E,{size:`sm`,colorPalette:`red`,variant:`outline`,loading:a.isPending,onClick:()=>a.mutate(),children:`Cancel`})]})})]})})}function _n(){let e=Qe(),t=z(),n=V.ops.cancelReplay.useMutation({onSuccess:()=>void t.refetch()}),{hasAccess:r}=S(),i=t.data;return!i||i.state!==`running`?null:(0,W.jsx)(P,{borderColor:`blue.200`,borderWidth:`1px`,children:(0,W.jsx)(F,{padding:4,children:(0,W.jsxs)(N,{justify:`space-between`,children:[(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(Xe,{colorPalette:`blue`,children:(0,W.jsx)(Je,{})}),(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`semibold`,children:`Replay running`}),i.currentProjection&&(0,W.jsx)(A,{size:`sm`,variant:`subtle`,children:i.currentProjection})]}),(0,W.jsxs)(N,{gap:2,children:[i.runId&&(0,W.jsx)(E,{size:`xs`,variant:`outline`,onClick:()=>void e.push(`/ops/projections/${i.runId}`),children:`View Progress`}),r&&(0,W.jsx)(E,{size:`xs`,colorPalette:`red`,variant:`outline`,loading:n.isPending,onClick:()=>n.mutate(),children:`Cancel`})]})]})})})}function vn(){let e=Qe(),t=V.ops.getReplayHistory.useQuery(void 0,{refetchInterval:1e4}).data;return!t||t.length===0?null:(0,W.jsx)(P,{overflow:`hidden`,children:(0,W.jsxs)(F,{padding:0,children:[(0,W.jsx)(N,{paddingX:4,paddingY:3,children:(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:`Replay History`})}),(0,W.jsx)(ae,{children:(0,W.jsxs)(Ee,{size:`sm`,variant:`line`,css:{"& tr:last-child td":{borderBottom:`none`}},children:[(0,W.jsx)(ve,{children:(0,W.jsxs)(de,{children:[(0,W.jsx)(T,{children:`Status`}),(0,W.jsx)(T,{children:`Description`}),(0,W.jsx)(T,{children:`Projections`}),(0,W.jsx)(T,{textAlign:`end`,children:`Duration`}),(0,W.jsx)(T,{textAlign:`end`,children:`Aggregates`}),(0,W.jsx)(T,{textAlign:`end`,children:`Events`}),(0,W.jsx)(T,{children:`When`}),(0,W.jsx)(T,{width:`40px`})]})}),(0,W.jsx)(ge,{children:t.map(t=>{let n=Ze(t.state);return(0,W.jsxs)(de,{cursor:`pointer`,_hover:{bg:`bg.subtle`},onClick:()=>void e.push(`/ops/projections/${t.runId}`),children:[(0,W.jsx)(w,{children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(Xe,{colorPalette:n,children:(0,W.jsx)(Je,{})}),(0,W.jsx)(A,{size:`sm`,variant:`subtle`,colorPalette:n,children:t.state})]})}),(0,W.jsx)(w,{children:(0,W.jsx)(j,{textStyle:`xs`,truncate:!0,maxW:`300px`,children:t.description??`—`})}),(0,W.jsx)(w,{children:(0,W.jsxs)(j,{textStyle:`xs`,color:`fg.muted`,children:[t.projectionNames?.length??0,` projection`,(t.projectionNames?.length??0)===1?``:`s`]})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{textStyle:`xs`,children:Ye(t.startedAt,t.completedAt)})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{textStyle:`xs`,children:(t.aggregatesProcessed??0).toLocaleString()})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{textStyle:`xs`,children:(t.eventsProcessed??0).toLocaleString()})}),(0,W.jsx)(w,{children:(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,whiteSpace:`nowrap`,children:t.startedAt?new Date(t.startedAt).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`—`})}),(0,W.jsx)(w,{children:(0,W.jsx)($e,{size:12,style:{opacity:.5}})})]},t.runId)})})]})})]})})}function yn({tenantIds:e,onTenantIdsChange:t}){let[n,r]=(0,G.useState)(``),i=V.ops.searchTenants.useQuery({query:n},{enabled:n.length>=2});return(0,W.jsxs)(B,{align:`stretch`,gap:2,children:[(0,W.jsxs)(an,{size:`sm`,value:e,onValueChange:e=>t(e.value),addOnPaste:!0,delimiter:`,`,blurBehavior:`add`,validate:e=>e.inputValue.trim().length>0,children:[(0,W.jsx)(on,{children:(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Tenants`})}),(0,W.jsxs)(sn,{children:[(0,W.jsx)(hn,{}),(0,W.jsx)(cn,{placeholder:`Type tenant ID and press Enter...`}),(0,W.jsx)(mn,{})]})]}),(0,W.jsxs)(D,{position:`relative`,children:[(0,W.jsxs)(N,{gap:2,borderWidth:`1px`,borderRadius:`md`,paddingX:3,paddingY:1.5,children:[(0,W.jsx)(ne,{size:12,color:`var(--chakra-colors-fg-muted)`}),(0,W.jsx)(`input`,{style:{flex:1,background:`transparent`,border:`none`,outline:`none`,fontSize:`12px`,color:`inherit`},placeholder:`Search tenants by name or ID...`,value:n,onChange:e=>r(e.target.value)})]}),i.data&&i.data.length>0&&(0,W.jsx)(D,{position:`absolute`,zIndex:10,width:`full`,borderWidth:`1px`,borderRadius:`md`,bg:`bg.panel`,shadow:`md`,maxHeight:`200px`,overflowY:`auto`,marginTop:1,children:i.data.map(n=>(0,W.jsx)(D,{paddingX:3,paddingY:2,cursor:`pointer`,_hover:{bg:`bg.subtle`},onClick:()=>{e.includes(n.id)||t([...e,n.id]),r(``)},children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,children:n.name}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,fontFamily:`mono`,children:n.id}),e.includes(n.id)&&(0,W.jsx)(A,{size:`sm`,colorPalette:`green`,children:`added`})]})},n.id))})]})]})}function bn({onReplayStarted:e}){let{hasAccess:t}=S(),[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(new Set),[u,d]=(0,G.useState)(``),f=V.ops.listProjections.useQuery(),p=z(),m=i||n.length>0,h=o.length>0,ee=m&&h,g=V.ops.discoverAggregates.useQuery({projectionNames:f.data?.projections.map(e=>e.projectionName)??[],since:o,tenantIds:i?[]:n},{enabled:!1}),_=(0,G.useRef)(``);(0,G.useEffect)(()=>{if(!ee)return;let e=JSON.stringify({tenantIds:i?[]:n,since:o});e!==_.current&&(_.current=e,g.refetch().then(e=>{e.data&&l(new Set(e.data.projections.filter(e=>e.aggregateCount>0).map(e=>e.projectionName)))}))},[ee,i,n,o]);let te=!!g.data,v=new Set(g.data?.projections.filter(e=>e.aggregateCount>0).map(e=>e.projectionName)??[]),y=V.ops.startReplay.useMutation({onSuccess:()=>{p.refetch(),k.create({title:`Projection replay started`,description:`Replaying ${c.size} projection${c.size===1?``:`s`}...`,type:`success`}),e()},onError:e=>{k.create({title:`Failed to start replay`,description:e.message,type:`error`})}}),[b,ne]=(0,G.useState)(null),re=V.ops.dryRunReplay.useMutation({onSuccess:e=>{ne(e),k.create({title:`Dry run complete`,description:e.message,type:`info`})},onError:e=>{k.create({title:`Dry run failed`,description:e.message,type:`error`})}});function ie(e){v.has(e)&&l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function ae(){l(new Set(v))}let C=g.data?.projections.filter(e=>c.has(e.projectionName)).reduce((e,t)=>e+t.aggregateCount,0)??0,oe=p.data?.state===`running`;function se(){y.mutate({projectionNames:[...c],since:o,tenantIds:i?[]:n,description:u||`Manual replay`})}function ce(){re.mutate({projectionNames:[...c],since:o,tenantIds:i?[]:n})}return f.isLoading?(0,W.jsx)(Ue,{paddingY:20,children:(0,W.jsx)(Ae,{size:`lg`})}):f.data&&f.data.projections.length===0?(0,W.jsx)(Ue,{paddingY:20,children:(0,W.jsx)(ue,{children:(0,W.jsxs)(he,{children:[(0,W.jsx)(x,{children:`No projections registered`}),(0,W.jsx)(me,{children:`No fold projections were found in the pipeline registry.`})]})})}):f.data?(0,W.jsxs)(B,{align:`stretch`,gap:4,children:[(0,W.jsx)(P,{children:(0,W.jsxs)(F,{padding:4,children:[(0,W.jsxs)(N,{marginBottom:3,justify:`space-between`,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:`1. Select tenants`}),(0,W.jsx)(De,{size:`sm`,checked:i,onCheckedChange:e=>{a(!!e.checked),e.checked&&r([])},children:(0,W.jsx)(j,{textStyle:`xs`,children:`All tenants`})})]}),(0,W.jsx)(D,{opacity:i?.4:1,pointerEvents:i?`none`:`auto`,children:(0,W.jsx)(yn,{tenantIds:n,onTenantIdsChange:r})}),!m&&!i&&(0,W.jsx)(j,{textStyle:`xs`,color:`orange.500`,marginTop:2,children:`At least 1 tenant is required to proceed`})]})}),(0,W.jsx)(P,{opacity:m?1:.5,pointerEvents:m?`auto`:`none`,children:(0,W.jsxs)(F,{padding:4,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,marginBottom:3,children:`2. Choose date range`}),(0,W.jsxs)(N,{gap:3,alignItems:`end`,flexWrap:`wrap`,children:[(0,W.jsxs)(D,{maxWidth:`220px`,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Replay events since`}),(0,W.jsx)(Ge,{type:`date`,size:`sm`,value:o,onChange:e=>s(e.target.value)})]}),(0,W.jsx)(N,{gap:1,children:[{label:`This month`,months:0},{label:`2 months`,months:2},{label:`3 months`,months:3},{label:`6 months`,months:6}].map(({label:e,months:t})=>{let n=new Date;t===0?n.setDate(1):n.setMonth(n.getMonth()-t);let r=n.toISOString().slice(0,10);return(0,W.jsx)(E,{size:`sm`,height:`36px`,variant:o===r?`solid`:`outline`,onClick:()=>s(r),children:e},e)})})]}),ee&&g.isFetching&&(0,W.jsxs)(N,{gap:2,marginTop:3,children:[(0,W.jsx)(Ae,{size:`xs`}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Discovering aggregates...`})]})]})}),te&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(P,{children:(0,W.jsxs)(F,{padding:0,overflowX:`auto`,children:[(0,W.jsxs)(N,{paddingX:4,paddingY:3,justify:`space-between`,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:`3. Select projections to replay`}),(0,W.jsx)(E,{variant:`ghost`,size:`xs`,onClick:ae,children:`Select all with data`})]}),(0,W.jsxs)(Ee,{size:`sm`,variant:`line`,children:[(0,W.jsx)(ve,{children:(0,W.jsxs)(de,{children:[(0,W.jsx)(T,{width:`40px`}),(0,W.jsx)(T,{children:`Projection`}),(0,W.jsx)(T,{children:`Pipeline`}),(0,W.jsx)(T,{textAlign:`end`,children:`Aggregates`}),(0,W.jsx)(T,{children:`Tenants`})]})}),(0,W.jsx)(ge,{children:g.data.projections.map(e=>{let t=e.aggregateCount>0,n=c.has(e.projectionName);return(0,W.jsxs)(de,{cursor:t?`pointer`:`default`,opacity:t?1:.4,onClick:()=>ie(e.projectionName),_hover:t?{bg:`bg.subtle`}:void 0,bg:n?`bg.subtle`:void 0,children:[(0,W.jsx)(w,{children:(0,W.jsx)(De,{checked:n,disabled:!t,onCheckedChange:()=>ie(e.projectionName)})}),(0,W.jsx)(w,{children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(j,{textStyle:`sm`,children:e.projectionName}),!t&&(0,W.jsx)(A,{size:`sm`,variant:`subtle`,colorPalette:`gray`,children:`no data`})]})}),(0,W.jsx)(w,{children:(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:f.data?.projections.find(t=>t.projectionName===e.projectionName)?.pipelineName??`—`})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{fontWeight:`medium`,children:e.aggregateCount})}),(0,W.jsx)(w,{children:(0,W.jsxs)(j,{textStyle:`xs`,color:`fg.muted`,children:[e.tenantBreakdown.length,` tenant`,e.tenantBreakdown.length===1?``:`s`]})})]},e.projectionName)})})]})]})}),c.size>0&&(0,W.jsx)(P,{children:(0,W.jsxs)(F,{padding:4,children:[(0,W.jsxs)(N,{gap:6,marginBottom:4,children:[(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Selected Aggregates`}),(0,W.jsx)(L,{children:C})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Projections`}),(0,W.jsx)(L,{children:c.size})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Tenants`}),(0,W.jsx)(L,{children:i?`All`:n.length})]})]}),t&&(0,W.jsxs)(B,{align:`stretch`,gap:3,children:[(0,W.jsxs)(D,{children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Description (for audit log)`}),(0,W.jsx)(be,{size:`sm`,placeholder:`Describe the reason for this replay...`,value:u,onChange:e=>d(e.target.value),rows:2})]}),(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(E,{size:`sm`,colorPalette:`orange`,disabled:oe||C===0,loading:y.isPending,onClick:se,children:`Start Full Replay`}),(0,W.jsx)(E,{size:`sm`,variant:`outline`,disabled:oe||C===0,loading:re.isPending,onClick:ce,children:`Dry Run (5 aggregates)`}),oe&&(0,W.jsx)(j,{textStyle:`xs`,color:`orange.500`,children:`A replay is already running`})]}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Full replay pauses projections, drains active jobs, replays events from ClickHouse, then unpauses. Dry run processes 5 sample aggregates in memory without writing.`}),b&&(0,W.jsx)(P,{borderColor:`blue.200`,borderWidth:`1px`,children:(0,W.jsxs)(F,{padding:3,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,color:`blue.500`,marginBottom:1,children:`Dry Run Result`}),(0,W.jsx)(j,{textStyle:`sm`,children:b.message}),(0,W.jsxs)(j,{textStyle:`xs`,color:`fg.muted`,marginTop:1,children:[`Projections:`,` `,b.projectionNames.join(`, `),` | Sample size: `,b.sampleSize]})]})})]})]})})]})]}):null}function xn({projections:e,onReplayStarted:t}){let n=z(),r=n.data?.state===`running`,[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(new Set),[u]=(0,G.useState)(()=>{let e=new Date;return e.setMonth(e.getMonth()-3),e.toISOString().slice(0,10)}),d=V.ops.startReplay.useMutation({onSuccess:()=>{n.refetch(),k.create({title:`Single aggregate replay started`,type:`success`}),t()},onError:e=>{k.create({title:`Failed to start replay`,description:e.message,type:`error`})}});function f(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,W.jsxs)(B,{align:`stretch`,gap:2,children:[(0,W.jsxs)(N,{gap:2,children:[(0,W.jsxs)(D,{flex:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Aggregate ID`}),(0,W.jsx)(Ge,{size:`sm`,placeholder:`e.g. trace_abc123`,value:i,onChange:e=>a(e.target.value),fontFamily:`mono`})]}),(0,W.jsxs)(D,{flex:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Tenant ID`}),(0,W.jsx)(Ge,{size:`sm`,placeholder:`e.g. project_xyz`,value:o,onChange:e=>s(e.target.value),fontFamily:`mono`})]})]}),(0,W.jsxs)(D,{children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Projections`}),(0,W.jsx)(N,{gap:1,flexWrap:`wrap`,children:e.map(e=>(0,W.jsx)(A,{size:`sm`,variant:c.has(e.projectionName)?`solid`:`outline`,colorPalette:c.has(e.projectionName)?`orange`:`gray`,cursor:`pointer`,onClick:()=>f(e.projectionName),children:e.projectionName},e.projectionName))})]}),(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(E,{size:`sm`,variant:`outline`,disabled:!i.trim()||!o.trim()||c.size===0||r,loading:d.isPending,onClick:()=>{d.mutate({projectionNames:[...c],since:u,tenantIds:[o.trim()],aggregateIds:[i.trim()],description:`Single aggregate replay: ${i.trim()}`})},children:`Replay Single`}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Replays selected projections for a single tenant (events from last 3 months)`})]})]})}function Sn(){let{hasAccess:e}=S(),[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(!1),a=V.ops.listProjections.useQuery().data?.projections??[];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(B,{align:`stretch`,gap:4,children:[(0,W.jsx)(_n,{}),(0,W.jsx)(bn,{onReplayStarted:()=>n(!0)}),e&&a.length>0&&(0,W.jsxs)(Te,{open:r,onOpenChange:e=>i(e.open),children:[(0,W.jsx)(we,{asChild:!0,children:(0,W.jsx)(D,{cursor:`pointer`,userSelect:`none`,children:(0,W.jsxs)(N,{gap:2,paddingY:1,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,color:`fg.muted`,children:`Advanced: Single Aggregate Replay`}),(0,W.jsx)(_e,{size:12,style:{transform:r?`rotate(180deg)`:`none`,transition:`transform 0.15s`}})]})})}),(0,W.jsx)(ye,{children:(0,W.jsx)(P,{marginTop:2,children:(0,W.jsx)(F,{padding:4,children:(0,W.jsx)(xn,{projections:a,onReplayStarted:()=>n(!0)})})})})]}),(0,W.jsx)(vn,{})]}),(0,W.jsx)(gn,{open:t,onClose:()=>n(!1)})]})}function Cn(){return(0,W.jsx)(et,{children:(0,W.jsxs)(Ce,{children:[(0,W.jsx)(pe.Header,{children:(0,W.jsx)(pe.Heading,{children:`Projection Replay`})}),(0,W.jsx)(pe.Container,{children:(0,W.jsx)(Sn,{})})]})})}export{Cn as default};
2
+ //# sourceMappingURL=projections-it4FOVjm.js.map