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

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 (171) 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-DDh108-i.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-TNQ6uyis.js} +4 -4
  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/scripts/seed-dogfood-password.ts +163 -0
  135. package/langwatch/src/app/api/workflows/post_event/__tests__/post-event-evaluator.integration.test.ts +458 -0
  136. package/langwatch/src/app/api/workflows/post_event/__tests__/post-event-routing.test.ts +180 -0
  137. package/langwatch/src/app/api/workflows/post_event/__tests__/post-event.integration.test.ts +274 -0
  138. package/langwatch/src/app/api/workflows/post_event/post-event.ts +29 -1
  139. package/langwatch/src/components/agents/AgentCodeEditorDrawer.tsx +4 -5
  140. package/langwatch/src/components/agents/__tests__/AgentCodeEditorDrawer.integration.test.tsx +40 -0
  141. package/langwatch/src/components/evaluations/wizard/hooks/evaluation-wizard-store/slices/factories/__tests__/code-execution-node.factory.unit.test.ts +47 -0
  142. package/langwatch/src/components/evaluations/wizard/hooks/evaluation-wizard-store/slices/factories/code-execution-node.factory.ts +2 -4
  143. package/langwatch/src/components/experiments/BatchEvaluationV2/BatchEvaluationV2EvaluationResults.tsx +6 -1
  144. package/langwatch/src/optimization_studio/__tests__/registry.test.ts +29 -1
  145. package/langwatch/src/optimization_studio/components/Optimize.tsx +17 -3
  146. package/langwatch/src/optimization_studio/components/properties/AgentPropertiesPanel.tsx +4 -5
  147. package/langwatch/src/optimization_studio/hooks/workflowStoreCore.ts +17 -6
  148. package/langwatch/src/optimization_studio/hooks/workflowStoreCore.unit.test.ts +42 -0
  149. package/langwatch/src/optimization_studio/registry.ts +2 -4
  150. package/langwatch/src/optimization_studio/server/lambda/index.ts +12 -2
  151. package/langwatch/src/server/api/routers/workflows.ts +18 -0
  152. package/langwatch/src/server/evaluations-v3/execution/workflowBuilder.ts +3 -2
  153. package/langwatch/src/server/evaluations-v3/services/__tests__/experiment-run.service.getRun-null.unit.test.ts +71 -0
  154. package/langwatch/src/server/evaluations-v3/services/experiment-run.service.ts +18 -9
  155. package/langwatch/src/server/modelProviders/utils.ts +11 -1
  156. package/langwatch/src/server/nlpgo/__tests__/nlpgoFetch.integration.test.ts +248 -0
  157. package/langwatch/src/server/nlpgo/nlpgoFetch.ts +142 -0
  158. package/langwatch/src/server/routes/__tests__/playground-proxy.integration.test.ts +242 -0
  159. package/langwatch/src/server/routes/playground.ts +11 -1
  160. package/langwatch/src/server/routes/workflows.ts +17 -0
  161. package/langwatch/src/server/topicClustering/topicClustering.ts +33 -8
  162. package/langwatch/src/server/workflows/runWorkflow.ts +10 -13
  163. package/langwatch_nlp/langwatch_nlp/topic_clustering/topic_naming.py +39 -32
  164. package/langwatch_nlp/scripts/entrypoint.sh +67 -0
  165. package/package.json +1 -1
  166. package/packages/server/dist/cli.cjs +67 -94
  167. package/langwatch/dist/client/assets/ChatWindow-DzB-tNlQ.js +0 -1
  168. package/langwatch/dist/client/assets/_not-found-PEUaWdF3.js +0 -1
  169. package/langwatch/dist/client/assets/_slug_-C-8AjsjC.js +0 -2
  170. package/langwatch/dist/client/assets/choose--PBky27o.js +0 -2
  171. 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{An as n,Da as r,Dn as i,Fa as a,Fn as o,Gn as s,In as c,Ln as l,Mn as u,Nn as d,Pn as f,Xa as p,jn as m,kn as h,ln as g,lo as _,pn as v,qi as y,r as b,un as x,wa as S}from"./command-bar-CaJygoez.js";import{j as C,n as w}from"./stack-oJ9iWdbl.js";import{t as T}from"./box-BsM8YLGl.js";import{f as ee}from"./LoadingScreen--vgXk5-2.js";import{r as te}from"./dialog.anatomy-hrluUh9u.js";import{t as E}from"./tooltip-AEm0YeiF.js";import{n as D}from"./toaster-C_DYALhL.js";import{t as O}from"./heading-D90dlSnH.js";import{t as k}from"./text-CwTrMF8x.js";import{t as A}from"./h-stack-BKLDJ2vg.js";import{a as j,i as M,n as N,r as P}from"./alert-SnQmACl1.js";import{r as F,t as I}from"./card-CMtKVPVl.js";import{t as ne}from"./link-CwZhwOLq.js";import{t as re}from"./spacer-2LJJGbo8.js";import{t as L}from"./v-stack-EOPQ57OZ.js";import{s as R}from"./auth-client-D3UhxhQi.js";import{t as z}from"./FilterDisplay-BB0xWrLn.js";import{r as B}from"./next-router-C6sliiV7.js";import{t as V}from"./useOrganizationTeamProject-DC0iozx2.js";import{s as H}from"./index.esm-X7lxUoP1.js";import{t as U}from"./createLucideIcon-BJKFyRLS.js";import{t as W}from"./chart-no-axes-column-BMqNR285.js";import{t as G}from"./WithPermissionGuard-DD8uo3UK.js";import{t as K}from"./GraphsLayout-BJ68J9e-.js";var q=U(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),J=U(`grid-3x3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Y=e=>{let t=[],n=new Set,r=(e,t)=>`${e},${t}`,i=(e,t,i,a)=>{for(let o=e;o<e+i;o++)for(let e=t;e<t+a;e++)if(o>=2||n.has(r(o,e)))return!1;return!0},a=(e,t,i,a)=>{for(let o=e;o<e+i;o++)for(let e=t;e<t+a;e++)n.add(r(o,e))};for(let n of e){let{colSpan:e,rowSpan:r}=n,o=!1,s=0;for(;!o;){for(let c=0;c<=2-e;c++)if(i(c,s,e,r)){a(c,s,e,r),t.push({graphId:n.id,gridColumn:c,gridRow:s,colSpan:e,rowSpan:r}),o=!0;break}o||s++}}return t},X=e(t()),Z=C(),Q=[{value:`1x1`,label:`Small (1x1)`,colSpan:1,rowSpan:1},{value:`2x1`,label:`Wide (2x1)`,colSpan:2,rowSpan:1},{value:`1x2`,label:`Tall (1x2)`,colSpan:1,rowSpan:2},{value:`2x2`,label:`Large (2x2)`,colSpan:2,rowSpan:2}],ie=(e,t)=>e===2&&t===2?`2x2`:e===2&&t===1?`2x1`:e===1&&t===2?`1x2`:`1x1`;function ae({graphId:e,projectSlug:t,dashboardId:n,colSpan:i,rowSpan:a,onSizeChange:o,onDelete:s,isDeleting:c}){let l=B(),u=ie(i,a),d=`/${t}/analytics/custom/${e}${n?`?dashboard=${n}`:``}`;return(0,Z.jsxs)(y.Root,{children:[(0,Z.jsx)(y.Trigger,{asChild:!0,children:(0,Z.jsx)(w,{variant:`ghost`,loading:c,children:(0,Z.jsx)(p,{})})}),(0,Z.jsxs)(y.Content,{children:[(0,Z.jsxs)(y.Item,{value:`edit`,onClick:()=>{l.push(d)},children:[(0,Z.jsx)(r,{}),` Edit Graph`]}),(0,Z.jsxs)(y.Root,{positioning:{placement:`right-start`,gutter:2},children:[(0,Z.jsxs)(y.TriggerItem,{value:`size`,children:[(0,Z.jsx)(J,{}),` Size (`,u,`)`]}),(0,Z.jsx)(y.Content,{children:Q.map(e=>(0,Z.jsxs)(y.Item,{value:e.value,onClick:()=>o(e.value),children:[e.label,e.value===u&&` ✓`]},e.value))})]}),(0,Z.jsxs)(y.Item,{value:`delete`,color:`red.600`,onClick:s,children:[(0,Z.jsx)(S,{}),` Delete Graph`]})]})]})}function oe({filters:e}){return(0,Z.jsx)(E,{content:(0,Z.jsx)(L,{align:`start`,backgroundColor:`black`,color:`white`,height:`100%`,textWrap:`wrap`,children:(0,Z.jsx)(z,{filters:e})}),positioning:{placement:`top`},showArrow:!0,children:(0,Z.jsx)(T,{padding:1,children:(0,Z.jsx)(q,{width:16,style:{minWidth:16}})})})}function se({graphId:e,name:t,graph:n,projectSlug:r,dashboardId:i,colSpan:a,rowSpan:o,filters:s,trigger:c,isDragging:l,dragAttributes:u,dragListeners:d,onSizeChange:f,onDelete:p,isDeleting:m}){let{openDrawer:h}=b(),v=(0,X.useMemo)(()=>{if(t&&t.trim())return t;if(n&&typeof n==`object`&&`series`in n){let e=n;if(e.series&&e.series.length>0){let t=e.series.map(e=>e.name).filter(Boolean).join(`, `);if(t)return t.replace(/,([^,]*)$/,` and$1`)}}return`Untitled Graph`},[t,n]),y=H({defaultValues:n?{...g(n),title:v}:void 0});(0,X.useEffect)(()=>{n&&y.setValue(`title`,v)},[v,y,n]);let x=(0,X.useMemo)(()=>!!(s&&typeof s==`object`&&Object.keys(s).length>0),[s]),S=!!(e&&e!==`custom`&&n);return(0,Z.jsxs)(A,{...u,...d,align:`center`,marginBottom:4,cursor:l?`grabbing`:`grab`,children:[(0,Z.jsx)(W,{color:`orange`}),(0,Z.jsx)(O,{size:`sm`,marginLeft:2,children:v}),(0,Z.jsx)(re,{}),S&&(0,Z.jsx)(Z.Fragment,{children:c?.active?(0,Z.jsx)(E,{content:`Alert configured (${c.alertType??`INFO`})`,positioning:{placement:`top`},showArrow:!0,children:(0,Z.jsx)(T,{padding:1,cursor:`pointer`,onClick:t=>{t.stopPropagation(),h(`customGraphAlert`,{form:y,graphId:e})},children:(0,Z.jsx)(_,{width:18,color:`black`})})}):(0,Z.jsxs)(w,{variant:`outline`,colorPalette:`gray`,size:`sm`,onClick:t=>{t.stopPropagation(),h(`customGraphAlert`,{form:y,graphId:e})},children:[(0,Z.jsx)(_,{width:16}),`Add alert`]})}),x&&(0,Z.jsx)(oe,{filters:s}),(0,Z.jsx)(ae,{graphId:e,projectSlug:r,dashboardId:i,colSpan:a,rowSpan:o,onSizeChange:f,onDelete:p,isDeleting:m})]})}function ce({graph:e,projectSlug:t,dashboardId:r,onDelete:i,onSizeChange:a,isDeleting:o}){let{attributes:c,listeners:u,setNodeRef:d,transform:f,transition:p,isDragging:m}=n({id:e.id}),h={transform:l.Transform.toString(f),transition:p,opacity:m?.5:1,gridColumn:`span ${e.colSpan}`,gridRow:`span ${e.rowSpan}`},g=e.rowSpan===2?600:300;return(0,Z.jsx)(T,{ref:d,style:h,minWidth:0,children:(0,Z.jsx)(F,{height:`full`,minWidth:0,children:(0,Z.jsxs)(I,{height:`full`,display:`flex`,flexDirection:`column`,minWidth:0,overflow:`hidden`,children:[(0,Z.jsx)(se,{graphId:e.id,name:e.name,graph:e.graph,projectSlug:t,dashboardId:r,colSpan:e.colSpan,rowSpan:e.rowSpan,filters:e.filters,trigger:e.trigger,isDragging:m,dragAttributes:c,dragListeners:u,onSizeChange:a,onDelete:i,isDeleting:o}),(0,Z.jsx)(T,{flex:1,minHeight:0,children:(0,Z.jsx)(s,{input:{...e.graph,height:g},filters:e.filters},e.id)})]})})})}function le({graphs:e,projectSlug:t,dashboardId:n,onGraphDelete:r,onGraphSizeChange:a,onGraphsReorder:s,deletingGraphId:l}){let[p,g]=(0,X.useState)(null),_=e.find(e=>e.id===p),v=c(o(d,{activationConstraint:{distance:8}}));return(0,Z.jsxs)(m,{sensors:v,collisionDetection:f,onDragStart:e=>{g(e.active.id)},onDragEnd:t=>{g(null);let{active:n,over:r}=t;if(!r||n.id===r.id)return;let i=e.findIndex(e=>e.id===n.id),a=e.findIndex(e=>e.id===r.id);if(i!==-1&&a!==-1){let t=[...e],[n]=t.splice(i,1);t.splice(a,0,n),s(Y(t))}},children:[(0,Z.jsx)(i,{items:e.map(e=>e.id),strategy:h,children:(0,Z.jsx)(te,{templateColumns:`repeat(2, 1fr)`,autoRows:`minmax(350px, auto)`,gap:5,width:`100%`,children:e.map(e=>(0,Z.jsx)(ce,{graph:e,projectSlug:t,dashboardId:n,onDelete:()=>r(e.id),onSizeChange:t=>a(e.id,t),isDeleting:l===e.id},e.id))})}),(0,Z.jsx)(u,{children:_?(0,Z.jsx)(F,{boxShadow:`xl`,opacity:.9,width:_.colSpan===2?`600px`:`300px`,height:_.rowSpan===2?`400px`:`200px`,children:(0,Z.jsxs)(I,{children:[(0,Z.jsxs)(A,{align:`center`,marginBottom:4,children:[(0,Z.jsx)(W,{color:`orange`}),(0,Z.jsx)(k,{marginLeft:2,fontSize:`md`,fontWeight:`bold`,children:_.name})]}),(0,Z.jsx)(T,{flex:1,background:`gray.50`,borderRadius:`md`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`fg.subtle`,height:`calc(100% - 40px)`,children:`Chart preview`})]})}):null})]})}function $(){let{project:e}=V(),{showFilters:t}=v(),n=B(),r=e?.id??``,i=n.query.dashboard,o=R.dashboards.getOrCreateFirst.useQuery({projectId:r},{enabled:!!r&&!i}),s=i??o.data?.id,c=R.dashboards.getAll.useQuery({projectId:r},{enabled:!!r}),l=c.data?.find(e=>e.id===s)?.name??`Reports`,u=R.graphs.getAll.useQuery({projectId:r,dashboardId:s},{enabled:!!r&&!!s}),d=R.graphs.delete.useMutation(),f=R.graphs.updateLayout.useMutation(),p=R.graphs.batchUpdateLayouts.useMutation(),m=R.dashboards.rename.useMutation(),h=e=>{s&&m.mutate({projectId:r,dashboardId:s,name:e},{onSuccess:()=>{c.refetch()},onError:()=>{D.create({title:`Error renaming dashboard`,type:`error`,duration:3e3,meta:{closable:!0}})}})},g=e=>{d.mutate({projectId:r,id:e},{onSuccess:()=>{u.refetch()},onError:()=>{D.create({title:`Error deleting graph`,type:`error`,duration:3e3,meta:{closable:!0}})}})},_=(e,t)=>{let n=Q.find(e=>e.value===t);if(!n)return;let i=u.data?.find(t=>t.id===e);i&&f.mutate({projectId:r,graphId:e,gridColumn:i.gridColumn,gridRow:i.gridRow,colSpan:n.colSpan,rowSpan:n.rowSpan},{onSuccess:()=>{let t=u.data?.map(t=>t.id===e?{...t,colSpan:n.colSpan,rowSpan:n.rowSpan}:t);if(t){let e=Y(t);p.mutate({projectId:r,layouts:e},{onSuccess:()=>{u.refetch()}})}},onError:()=>{D.create({title:`Error updating graph size`,type:`error`,duration:3e3,meta:{closable:!0}})}})},y=e=>{p.mutate({projectId:r,layouts:e},{onSuccess:()=>{u.refetch()},onError:()=>{D.create({title:`Error reordering graphs`,type:`error`,duration:3e3,meta:{closable:!0}})}})},b=u.data??[],S=b.length===0&&!u.isLoading,C=s?`/${e?.slug}/analytics/custom?dashboard=${s}`:`/${e?.slug}/analytics/custom`;return(0,Z.jsxs)(K,{title:l,analyticsHeaderProps:{isEditable:!0,onTitleSave:h},extraHeaderButtons:e?(0,Z.jsx)(ne,{href:C,asChild:!0,children:(0,Z.jsxs)(w,{colorPalette:`orange`,size:`sm`,children:[(0,Z.jsx)(a,{}),` Add chart`]})}):null,children:[S&&(0,Z.jsxs)(M,{status:`info`,borderStartWidth:`4px`,borderStartColor:`colorPalette.solid`,marginBottom:6,children:[(0,Z.jsx)(P,{alignSelf:`start`}),(0,Z.jsxs)(L,{align:`start`,children:[(0,Z.jsx)(j,{children:`Add your custom graphs here`}),(0,Z.jsx)(N,{children:(0,Z.jsxs)(k,{as:`span`,children:[`You haven`,`'`,`t set up any custom graphs yet. Click + Add chart to get started.`]})})]})]}),(0,Z.jsxs)(A,{align:`start`,gap:6,width:`full`,children:[(0,Z.jsx)(T,{flex:1,children:u.isLoading?(0,Z.jsx)(ee,{height:`300px`}):(0,Z.jsx)(le,{graphs:b,projectSlug:e?.slug??``,dashboardId:s??void 0,onGraphDelete:g,onGraphSizeChange:_,onGraphsReorder:y,deletingGraphId:d.isLoading?d.variables?.id??null:null})}),t?(0,Z.jsx)(x,{}):null]})]})}var ue=G(`analytics:view`)($);export{ue as default};
2
- //# sourceMappingURL=reports-D3QFKhNP.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{An as n,Da as r,Dn as i,Fa as a,Fn as o,Gn as s,In as c,Ln as l,Mn as u,Nn as d,Pn as f,Xa as p,jn as m,kn as h,ln as g,lo as _,pn as v,qi as y,r as b,un as x,wa as S}from"./command-bar-DUK45yin.js";import{j as C,n as w}from"./stack-oJ9iWdbl.js";import{t as T}from"./box-BsM8YLGl.js";import{f as ee}from"./LoadingScreen--vgXk5-2.js";import{r as te}from"./dialog.anatomy-hrluUh9u.js";import{t as E}from"./tooltip-AEm0YeiF.js";import{n as D}from"./toaster-C_DYALhL.js";import{t as O}from"./heading-D90dlSnH.js";import{t as k}from"./text-CwTrMF8x.js";import{t as A}from"./h-stack-BKLDJ2vg.js";import{a as j,i as M,n as N,r as P}from"./alert-SnQmACl1.js";import{r as F,t as I}from"./card-CMtKVPVl.js";import{t as ne}from"./link-CwZhwOLq.js";import{t as re}from"./spacer-2LJJGbo8.js";import{t as L}from"./v-stack-EOPQ57OZ.js";import{s as R}from"./auth-client-D3UhxhQi.js";import{t as z}from"./FilterDisplay-0S3NqCkq.js";import{r as B}from"./next-router-C6sliiV7.js";import{t as V}from"./useOrganizationTeamProject-DC0iozx2.js";import{s as H}from"./index.esm-X7lxUoP1.js";import{t as U}from"./createLucideIcon-BJKFyRLS.js";import{t as W}from"./chart-no-axes-column-BMqNR285.js";import{t as G}from"./WithPermissionGuard-B4Jo8E5-.js";import{t as K}from"./GraphsLayout-DJ-HI9N1.js";var q=U(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),J=U(`grid-3x3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Y=e=>{let t=[],n=new Set,r=(e,t)=>`${e},${t}`,i=(e,t,i,a)=>{for(let o=e;o<e+i;o++)for(let e=t;e<t+a;e++)if(o>=2||n.has(r(o,e)))return!1;return!0},a=(e,t,i,a)=>{for(let o=e;o<e+i;o++)for(let e=t;e<t+a;e++)n.add(r(o,e))};for(let n of e){let{colSpan:e,rowSpan:r}=n,o=!1,s=0;for(;!o;){for(let c=0;c<=2-e;c++)if(i(c,s,e,r)){a(c,s,e,r),t.push({graphId:n.id,gridColumn:c,gridRow:s,colSpan:e,rowSpan:r}),o=!0;break}o||s++}}return t},X=e(t()),Z=C(),Q=[{value:`1x1`,label:`Small (1x1)`,colSpan:1,rowSpan:1},{value:`2x1`,label:`Wide (2x1)`,colSpan:2,rowSpan:1},{value:`1x2`,label:`Tall (1x2)`,colSpan:1,rowSpan:2},{value:`2x2`,label:`Large (2x2)`,colSpan:2,rowSpan:2}],ie=(e,t)=>e===2&&t===2?`2x2`:e===2&&t===1?`2x1`:e===1&&t===2?`1x2`:`1x1`;function ae({graphId:e,projectSlug:t,dashboardId:n,colSpan:i,rowSpan:a,onSizeChange:o,onDelete:s,isDeleting:c}){let l=B(),u=ie(i,a),d=`/${t}/analytics/custom/${e}${n?`?dashboard=${n}`:``}`;return(0,Z.jsxs)(y.Root,{children:[(0,Z.jsx)(y.Trigger,{asChild:!0,children:(0,Z.jsx)(w,{variant:`ghost`,loading:c,children:(0,Z.jsx)(p,{})})}),(0,Z.jsxs)(y.Content,{children:[(0,Z.jsxs)(y.Item,{value:`edit`,onClick:()=>{l.push(d)},children:[(0,Z.jsx)(r,{}),` Edit Graph`]}),(0,Z.jsxs)(y.Root,{positioning:{placement:`right-start`,gutter:2},children:[(0,Z.jsxs)(y.TriggerItem,{value:`size`,children:[(0,Z.jsx)(J,{}),` Size (`,u,`)`]}),(0,Z.jsx)(y.Content,{children:Q.map(e=>(0,Z.jsxs)(y.Item,{value:e.value,onClick:()=>o(e.value),children:[e.label,e.value===u&&` ✓`]},e.value))})]}),(0,Z.jsxs)(y.Item,{value:`delete`,color:`red.600`,onClick:s,children:[(0,Z.jsx)(S,{}),` Delete Graph`]})]})]})}function oe({filters:e}){return(0,Z.jsx)(E,{content:(0,Z.jsx)(L,{align:`start`,backgroundColor:`black`,color:`white`,height:`100%`,textWrap:`wrap`,children:(0,Z.jsx)(z,{filters:e})}),positioning:{placement:`top`},showArrow:!0,children:(0,Z.jsx)(T,{padding:1,children:(0,Z.jsx)(q,{width:16,style:{minWidth:16}})})})}function se({graphId:e,name:t,graph:n,projectSlug:r,dashboardId:i,colSpan:a,rowSpan:o,filters:s,trigger:c,isDragging:l,dragAttributes:u,dragListeners:d,onSizeChange:f,onDelete:p,isDeleting:m}){let{openDrawer:h}=b(),v=(0,X.useMemo)(()=>{if(t&&t.trim())return t;if(n&&typeof n==`object`&&`series`in n){let e=n;if(e.series&&e.series.length>0){let t=e.series.map(e=>e.name).filter(Boolean).join(`, `);if(t)return t.replace(/,([^,]*)$/,` and$1`)}}return`Untitled Graph`},[t,n]),y=H({defaultValues:n?{...g(n),title:v}:void 0});(0,X.useEffect)(()=>{n&&y.setValue(`title`,v)},[v,y,n]);let x=(0,X.useMemo)(()=>!!(s&&typeof s==`object`&&Object.keys(s).length>0),[s]),S=!!(e&&e!==`custom`&&n);return(0,Z.jsxs)(A,{...u,...d,align:`center`,marginBottom:4,cursor:l?`grabbing`:`grab`,children:[(0,Z.jsx)(W,{color:`orange`}),(0,Z.jsx)(O,{size:`sm`,marginLeft:2,children:v}),(0,Z.jsx)(re,{}),S&&(0,Z.jsx)(Z.Fragment,{children:c?.active?(0,Z.jsx)(E,{content:`Alert configured (${c.alertType??`INFO`})`,positioning:{placement:`top`},showArrow:!0,children:(0,Z.jsx)(T,{padding:1,cursor:`pointer`,onClick:t=>{t.stopPropagation(),h(`customGraphAlert`,{form:y,graphId:e})},children:(0,Z.jsx)(_,{width:18,color:`black`})})}):(0,Z.jsxs)(w,{variant:`outline`,colorPalette:`gray`,size:`sm`,onClick:t=>{t.stopPropagation(),h(`customGraphAlert`,{form:y,graphId:e})},children:[(0,Z.jsx)(_,{width:16}),`Add alert`]})}),x&&(0,Z.jsx)(oe,{filters:s}),(0,Z.jsx)(ae,{graphId:e,projectSlug:r,dashboardId:i,colSpan:a,rowSpan:o,onSizeChange:f,onDelete:p,isDeleting:m})]})}function ce({graph:e,projectSlug:t,dashboardId:r,onDelete:i,onSizeChange:a,isDeleting:o}){let{attributes:c,listeners:u,setNodeRef:d,transform:f,transition:p,isDragging:m}=n({id:e.id}),h={transform:l.Transform.toString(f),transition:p,opacity:m?.5:1,gridColumn:`span ${e.colSpan}`,gridRow:`span ${e.rowSpan}`},g=e.rowSpan===2?600:300;return(0,Z.jsx)(T,{ref:d,style:h,minWidth:0,children:(0,Z.jsx)(F,{height:`full`,minWidth:0,children:(0,Z.jsxs)(I,{height:`full`,display:`flex`,flexDirection:`column`,minWidth:0,overflow:`hidden`,children:[(0,Z.jsx)(se,{graphId:e.id,name:e.name,graph:e.graph,projectSlug:t,dashboardId:r,colSpan:e.colSpan,rowSpan:e.rowSpan,filters:e.filters,trigger:e.trigger,isDragging:m,dragAttributes:c,dragListeners:u,onSizeChange:a,onDelete:i,isDeleting:o}),(0,Z.jsx)(T,{flex:1,minHeight:0,children:(0,Z.jsx)(s,{input:{...e.graph,height:g},filters:e.filters},e.id)})]})})})}function le({graphs:e,projectSlug:t,dashboardId:n,onGraphDelete:r,onGraphSizeChange:a,onGraphsReorder:s,deletingGraphId:l}){let[p,g]=(0,X.useState)(null),_=e.find(e=>e.id===p),v=c(o(d,{activationConstraint:{distance:8}}));return(0,Z.jsxs)(m,{sensors:v,collisionDetection:f,onDragStart:e=>{g(e.active.id)},onDragEnd:t=>{g(null);let{active:n,over:r}=t;if(!r||n.id===r.id)return;let i=e.findIndex(e=>e.id===n.id),a=e.findIndex(e=>e.id===r.id);if(i!==-1&&a!==-1){let t=[...e],[n]=t.splice(i,1);t.splice(a,0,n),s(Y(t))}},children:[(0,Z.jsx)(i,{items:e.map(e=>e.id),strategy:h,children:(0,Z.jsx)(te,{templateColumns:`repeat(2, 1fr)`,autoRows:`minmax(350px, auto)`,gap:5,width:`100%`,children:e.map(e=>(0,Z.jsx)(ce,{graph:e,projectSlug:t,dashboardId:n,onDelete:()=>r(e.id),onSizeChange:t=>a(e.id,t),isDeleting:l===e.id},e.id))})}),(0,Z.jsx)(u,{children:_?(0,Z.jsx)(F,{boxShadow:`xl`,opacity:.9,width:_.colSpan===2?`600px`:`300px`,height:_.rowSpan===2?`400px`:`200px`,children:(0,Z.jsxs)(I,{children:[(0,Z.jsxs)(A,{align:`center`,marginBottom:4,children:[(0,Z.jsx)(W,{color:`orange`}),(0,Z.jsx)(k,{marginLeft:2,fontSize:`md`,fontWeight:`bold`,children:_.name})]}),(0,Z.jsx)(T,{flex:1,background:`gray.50`,borderRadius:`md`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`fg.subtle`,height:`calc(100% - 40px)`,children:`Chart preview`})]})}):null})]})}function $(){let{project:e}=V(),{showFilters:t}=v(),n=B(),r=e?.id??``,i=n.query.dashboard,o=R.dashboards.getOrCreateFirst.useQuery({projectId:r},{enabled:!!r&&!i}),s=i??o.data?.id,c=R.dashboards.getAll.useQuery({projectId:r},{enabled:!!r}),l=c.data?.find(e=>e.id===s)?.name??`Reports`,u=R.graphs.getAll.useQuery({projectId:r,dashboardId:s},{enabled:!!r&&!!s}),d=R.graphs.delete.useMutation(),f=R.graphs.updateLayout.useMutation(),p=R.graphs.batchUpdateLayouts.useMutation(),m=R.dashboards.rename.useMutation(),h=e=>{s&&m.mutate({projectId:r,dashboardId:s,name:e},{onSuccess:()=>{c.refetch()},onError:()=>{D.create({title:`Error renaming dashboard`,type:`error`,duration:3e3,meta:{closable:!0}})}})},g=e=>{d.mutate({projectId:r,id:e},{onSuccess:()=>{u.refetch()},onError:()=>{D.create({title:`Error deleting graph`,type:`error`,duration:3e3,meta:{closable:!0}})}})},_=(e,t)=>{let n=Q.find(e=>e.value===t);if(!n)return;let i=u.data?.find(t=>t.id===e);i&&f.mutate({projectId:r,graphId:e,gridColumn:i.gridColumn,gridRow:i.gridRow,colSpan:n.colSpan,rowSpan:n.rowSpan},{onSuccess:()=>{let t=u.data?.map(t=>t.id===e?{...t,colSpan:n.colSpan,rowSpan:n.rowSpan}:t);if(t){let e=Y(t);p.mutate({projectId:r,layouts:e},{onSuccess:()=>{u.refetch()}})}},onError:()=>{D.create({title:`Error updating graph size`,type:`error`,duration:3e3,meta:{closable:!0}})}})},y=e=>{p.mutate({projectId:r,layouts:e},{onSuccess:()=>{u.refetch()},onError:()=>{D.create({title:`Error reordering graphs`,type:`error`,duration:3e3,meta:{closable:!0}})}})},b=u.data??[],S=b.length===0&&!u.isLoading,C=s?`/${e?.slug}/analytics/custom?dashboard=${s}`:`/${e?.slug}/analytics/custom`;return(0,Z.jsxs)(K,{title:l,analyticsHeaderProps:{isEditable:!0,onTitleSave:h},extraHeaderButtons:e?(0,Z.jsx)(ne,{href:C,asChild:!0,children:(0,Z.jsxs)(w,{colorPalette:`orange`,size:`sm`,children:[(0,Z.jsx)(a,{}),` Add chart`]})}):null,children:[S&&(0,Z.jsxs)(M,{status:`info`,borderStartWidth:`4px`,borderStartColor:`colorPalette.solid`,marginBottom:6,children:[(0,Z.jsx)(P,{alignSelf:`start`}),(0,Z.jsxs)(L,{align:`start`,children:[(0,Z.jsx)(j,{children:`Add your custom graphs here`}),(0,Z.jsx)(N,{children:(0,Z.jsxs)(k,{as:`span`,children:[`You haven`,`'`,`t set up any custom graphs yet. Click + Add chart to get started.`]})})]})]}),(0,Z.jsxs)(A,{align:`start`,gap:6,width:`full`,children:[(0,Z.jsx)(T,{flex:1,children:u.isLoading?(0,Z.jsx)(ee,{height:`300px`}):(0,Z.jsx)(le,{graphs:b,projectSlug:e?.slug??``,dashboardId:s??void 0,onGraphDelete:g,onGraphSizeChange:_,onGraphsReorder:y,deletingGraphId:d.isLoading?d.variables?.id??null:null})}),t?(0,Z.jsx)(x,{}):null]})]})}var ue=G(`analytics:view`)($);export{ue as default};
2
+ //# sourceMappingURL=reports-vlrcTrLs.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Bo as n,Da as r,Js as i,Ks as a,Xr as o,cc as s,gs as c,ls as l,qs as u,ts as d,wa as f,yo as p}from"./command-bar-CaJygoez.js";import{j as m,n as h,r as g}from"./stack-oJ9iWdbl.js";import{t as _}from"./box-BsM8YLGl.js";import{t as ee}from"./tooltip-AEm0YeiF.js";import{n as v,r as y}from"./toaster-C_DYALhL.js";import{Qt as te,Zt as ne,an as b,f as x}from"./dist-SwV3YZv3.js";import{c as S,h as C,n as w}from"./terminal-CfM0q99k.js";import{t as T}from"./heading-D90dlSnH.js";import{t as E}from"./text-CwTrMF8x.js";import{a as D,n as O,r as k,t as A}from"./field-CnUiixMS.js";import{t as j}from"./input-C7emsUCL.js";import{t as M}from"./h-stack-BKLDJ2vg.js";import{a as N,i as P,n as F,r as I,t as L}from"./alert-SnQmACl1.js";import{n as R,r as z,t as B}from"./card-CMtKVPVl.js";import{t as V}from"./v-stack-EOPQ57OZ.js";import{m as H,s as U}from"./auth-client-D3UhxhQi.js";import{c as W,i as re,n as G,r as K,t as ie}from"./useOrganizationTeamProject-DC0iozx2.js";import{s as ae}from"./index.esm-X7lxUoP1.js";import{t as oe}from"./createLucideIcon-BJKFyRLS.js";import{n as se,t as q}from"./SettingsLayout-CLCGxMAe.js";import{t as ce}from"./ContactSalesBlock-CijLBwRC.js";import{t as le}from"./WithPermissionGuard-DD8uo3UK.js";var ue=oe(`shield-user`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M6.376 18.91a6 6 0 0 1 11.249.003`,key:`hnjrf2`}],[`circle`,{cx:`12`,cy:`11`,r:`4`,key:`1gt34v`}]]),J=e(t()),Y=W(),X=[K.TRACES,K.COST,K.SCENARIOS,K.ANNOTATIONS,K.ANALYTICS,K.EVALUATIONS,K.DATASETS,K.TRIGGERS,K.WORKFLOWS,K.PROMPTS,K.SECRETS,K.AUDIT_LOG,K.TEAM,K.PROJECT];function Z(e){return e===K.COST?[G.VIEW]:e===K.TRACES?[G.VIEW,G.SHARE]:e===K.SECRETS?[G.VIEW,G.MANAGE]:e===K.SCENARIOS||e===K.AUDIT_LOG?[G.VIEW]:[G.MANAGE,G.VIEW,G.CREATE,G.UPDATE,G.DELETE]}var Q=m();function de({permissions:e}){let t=(e,t)=>`${e}:${t}`,n={};return X.forEach(e=>{n[e]=Z(e).map(n=>t(e,n))}),(0,Q.jsx)(V,{align:`start`,width:`full`,gap:4,children:Object.keys(n).map(n=>{let r=Z(n);if(!r.some(t=>e.includes(`${n}:${t}`)))return null;let i=r.filter(t=>e.includes(`${n}:${t}`)),a=i.includes(`manage`)?i.filter(e=>e===`manage`||e===`share`):i;return(0,Q.jsxs)(_,{width:`full`,children:[(0,Q.jsxs)(V,{align:`start`,gap:2,width:`full`,children:[(0,Q.jsx)(E,{fontWeight:`semibold`,textTransform:`capitalize`,fontSize:`md`,children:n}),(0,Q.jsx)(V,{align:`start`,gap:1.5,paddingLeft:4,width:`full`,children:a.map(e=>{let r=t(n,e),i=e===`manage`?`Manage (Create, Update, Delete)`:e.charAt(0).toUpperCase()+e.slice(1);return(0,Q.jsxs)(M,{gap:2,align:`center`,children:[(0,Q.jsx)(l,{size:14,color:`var(--chakra-colors-green-500)`}),(0,Q.jsx)(E,{fontSize:`sm`,color:`fg`,children:i})]},r)})})]}),(0,Q.jsx)(C,{marginY:3})]},n)})})}function $({name:e,description:t,permissionCount:n,isDefault:i=!1,icon:a=w,onDelete:o,onEdit:s,onViewPermissions:c,hasPermission:l}){let u=l(`organization:manage`);return(0,Q.jsxs)(z,{width:`100%`,height:`100%`,borderWidth:`1px`,borderColor:`border`,_hover:c?{borderColor:`orange.400`,shadow:`md`}:{},transition:`all 0.2s`,display:`flex`,flexDirection:`column`,cursor:c&&u?`pointer`:`default`,onClick:c&&u?c:void 0,position:`relative`,children:[!i&&(0,Q.jsxs)(M,{gap:1,onClick:e=>e.stopPropagation(),position:`absolute`,right:4,top:`50%`,transform:`translateY(-50%)`,children:[c&&(0,Q.jsx)(h,{size:`sm`,variant:`ghost`,colorPalette:`blue`,onClick:e=>{e.stopPropagation(),c()},disabled:!l(`organization:manage`),children:(0,Q.jsx)(S,{size:14})}),s&&(0,Q.jsx)(h,{size:`sm`,variant:`ghost`,colorPalette:`orange`,onClick:e=>{e.stopPropagation(),s()},disabled:!l(`organization:manage`),children:(0,Q.jsx)(r,{size:14})}),o&&(0,Q.jsx)(h,{size:`sm`,variant:`ghost`,colorPalette:`red`,onClick:e=>{e.stopPropagation(),o()},disabled:!l(`organization:manage`),children:(0,Q.jsx)(f,{size:14})})]}),(0,Q.jsx)(R,{children:(0,Q.jsxs)(V,{align:`start`,gap:1,children:[(0,Q.jsxs)(M,{children:[(0,Q.jsx)(a,{size:18}),(0,Q.jsx)(E,{fontWeight:`semibold`,children:e})]}),i&&(0,Q.jsx)(E,{fontSize:`xs`,color:`fg.muted`,children:`Built-in Role`})]})}),(0,Q.jsx)(B,{paddingTop:0,flex:1,display:`flex`,flexDirection:`column`,children:(0,Q.jsxs)(V,{align:`start`,gap:2,flex:1,width:`full`,justifyContent:`space-between`,children:[(0,Q.jsx)(E,{fontSize:`sm`,color:`fg.muted`,children:t}),i?(0,Q.jsx)(b,{colorPalette:`orange`,size:`sm`,children:n}):(0,Q.jsx)(E,{fontSize:`xs`,color:`orange.fg`,fontWeight:`medium`,children:n})]})})]})}function fe({selectedPermissions:e,onChange:t}){let n=(e,t)=>`${e}:${t}`,r=(0,J.useMemo)(()=>{let e={};return X.forEach(t=>{e[t]=Z(t).map(e=>n(t,e))}),e},[]),o=(e,t)=>{if(e.endsWith(`:manage`))return r[t]||[];let[n,i]=e.split(`:`);if(i===`view`){let n=r[t]||[],i=[`create`,`update`,`delete`];return[e,...n.filter(e=>i.some(t=>e.endsWith(`:${t}`)))]}return[e]},s=(e,t)=>{if(e.endsWith(`:manage`))return r[t]||[];let[i,a]=e.split(`:`);return a===`create`||a===`update`||a===`delete`?[e,n(t,`view`)]:[e]},c=n=>{let[r]=n.split(`:`),i=o(n,r);t(e.filter(e=>!i.includes(e)))},l=n=>{let[r]=n.split(`:`),i=s(n,r);t([...e,...i.filter(t=>!e.includes(t))])},d=t=>{let[r,i]=t.split(`:`),a=n(r,`manage`),o=e.includes(a);e.includes(t)||o&&i!==`manage`?c(t):l(t)};return(0,Q.jsx)(V,{align:`start`,width:`full`,gap:4,children:Object.keys(r).map(t=>{let r=Z(t);return(0,Q.jsxs)(_,{width:`full`,children:[(0,Q.jsxs)(i,{children:[(0,Q.jsx)(u,{fontSize:`sm`,fontWeight:`semibold`,textTransform:`capitalize`,marginBottom:2,children:(0,Q.jsx)(E,{children:t})}),(0,Q.jsx)(a,{children:(0,Q.jsx)(M,{gap:4,flexWrap:`wrap`,paddingLeft:6,children:r.map(r=>{let i=n(t,r),a=e.includes(i),o=n(t,`manage`),s=e.includes(o),c=r!==`manage`&&s;return(0,Q.jsx)(p,{checked:a||c,onChange:()=>{d(c?o:i)},opacity:c?.6:1,cursor:c?`not-allowed`:`pointer`,children:r===`manage`?(0,Q.jsx)(ee,{content:`Manage includes all permissions (view, create, update, delete) for this resource`,positioning:{placement:`top`},showArrow:!0,children:(0,Q.jsxs)(M,{gap:1,children:[(0,Q.jsx)(E,{fontSize:`sm`,textTransform:`capitalize`,children:r}),(0,Q.jsx)(_,{color:`fg.muted`,children:(0,Q.jsx)(y,{size:14})})]})}):(0,Q.jsx)(E,{fontSize:`sm`,textTransform:`capitalize`,children:r})},i)})})})]}),(0,Q.jsx)(C,{marginY:3})]},t)})})}function pe({open:e,onClose:t,onSubmit:n,initialData:r,title:i,submitLabel:a=`Create Role`,isSubmitting:o=!1}){let{register:s,handleSubmit:l,reset:u,formState:{errors:d},setValue:f,watch:p}=ae({defaultValues:{name:r?.name??``,description:r?.description??``,permissions:r?.permissions??[]}}),m=p(`permissions`)||[];(0,J.useEffect)(()=>{r?(f(`name`,r.name),f(`description`,r.description),f(`permissions`,r.permissions)):u({name:``,description:``,permissions:[]})},[r,f,u]);let g=l(async e=>{await n(e),r||u()});return(0,Q.jsx)(x.Root,{open:e,onOpenChange:({open:e})=>!e&&t(),children:(0,Q.jsxs)(x.Content,{maxWidth:`900px`,maxHeight:`90vh`,overflowY:`auto`,children:[(0,Q.jsx)(x.Header,{children:(0,Q.jsx)(x.Title,{children:i})}),(0,Q.jsx)(x.Body,{children:(0,Q.jsx)(`form`,{id:`role-form`,onSubmit:e=>void g(e),children:(0,Q.jsxs)(V,{gap:6,align:`start`,children:[(0,Q.jsxs)(D,{invalid:!!d.name,children:[(0,Q.jsxs)(k,{children:[`Role Name`,` `,(0,Q.jsx)(E,{as:`span`,color:`red.500`,children:`*`})]}),(0,Q.jsx)(j,{...s(`name`,{required:`Role name is required`}),placeholder:`e.g., Data Analyst`}),d.name&&(0,Q.jsx)(A,{children:d.name.message})]}),(0,Q.jsxs)(D,{children:[(0,Q.jsx)(k,{children:`Description`}),(0,Q.jsx)(O,{children:`Describe what this role is for`}),(0,Q.jsx)(c,{...s(`description`),placeholder:`e.g., Can view and analyze data but cannot modify settings`,rows:3})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:4,children:[(0,Q.jsx)(T,{size:`sm`,children:`Permissions`}),(0,Q.jsx)(E,{fontSize:`sm`,color:`fg.muted`,children:`Select the permissions this role should have`}),(0,Q.jsx)(fe,{selectedPermissions:m,onChange:e=>f(`permissions`,e)})]})]})})}),(0,Q.jsxs)(x.Footer,{children:[(0,Q.jsx)(h,{variant:`outline`,onClick:t,children:`Cancel`}),(0,Q.jsx)(h,{type:`submit`,form:`role-form`,colorPalette:`orange`,loading:o,children:a})]}),(0,Q.jsx)(x.CloseTrigger,{})]})})}function me(){let{organization:e,hasPermission:t}=ie(),{isEnterprise:n,isLoading:r}=se();return!e||r?(0,Q.jsx)(q,{children:(0,Q.jsx)(V,{align:`center`,justify:`center`,width:`full`,height:`200px`,children:(0,Q.jsx)(g,{})})}):n?(0,Q.jsx)(q,{children:(0,Q.jsx)(ge,{organizationId:e.id,hasPermission:t})}):(0,Q.jsx)(q,{children:(0,Q.jsxs)(V,{gap:6,width:`full`,align:`start`,children:[(0,Q.jsxs)(P,{status:`info`,children:[(0,Q.jsx)(I,{}),(0,Q.jsxs)(L,{children:[(0,Q.jsx)(N,{children:`Enterprise Feature`}),(0,Q.jsx)(F,{children:`Custom roles are available on Enterprise plans. Contact sales to upgrade.`})]})]}),(0,Q.jsx)(_,{width:`full`,children:(0,Q.jsx)(ce,{})})]})})}var he=le(`organization:view`,{layoutComponent:q})(me);function ge({organizationId:e,hasPermission:t}){let{open:r,onOpen:i,onClose:a}=s(),{open:c,onOpen:l,onClose:u}=s(),{open:f,onOpen:p,onClose:m}=s(),{open:y,onOpen:b,onClose:S}=s(),[w,D]=(0,J.useState)(null),[O,k]=(0,J.useState)(null),[A,j]=(0,J.useState)(null),N=U.useContext(),P=U.role.getAll.useQuery({organizationId:e}),F=U.role.create.useMutation({onSuccess:()=>{N.role.getAll.invalidate(),v.create({title:`Role created successfully`,type:`success`}),a()},onError:e=>{H(e)||v.create({title:`Failed to create role`,description:e.message,type:`error`})}}),I=U.role.delete.useMutation({onSuccess:()=>{N.role.getAll.invalidate(),v.create({title:`Role deleted successfully`,type:`success`})},onError:e=>{H(e)||v.create({title:`Failed to delete role`,description:e.message,type:`error`})}}),L=U.role.update.useMutation({onSuccess:()=>{N.role.getAll.invalidate(),v.create({title:`Role updated successfully`,type:`success`}),u(),D(null)},onError:e=>{H(e)||v.create({title:`Failed to update role`,description:e.message,type:`error`})}}),R=async e=>{try{let t=await N.role.getById.fetch({roleId:e});D({id:t.id,name:t.name,description:t.description??``,permissions:t.permissions}),l()}catch{v.create({title:`Failed to load role`,description:`Could not load role details for editing`,type:`error`})}},W=async e=>{try{let t=await N.role.getById.fetch({roleId:e});k({id:t.id,name:t.name,description:t.description??``,permissions:t.permissions}),p()}catch{v.create({title:`Failed to load role`,description:`Could not load role details for viewing`,type:`error`})}},G=(e,t)=>{let n=re(t);j({name:e,description:K(e),permissions:n}),b()},K=e=>{switch(e){case`Admin`:return`Full access to all features and settings`;case`Member`:return`Can create and modify most resources, view costs and debug info`;case`Viewer`:return`Read-only access to analytics, messages, and guardrails`;default:return``}};return(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:6,children:[(0,Q.jsxs)(M,{justify:`space-between`,width:`full`,children:[(0,Q.jsxs)(V,{align:`start`,gap:1,children:[(0,Q.jsx)(T,{as:`h2`,children:`Roles & Permissions`}),(0,Q.jsx)(E,{color:`fg.muted`,fontSize:`sm`,children:`Create custom roles and assign specific permissions to control access`})]}),(0,Q.jsx)(ee,{content:`You need organization:manage permissions to create roles.`,disabled:t(`organization:manage`),children:(0,Q.jsxs)(o.HeaderButton,{onClick:i,disabled:!t(`organization:manage`),children:[(0,Q.jsx)(te,{size:16}),` Create Role`]})})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:4,children:[(0,Q.jsxs)(_,{children:[(0,Q.jsx)(T,{as:`h3`,children:`Default Roles`}),(0,Q.jsx)(E,{color:`fg.muted`,fontSize:`sm`,children:`These are the built-in roles that cannot be modified or deleted.`})]}),(0,Q.jsxs)(_,{width:`full`,display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(300px, 1fr))`,gap:4,children:[(0,Q.jsx)($,{hasPermission:t,name:`Admin`,description:`Full access to all features and settings`,isDefault:!0,permissionCount:`All Permissions`,icon:ue,onViewPermissions:()=>G(`Admin`,Y.TeamUserRole.ADMIN)}),(0,Q.jsx)($,{hasPermission:t,name:`Member`,description:`Can create and modify most resources, view costs and debug info`,isDefault:!0,permissionCount:`Most Permissions`,icon:n,onViewPermissions:()=>G(`Member`,Y.TeamUserRole.MEMBER)}),(0,Q.jsx)($,{hasPermission:t,name:`Viewer`,description:`Read-only access to analytics, messages, and guardrails`,isDefault:!0,permissionCount:`View Only`,icon:d,onViewPermissions:()=>G(`Viewer`,Y.TeamUserRole.VIEWER)})]})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:4,children:[(0,Q.jsxs)(_,{children:[(0,Q.jsx)(T,{as:`h3`,children:`Custom Roles`}),(0,Q.jsx)(E,{color:`fg.muted`,fontSize:`sm`,children:`Custom roles created for your organization with specific permission sets.`})]}),P.isLoading&&(0,Q.jsx)(V,{align:`center`,width:`full`,padding:8,children:(0,Q.jsx)(g,{})}),P.data&&P.data.length===0&&(0,Q.jsx)(z,{width:`full`,children:(0,Q.jsx)(B,{textAlign:`center`,padding:8,children:(0,Q.jsxs)(V,{gap:2,children:[(0,Q.jsx)(ne,{size:48,color:`gray`}),(0,Q.jsx)(E,{color:`fg.muted`,children:`No custom roles yet. Create your first custom role to get started.`})]})})}),(0,Q.jsx)(_,{width:`full`,display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(300px, 1fr))`,gap:4,children:P.data?.map(e=>(0,Q.jsx)($,{name:e.name,description:e.description??``,permissionCount:`${e.permissions.length} permissions`,hasPermission:t,onDelete:()=>{confirm(`Are you sure you want to delete the role "${e.name}"?`)&&I.mutate({roleId:e.id})},onEdit:()=>{R(e.id)},onViewPermissions:()=>{W(e.id)}},e.id))})]}),(0,Q.jsx)(pe,{open:r,onClose:a,onSubmit:async t=>{await F.mutateAsync({organizationId:e,name:t.name,description:t.description,permissions:t.permissions})},title:`Create Custom Role`,submitLabel:`Create Role`,isSubmitting:F.isLoading}),(0,Q.jsx)(pe,{open:c,onClose:()=>{u(),D(null)},onSubmit:async e=>{w&&await L.mutateAsync({roleId:w.id,name:e.name,description:e.description,permissions:e.permissions})},initialData:w?{name:w.name,description:w.description,permissions:w.permissions}:void 0,title:`Edit Role`,submitLabel:`Update Role`,isSubmitting:L.isLoading}),(0,Q.jsx)(x.Root,{open:f,onOpenChange:({open:e})=>!e&&m(),children:(0,Q.jsxs)(x.Content,{maxWidth:`600px`,maxHeight:`80vh`,overflowY:`auto`,children:[(0,Q.jsx)(x.Header,{children:(0,Q.jsxs)(x.Title,{children:[`View Permissions - `,O?.name]})}),(0,Q.jsx)(x.Body,{children:O&&(0,Q.jsxs)(V,{gap:4,align:`start`,children:[(0,Q.jsxs)(V,{align:`start`,gap:2,width:`full`,children:[(0,Q.jsx)(E,{fontWeight:`semibold`,children:`Description:`}),(0,Q.jsx)(E,{color:`fg.muted`,children:O.description||`No description provided`})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,gap:3,width:`full`,children:[(0,Q.jsxs)(E,{fontWeight:`semibold`,children:[`Permissions (`,O.permissions.length,`):`]}),(0,Q.jsx)(de,{permissions:O.permissions})]})]})}),(0,Q.jsx)(x.Footer,{children:(0,Q.jsx)(h,{variant:`outline`,onClick:m,children:`Close`})}),(0,Q.jsx)(x.CloseTrigger,{})]})}),(0,Q.jsx)(x.Root,{open:y,onOpenChange:({open:e})=>!e&&S(),children:(0,Q.jsxs)(x.Content,{maxWidth:`600px`,maxHeight:`80vh`,overflowY:`auto`,children:[(0,Q.jsx)(x.Header,{children:(0,Q.jsxs)(x.Title,{children:[`View Permissions - `,A?.name]})}),(0,Q.jsx)(x.Body,{children:A&&(0,Q.jsxs)(V,{gap:4,align:`start`,children:[(0,Q.jsxs)(V,{align:`start`,gap:2,width:`full`,children:[(0,Q.jsx)(E,{fontWeight:`semibold`,children:`Description:`}),(0,Q.jsx)(E,{color:`fg.muted`,children:A.description})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,gap:3,width:`full`,children:[(0,Q.jsxs)(E,{fontWeight:`semibold`,children:[`Permissions (`,A.permissions.length,`):`]}),(0,Q.jsx)(de,{permissions:A.permissions})]})]})}),(0,Q.jsx)(x.Footer,{children:(0,Q.jsx)(h,{variant:`outline`,onClick:S,children:`Close`})}),(0,Q.jsx)(x.CloseTrigger,{})]})})]})}export{he as default};
2
- //# sourceMappingURL=roles-B_0t5DWA.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Bo as n,Da as r,Js as i,Ks as a,Xr as o,cc as s,gs as c,ls as l,qs as u,ts as d,wa as f,yo as p}from"./command-bar-DUK45yin.js";import{j as m,n as h,r as g}from"./stack-oJ9iWdbl.js";import{t as _}from"./box-BsM8YLGl.js";import{t as ee}from"./tooltip-AEm0YeiF.js";import{n as v,r as y}from"./toaster-C_DYALhL.js";import{Qt as te,Zt as ne,an as b,f as x}from"./dist-Cds4Mqhj.js";import{c as S,h as C,n as w}from"./terminal-CfM0q99k.js";import{t as T}from"./heading-D90dlSnH.js";import{t as E}from"./text-CwTrMF8x.js";import{a as D,n as O,r as k,t as A}from"./field-CnUiixMS.js";import{t as j}from"./input-C7emsUCL.js";import{t as M}from"./h-stack-BKLDJ2vg.js";import{a as N,i as P,n as F,r as I,t as L}from"./alert-SnQmACl1.js";import{n as R,r as z,t as B}from"./card-CMtKVPVl.js";import{t as V}from"./v-stack-EOPQ57OZ.js";import{m as H,s as U}from"./auth-client-D3UhxhQi.js";import{c as W,i as re,n as G,r as K,t as ie}from"./useOrganizationTeamProject-DC0iozx2.js";import{s as ae}from"./index.esm-X7lxUoP1.js";import{t as oe}from"./createLucideIcon-BJKFyRLS.js";import{n as se,t as q}from"./SettingsLayout--1gdEuhv.js";import{t as ce}from"./ContactSalesBlock-CnnuZ8iI.js";import{t as le}from"./WithPermissionGuard-B4Jo8E5-.js";var ue=oe(`shield-user`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M6.376 18.91a6 6 0 0 1 11.249.003`,key:`hnjrf2`}],[`circle`,{cx:`12`,cy:`11`,r:`4`,key:`1gt34v`}]]),J=e(t()),Y=W(),X=[K.TRACES,K.COST,K.SCENARIOS,K.ANNOTATIONS,K.ANALYTICS,K.EVALUATIONS,K.DATASETS,K.TRIGGERS,K.WORKFLOWS,K.PROMPTS,K.SECRETS,K.AUDIT_LOG,K.TEAM,K.PROJECT];function Z(e){return e===K.COST?[G.VIEW]:e===K.TRACES?[G.VIEW,G.SHARE]:e===K.SECRETS?[G.VIEW,G.MANAGE]:e===K.SCENARIOS||e===K.AUDIT_LOG?[G.VIEW]:[G.MANAGE,G.VIEW,G.CREATE,G.UPDATE,G.DELETE]}var Q=m();function de({permissions:e}){let t=(e,t)=>`${e}:${t}`,n={};return X.forEach(e=>{n[e]=Z(e).map(n=>t(e,n))}),(0,Q.jsx)(V,{align:`start`,width:`full`,gap:4,children:Object.keys(n).map(n=>{let r=Z(n);if(!r.some(t=>e.includes(`${n}:${t}`)))return null;let i=r.filter(t=>e.includes(`${n}:${t}`)),a=i.includes(`manage`)?i.filter(e=>e===`manage`||e===`share`):i;return(0,Q.jsxs)(_,{width:`full`,children:[(0,Q.jsxs)(V,{align:`start`,gap:2,width:`full`,children:[(0,Q.jsx)(E,{fontWeight:`semibold`,textTransform:`capitalize`,fontSize:`md`,children:n}),(0,Q.jsx)(V,{align:`start`,gap:1.5,paddingLeft:4,width:`full`,children:a.map(e=>{let r=t(n,e),i=e===`manage`?`Manage (Create, Update, Delete)`:e.charAt(0).toUpperCase()+e.slice(1);return(0,Q.jsxs)(M,{gap:2,align:`center`,children:[(0,Q.jsx)(l,{size:14,color:`var(--chakra-colors-green-500)`}),(0,Q.jsx)(E,{fontSize:`sm`,color:`fg`,children:i})]},r)})})]}),(0,Q.jsx)(C,{marginY:3})]},n)})})}function $({name:e,description:t,permissionCount:n,isDefault:i=!1,icon:a=w,onDelete:o,onEdit:s,onViewPermissions:c,hasPermission:l}){let u=l(`organization:manage`);return(0,Q.jsxs)(z,{width:`100%`,height:`100%`,borderWidth:`1px`,borderColor:`border`,_hover:c?{borderColor:`orange.400`,shadow:`md`}:{},transition:`all 0.2s`,display:`flex`,flexDirection:`column`,cursor:c&&u?`pointer`:`default`,onClick:c&&u?c:void 0,position:`relative`,children:[!i&&(0,Q.jsxs)(M,{gap:1,onClick:e=>e.stopPropagation(),position:`absolute`,right:4,top:`50%`,transform:`translateY(-50%)`,children:[c&&(0,Q.jsx)(h,{size:`sm`,variant:`ghost`,colorPalette:`blue`,onClick:e=>{e.stopPropagation(),c()},disabled:!l(`organization:manage`),children:(0,Q.jsx)(S,{size:14})}),s&&(0,Q.jsx)(h,{size:`sm`,variant:`ghost`,colorPalette:`orange`,onClick:e=>{e.stopPropagation(),s()},disabled:!l(`organization:manage`),children:(0,Q.jsx)(r,{size:14})}),o&&(0,Q.jsx)(h,{size:`sm`,variant:`ghost`,colorPalette:`red`,onClick:e=>{e.stopPropagation(),o()},disabled:!l(`organization:manage`),children:(0,Q.jsx)(f,{size:14})})]}),(0,Q.jsx)(R,{children:(0,Q.jsxs)(V,{align:`start`,gap:1,children:[(0,Q.jsxs)(M,{children:[(0,Q.jsx)(a,{size:18}),(0,Q.jsx)(E,{fontWeight:`semibold`,children:e})]}),i&&(0,Q.jsx)(E,{fontSize:`xs`,color:`fg.muted`,children:`Built-in Role`})]})}),(0,Q.jsx)(B,{paddingTop:0,flex:1,display:`flex`,flexDirection:`column`,children:(0,Q.jsxs)(V,{align:`start`,gap:2,flex:1,width:`full`,justifyContent:`space-between`,children:[(0,Q.jsx)(E,{fontSize:`sm`,color:`fg.muted`,children:t}),i?(0,Q.jsx)(b,{colorPalette:`orange`,size:`sm`,children:n}):(0,Q.jsx)(E,{fontSize:`xs`,color:`orange.fg`,fontWeight:`medium`,children:n})]})})]})}function fe({selectedPermissions:e,onChange:t}){let n=(e,t)=>`${e}:${t}`,r=(0,J.useMemo)(()=>{let e={};return X.forEach(t=>{e[t]=Z(t).map(e=>n(t,e))}),e},[]),o=(e,t)=>{if(e.endsWith(`:manage`))return r[t]||[];let[n,i]=e.split(`:`);if(i===`view`){let n=r[t]||[],i=[`create`,`update`,`delete`];return[e,...n.filter(e=>i.some(t=>e.endsWith(`:${t}`)))]}return[e]},s=(e,t)=>{if(e.endsWith(`:manage`))return r[t]||[];let[i,a]=e.split(`:`);return a===`create`||a===`update`||a===`delete`?[e,n(t,`view`)]:[e]},c=n=>{let[r]=n.split(`:`),i=o(n,r);t(e.filter(e=>!i.includes(e)))},l=n=>{let[r]=n.split(`:`),i=s(n,r);t([...e,...i.filter(t=>!e.includes(t))])},d=t=>{let[r,i]=t.split(`:`),a=n(r,`manage`),o=e.includes(a);e.includes(t)||o&&i!==`manage`?c(t):l(t)};return(0,Q.jsx)(V,{align:`start`,width:`full`,gap:4,children:Object.keys(r).map(t=>{let r=Z(t);return(0,Q.jsxs)(_,{width:`full`,children:[(0,Q.jsxs)(i,{children:[(0,Q.jsx)(u,{fontSize:`sm`,fontWeight:`semibold`,textTransform:`capitalize`,marginBottom:2,children:(0,Q.jsx)(E,{children:t})}),(0,Q.jsx)(a,{children:(0,Q.jsx)(M,{gap:4,flexWrap:`wrap`,paddingLeft:6,children:r.map(r=>{let i=n(t,r),a=e.includes(i),o=n(t,`manage`),s=e.includes(o),c=r!==`manage`&&s;return(0,Q.jsx)(p,{checked:a||c,onChange:()=>{d(c?o:i)},opacity:c?.6:1,cursor:c?`not-allowed`:`pointer`,children:r===`manage`?(0,Q.jsx)(ee,{content:`Manage includes all permissions (view, create, update, delete) for this resource`,positioning:{placement:`top`},showArrow:!0,children:(0,Q.jsxs)(M,{gap:1,children:[(0,Q.jsx)(E,{fontSize:`sm`,textTransform:`capitalize`,children:r}),(0,Q.jsx)(_,{color:`fg.muted`,children:(0,Q.jsx)(y,{size:14})})]})}):(0,Q.jsx)(E,{fontSize:`sm`,textTransform:`capitalize`,children:r})},i)})})})]}),(0,Q.jsx)(C,{marginY:3})]},t)})})}function pe({open:e,onClose:t,onSubmit:n,initialData:r,title:i,submitLabel:a=`Create Role`,isSubmitting:o=!1}){let{register:s,handleSubmit:l,reset:u,formState:{errors:d},setValue:f,watch:p}=ae({defaultValues:{name:r?.name??``,description:r?.description??``,permissions:r?.permissions??[]}}),m=p(`permissions`)||[];(0,J.useEffect)(()=>{r?(f(`name`,r.name),f(`description`,r.description),f(`permissions`,r.permissions)):u({name:``,description:``,permissions:[]})},[r,f,u]);let g=l(async e=>{await n(e),r||u()});return(0,Q.jsx)(x.Root,{open:e,onOpenChange:({open:e})=>!e&&t(),children:(0,Q.jsxs)(x.Content,{maxWidth:`900px`,maxHeight:`90vh`,overflowY:`auto`,children:[(0,Q.jsx)(x.Header,{children:(0,Q.jsx)(x.Title,{children:i})}),(0,Q.jsx)(x.Body,{children:(0,Q.jsx)(`form`,{id:`role-form`,onSubmit:e=>void g(e),children:(0,Q.jsxs)(V,{gap:6,align:`start`,children:[(0,Q.jsxs)(D,{invalid:!!d.name,children:[(0,Q.jsxs)(k,{children:[`Role Name`,` `,(0,Q.jsx)(E,{as:`span`,color:`red.500`,children:`*`})]}),(0,Q.jsx)(j,{...s(`name`,{required:`Role name is required`}),placeholder:`e.g., Data Analyst`}),d.name&&(0,Q.jsx)(A,{children:d.name.message})]}),(0,Q.jsxs)(D,{children:[(0,Q.jsx)(k,{children:`Description`}),(0,Q.jsx)(O,{children:`Describe what this role is for`}),(0,Q.jsx)(c,{...s(`description`),placeholder:`e.g., Can view and analyze data but cannot modify settings`,rows:3})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:4,children:[(0,Q.jsx)(T,{size:`sm`,children:`Permissions`}),(0,Q.jsx)(E,{fontSize:`sm`,color:`fg.muted`,children:`Select the permissions this role should have`}),(0,Q.jsx)(fe,{selectedPermissions:m,onChange:e=>f(`permissions`,e)})]})]})})}),(0,Q.jsxs)(x.Footer,{children:[(0,Q.jsx)(h,{variant:`outline`,onClick:t,children:`Cancel`}),(0,Q.jsx)(h,{type:`submit`,form:`role-form`,colorPalette:`orange`,loading:o,children:a})]}),(0,Q.jsx)(x.CloseTrigger,{})]})})}function me(){let{organization:e,hasPermission:t}=ie(),{isEnterprise:n,isLoading:r}=se();return!e||r?(0,Q.jsx)(q,{children:(0,Q.jsx)(V,{align:`center`,justify:`center`,width:`full`,height:`200px`,children:(0,Q.jsx)(g,{})})}):n?(0,Q.jsx)(q,{children:(0,Q.jsx)(ge,{organizationId:e.id,hasPermission:t})}):(0,Q.jsx)(q,{children:(0,Q.jsxs)(V,{gap:6,width:`full`,align:`start`,children:[(0,Q.jsxs)(P,{status:`info`,children:[(0,Q.jsx)(I,{}),(0,Q.jsxs)(L,{children:[(0,Q.jsx)(N,{children:`Enterprise Feature`}),(0,Q.jsx)(F,{children:`Custom roles are available on Enterprise plans. Contact sales to upgrade.`})]})]}),(0,Q.jsx)(_,{width:`full`,children:(0,Q.jsx)(ce,{})})]})})}var he=le(`organization:view`,{layoutComponent:q})(me);function ge({organizationId:e,hasPermission:t}){let{open:r,onOpen:i,onClose:a}=s(),{open:c,onOpen:l,onClose:u}=s(),{open:f,onOpen:p,onClose:m}=s(),{open:y,onOpen:b,onClose:S}=s(),[w,D]=(0,J.useState)(null),[O,k]=(0,J.useState)(null),[A,j]=(0,J.useState)(null),N=U.useContext(),P=U.role.getAll.useQuery({organizationId:e}),F=U.role.create.useMutation({onSuccess:()=>{N.role.getAll.invalidate(),v.create({title:`Role created successfully`,type:`success`}),a()},onError:e=>{H(e)||v.create({title:`Failed to create role`,description:e.message,type:`error`})}}),I=U.role.delete.useMutation({onSuccess:()=>{N.role.getAll.invalidate(),v.create({title:`Role deleted successfully`,type:`success`})},onError:e=>{H(e)||v.create({title:`Failed to delete role`,description:e.message,type:`error`})}}),L=U.role.update.useMutation({onSuccess:()=>{N.role.getAll.invalidate(),v.create({title:`Role updated successfully`,type:`success`}),u(),D(null)},onError:e=>{H(e)||v.create({title:`Failed to update role`,description:e.message,type:`error`})}}),R=async e=>{try{let t=await N.role.getById.fetch({roleId:e});D({id:t.id,name:t.name,description:t.description??``,permissions:t.permissions}),l()}catch{v.create({title:`Failed to load role`,description:`Could not load role details for editing`,type:`error`})}},W=async e=>{try{let t=await N.role.getById.fetch({roleId:e});k({id:t.id,name:t.name,description:t.description??``,permissions:t.permissions}),p()}catch{v.create({title:`Failed to load role`,description:`Could not load role details for viewing`,type:`error`})}},G=(e,t)=>{let n=re(t);j({name:e,description:K(e),permissions:n}),b()},K=e=>{switch(e){case`Admin`:return`Full access to all features and settings`;case`Member`:return`Can create and modify most resources, view costs and debug info`;case`Viewer`:return`Read-only access to analytics, messages, and guardrails`;default:return``}};return(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:6,children:[(0,Q.jsxs)(M,{justify:`space-between`,width:`full`,children:[(0,Q.jsxs)(V,{align:`start`,gap:1,children:[(0,Q.jsx)(T,{as:`h2`,children:`Roles & Permissions`}),(0,Q.jsx)(E,{color:`fg.muted`,fontSize:`sm`,children:`Create custom roles and assign specific permissions to control access`})]}),(0,Q.jsx)(ee,{content:`You need organization:manage permissions to create roles.`,disabled:t(`organization:manage`),children:(0,Q.jsxs)(o.HeaderButton,{onClick:i,disabled:!t(`organization:manage`),children:[(0,Q.jsx)(te,{size:16}),` Create Role`]})})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:4,children:[(0,Q.jsxs)(_,{children:[(0,Q.jsx)(T,{as:`h3`,children:`Default Roles`}),(0,Q.jsx)(E,{color:`fg.muted`,fontSize:`sm`,children:`These are the built-in roles that cannot be modified or deleted.`})]}),(0,Q.jsxs)(_,{width:`full`,display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(300px, 1fr))`,gap:4,children:[(0,Q.jsx)($,{hasPermission:t,name:`Admin`,description:`Full access to all features and settings`,isDefault:!0,permissionCount:`All Permissions`,icon:ue,onViewPermissions:()=>G(`Admin`,Y.TeamUserRole.ADMIN)}),(0,Q.jsx)($,{hasPermission:t,name:`Member`,description:`Can create and modify most resources, view costs and debug info`,isDefault:!0,permissionCount:`Most Permissions`,icon:n,onViewPermissions:()=>G(`Member`,Y.TeamUserRole.MEMBER)}),(0,Q.jsx)($,{hasPermission:t,name:`Viewer`,description:`Read-only access to analytics, messages, and guardrails`,isDefault:!0,permissionCount:`View Only`,icon:d,onViewPermissions:()=>G(`Viewer`,Y.TeamUserRole.VIEWER)})]})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:4,children:[(0,Q.jsxs)(_,{children:[(0,Q.jsx)(T,{as:`h3`,children:`Custom Roles`}),(0,Q.jsx)(E,{color:`fg.muted`,fontSize:`sm`,children:`Custom roles created for your organization with specific permission sets.`})]}),P.isLoading&&(0,Q.jsx)(V,{align:`center`,width:`full`,padding:8,children:(0,Q.jsx)(g,{})}),P.data&&P.data.length===0&&(0,Q.jsx)(z,{width:`full`,children:(0,Q.jsx)(B,{textAlign:`center`,padding:8,children:(0,Q.jsxs)(V,{gap:2,children:[(0,Q.jsx)(ne,{size:48,color:`gray`}),(0,Q.jsx)(E,{color:`fg.muted`,children:`No custom roles yet. Create your first custom role to get started.`})]})})}),(0,Q.jsx)(_,{width:`full`,display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(300px, 1fr))`,gap:4,children:P.data?.map(e=>(0,Q.jsx)($,{name:e.name,description:e.description??``,permissionCount:`${e.permissions.length} permissions`,hasPermission:t,onDelete:()=>{confirm(`Are you sure you want to delete the role "${e.name}"?`)&&I.mutate({roleId:e.id})},onEdit:()=>{R(e.id)},onViewPermissions:()=>{W(e.id)}},e.id))})]}),(0,Q.jsx)(pe,{open:r,onClose:a,onSubmit:async t=>{await F.mutateAsync({organizationId:e,name:t.name,description:t.description,permissions:t.permissions})},title:`Create Custom Role`,submitLabel:`Create Role`,isSubmitting:F.isLoading}),(0,Q.jsx)(pe,{open:c,onClose:()=>{u(),D(null)},onSubmit:async e=>{w&&await L.mutateAsync({roleId:w.id,name:e.name,description:e.description,permissions:e.permissions})},initialData:w?{name:w.name,description:w.description,permissions:w.permissions}:void 0,title:`Edit Role`,submitLabel:`Update Role`,isSubmitting:L.isLoading}),(0,Q.jsx)(x.Root,{open:f,onOpenChange:({open:e})=>!e&&m(),children:(0,Q.jsxs)(x.Content,{maxWidth:`600px`,maxHeight:`80vh`,overflowY:`auto`,children:[(0,Q.jsx)(x.Header,{children:(0,Q.jsxs)(x.Title,{children:[`View Permissions - `,O?.name]})}),(0,Q.jsx)(x.Body,{children:O&&(0,Q.jsxs)(V,{gap:4,align:`start`,children:[(0,Q.jsxs)(V,{align:`start`,gap:2,width:`full`,children:[(0,Q.jsx)(E,{fontWeight:`semibold`,children:`Description:`}),(0,Q.jsx)(E,{color:`fg.muted`,children:O.description||`No description provided`})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,gap:3,width:`full`,children:[(0,Q.jsxs)(E,{fontWeight:`semibold`,children:[`Permissions (`,O.permissions.length,`):`]}),(0,Q.jsx)(de,{permissions:O.permissions})]})]})}),(0,Q.jsx)(x.Footer,{children:(0,Q.jsx)(h,{variant:`outline`,onClick:m,children:`Close`})}),(0,Q.jsx)(x.CloseTrigger,{})]})}),(0,Q.jsx)(x.Root,{open:y,onOpenChange:({open:e})=>!e&&S(),children:(0,Q.jsxs)(x.Content,{maxWidth:`600px`,maxHeight:`80vh`,overflowY:`auto`,children:[(0,Q.jsx)(x.Header,{children:(0,Q.jsxs)(x.Title,{children:[`View Permissions - `,A?.name]})}),(0,Q.jsx)(x.Body,{children:A&&(0,Q.jsxs)(V,{gap:4,align:`start`,children:[(0,Q.jsxs)(V,{align:`start`,gap:2,width:`full`,children:[(0,Q.jsx)(E,{fontWeight:`semibold`,children:`Description:`}),(0,Q.jsx)(E,{color:`fg.muted`,children:A.description})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,gap:3,width:`full`,children:[(0,Q.jsxs)(E,{fontWeight:`semibold`,children:[`Permissions (`,A.permissions.length,`):`]}),(0,Q.jsx)(de,{permissions:A.permissions})]})]})}),(0,Q.jsx)(x.Footer,{children:(0,Q.jsx)(h,{variant:`outline`,onClick:S,children:`Close`})}),(0,Q.jsx)(x.CloseTrigger,{})]})})]})}export{he as default};
2
+ //# sourceMappingURL=roles-DNgi-NQ9.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,Ca as r,Co as i,Eo as a,Fa as o,Pa as s,Pr as c,Ss as l,To as u,Us as d,Ws as f,Xa as p,Xr as m,_s as h,ao as g,bs as _,do as v,et as y,fo as b,gs as x,ka as S,mn as C,nt as w,qi as T,r as E,ro as D,tt as O,vs as k,wo as A,xi as j,xs as M,yo as N,ys as P}from"./command-bar-CaJygoez.js";import{j as F,n as I,r as L}from"./stack-oJ9iWdbl.js";import{t as R}from"./box-BsM8YLGl.js";import{n as z}from"./toaster-C_DYALhL.js";import{f as B}from"./dist-SwV3YZv3.js";import{s as V}from"./terminal-CfM0q99k.js";import{t as ee}from"./heading-D90dlSnH.js";import{t as H}from"./text-CwTrMF8x.js";import{t as U}from"./icon-BwEPrfAc.js";import{t as W}from"./h-stack-BKLDJ2vg.js";import{Pt as te}from"./lu-Bf6j_N19.js";import{n as ne}from"./link-CwZhwOLq.js";import{t as re}from"./spacer-2LJJGbo8.js";import{t as G}from"./v-stack-EOPQ57OZ.js";import{m as ie,s as K}from"./auth-client-D3UhxhQi.js";import{t as q}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as ae}from"./createLucideIcon-BJKFyRLS.js";import{t as oe}from"./arrow-right-B3ZN8yal.js";import{t as se}from"./chevron-up-BvG6wkCS.js";import{t as ce}from"./WithPermissionGuard-DD8uo3UK.js";import{a as le,i as ue,n as de,o as fe,r as pe,t as J}from"./lib-BYJUJC_x.js";var me=ae(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),Y=e(t()),X=F();function he({allLabels:e,activeLabels:t,onToggle:n}){let r=t.length>0;return(0,X.jsxs)(u,{positioning:{placement:`bottom-start`},children:[(0,X.jsx)(a,{asChild:!0,children:(0,X.jsxs)(I,{size:`sm`,variant:r?`solid`:`outline`,colorPalette:r?`blue`:`gray`,children:[(0,X.jsx)(me,{size:14}),`Labels`,r&&(0,X.jsxs)(H,{as:`span`,fontSize:`xs`,ml:1,children:[`(`,t.length,`)`]})]})}),(0,X.jsx)(A,{width:`200px`,children:(0,X.jsx)(i,{children:e.length===0?(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,children:`No labels available`}):(0,X.jsx)(G,{align:`stretch`,gap:2,children:e.map(e=>(0,X.jsxs)(W,{cursor:`pointer`,onClick:()=>n(e),children:[(0,X.jsx)(N,{checked:t.includes(e)}),(0,X.jsx)(H,{fontSize:`sm`,children:e})]},e))})})})]})}function ge({selectedCount:e,onArchive:t}){return e===0?null:(0,X.jsx)(R,{position:`fixed`,bottom:10,left:`50%`,transform:`translateX(-50%)`,backgroundColor:`#ffffff`,border:`1px solid #ccc`,boxShadow:`0 0 15px rgba(0, 0, 0, 0.2)`,borderRadius:`md`,padding:`8px`,paddingX:`16px`,zIndex:1e3,"data-testid":`batch-action-bar`,children:(0,X.jsxs)(W,{gap:3,children:[(0,X.jsxs)(H,{whiteSpace:`nowrap`,fontSize:`sm`,fontWeight:`medium`,children:[e,` selected`]}),(0,X.jsxs)(I,{size:`sm`,variant:`outline`,colorPalette:`orange`,onClick:t,children:[(0,X.jsx)(v,{size:14}),`Archive`]})]})})}function _e({open:e,onClose:t,onConfirm:n,scenarios:r,isLoading:i=!1}){let a=r.length>1,o=a?`Archive ${r.length} scenarios?`:`Archive scenario?`;return(0,X.jsx)(B.Root,{open:e,onOpenChange:t,placement:`center`,children:(0,X.jsxs)(B.Content,{maxWidth:`500px`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(B.CloseTrigger,{}),(0,X.jsx)(B.Header,{children:(0,X.jsx)(B.Title,{fontSize:`md`,fontWeight:`500`,children:o})}),(0,X.jsx)(B.Body,{children:(0,X.jsxs)(G,{align:`stretch`,gap:4,children:[a?(0,X.jsx)(f,{paddingLeft:4,children:r.map(e=>(0,X.jsx)(d,{fontSize:`sm`,children:e.name},e.id))}):r[0]&&(0,X.jsx)(H,{children:(0,X.jsx)(H,{as:`span`,fontWeight:`semibold`,children:r[0].name})}),(0,X.jsx)(H,{color:`fg.muted`,fontSize:`sm`,children:`Archived scenarios will no longer appear in the library.`})]})}),(0,X.jsxs)(B.Footer,{children:[(0,X.jsx)(I,{variant:`outline`,mr:3,onClick:e=>{e.stopPropagation(),t()},disabled:i,children:`Cancel`}),(0,X.jsx)(I,{colorPalette:`orange`,onClick:e=>{e.stopPropagation(),n()},disabled:i,children:i?(0,X.jsx)(L,{size:`sm`}):`Archive`})]})]})})}var ve=`Describe your scenario. What does your agent do? What situation do you want to test?`,ye=`Generating...`,be=6e4;function xe({open:e,onClose:t,title:n,placeholder:r=ve,exampleTemplates:i,onGenerate:a,onSkip:o,generatingText:s=ye,hasModelProviders:c=!0}){let[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(`idle`),[p,m]=(0,Y.useState)(``),h=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]),(0,Y.useEffect)(()=>{e&&(u(``),f(`idle`),m(``))},[e]);let g=(0,Y.useCallback)(e=>{u(e.target.value)},[]),_=(0,Y.useCallback)(e=>{u(e)},[]),v=(0,Y.useCallback)(async()=>{if(!l.trim())return;let e=a(l);if(!e)return;f(`generating`),m(``);let t=new Promise((e,t)=>{h.current=setTimeout(()=>{t(Error(`Generation timed out. Please try again.`))},be)});try{await Promise.race([e,t])}catch(e){f(`error`),m(e instanceof Error?e.message:`An unexpected error occurred`)}finally{h.current&&=(clearTimeout(h.current),null)}},[l,a]),y=(0,Y.useCallback)(()=>{v()},[v]),b=(0,Y.useCallback)(()=>{o()},[o]),x=(0,Y.useCallback)(e=>{!e.open&&d!==`generating`&&t()},[d,t]),S=d!==`generating`;return(0,X.jsx)(B.Root,{open:e,onOpenChange:x,children:(0,X.jsxs)(B.Content,{children:[S&&(0,X.jsx)(B.CloseTrigger,{}),(0,X.jsx)(B.Header,{children:(0,X.jsx)(B.Title,{children:n})}),(0,X.jsxs)(B.Body,{children:[!c&&(0,X.jsx)(De,{}),c&&d===`idle`&&(0,X.jsx)(Se,{description:l,placeholder:r,exampleTemplates:i,onDescriptionChange:g,onExampleClick:_}),c&&d===`generating`&&(0,X.jsx)(Ce,{text:s}),c&&d===`error`&&(0,X.jsx)(we,{errorMessage:p})]}),(0,X.jsxs)(B.Footer,{children:[!c&&(0,X.jsx)(Oe,{}),c&&d===`idle`&&(0,X.jsx)(Te,{onSkip:b,onGenerate:v,isGenerateDisabled:!l.trim()}),c&&d===`error`&&(0,X.jsx)(Ee,{onSkip:b,onTryAgain:y})]})]})})}function Se({description:e,placeholder:t,exampleTemplates:n,onDescriptionChange:r,onExampleClick:i}){return(0,X.jsxs)(G,{align:`stretch`,gap:4,children:[(0,X.jsx)(R,{children:(0,X.jsx)(x,{placeholder:t,value:e,onChange:r,rows:5,resize:`vertical`})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,mb:2,children:`Try an example:`}),(0,X.jsx)(W,{gap:2,flexWrap:`wrap`,children:n.map(e=>(0,X.jsx)(I,{size:`xs`,variant:`outline`,onClick:()=>i(e.text),children:e.label},e.label))})]})]})}function Ce({text:e}){return(0,X.jsxs)(G,{gap:4,py:8,children:[(0,X.jsx)(L,{size:`lg`,color:`blue.500`}),(0,X.jsx)(H,{color:`fg.muted`,children:e})]})}function we({errorMessage:e}){return(0,X.jsxs)(G,{gap:4,py:4,children:[(0,X.jsx)(R,{p:3,borderRadius:`full`,bg:`red.100`,color:`red.600`,children:(0,X.jsx)(U,{as:D,boxSize:6})}),(0,X.jsxs)(G,{gap:1,children:[(0,X.jsx)(H,{fontWeight:`semibold`,children:`Something went wrong`}),(0,X.jsx)(H,{color:`fg.muted`,fontSize:`sm`,textAlign:`center`,children:e})]})]})}function Te({onSkip:e,onGenerate:t,isGenerateDisabled:n}){return(0,X.jsxs)(W,{gap:2,justify:`flex-end`,children:[(0,X.jsx)(I,{variant:`ghost`,onClick:e,children:`I'll write it myself`}),(0,X.jsxs)(I,{colorPalette:`blue`,onClick:t,disabled:n,children:[(0,X.jsx)(S,{size:14}),`Generate with AI`]})]})}function Ee({onSkip:e,onTryAgain:t}){return(0,X.jsxs)(W,{gap:2,justify:`flex-end`,children:[(0,X.jsx)(I,{variant:`ghost`,onClick:e,children:`I'll write it myself`}),(0,X.jsx)(I,{colorPalette:`blue`,onClick:t,children:`Try again`})]})}function De(){return(0,X.jsxs)(G,{gap:4,py:8,align:`center`,justify:`center`,children:[(0,X.jsx)(R,{p:3,borderRadius:`full`,bg:`orange.100`,color:`orange.600`,children:(0,X.jsx)(U,{as:r,boxSize:6})}),(0,X.jsxs)(G,{gap:1,children:[(0,X.jsx)(H,{fontWeight:`semibold`,children:`No model provider configured`}),(0,X.jsxs)(H,{color:`fg.muted`,fontSize:`sm`,textAlign:`center`,children:[`Scenarios require a model provider to run. Please configure one to get started.`,` `,(0,X.jsx)(ne,{href:`/settings/model-providers`,target:`_blank`,rel:`noopener noreferrer`,color:`blue.500`,fontWeight:`medium`,children:`Configure model provider`})]})]})]})}function Oe(){return(0,X.jsx)(W,{gap:2,justify:`flex-end`,children:(0,X.jsx)(I,{colorPalette:`blue`,asChild:!0,children:(0,X.jsx)(`a`,{"data-testid":`ai-create-modal-configure-model-provider-button`,href:`/settings/model-providers`,target:`_blank`,rel:`noopener noreferrer`,children:`Configure model provider`})})})}var ke=`Create new scenario`,Ae=`Explain your agent, its goals and what behavior you want to test.`,je=`Generating scenario...`,Me=[{label:`Customer Support`,text:`A customer support agent that handles complaints. Test an angry customer who was charged twice and wants a refund.`},{label:`RAG Q&A`,text:`A knowledge bot that answers questions from documentation. Test a question that requires combining info from multiple sources.`},{label:`Tool-calling Agent`,text:`An agent that uses tools to complete tasks. Test a request that requires calling multiple tools in sequence.`}];function Ne({open:e,onClose:t}){let{project:n}=q(),{openDrawer:r}=E(),{checkAndProceed:i}=b(`scenarios`),{hasEnabledProviders:a,providers:o}=j({projectId:n?.id}),s=y({hasEnabledProviders:a,providers:o,defaultModel:n?.defaultModel}),c=(0,Y.useCallback)(e=>{r(`scenarioEditor`,{initialFormData:e},{resetStack:!0}),t()},[r,t]),l=(0,Y.useCallback)(async e=>{if(!n?.id)throw Error(`No project selected`);if(!s.ok){if(s.reason===`no-default`)throw Error(`No default model set. Configure one in Settings → Model Providers.`);if(s.reason===`stale-default`)throw Error(`Your default model's provider is disabled. Configure a new default in Settings → Model Providers.`);s.reason;return}try{c(await O(e,n.id))}catch(e){if(ie(e))return;throw e}},[n?.id,s,c]),u=(0,Y.useCallback)(()=>{c({name:``,situation:``,criteria:[]})},[c]);return(0,X.jsx)(xe,{open:e,onClose:t,title:ke,placeholder:Ae,exampleTemplates:Me,onGenerate:e=>i(()=>l(e)),onSkip:()=>i(u),generatingText:je,hasModelProviders:s.ok||s.reason!==`no-providers`})}function Pe({onCreateClick:e}){return(0,X.jsxs)(G,{gap:4,align:`center`,py:12,children:[(0,X.jsx)(H,{fontSize:`lg`,color:`fg.muted`,children:`No scenarios yet`}),(0,X.jsx)(H,{fontSize:`sm`,color:`fg.subtle`,children:`Create your first scenario to get started`}),(0,X.jsxs)(I,{colorPalette:`blue`,onClick:e,children:[(0,X.jsx)(o,{size:16}),` Create Scenario`]})]})}var Z=pe(),Fe=(e,t,n)=>{let r=e.getValue(t),i=n;return!i||i.length===0?!0:i.some(e=>r.includes(e))};function Ie({scenarios:e,columnFilters:t,onColumnFiltersChange:n,onRowClick:r,rowSelection:i,onRowSelectionChange:a,onArchive:o}){let[s,u]=(0,Y.useState)([]),d=de({data:e,columns:(0,Y.useMemo)(()=>[Z.display({id:`select`,header:({table:e})=>(0,X.jsx)(N,{"aria-label":`Select all`,checked:e.getIsAllPageRowsSelected(),onChange:()=>e.toggleAllPageRowsSelected(),onClick:e=>e.stopPropagation()}),cell:({row:e})=>(0,X.jsx)(N,{"aria-label":`Select ${e.original.name}`,checked:e.getIsSelected(),onChange:()=>e.toggleSelected(),onClick:e=>e.stopPropagation()}),enableSorting:!1}),Z.accessor(`name`,{header:`Name`,cell:e=>(0,X.jsx)(H,{fontWeight:`medium`,children:e.getValue()})}),Z.accessor(`labels`,{header:`Labels`,enableSorting:!1,filterFn:Fe,cell:e=>(0,X.jsx)(w,{labels:e.getValue()})}),Z.accessor(`updatedAt`,{header:`Updated`,cell:e=>(0,X.jsx)(H,{color:`fg.muted`,children:c(e.getValue().getTime())})}),Z.display({id:`actions`,header:``,cell:({row:e})=>(0,X.jsxs)(T.Root,{children:[(0,X.jsx)(T.Trigger,{asChild:!0,children:(0,X.jsx)(te,{"aria-label":`Actions for ${e.original.name}`,variant:`ghost`,size:`sm`,onClick:e=>e.stopPropagation(),children:(0,X.jsx)(p,{size:16})})}),(0,X.jsx)(T.Content,{portalled:!1,children:(0,X.jsxs)(T.Item,{value:`archive`,color:`orange.500`,onClick:t=>{t.stopPropagation(),o(e.original)},children:[(0,X.jsx)(v,{size:14}),`Archive`]})})]}),enableSorting:!1})],[o]),state:{sorting:s,columnFilters:t,rowSelection:i},enableRowSelection:!0,onRowSelectionChange:e=>{a(typeof e==`function`?e(i):e)},onSortingChange:u,onColumnFiltersChange:e=>{n(typeof e==`function`?e(t):e)},getCoreRowModel:ue(),getFilteredRowModel:le(),getSortedRowModel:fe(),getRowId:e=>e.id});return(0,X.jsxs)(M,{variant:`line`,width:`full`,size:`md`,children:[(0,X.jsx)(_,{children:d.getHeaderGroups().map(e=>(0,X.jsx)(l,{children:e.headers.map(e=>(0,X.jsx)(P,{cursor:e.column.getCanSort()?`pointer`:`default`,onClick:e.column.getToggleSortingHandler(),userSelect:`none`,width:e.id===`select`?`40px`:e.id===`actions`?`48px`:void 0,children:(0,X.jsxs)(W,{gap:1,children:[J(e.column.columnDef.header,e.getContext()),e.column.getIsSorted()===`asc`&&(0,X.jsx)(se,{size:14}),e.column.getIsSorted()===`desc`&&(0,X.jsx)(g,{size:14})]})},e.id))},e.id))}),(0,X.jsx)(h,{children:d.getRowModel().rows.map(e=>(0,X.jsx)(l,{cursor:`pointer`,_hover:{bg:`bg.emphasized`},onClick:()=>r(e.original.id),children:e.getVisibleCells().map(e=>(0,X.jsx)(k,{children:J(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})}var Le=[{icon:V,title:`Automated Testing`,description:`Define test scenarios that run automatically against your AI agent to verify it handles real-world situations correctly.`},{icon:s,title:`Regression Detection`,description:`Catch regressions early by re-running scenarios after every change, ensuring your agent never breaks existing behavior.`}];function Q({onProceed:e}){return(0,X.jsxs)(G,{gap:8,align:`center`,children:[(0,X.jsxs)(G,{gap:3,textAlign:`center`,children:[(0,X.jsx)(ee,{as:`h2`,size:`xl`,children:`Welcome to Scenarios`}),(0,X.jsx)(H,{fontSize:`md`,color:`fg.muted`,children:`Scenarios let you test your agent behavior with repeatable, automated checks. Define situations, set expectations, and verify your agent responds correctly every time.`})]}),(0,X.jsx)(G,{gap:4,w:`full`,children:Le.map(({icon:e,title:t,description:n})=>(0,X.jsxs)(W,{gap:4,p:5,w:`full`,borderWidth:`1px`,borderColor:`border`,borderRadius:`lg`,align:`start`,children:[(0,X.jsx)(R,{p:2,borderRadius:`md`,bg:`blue.50`,color:`blue.600`,_dark:{bg:`blue.900`,color:`blue.200`},flexShrink:0,children:(0,X.jsx)(e,{size:20})}),(0,X.jsxs)(G,{gap:1,align:`start`,children:[(0,X.jsx)(H,{fontWeight:`semibold`,children:t}),(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,children:n})]})]},t))}),(0,X.jsxs)(I,{colorPalette:`blue`,size:`lg`,onClick:e,children:[`Create Your First Scenario `,(0,X.jsx)(oe,{size:16})]})]})}function Re({onProceed:e}){return(0,X.jsx)(G,{py:16,px:8,maxW:`640px`,mx:`auto`,children:(0,X.jsx)(Q,{onProceed:e})})}function ze({open:e,onOpenChange:t,onProceed:n}){return(0,X.jsx)(B.Root,{open:e,onOpenChange:e=>t(e.open),placement:`center`,size:`lg`,children:(0,X.jsxs)(B.Content,{maxWidth:`640px`,children:[(0,X.jsx)(B.CloseTrigger,{}),(0,X.jsx)(B.Body,{py:8,px:8,children:(0,X.jsx)(Q,{onProceed:n})})]})})}function Be(e){let[t,n]=(0,Y.useState)([]);return{columnFilters:t,setColumnFilters:n,allLabels:(0,Y.useMemo)(()=>{if(!e)return[];let t=new Set;return e.forEach(e=>e.labels.forEach(e=>t.add(e))),Array.from(t).sort()},[e]),activeLabels:(0,Y.useMemo)(()=>t.find(e=>e.id===`labels`)?.value??[],[t]),handleLabelToggle:(0,Y.useCallback)(e=>{n(t=>{let n=t.find(e=>e.id===`labels`)?.value??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e],i=t.filter(e=>e.id!==`labels`);return r.length===0?i:[...i,{id:`labels`,value:r}]})},[])}}var $=`langwatch:scenarios:welcomeSeen`;function Ve(){try{return localStorage.getItem($)===`true`}catch{return!1}}function He(){try{localStorage.setItem($,`true`)}catch{}}function Ue({scenarioCount:e,isLoading:t}){let[n,r]=(0,Y.useState)(Ve),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),c=!t&&e===0&&!n,l=(0,Y.useCallback)(()=>{He(),r(!0)},[]);return{showInlineWelcome:c,showWelcomeModal:i,showCreateModal:o,handleNewScenario:(0,Y.useCallback)(()=>{!n&&!t&&e===0?a(!0):s(!0)},[n,t,e]),handleWelcomeProceed:(0,Y.useCallback)(()=>{l(),a(!1),s(!0)},[l]),handleWelcomeModalOpenChange:(0,Y.useCallback)(e=>{e||(l(),a(!1))},[l]),handleCloseCreateModal:(0,Y.useCallback)(()=>{s(!1)},[])}}function We(){let[e,t]=(0,Y.useState)({}),n=(0,Y.useCallback)(e=>{t(t=>typeof e==`function`?e(t):e)},[]),r=(0,Y.useCallback)(e=>{t(t=>{let n={...t};return n[e]?delete n[e]:n[e]=!0,n})},[]),i=(0,Y.useCallback)(e=>{t(t=>{let n={...t};for(let t of e)n[t]=!0;return n})},[]),a=(0,Y.useCallback)(()=>{t({})},[]),o=(0,Y.useMemo)(()=>Object.keys(e).filter(t=>e[t]),[e]);return{toggle:r,selectAll:i,deselectAll:a,selectedIds:o,selectionCount:o.length,rowSelection:e,onRowSelectionChange:n}}function Ge(){let{project:e}=q(),{openDrawer:t,drawerOpen:r}=E(),{rowSelection:i,onRowSelectionChange:a,selectedIds:s,selectionCount:c,deselectAll:l}=We(),[u,d]=(0,Y.useState)(null),f=K.useContext(),{data:p,isLoading:h,error:g}=K.scenarios.getAll.useQuery({projectId:e?.id??``},{enabled:!!e}),_=(0,Y.useCallback)(()=>{f.scenarios.getAll.invalidate(),l(),d(null)},[f.scenarios.getAll,l]),v=K.scenarios.archive.useMutation({onSuccess:_,onError:e=>{z.create({title:`Failed to archive scenario`,description:e.message,type:`error`,meta:{closable:!0}})}}),y=K.scenarios.batchArchive.useMutation({onSuccess:e=>{e.failed.length>0&&z.create({title:`Some scenarios couldn't be archived`,description:`${e.failed.length} failed. Please retry.`,type:`error`,meta:{closable:!0}}),f.scenarios.getAll.invalidate(),l(),d(null)},onError:e=>{z.create({title:`Failed to archive scenarios`,description:e.message,type:`error`,meta:{closable:!0}})}}),{columnFilters:b,setColumnFilters:x,allLabels:S,activeLabels:w,handleLabelToggle:T}=Be(p),{showInlineWelcome:D,showWelcomeModal:O,showCreateModal:k,handleNewScenario:A,handleWelcomeProceed:j,handleWelcomeModalOpenChange:M,handleCloseCreateModal:N}=Ue({scenarioCount:p?.length??0,isLoading:h}),P=e=>{t(`scenarioEditor`,{urlParams:{scenarioId:e}})},F=(0,Y.useCallback)(e=>{d({type:`single`,scenario:e})},[]),I=(0,Y.useCallback)(()=>{d({type:`batch`})},[]),R=()=>{e?.id&&(u?.type===`single`?v.mutate({projectId:e.id,id:u.scenario.id}):u?.type===`batch`&&y.mutate({projectId:e.id,ids:s}))},B=()=>{d(null)},V=(0,Y.useMemo)(()=>!u||!p?[]:u.type===`single`?[{id:u.scenario.id,name:u.scenario.name}]:p.filter(e=>s.includes(e.id)).map(e=>({id:e.id,name:e.name})),[u,p,s]);return(0,X.jsxs)(C,{children:[(0,X.jsx)(m.Header,{children:(0,X.jsxs)(W,{justify:`space-between`,align:`center`,w:`full`,children:[(0,X.jsx)(m.Heading,{children:`Scenario Library`}),(0,X.jsx)(re,{}),(0,X.jsx)(he,{allLabels:S,activeLabels:w,onToggle:T}),(0,X.jsxs)(m.HeaderButton,{onClick:A,children:[(0,X.jsx)(o,{size:16}),` New Scenario`]})]})}),(0,X.jsxs)(m.Container,{padding:0,children:[h&&(0,X.jsx)(G,{gap:4,align:`center`,py:8,children:(0,X.jsx)(L,{borderWidth:`3px`,animationDuration:`0.8s`})}),g&&!p?.length&&(0,X.jsxs)(G,{gap:4,align:`center`,py:8,children:[(0,X.jsx)(H,{color:`red.500`,children:`Error loading scenarios`}),(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,children:g.message})]}),!h&&!g&&p?.length===0&&D&&(0,X.jsx)(Re,{onProceed:j}),!h&&!g&&p?.length===0&&!D&&(0,X.jsx)(Pe,{onCreateClick:A}),p&&p.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ge,{selectedCount:c,onArchive:I}),(0,X.jsx)(Ie,{scenarios:p,columnFilters:b,onColumnFiltersChange:x,onRowClick:P,rowSelection:i,onRowSelectionChange:a,onArchive:F})]})]}),(0,X.jsx)(n,{open:r(`scenarioEditor`)}),(0,X.jsx)(ze,{open:O,onOpenChange:M,onProceed:j}),(0,X.jsx)(Ne,{open:k,onClose:N}),(0,X.jsx)(_e,{open:u!==null,onClose:B,onConfirm:R,scenarios:V,isLoading:v.isPending||y.isPending})]})}var Ke=ce(`scenarios:view`,{layoutComponent:C})(Ge);export{Ke as default};
2
- //# sourceMappingURL=scenarios-BX3XslU0.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$ as n,Ca as r,Co as i,Eo as a,Fa as o,Pa as s,Pr as c,Ss as l,To as u,Us as d,Ws as f,Xa as p,Xr as m,_s as h,ao as g,bs as _,do as v,et as y,fo as b,gs as x,ka as S,mn as C,nt as w,qi as T,r as E,ro as D,tt as O,vs as k,wo as A,xi as j,xs as M,yo as N,ys as P}from"./command-bar-DUK45yin.js";import{j as F,n as I,r as L}from"./stack-oJ9iWdbl.js";import{t as R}from"./box-BsM8YLGl.js";import{n as z}from"./toaster-C_DYALhL.js";import{f as B}from"./dist-Cds4Mqhj.js";import{s as V}from"./terminal-CfM0q99k.js";import{t as ee}from"./heading-D90dlSnH.js";import{t as H}from"./text-CwTrMF8x.js";import{t as U}from"./icon-BwEPrfAc.js";import{t as W}from"./h-stack-BKLDJ2vg.js";import{Pt as te}from"./lu-Bf6j_N19.js";import{n as ne}from"./link-CwZhwOLq.js";import{t as re}from"./spacer-2LJJGbo8.js";import{t as G}from"./v-stack-EOPQ57OZ.js";import{m as ie,s as K}from"./auth-client-D3UhxhQi.js";import{t as q}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as ae}from"./createLucideIcon-BJKFyRLS.js";import{t as oe}from"./arrow-right-B3ZN8yal.js";import{t as se}from"./chevron-up-BvG6wkCS.js";import{t as ce}from"./WithPermissionGuard-B4Jo8E5-.js";import{a as le,i as ue,n as de,o as fe,r as pe,t as J}from"./lib-BYJUJC_x.js";var me=ae(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),Y=e(t()),X=F();function he({allLabels:e,activeLabels:t,onToggle:n}){let r=t.length>0;return(0,X.jsxs)(u,{positioning:{placement:`bottom-start`},children:[(0,X.jsx)(a,{asChild:!0,children:(0,X.jsxs)(I,{size:`sm`,variant:r?`solid`:`outline`,colorPalette:r?`blue`:`gray`,children:[(0,X.jsx)(me,{size:14}),`Labels`,r&&(0,X.jsxs)(H,{as:`span`,fontSize:`xs`,ml:1,children:[`(`,t.length,`)`]})]})}),(0,X.jsx)(A,{width:`200px`,children:(0,X.jsx)(i,{children:e.length===0?(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,children:`No labels available`}):(0,X.jsx)(G,{align:`stretch`,gap:2,children:e.map(e=>(0,X.jsxs)(W,{cursor:`pointer`,onClick:()=>n(e),children:[(0,X.jsx)(N,{checked:t.includes(e)}),(0,X.jsx)(H,{fontSize:`sm`,children:e})]},e))})})})]})}function ge({selectedCount:e,onArchive:t}){return e===0?null:(0,X.jsx)(R,{position:`fixed`,bottom:10,left:`50%`,transform:`translateX(-50%)`,backgroundColor:`#ffffff`,border:`1px solid #ccc`,boxShadow:`0 0 15px rgba(0, 0, 0, 0.2)`,borderRadius:`md`,padding:`8px`,paddingX:`16px`,zIndex:1e3,"data-testid":`batch-action-bar`,children:(0,X.jsxs)(W,{gap:3,children:[(0,X.jsxs)(H,{whiteSpace:`nowrap`,fontSize:`sm`,fontWeight:`medium`,children:[e,` selected`]}),(0,X.jsxs)(I,{size:`sm`,variant:`outline`,colorPalette:`orange`,onClick:t,children:[(0,X.jsx)(v,{size:14}),`Archive`]})]})})}function _e({open:e,onClose:t,onConfirm:n,scenarios:r,isLoading:i=!1}){let a=r.length>1,o=a?`Archive ${r.length} scenarios?`:`Archive scenario?`;return(0,X.jsx)(B.Root,{open:e,onOpenChange:t,placement:`center`,children:(0,X.jsxs)(B.Content,{maxWidth:`500px`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(B.CloseTrigger,{}),(0,X.jsx)(B.Header,{children:(0,X.jsx)(B.Title,{fontSize:`md`,fontWeight:`500`,children:o})}),(0,X.jsx)(B.Body,{children:(0,X.jsxs)(G,{align:`stretch`,gap:4,children:[a?(0,X.jsx)(f,{paddingLeft:4,children:r.map(e=>(0,X.jsx)(d,{fontSize:`sm`,children:e.name},e.id))}):r[0]&&(0,X.jsx)(H,{children:(0,X.jsx)(H,{as:`span`,fontWeight:`semibold`,children:r[0].name})}),(0,X.jsx)(H,{color:`fg.muted`,fontSize:`sm`,children:`Archived scenarios will no longer appear in the library.`})]})}),(0,X.jsxs)(B.Footer,{children:[(0,X.jsx)(I,{variant:`outline`,mr:3,onClick:e=>{e.stopPropagation(),t()},disabled:i,children:`Cancel`}),(0,X.jsx)(I,{colorPalette:`orange`,onClick:e=>{e.stopPropagation(),n()},disabled:i,children:i?(0,X.jsx)(L,{size:`sm`}):`Archive`})]})]})})}var ve=`Describe your scenario. What does your agent do? What situation do you want to test?`,ye=`Generating...`,be=6e4;function xe({open:e,onClose:t,title:n,placeholder:r=ve,exampleTemplates:i,onGenerate:a,onSkip:o,generatingText:s=ye,hasModelProviders:c=!0}){let[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(`idle`),[p,m]=(0,Y.useState)(``),h=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]),(0,Y.useEffect)(()=>{e&&(u(``),f(`idle`),m(``))},[e]);let g=(0,Y.useCallback)(e=>{u(e.target.value)},[]),_=(0,Y.useCallback)(e=>{u(e)},[]),v=(0,Y.useCallback)(async()=>{if(!l.trim())return;let e=a(l);if(!e)return;f(`generating`),m(``);let t=new Promise((e,t)=>{h.current=setTimeout(()=>{t(Error(`Generation timed out. Please try again.`))},be)});try{await Promise.race([e,t])}catch(e){f(`error`),m(e instanceof Error?e.message:`An unexpected error occurred`)}finally{h.current&&=(clearTimeout(h.current),null)}},[l,a]),y=(0,Y.useCallback)(()=>{v()},[v]),b=(0,Y.useCallback)(()=>{o()},[o]),x=(0,Y.useCallback)(e=>{!e.open&&d!==`generating`&&t()},[d,t]),S=d!==`generating`;return(0,X.jsx)(B.Root,{open:e,onOpenChange:x,children:(0,X.jsxs)(B.Content,{children:[S&&(0,X.jsx)(B.CloseTrigger,{}),(0,X.jsx)(B.Header,{children:(0,X.jsx)(B.Title,{children:n})}),(0,X.jsxs)(B.Body,{children:[!c&&(0,X.jsx)(De,{}),c&&d===`idle`&&(0,X.jsx)(Se,{description:l,placeholder:r,exampleTemplates:i,onDescriptionChange:g,onExampleClick:_}),c&&d===`generating`&&(0,X.jsx)(Ce,{text:s}),c&&d===`error`&&(0,X.jsx)(we,{errorMessage:p})]}),(0,X.jsxs)(B.Footer,{children:[!c&&(0,X.jsx)(Oe,{}),c&&d===`idle`&&(0,X.jsx)(Te,{onSkip:b,onGenerate:v,isGenerateDisabled:!l.trim()}),c&&d===`error`&&(0,X.jsx)(Ee,{onSkip:b,onTryAgain:y})]})]})})}function Se({description:e,placeholder:t,exampleTemplates:n,onDescriptionChange:r,onExampleClick:i}){return(0,X.jsxs)(G,{align:`stretch`,gap:4,children:[(0,X.jsx)(R,{children:(0,X.jsx)(x,{placeholder:t,value:e,onChange:r,rows:5,resize:`vertical`})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,mb:2,children:`Try an example:`}),(0,X.jsx)(W,{gap:2,flexWrap:`wrap`,children:n.map(e=>(0,X.jsx)(I,{size:`xs`,variant:`outline`,onClick:()=>i(e.text),children:e.label},e.label))})]})]})}function Ce({text:e}){return(0,X.jsxs)(G,{gap:4,py:8,children:[(0,X.jsx)(L,{size:`lg`,color:`blue.500`}),(0,X.jsx)(H,{color:`fg.muted`,children:e})]})}function we({errorMessage:e}){return(0,X.jsxs)(G,{gap:4,py:4,children:[(0,X.jsx)(R,{p:3,borderRadius:`full`,bg:`red.100`,color:`red.600`,children:(0,X.jsx)(U,{as:D,boxSize:6})}),(0,X.jsxs)(G,{gap:1,children:[(0,X.jsx)(H,{fontWeight:`semibold`,children:`Something went wrong`}),(0,X.jsx)(H,{color:`fg.muted`,fontSize:`sm`,textAlign:`center`,children:e})]})]})}function Te({onSkip:e,onGenerate:t,isGenerateDisabled:n}){return(0,X.jsxs)(W,{gap:2,justify:`flex-end`,children:[(0,X.jsx)(I,{variant:`ghost`,onClick:e,children:`I'll write it myself`}),(0,X.jsxs)(I,{colorPalette:`blue`,onClick:t,disabled:n,children:[(0,X.jsx)(S,{size:14}),`Generate with AI`]})]})}function Ee({onSkip:e,onTryAgain:t}){return(0,X.jsxs)(W,{gap:2,justify:`flex-end`,children:[(0,X.jsx)(I,{variant:`ghost`,onClick:e,children:`I'll write it myself`}),(0,X.jsx)(I,{colorPalette:`blue`,onClick:t,children:`Try again`})]})}function De(){return(0,X.jsxs)(G,{gap:4,py:8,align:`center`,justify:`center`,children:[(0,X.jsx)(R,{p:3,borderRadius:`full`,bg:`orange.100`,color:`orange.600`,children:(0,X.jsx)(U,{as:r,boxSize:6})}),(0,X.jsxs)(G,{gap:1,children:[(0,X.jsx)(H,{fontWeight:`semibold`,children:`No model provider configured`}),(0,X.jsxs)(H,{color:`fg.muted`,fontSize:`sm`,textAlign:`center`,children:[`Scenarios require a model provider to run. Please configure one to get started.`,` `,(0,X.jsx)(ne,{href:`/settings/model-providers`,target:`_blank`,rel:`noopener noreferrer`,color:`blue.500`,fontWeight:`medium`,children:`Configure model provider`})]})]})]})}function Oe(){return(0,X.jsx)(W,{gap:2,justify:`flex-end`,children:(0,X.jsx)(I,{colorPalette:`blue`,asChild:!0,children:(0,X.jsx)(`a`,{"data-testid":`ai-create-modal-configure-model-provider-button`,href:`/settings/model-providers`,target:`_blank`,rel:`noopener noreferrer`,children:`Configure model provider`})})})}var ke=`Create new scenario`,Ae=`Explain your agent, its goals and what behavior you want to test.`,je=`Generating scenario...`,Me=[{label:`Customer Support`,text:`A customer support agent that handles complaints. Test an angry customer who was charged twice and wants a refund.`},{label:`RAG Q&A`,text:`A knowledge bot that answers questions from documentation. Test a question that requires combining info from multiple sources.`},{label:`Tool-calling Agent`,text:`An agent that uses tools to complete tasks. Test a request that requires calling multiple tools in sequence.`}];function Ne({open:e,onClose:t}){let{project:n}=q(),{openDrawer:r}=E(),{checkAndProceed:i}=b(`scenarios`),{hasEnabledProviders:a,providers:o}=j({projectId:n?.id}),s=y({hasEnabledProviders:a,providers:o,defaultModel:n?.defaultModel}),c=(0,Y.useCallback)(e=>{r(`scenarioEditor`,{initialFormData:e},{resetStack:!0}),t()},[r,t]),l=(0,Y.useCallback)(async e=>{if(!n?.id)throw Error(`No project selected`);if(!s.ok){if(s.reason===`no-default`)throw Error(`No default model set. Configure one in Settings → Model Providers.`);if(s.reason===`stale-default`)throw Error(`Your default model's provider is disabled. Configure a new default in Settings → Model Providers.`);s.reason;return}try{c(await O(e,n.id))}catch(e){if(ie(e))return;throw e}},[n?.id,s,c]),u=(0,Y.useCallback)(()=>{c({name:``,situation:``,criteria:[]})},[c]);return(0,X.jsx)(xe,{open:e,onClose:t,title:ke,placeholder:Ae,exampleTemplates:Me,onGenerate:e=>i(()=>l(e)),onSkip:()=>i(u),generatingText:je,hasModelProviders:s.ok||s.reason!==`no-providers`})}function Pe({onCreateClick:e}){return(0,X.jsxs)(G,{gap:4,align:`center`,py:12,children:[(0,X.jsx)(H,{fontSize:`lg`,color:`fg.muted`,children:`No scenarios yet`}),(0,X.jsx)(H,{fontSize:`sm`,color:`fg.subtle`,children:`Create your first scenario to get started`}),(0,X.jsxs)(I,{colorPalette:`blue`,onClick:e,children:[(0,X.jsx)(o,{size:16}),` Create Scenario`]})]})}var Z=pe(),Fe=(e,t,n)=>{let r=e.getValue(t),i=n;return!i||i.length===0?!0:i.some(e=>r.includes(e))};function Ie({scenarios:e,columnFilters:t,onColumnFiltersChange:n,onRowClick:r,rowSelection:i,onRowSelectionChange:a,onArchive:o}){let[s,u]=(0,Y.useState)([]),d=de({data:e,columns:(0,Y.useMemo)(()=>[Z.display({id:`select`,header:({table:e})=>(0,X.jsx)(N,{"aria-label":`Select all`,checked:e.getIsAllPageRowsSelected(),onChange:()=>e.toggleAllPageRowsSelected(),onClick:e=>e.stopPropagation()}),cell:({row:e})=>(0,X.jsx)(N,{"aria-label":`Select ${e.original.name}`,checked:e.getIsSelected(),onChange:()=>e.toggleSelected(),onClick:e=>e.stopPropagation()}),enableSorting:!1}),Z.accessor(`name`,{header:`Name`,cell:e=>(0,X.jsx)(H,{fontWeight:`medium`,children:e.getValue()})}),Z.accessor(`labels`,{header:`Labels`,enableSorting:!1,filterFn:Fe,cell:e=>(0,X.jsx)(w,{labels:e.getValue()})}),Z.accessor(`updatedAt`,{header:`Updated`,cell:e=>(0,X.jsx)(H,{color:`fg.muted`,children:c(e.getValue().getTime())})}),Z.display({id:`actions`,header:``,cell:({row:e})=>(0,X.jsxs)(T.Root,{children:[(0,X.jsx)(T.Trigger,{asChild:!0,children:(0,X.jsx)(te,{"aria-label":`Actions for ${e.original.name}`,variant:`ghost`,size:`sm`,onClick:e=>e.stopPropagation(),children:(0,X.jsx)(p,{size:16})})}),(0,X.jsx)(T.Content,{portalled:!1,children:(0,X.jsxs)(T.Item,{value:`archive`,color:`orange.500`,onClick:t=>{t.stopPropagation(),o(e.original)},children:[(0,X.jsx)(v,{size:14}),`Archive`]})})]}),enableSorting:!1})],[o]),state:{sorting:s,columnFilters:t,rowSelection:i},enableRowSelection:!0,onRowSelectionChange:e=>{a(typeof e==`function`?e(i):e)},onSortingChange:u,onColumnFiltersChange:e=>{n(typeof e==`function`?e(t):e)},getCoreRowModel:ue(),getFilteredRowModel:le(),getSortedRowModel:fe(),getRowId:e=>e.id});return(0,X.jsxs)(M,{variant:`line`,width:`full`,size:`md`,children:[(0,X.jsx)(_,{children:d.getHeaderGroups().map(e=>(0,X.jsx)(l,{children:e.headers.map(e=>(0,X.jsx)(P,{cursor:e.column.getCanSort()?`pointer`:`default`,onClick:e.column.getToggleSortingHandler(),userSelect:`none`,width:e.id===`select`?`40px`:e.id===`actions`?`48px`:void 0,children:(0,X.jsxs)(W,{gap:1,children:[J(e.column.columnDef.header,e.getContext()),e.column.getIsSorted()===`asc`&&(0,X.jsx)(se,{size:14}),e.column.getIsSorted()===`desc`&&(0,X.jsx)(g,{size:14})]})},e.id))},e.id))}),(0,X.jsx)(h,{children:d.getRowModel().rows.map(e=>(0,X.jsx)(l,{cursor:`pointer`,_hover:{bg:`bg.emphasized`},onClick:()=>r(e.original.id),children:e.getVisibleCells().map(e=>(0,X.jsx)(k,{children:J(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})}var Le=[{icon:V,title:`Automated Testing`,description:`Define test scenarios that run automatically against your AI agent to verify it handles real-world situations correctly.`},{icon:s,title:`Regression Detection`,description:`Catch regressions early by re-running scenarios after every change, ensuring your agent never breaks existing behavior.`}];function Q({onProceed:e}){return(0,X.jsxs)(G,{gap:8,align:`center`,children:[(0,X.jsxs)(G,{gap:3,textAlign:`center`,children:[(0,X.jsx)(ee,{as:`h2`,size:`xl`,children:`Welcome to Scenarios`}),(0,X.jsx)(H,{fontSize:`md`,color:`fg.muted`,children:`Scenarios let you test your agent behavior with repeatable, automated checks. Define situations, set expectations, and verify your agent responds correctly every time.`})]}),(0,X.jsx)(G,{gap:4,w:`full`,children:Le.map(({icon:e,title:t,description:n})=>(0,X.jsxs)(W,{gap:4,p:5,w:`full`,borderWidth:`1px`,borderColor:`border`,borderRadius:`lg`,align:`start`,children:[(0,X.jsx)(R,{p:2,borderRadius:`md`,bg:`blue.50`,color:`blue.600`,_dark:{bg:`blue.900`,color:`blue.200`},flexShrink:0,children:(0,X.jsx)(e,{size:20})}),(0,X.jsxs)(G,{gap:1,align:`start`,children:[(0,X.jsx)(H,{fontWeight:`semibold`,children:t}),(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,children:n})]})]},t))}),(0,X.jsxs)(I,{colorPalette:`blue`,size:`lg`,onClick:e,children:[`Create Your First Scenario `,(0,X.jsx)(oe,{size:16})]})]})}function Re({onProceed:e}){return(0,X.jsx)(G,{py:16,px:8,maxW:`640px`,mx:`auto`,children:(0,X.jsx)(Q,{onProceed:e})})}function ze({open:e,onOpenChange:t,onProceed:n}){return(0,X.jsx)(B.Root,{open:e,onOpenChange:e=>t(e.open),placement:`center`,size:`lg`,children:(0,X.jsxs)(B.Content,{maxWidth:`640px`,children:[(0,X.jsx)(B.CloseTrigger,{}),(0,X.jsx)(B.Body,{py:8,px:8,children:(0,X.jsx)(Q,{onProceed:n})})]})})}function Be(e){let[t,n]=(0,Y.useState)([]);return{columnFilters:t,setColumnFilters:n,allLabels:(0,Y.useMemo)(()=>{if(!e)return[];let t=new Set;return e.forEach(e=>e.labels.forEach(e=>t.add(e))),Array.from(t).sort()},[e]),activeLabels:(0,Y.useMemo)(()=>t.find(e=>e.id===`labels`)?.value??[],[t]),handleLabelToggle:(0,Y.useCallback)(e=>{n(t=>{let n=t.find(e=>e.id===`labels`)?.value??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e],i=t.filter(e=>e.id!==`labels`);return r.length===0?i:[...i,{id:`labels`,value:r}]})},[])}}var $=`langwatch:scenarios:welcomeSeen`;function Ve(){try{return localStorage.getItem($)===`true`}catch{return!1}}function He(){try{localStorage.setItem($,`true`)}catch{}}function Ue({scenarioCount:e,isLoading:t}){let[n,r]=(0,Y.useState)(Ve),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),c=!t&&e===0&&!n,l=(0,Y.useCallback)(()=>{He(),r(!0)},[]);return{showInlineWelcome:c,showWelcomeModal:i,showCreateModal:o,handleNewScenario:(0,Y.useCallback)(()=>{!n&&!t&&e===0?a(!0):s(!0)},[n,t,e]),handleWelcomeProceed:(0,Y.useCallback)(()=>{l(),a(!1),s(!0)},[l]),handleWelcomeModalOpenChange:(0,Y.useCallback)(e=>{e||(l(),a(!1))},[l]),handleCloseCreateModal:(0,Y.useCallback)(()=>{s(!1)},[])}}function We(){let[e,t]=(0,Y.useState)({}),n=(0,Y.useCallback)(e=>{t(t=>typeof e==`function`?e(t):e)},[]),r=(0,Y.useCallback)(e=>{t(t=>{let n={...t};return n[e]?delete n[e]:n[e]=!0,n})},[]),i=(0,Y.useCallback)(e=>{t(t=>{let n={...t};for(let t of e)n[t]=!0;return n})},[]),a=(0,Y.useCallback)(()=>{t({})},[]),o=(0,Y.useMemo)(()=>Object.keys(e).filter(t=>e[t]),[e]);return{toggle:r,selectAll:i,deselectAll:a,selectedIds:o,selectionCount:o.length,rowSelection:e,onRowSelectionChange:n}}function Ge(){let{project:e}=q(),{openDrawer:t,drawerOpen:r}=E(),{rowSelection:i,onRowSelectionChange:a,selectedIds:s,selectionCount:c,deselectAll:l}=We(),[u,d]=(0,Y.useState)(null),f=K.useContext(),{data:p,isLoading:h,error:g}=K.scenarios.getAll.useQuery({projectId:e?.id??``},{enabled:!!e}),_=(0,Y.useCallback)(()=>{f.scenarios.getAll.invalidate(),l(),d(null)},[f.scenarios.getAll,l]),v=K.scenarios.archive.useMutation({onSuccess:_,onError:e=>{z.create({title:`Failed to archive scenario`,description:e.message,type:`error`,meta:{closable:!0}})}}),y=K.scenarios.batchArchive.useMutation({onSuccess:e=>{e.failed.length>0&&z.create({title:`Some scenarios couldn't be archived`,description:`${e.failed.length} failed. Please retry.`,type:`error`,meta:{closable:!0}}),f.scenarios.getAll.invalidate(),l(),d(null)},onError:e=>{z.create({title:`Failed to archive scenarios`,description:e.message,type:`error`,meta:{closable:!0}})}}),{columnFilters:b,setColumnFilters:x,allLabels:S,activeLabels:w,handleLabelToggle:T}=Be(p),{showInlineWelcome:D,showWelcomeModal:O,showCreateModal:k,handleNewScenario:A,handleWelcomeProceed:j,handleWelcomeModalOpenChange:M,handleCloseCreateModal:N}=Ue({scenarioCount:p?.length??0,isLoading:h}),P=e=>{t(`scenarioEditor`,{urlParams:{scenarioId:e}})},F=(0,Y.useCallback)(e=>{d({type:`single`,scenario:e})},[]),I=(0,Y.useCallback)(()=>{d({type:`batch`})},[]),R=()=>{e?.id&&(u?.type===`single`?v.mutate({projectId:e.id,id:u.scenario.id}):u?.type===`batch`&&y.mutate({projectId:e.id,ids:s}))},B=()=>{d(null)},V=(0,Y.useMemo)(()=>!u||!p?[]:u.type===`single`?[{id:u.scenario.id,name:u.scenario.name}]:p.filter(e=>s.includes(e.id)).map(e=>({id:e.id,name:e.name})),[u,p,s]);return(0,X.jsxs)(C,{children:[(0,X.jsx)(m.Header,{children:(0,X.jsxs)(W,{justify:`space-between`,align:`center`,w:`full`,children:[(0,X.jsx)(m.Heading,{children:`Scenario Library`}),(0,X.jsx)(re,{}),(0,X.jsx)(he,{allLabels:S,activeLabels:w,onToggle:T}),(0,X.jsxs)(m.HeaderButton,{onClick:A,children:[(0,X.jsx)(o,{size:16}),` New Scenario`]})]})}),(0,X.jsxs)(m.Container,{padding:0,children:[h&&(0,X.jsx)(G,{gap:4,align:`center`,py:8,children:(0,X.jsx)(L,{borderWidth:`3px`,animationDuration:`0.8s`})}),g&&!p?.length&&(0,X.jsxs)(G,{gap:4,align:`center`,py:8,children:[(0,X.jsx)(H,{color:`red.500`,children:`Error loading scenarios`}),(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,children:g.message})]}),!h&&!g&&p?.length===0&&D&&(0,X.jsx)(Re,{onProceed:j}),!h&&!g&&p?.length===0&&!D&&(0,X.jsx)(Pe,{onCreateClick:A}),p&&p.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ge,{selectedCount:c,onArchive:I}),(0,X.jsx)(Ie,{scenarios:p,columnFilters:b,onColumnFiltersChange:x,onRowClick:P,rowSelection:i,onRowSelectionChange:a,onArchive:F})]})]}),(0,X.jsx)(n,{open:r(`scenarioEditor`)}),(0,X.jsx)(ze,{open:O,onOpenChange:M,onProceed:j}),(0,X.jsx)(Ne,{open:k,onClose:N}),(0,X.jsx)(_e,{open:u!==null,onClose:B,onConfirm:R,scenarios:V,isLoading:v.isPending||y.isPending})]})}var Ke=ce(`scenarios:view`,{layoutComponent:C})(Ge);export{Ke as default};
2
+ //# sourceMappingURL=scenarios-BmG_wDkR.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Fa as n,Ha as r,Ss as i,_s as a,bs as o,cc as s,m as c,vs as l,wa 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{n as h}from"./toaster-C_DYALhL.js";import{an as g,f as _}from"./dist-SwV3YZv3.js";import{t as v}from"./heading-D90dlSnH.js";import{t as y}from"./text-CwTrMF8x.js";import{t as b}from"./input-C7emsUCL.js";import{t as x}from"./h-stack-BKLDJ2vg.js";import{r as S,t as C}from"./card-CMtKVPVl.js";import{t as w}from"./spacer-2LJJGbo8.js";import{t as T}from"./v-stack-EOPQ57OZ.js";import{s as E}from"./auth-client-D3UhxhQi.js";import{t as D}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as O}from"./SettingsLayout-CLCGxMAe.js";import{t as k}from"./WithPermissionGuard-DD8uo3UK.js";var A=e(t()),j=p();function M(){let{organization:e}=D();return e?(0,j.jsx)(P,{organizationId:e.id}):(0,j.jsx)(O,{})}var N=k(`organization:manage`,{layoutComponent:O})(M);function P({organizationId:e}){let t=E.scimToken.list.useQuery({organizationId:e}),p=E.scimToken.generate.useMutation(),D=E.scimToken.revoke.useMutation(),k=E.useContext(),{open:M,onOpen:N,onClose:P}=s(),[F,I]=(0,A.useState)(``),[L,R]=(0,A.useState)(null),[z,B]=(0,A.useState)(null),V=()=>{p.mutate({organizationId:e,description:F||void 0},{onSuccess:e=>{R(e.token),I(``),k.scimToken.list.invalidate()},onError:()=>{h.create({title:`Failed to generate token`,type:`error`,duration:5e3,meta:{closable:!0}})}})},H=t=>{D.mutate({organizationId:e,tokenId:t},{onSuccess:()=>{B(null),h.create({title:`Token revoked`,type:`success`,duration:3e3,meta:{closable:!0}}),k.scimToken.list.invalidate()},onError:()=>{h.create({title:`Failed to revoke token`,type:`error`,duration:5e3,meta:{closable:!0}})}})},U=typeof window<`u`?`${window.location.origin}/api/scim/v2`:``;return(0,j.jsxs)(O,{children:[(0,j.jsxs)(T,{gap:6,width:`full`,align:`start`,children:[(0,j.jsxs)(x,{width:`full`,children:[(0,j.jsx)(v,{children:`SCIM Provisioning`}),(0,j.jsx)(w,{})]}),(0,j.jsx)(S,{width:`full`,children:(0,j.jsx)(C,{children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{children:`SCIM (System for Cross-domain Identity Management) allows your identity provider (Okta, Azure AD, etc.) to automatically provision and deprovision users in LangWatch.`}),(0,j.jsxs)(T,{gap:2,align:`start`,width:`full`,children:[(0,j.jsx)(y,{fontWeight:`600`,children:`SCIM Base URL`}),(0,j.jsx)(c,{value:U,label:`SCIM Base URL`})]}),(0,j.jsx)(y,{fontSize:`sm`,color:`gray.500`,children:`Use this URL and a bearer token below to configure SCIM in your identity provider.`})]})})}),(0,j.jsxs)(x,{width:`full`,children:[(0,j.jsx)(v,{size:`md`,children:`Bearer Tokens`}),(0,j.jsx)(w,{}),(0,j.jsxs)(m,{size:`sm`,onClick:N,children:[(0,j.jsx)(n,{size:16}),`Generate Token`]})]}),(0,j.jsx)(S,{width:`full`,overflow:`hidden`,children:(0,j.jsx)(C,{paddingY:0,paddingX:0,children:(0,j.jsxs)(d,{variant:`line`,size:`md`,width:`full`,children:[(0,j.jsx)(o,{children:(0,j.jsxs)(i,{children:[(0,j.jsx)(f,{children:`Description`}),(0,j.jsx)(f,{children:`Created`}),(0,j.jsx)(f,{children:`Last Used`}),(0,j.jsx)(f,{width:`80px`})]})}),(0,j.jsxs)(a,{children:[t.data?.length===0&&(0,j.jsx)(i,{children:(0,j.jsx)(l,{colSpan:4,children:(0,j.jsx)(y,{color:`gray.500`,textAlign:`center`,paddingY:4,children:`No SCIM tokens yet. Generate one to get started.`})})}),t.data?.map(e=>(0,j.jsxs)(i,{children:[(0,j.jsx)(l,{children:(0,j.jsxs)(x,{children:[(0,j.jsx)(r,{size:14}),(0,j.jsx)(y,{children:e.description??`No description`})]})}),(0,j.jsx)(l,{children:new Date(e.createdAt).toLocaleDateString()}),(0,j.jsx)(l,{children:e.lastUsedAt?new Date(e.lastUsedAt).toLocaleDateString():(0,j.jsx)(g,{size:`sm`,colorPalette:`gray`,children:`Never`})}),(0,j.jsx)(l,{children:(0,j.jsx)(m,{size:`xs`,variant:`ghost`,colorPalette:`red`,onClick:()=>B(e.id),children:(0,j.jsx)(u,{size:14})})})]},e.id))]})]})})})]}),(0,j.jsx)(_.Root,{open:M&&!L,onOpenChange:({open:e})=>{e||(P(),I(``))},children:(0,j.jsxs)(_.Content,{children:[(0,j.jsx)(_.Header,{children:(0,j.jsx)(_.Title,{children:(0,j.jsx)(v,{size:`md`,children:`Generate SCIM Token`})})}),(0,j.jsx)(_.CloseTrigger,{}),(0,j.jsx)(_.Body,{paddingBottom:6,children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{children:`This token will be used by your identity provider to authenticate SCIM requests.`}),(0,j.jsxs)(T,{gap:1,align:`start`,width:`full`,children:[(0,j.jsx)(y,{fontWeight:`600`,fontSize:`sm`,children:`Description (optional)`}),(0,j.jsx)(b,{placeholder:`e.g., Okta SCIM integration`,value:F,onChange:e=>I(e.target.value)})]}),(0,j.jsx)(m,{width:`full`,onClick:V,disabled:p.isLoading,children:`Generate Token`})]})})]})}),(0,j.jsx)(_.Root,{open:!!L,onOpenChange:({open:e})=>{e||(R(null),P())},children:(0,j.jsxs)(_.Content,{children:[(0,j.jsx)(_.Header,{children:(0,j.jsx)(_.Title,{children:(0,j.jsx)(v,{size:`md`,children:`Token Generated`})})}),(0,j.jsx)(_.CloseTrigger,{}),(0,j.jsx)(_.Body,{paddingBottom:6,children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{color:`orange.500`,fontWeight:`600`,children:`Copy this token now. You won't be able to see it again.`}),L&&(0,j.jsx)(c,{value:L,label:`SCIM Token`})]})})]})}),(0,j.jsx)(_.Root,{open:!!z,onOpenChange:({open:e})=>{e||B(null)},children:(0,j.jsxs)(_.Content,{children:[(0,j.jsx)(_.Header,{children:(0,j.jsx)(_.Title,{children:(0,j.jsx)(v,{size:`md`,children:`Revoke Token`})})}),(0,j.jsx)(_.CloseTrigger,{}),(0,j.jsx)(_.Body,{paddingBottom:6,children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{children:`Are you sure you want to revoke this token? Any identity provider using it will no longer be able to provision users.`}),(0,j.jsxs)(x,{width:`full`,justify:`end`,gap:2,children:[(0,j.jsx)(m,{variant:`outline`,onClick:()=>B(null),children:`Cancel`}),(0,j.jsx)(m,{colorPalette:`red`,onClick:()=>z&&H(z),disabled:D.isLoading,children:`Revoke`})]})]})})]})})]})}export{N as default};
2
- //# sourceMappingURL=scim-DDsLO39r.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Fa as n,Ha as r,Ss as i,_s as a,bs as o,cc as s,m as c,vs as l,wa 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{n as h}from"./toaster-C_DYALhL.js";import{an as g,f as _}from"./dist-Cds4Mqhj.js";import{t as v}from"./heading-D90dlSnH.js";import{t as y}from"./text-CwTrMF8x.js";import{t as b}from"./input-C7emsUCL.js";import{t as x}from"./h-stack-BKLDJ2vg.js";import{r as S,t as C}from"./card-CMtKVPVl.js";import{t as w}from"./spacer-2LJJGbo8.js";import{t as T}from"./v-stack-EOPQ57OZ.js";import{s as E}from"./auth-client-D3UhxhQi.js";import{t as D}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as O}from"./SettingsLayout--1gdEuhv.js";import{t as k}from"./WithPermissionGuard-B4Jo8E5-.js";var A=e(t()),j=p();function M(){let{organization:e}=D();return e?(0,j.jsx)(P,{organizationId:e.id}):(0,j.jsx)(O,{})}var N=k(`organization:manage`,{layoutComponent:O})(M);function P({organizationId:e}){let t=E.scimToken.list.useQuery({organizationId:e}),p=E.scimToken.generate.useMutation(),D=E.scimToken.revoke.useMutation(),k=E.useContext(),{open:M,onOpen:N,onClose:P}=s(),[F,I]=(0,A.useState)(``),[L,R]=(0,A.useState)(null),[z,B]=(0,A.useState)(null),V=()=>{p.mutate({organizationId:e,description:F||void 0},{onSuccess:e=>{R(e.token),I(``),k.scimToken.list.invalidate()},onError:()=>{h.create({title:`Failed to generate token`,type:`error`,duration:5e3,meta:{closable:!0}})}})},H=t=>{D.mutate({organizationId:e,tokenId:t},{onSuccess:()=>{B(null),h.create({title:`Token revoked`,type:`success`,duration:3e3,meta:{closable:!0}}),k.scimToken.list.invalidate()},onError:()=>{h.create({title:`Failed to revoke token`,type:`error`,duration:5e3,meta:{closable:!0}})}})},U=typeof window<`u`?`${window.location.origin}/api/scim/v2`:``;return(0,j.jsxs)(O,{children:[(0,j.jsxs)(T,{gap:6,width:`full`,align:`start`,children:[(0,j.jsxs)(x,{width:`full`,children:[(0,j.jsx)(v,{children:`SCIM Provisioning`}),(0,j.jsx)(w,{})]}),(0,j.jsx)(S,{width:`full`,children:(0,j.jsx)(C,{children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{children:`SCIM (System for Cross-domain Identity Management) allows your identity provider (Okta, Azure AD, etc.) to automatically provision and deprovision users in LangWatch.`}),(0,j.jsxs)(T,{gap:2,align:`start`,width:`full`,children:[(0,j.jsx)(y,{fontWeight:`600`,children:`SCIM Base URL`}),(0,j.jsx)(c,{value:U,label:`SCIM Base URL`})]}),(0,j.jsx)(y,{fontSize:`sm`,color:`gray.500`,children:`Use this URL and a bearer token below to configure SCIM in your identity provider.`})]})})}),(0,j.jsxs)(x,{width:`full`,children:[(0,j.jsx)(v,{size:`md`,children:`Bearer Tokens`}),(0,j.jsx)(w,{}),(0,j.jsxs)(m,{size:`sm`,onClick:N,children:[(0,j.jsx)(n,{size:16}),`Generate Token`]})]}),(0,j.jsx)(S,{width:`full`,overflow:`hidden`,children:(0,j.jsx)(C,{paddingY:0,paddingX:0,children:(0,j.jsxs)(d,{variant:`line`,size:`md`,width:`full`,children:[(0,j.jsx)(o,{children:(0,j.jsxs)(i,{children:[(0,j.jsx)(f,{children:`Description`}),(0,j.jsx)(f,{children:`Created`}),(0,j.jsx)(f,{children:`Last Used`}),(0,j.jsx)(f,{width:`80px`})]})}),(0,j.jsxs)(a,{children:[t.data?.length===0&&(0,j.jsx)(i,{children:(0,j.jsx)(l,{colSpan:4,children:(0,j.jsx)(y,{color:`gray.500`,textAlign:`center`,paddingY:4,children:`No SCIM tokens yet. Generate one to get started.`})})}),t.data?.map(e=>(0,j.jsxs)(i,{children:[(0,j.jsx)(l,{children:(0,j.jsxs)(x,{children:[(0,j.jsx)(r,{size:14}),(0,j.jsx)(y,{children:e.description??`No description`})]})}),(0,j.jsx)(l,{children:new Date(e.createdAt).toLocaleDateString()}),(0,j.jsx)(l,{children:e.lastUsedAt?new Date(e.lastUsedAt).toLocaleDateString():(0,j.jsx)(g,{size:`sm`,colorPalette:`gray`,children:`Never`})}),(0,j.jsx)(l,{children:(0,j.jsx)(m,{size:`xs`,variant:`ghost`,colorPalette:`red`,onClick:()=>B(e.id),children:(0,j.jsx)(u,{size:14})})})]},e.id))]})]})})})]}),(0,j.jsx)(_.Root,{open:M&&!L,onOpenChange:({open:e})=>{e||(P(),I(``))},children:(0,j.jsxs)(_.Content,{children:[(0,j.jsx)(_.Header,{children:(0,j.jsx)(_.Title,{children:(0,j.jsx)(v,{size:`md`,children:`Generate SCIM Token`})})}),(0,j.jsx)(_.CloseTrigger,{}),(0,j.jsx)(_.Body,{paddingBottom:6,children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{children:`This token will be used by your identity provider to authenticate SCIM requests.`}),(0,j.jsxs)(T,{gap:1,align:`start`,width:`full`,children:[(0,j.jsx)(y,{fontWeight:`600`,fontSize:`sm`,children:`Description (optional)`}),(0,j.jsx)(b,{placeholder:`e.g., Okta SCIM integration`,value:F,onChange:e=>I(e.target.value)})]}),(0,j.jsx)(m,{width:`full`,onClick:V,disabled:p.isLoading,children:`Generate Token`})]})})]})}),(0,j.jsx)(_.Root,{open:!!L,onOpenChange:({open:e})=>{e||(R(null),P())},children:(0,j.jsxs)(_.Content,{children:[(0,j.jsx)(_.Header,{children:(0,j.jsx)(_.Title,{children:(0,j.jsx)(v,{size:`md`,children:`Token Generated`})})}),(0,j.jsx)(_.CloseTrigger,{}),(0,j.jsx)(_.Body,{paddingBottom:6,children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{color:`orange.500`,fontWeight:`600`,children:`Copy this token now. You won't be able to see it again.`}),L&&(0,j.jsx)(c,{value:L,label:`SCIM Token`})]})})]})}),(0,j.jsx)(_.Root,{open:!!z,onOpenChange:({open:e})=>{e||B(null)},children:(0,j.jsxs)(_.Content,{children:[(0,j.jsx)(_.Header,{children:(0,j.jsx)(_.Title,{children:(0,j.jsx)(v,{size:`md`,children:`Revoke Token`})})}),(0,j.jsx)(_.CloseTrigger,{}),(0,j.jsx)(_.Body,{paddingBottom:6,children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{children:`Are you sure you want to revoke this token? Any identity provider using it will no longer be able to provision users.`}),(0,j.jsxs)(x,{width:`full`,justify:`end`,gap:2,children:[(0,j.jsx)(m,{variant:`outline`,onClick:()=>B(null),children:`Cancel`}),(0,j.jsx)(m,{colorPalette:`red`,onClick:()=>z&&H(z),disabled:D.isLoading,children:`Revoke`})]})]})})]})})]})}export{N as default};
2
+ //# sourceMappingURL=scim-BKr1_FHt.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$s as ee,Da as te,Fa as n,Ha as r,Qs as i,Ss as a,Xa as o,Xr as s,Xs as c,Ys as l,Zs as u,_s as d,bs as f,hn as p,qi as m,vs as h,wa as ne,xs as re,ys as g}from"./command-bar-CaJygoez.js";import{j as _,n as v,r as y}from"./stack-oJ9iWdbl.js";import{t as b}from"./box-BsM8YLGl.js";import{t as x}from"./tooltip-AEm0YeiF.js";import{n as S}from"./toaster-C_DYALhL.js";import{f as C}from"./dist-SwV3YZv3.js";import{t as w}from"./heading-D90dlSnH.js";import{t as T}from"./text-CwTrMF8x.js";import{t as E}from"./input-C7emsUCL.js";import{t as D}from"./h-stack-BKLDJ2vg.js";import{t as O}from"./spacer-2LJJGbo8.js";import{t as k}from"./v-stack-EOPQ57OZ.js";import{s as A}from"./auth-client-D3UhxhQi.js";import{t as j}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as M}from"./SettingsLayout-CLCGxMAe.js";var N=e(t()),P=_();function F(){let{project:e,organizations:t,hasPermission:_}=j(),F=_(`secrets:manage`),I=A.secrets.list.useQuery({projectId:e?.id??``},{enabled:!!e?.id}),L=I.data??[],R=A.secrets.create.useMutation(),z=A.secrets.update.useMutation(),B=A.secrets.delete.useMutation(),V=A.useContext(),[H,U]=(0,N.useState)(!1),[W,G]=(0,N.useState)(``),[K,q]=(0,N.useState)(``),[J,Y]=(0,N.useState)(null),[X,Z]=(0,N.useState)(null),[Q,$]=(0,N.useState)(``),ie=async()=>{if(!(!e?.id||!W||!K))try{await R.mutateAsync({projectId:e.id,name:W,value:K}),U(!1),G(``),q(``),await V.secrets.list.invalidate()}catch(e){S.create({title:e instanceof Error?e.message:`Failed to create secret`,type:`error`})}},ae=async()=>{if(!(!e?.id||!J))try{await B.mutateAsync({projectId:e.id,secretId:J.id}),Y(null),await V.secrets.list.invalidate()}catch(e){S.create({title:e instanceof Error?e.message:`Failed to delete secret`,type:`error`})}},oe=async()=>{if(!(!e?.id||!X||!Q))try{await z.mutateAsync({projectId:e.id,secretId:X.id,value:Q}),Z(null),$(``),await V.secrets.list.invalidate()}catch(e){S.create({title:e instanceof Error?e.message:`Failed to update secret`,type:`error`})}};return(0,P.jsx)(M,{children:(0,P.jsxs)(k,{gap:6,width:`full`,align:`start`,children:[(0,P.jsxs)(D,{width:`full`,marginTop:2,children:[(0,P.jsx)(w,{as:`h2`,children:`Secrets`}),(0,P.jsx)(O,{}),t&&e&&(0,P.jsx)(p,{organizations:t,project:e}),F&&(0,P.jsx)(x,{content:`Add a new secret for use in code blocks`,disabled:!1,children:(0,P.jsxs)(s.HeaderButton,{onClick:()=>U(!0),children:[(0,P.jsx)(n,{}),` Add Secret`]})})]}),I.isLoading?(0,P.jsx)(y,{}):L.length===0?(0,P.jsx)(i,{width:`full`,children:(0,P.jsxs)(l,{children:[(0,P.jsx)(u,{children:(0,P.jsx)(r,{size:24})}),(0,P.jsxs)(k,{textAlign:`center`,children:[(0,P.jsx)(ee,{children:`No secrets configured`}),(0,P.jsx)(c,{children:`Add secrets to use in code blocks`})]})]})}):(0,P.jsxs)(re,{width:`full`,children:[(0,P.jsx)(f,{children:(0,P.jsxs)(a,{children:[(0,P.jsx)(g,{children:`Name`}),(0,P.jsx)(g,{children:`Created By`}),(0,P.jsx)(g,{children:`Last Updated`}),(0,P.jsx)(g,{})]})}),(0,P.jsx)(d,{children:L.map(e=>(0,P.jsxs)(a,{children:[(0,P.jsx)(h,{children:(0,P.jsx)(T,{fontFamily:`mono`,children:e.name})}),(0,P.jsx)(h,{children:(0,P.jsx)(T,{children:e.createdBy?.name??`-`})}),(0,P.jsx)(h,{children:(0,P.jsx)(T,{children:new Date(e.updatedAt).toLocaleDateString()})}),(0,P.jsx)(h,{textAlign:`right`,children:F&&(0,P.jsxs)(m.Root,{children:[(0,P.jsx)(m.Trigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`ghost`,size:`sm`,children:(0,P.jsx)(o,{})})}),(0,P.jsxs)(m.Content,{children:[(0,P.jsx)(m.Item,{value:`update`,onClick:()=>{Z({id:e.id,name:e.name}),$(``)},children:(0,P.jsxs)(b,{display:`flex`,alignItems:`center`,gap:2,children:[(0,P.jsx)(te,{size:14}),`Update Value`]})}),(0,P.jsx)(m.Item,{value:`delete`,color:`red`,onClick:()=>{Y({id:e.id,name:e.name})},children:(0,P.jsxs)(b,{display:`flex`,alignItems:`center`,gap:2,children:[(0,P.jsx)(ne,{size:14}),`Delete Secret`]})})]})]})})]},e.id))})]}),(0,P.jsx)(C.Root,{open:H,onOpenChange:e=>{e.open||(U(!1),G(``),q(``))},children:(0,P.jsxs)(C.Content,{children:[(0,P.jsx)(C.Header,{children:(0,P.jsx)(C.Title,{children:`Add Secret`})}),(0,P.jsx)(C.Body,{children:(0,P.jsxs)(k,{gap:4,align:`start`,children:[(0,P.jsxs)(k,{gap:1,align:`start`,width:`full`,children:[(0,P.jsx)(T,{fontWeight:`medium`,children:`Name`}),(0,P.jsx)(E,{placeholder:`e.g., OPENAI_API_KEY`,value:W,onChange:e=>G(e.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,``))})]}),(0,P.jsxs)(k,{gap:1,align:`start`,width:`full`,children:[(0,P.jsx)(T,{fontWeight:`medium`,children:`Value`}),(0,P.jsx)(E,{type:`password`,placeholder:`Enter secret value`,value:K,onChange:e=>q(e.target.value)})]})]})}),(0,P.jsxs)(C.Footer,{children:[(0,P.jsx)(C.ActionTrigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`outline`,children:`Cancel`})}),(0,P.jsx)(v,{colorPalette:`blue`,loading:R.isPending,disabled:!W||!K,onClick:()=>void ie(),children:`Save`})]}),(0,P.jsx)(C.CloseTrigger,{})]})}),(0,P.jsx)(C.Root,{open:!!J,onOpenChange:e=>{e.open||Y(null)},children:(0,P.jsxs)(C.Content,{children:[(0,P.jsx)(C.Header,{children:(0,P.jsxs)(C.Title,{children:[`Delete `,J?.name??``,`?`]})}),(0,P.jsx)(C.Body,{children:(0,P.jsx)(T,{children:`Code blocks referencing this secret will no longer have access.`})}),(0,P.jsxs)(C.Footer,{children:[(0,P.jsx)(C.ActionTrigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`outline`,children:`Cancel`})}),(0,P.jsx)(v,{colorPalette:`red`,loading:B.isPending,onClick:()=>void ae(),children:`Delete`})]}),(0,P.jsx)(C.CloseTrigger,{})]})}),(0,P.jsx)(C.Root,{open:!!X,onOpenChange:e=>{e.open||(Z(null),$(``))},children:(0,P.jsxs)(C.Content,{children:[(0,P.jsx)(C.Header,{children:(0,P.jsxs)(C.Title,{children:[`Update Value for `,X?.name??``]})}),(0,P.jsx)(C.Body,{children:(0,P.jsxs)(k,{gap:1,align:`start`,width:`full`,children:[(0,P.jsx)(T,{fontWeight:`medium`,children:`New Value`}),(0,P.jsx)(E,{type:`password`,placeholder:`Enter new secret value`,value:Q,onChange:e=>$(e.target.value)})]})}),(0,P.jsxs)(C.Footer,{children:[(0,P.jsx)(C.ActionTrigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`outline`,children:`Cancel`})}),(0,P.jsx)(v,{colorPalette:`blue`,loading:z.isPending,disabled:!Q,onClick:()=>void oe(),children:`Save`})]}),(0,P.jsx)(C.CloseTrigger,{})]})})]})})}export{F as default};
2
- //# sourceMappingURL=secrets-BvEGwDCy.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$s as ee,Da as te,Fa as n,Ha as r,Qs as i,Ss as a,Xa as o,Xr as s,Xs as c,Ys as l,Zs as u,_s as d,bs as f,hn as p,qi as m,vs as h,wa as ne,xs as re,ys as g}from"./command-bar-DUK45yin.js";import{j as _,n as v,r as y}from"./stack-oJ9iWdbl.js";import{t as b}from"./box-BsM8YLGl.js";import{t as x}from"./tooltip-AEm0YeiF.js";import{n as S}from"./toaster-C_DYALhL.js";import{f as C}from"./dist-Cds4Mqhj.js";import{t as w}from"./heading-D90dlSnH.js";import{t as T}from"./text-CwTrMF8x.js";import{t as E}from"./input-C7emsUCL.js";import{t as D}from"./h-stack-BKLDJ2vg.js";import{t as O}from"./spacer-2LJJGbo8.js";import{t as k}from"./v-stack-EOPQ57OZ.js";import{s as A}from"./auth-client-D3UhxhQi.js";import{t as j}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as M}from"./SettingsLayout--1gdEuhv.js";var N=e(t()),P=_();function F(){let{project:e,organizations:t,hasPermission:_}=j(),F=_(`secrets:manage`),I=A.secrets.list.useQuery({projectId:e?.id??``},{enabled:!!e?.id}),L=I.data??[],R=A.secrets.create.useMutation(),z=A.secrets.update.useMutation(),B=A.secrets.delete.useMutation(),V=A.useContext(),[H,U]=(0,N.useState)(!1),[W,G]=(0,N.useState)(``),[K,q]=(0,N.useState)(``),[J,Y]=(0,N.useState)(null),[X,Z]=(0,N.useState)(null),[Q,$]=(0,N.useState)(``),ie=async()=>{if(!(!e?.id||!W||!K))try{await R.mutateAsync({projectId:e.id,name:W,value:K}),U(!1),G(``),q(``),await V.secrets.list.invalidate()}catch(e){S.create({title:e instanceof Error?e.message:`Failed to create secret`,type:`error`})}},ae=async()=>{if(!(!e?.id||!J))try{await B.mutateAsync({projectId:e.id,secretId:J.id}),Y(null),await V.secrets.list.invalidate()}catch(e){S.create({title:e instanceof Error?e.message:`Failed to delete secret`,type:`error`})}},oe=async()=>{if(!(!e?.id||!X||!Q))try{await z.mutateAsync({projectId:e.id,secretId:X.id,value:Q}),Z(null),$(``),await V.secrets.list.invalidate()}catch(e){S.create({title:e instanceof Error?e.message:`Failed to update secret`,type:`error`})}};return(0,P.jsx)(M,{children:(0,P.jsxs)(k,{gap:6,width:`full`,align:`start`,children:[(0,P.jsxs)(D,{width:`full`,marginTop:2,children:[(0,P.jsx)(w,{as:`h2`,children:`Secrets`}),(0,P.jsx)(O,{}),t&&e&&(0,P.jsx)(p,{organizations:t,project:e}),F&&(0,P.jsx)(x,{content:`Add a new secret for use in code blocks`,disabled:!1,children:(0,P.jsxs)(s.HeaderButton,{onClick:()=>U(!0),children:[(0,P.jsx)(n,{}),` Add Secret`]})})]}),I.isLoading?(0,P.jsx)(y,{}):L.length===0?(0,P.jsx)(i,{width:`full`,children:(0,P.jsxs)(l,{children:[(0,P.jsx)(u,{children:(0,P.jsx)(r,{size:24})}),(0,P.jsxs)(k,{textAlign:`center`,children:[(0,P.jsx)(ee,{children:`No secrets configured`}),(0,P.jsx)(c,{children:`Add secrets to use in code blocks`})]})]})}):(0,P.jsxs)(re,{width:`full`,children:[(0,P.jsx)(f,{children:(0,P.jsxs)(a,{children:[(0,P.jsx)(g,{children:`Name`}),(0,P.jsx)(g,{children:`Created By`}),(0,P.jsx)(g,{children:`Last Updated`}),(0,P.jsx)(g,{})]})}),(0,P.jsx)(d,{children:L.map(e=>(0,P.jsxs)(a,{children:[(0,P.jsx)(h,{children:(0,P.jsx)(T,{fontFamily:`mono`,children:e.name})}),(0,P.jsx)(h,{children:(0,P.jsx)(T,{children:e.createdBy?.name??`-`})}),(0,P.jsx)(h,{children:(0,P.jsx)(T,{children:new Date(e.updatedAt).toLocaleDateString()})}),(0,P.jsx)(h,{textAlign:`right`,children:F&&(0,P.jsxs)(m.Root,{children:[(0,P.jsx)(m.Trigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`ghost`,size:`sm`,children:(0,P.jsx)(o,{})})}),(0,P.jsxs)(m.Content,{children:[(0,P.jsx)(m.Item,{value:`update`,onClick:()=>{Z({id:e.id,name:e.name}),$(``)},children:(0,P.jsxs)(b,{display:`flex`,alignItems:`center`,gap:2,children:[(0,P.jsx)(te,{size:14}),`Update Value`]})}),(0,P.jsx)(m.Item,{value:`delete`,color:`red`,onClick:()=>{Y({id:e.id,name:e.name})},children:(0,P.jsxs)(b,{display:`flex`,alignItems:`center`,gap:2,children:[(0,P.jsx)(ne,{size:14}),`Delete Secret`]})})]})]})})]},e.id))})]}),(0,P.jsx)(C.Root,{open:H,onOpenChange:e=>{e.open||(U(!1),G(``),q(``))},children:(0,P.jsxs)(C.Content,{children:[(0,P.jsx)(C.Header,{children:(0,P.jsx)(C.Title,{children:`Add Secret`})}),(0,P.jsx)(C.Body,{children:(0,P.jsxs)(k,{gap:4,align:`start`,children:[(0,P.jsxs)(k,{gap:1,align:`start`,width:`full`,children:[(0,P.jsx)(T,{fontWeight:`medium`,children:`Name`}),(0,P.jsx)(E,{placeholder:`e.g., OPENAI_API_KEY`,value:W,onChange:e=>G(e.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,``))})]}),(0,P.jsxs)(k,{gap:1,align:`start`,width:`full`,children:[(0,P.jsx)(T,{fontWeight:`medium`,children:`Value`}),(0,P.jsx)(E,{type:`password`,placeholder:`Enter secret value`,value:K,onChange:e=>q(e.target.value)})]})]})}),(0,P.jsxs)(C.Footer,{children:[(0,P.jsx)(C.ActionTrigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`outline`,children:`Cancel`})}),(0,P.jsx)(v,{colorPalette:`blue`,loading:R.isPending,disabled:!W||!K,onClick:()=>void ie(),children:`Save`})]}),(0,P.jsx)(C.CloseTrigger,{})]})}),(0,P.jsx)(C.Root,{open:!!J,onOpenChange:e=>{e.open||Y(null)},children:(0,P.jsxs)(C.Content,{children:[(0,P.jsx)(C.Header,{children:(0,P.jsxs)(C.Title,{children:[`Delete `,J?.name??``,`?`]})}),(0,P.jsx)(C.Body,{children:(0,P.jsx)(T,{children:`Code blocks referencing this secret will no longer have access.`})}),(0,P.jsxs)(C.Footer,{children:[(0,P.jsx)(C.ActionTrigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`outline`,children:`Cancel`})}),(0,P.jsx)(v,{colorPalette:`red`,loading:B.isPending,onClick:()=>void ae(),children:`Delete`})]}),(0,P.jsx)(C.CloseTrigger,{})]})}),(0,P.jsx)(C.Root,{open:!!X,onOpenChange:e=>{e.open||(Z(null),$(``))},children:(0,P.jsxs)(C.Content,{children:[(0,P.jsx)(C.Header,{children:(0,P.jsxs)(C.Title,{children:[`Update Value for `,X?.name??``]})}),(0,P.jsx)(C.Body,{children:(0,P.jsxs)(k,{gap:1,align:`start`,width:`full`,children:[(0,P.jsx)(T,{fontWeight:`medium`,children:`New Value`}),(0,P.jsx)(E,{type:`password`,placeholder:`Enter new secret value`,value:Q,onChange:e=>$(e.target.value)})]})}),(0,P.jsxs)(C.Footer,{children:[(0,P.jsx)(C.ActionTrigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`outline`,children:`Cancel`})}),(0,P.jsx)(v,{colorPalette:`blue`,loading:z.isPending,disabled:!Q,onClick:()=>void oe(),children:`Save`})]}),(0,P.jsx)(C.CloseTrigger,{})]})})]})})}export{F as default};
2
+ //# sourceMappingURL=secrets-CU8ocTGv.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$o as n,Hi as r,Un as i,fa as a,hn as o,na as s,sc as c}from"./command-bar-CaJygoez.js";import{j as l,n as u,r as d}from"./stack-oJ9iWdbl.js";import{t as f}from"./tooltip-AEm0YeiF.js";import{n as p}from"./toaster-C_DYALhL.js";import{an as m,f as h}from"./dist-SwV3YZv3.js";import{t as g}from"./heading-D90dlSnH.js";import{t as _}from"./text-CwTrMF8x.js";import{t as v}from"./field-CnUiixMS.js";import{t as y}from"./input-C7emsUCL.js";import{t as b}from"./h-stack-BKLDJ2vg.js";import{t as x}from"./spacer-2LJJGbo8.js";import{t as S}from"./v-stack-EOPQ57OZ.js";import{s as C}from"./auth-client-D3UhxhQi.js";import{t as ee}from"./usePublicEnv-1QvVAhAk.js";import{c as w,t as T}from"./useOrganizationTeamProject-DC0iozx2.js";import{s as E,t as D}from"./index.esm-X7lxUoP1.js";import{t as O}from"./HorizontalFormControl-BCD7-fcT.js";import{n as k,t as A}from"./SettingsLayout-CLCGxMAe.js";import{t as j}from"./WithPermissionGuard-DD8uo3UK.js";import{i as M,r as N}from"./project-zSxGdatx.js";var P=w(),F=e(t()),I=l();function L(){let{organization:e,project:t}=T();return!e||!t?null:(0,I.jsx)(z,{organization:e,project:t})}var R=j(`organization:view`,{layoutComponent:A})(L);function z({organization:e,project:t}){let{hasPermission:n}=T(),{isLiteMember:a}=i(),[o,s]=(0,F.useState)({name:e.name,s3Endpoint:e.s3Endpoint??``,s3AccessKeyId:e.s3AccessKeyId??``,s3SecretAccessKey:e.s3SecretAccessKey??``,elasticsearchNodeUrl:e.elasticsearchNodeUrl??``,elasticsearchApiKey:e.elasticsearchApiKey??``,s3Bucket:e.s3Bucket??``}),{register:c,handleSubmit:l,getFieldState:f}=E({defaultValues:o}),m=C.organization.update.useMutation(),h=C.useContext();return(0,I.jsx)(A,{children:(0,I.jsxs)(S,{gap:6,width:`full`,align:`start`,children:[(0,I.jsxs)(b,{width:`full`,children:[(0,I.jsx)(g,{as:`h2`,children:`Organization Settings`}),(0,I.jsx)(x,{}),m.isLoading&&(0,I.jsx)(d,{})]}),(0,I.jsx)(`form`,{onSubmit:l(t=>{r(t,o)||(s(t),m.mutate({organizationId:e.id,name:t.name,s3Endpoint:t.s3Endpoint,s3AccessKeyId:t.s3AccessKeyId,s3SecretAccessKey:t.s3SecretAccessKey,elasticsearchNodeUrl:t.elasticsearchNodeUrl,elasticsearchApiKey:t.elasticsearchApiKey,s3Bucket:t.s3Bucket},{onSuccess:()=>{h.organization.getAll.refetch(),p.create({title:`Organization updated`,description:`Your organization settings have been saved`,type:`success`,meta:{closable:!0}})},onError:()=>{p.create({title:`Failed to update organization`,description:`Please make sure you have filled out all fields related to either S3 or Elasticsearch`,type:`error`,meta:{closable:!0}})}}))}),style:{width:`100%`},children:(0,I.jsxs)(S,{gap:0,children:[(0,I.jsxs)(S,{gap:0,width:`full`,children:[(0,I.jsx)(O,{label:`Name`,helper:`The name of your organization`,invalid:!!f(`name`).error,children:n(`organization:manage`)?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(y,{width:`full`,type:`text`,...c(`name`,{required:!0,validate:e=>{if(!e.trim())return!1}})}),(0,I.jsx)(v,{children:`Name is required`})]}):(0,I.jsx)(_,{children:e.name})}),(0,I.jsx)(O,{label:`Slug`,helper:`The unique ID of your organization`,children:n(`organization:manage`)?(0,I.jsx)(y,{width:`full`,disabled:!0,type:`text`,value:e.slug}):(0,I.jsx)(_,{children:e.slug})}),(0,I.jsx)(O,{label:`Project ID`,helper:`Use this ID when authenticating with Personal Access Tokens`,children:(0,I.jsx)(y,{width:`full`,disabled:!0,type:`text`,value:t.id})}),e.useCustomS3&&(0,I.jsx)(O,{label:`S3 Storage`,helper:`Configure S3 storage to host data on your own infrastructure. Leave empty to use LangWatch's managed storage.`,children:n(`organization:manage`)?(0,I.jsxs)(S,{width:`full`,align:`start`,gap:3,children:[(0,I.jsx)(y,{width:`full`,type:`text`,placeholder:`S3 Endpoint`,...c(`s3Endpoint`)}),(0,I.jsx)(y,{width:`full`,type:`text`,placeholder:`Access Key ID`,...c(`s3AccessKeyId`)}),(0,I.jsx)(y,{width:`full`,type:`password`,placeholder:`Secret Access Key`,...c(`s3SecretAccessKey`)}),(0,I.jsx)(y,{width:`full`,type:`text`,placeholder:`S3 Bucket Name`,...c(`s3Bucket`)})]}):(0,I.jsx)(_,{children:`S3 storage configuration is only visible to organization managers`})}),e.useCustomElasticsearch&&(0,I.jsx)(O,{label:`Elasticsearch`,helper:`Configure your Elasticsearch instance for advanced search capabilities`,children:n(`organization:manage`)?(0,I.jsxs)(S,{width:`full`,align:`start`,gap:3,children:[(0,I.jsx)(y,{width:`full`,type:`text`,placeholder:`Elasticsearch Node URL`,...c(`elasticsearchNodeUrl`)}),(0,I.jsx)(y,{width:`full`,type:`password`,placeholder:`Elasticsearch API Key`,...c(`elasticsearchApiKey`)})]}):(0,I.jsx)(_,{children:`Elasticsearch configuration is only visible to organization managers`})})]}),!a&&(0,I.jsx)(b,{width:`full`,justify:`flex-end`,paddingTop:4,children:(0,I.jsx)(u,{type:`submit`,colorPalette:`blue`,loading:m.isLoading,children:`Save Changes`})})]})}),n(`project:update`)&&(0,I.jsx)(B,{project:t})]})})}function B({project:e}){let{organization:t,organizations:i}=T(),l=ee(),{isFree:w}=k(),A=c({items:[{label:`Strict`,value:P.PIIRedactionLevel.STRICT,description:`Redacts all PII data including names and addresses`},{label:`Essential`,value:P.PIIRedactionLevel.ESSENTIAL,description:`Redacts only essential PII data like email addresses, phone numbers, credit card numbers and IP addresses`},...t?.signedDPA||!l.data?.IS_SAAS||l.data?.NODE_ENV===`development`?[{label:`Disabled`,value:P.PIIRedactionLevel.DISABLED,description:`PII data will not be redacted`}]:[]]}),j=c({items:[{label:`Redacted to All`,value:P.ProjectSensitiveDataVisibilityLevel.REDACTED_TO_ALL,description:`Redacts captured input for all users`,isPaidOnly:!0},{label:`Visible to Admin`,value:P.ProjectSensitiveDataVisibilityLevel.VISIBLE_TO_ADMIN,description:`Redacts captured input for all users except admins`,isPaidOnly:!0},{label:`Visible to All`,value:P.ProjectSensitiveDataVisibilityLevel.VISIBLE_TO_ALL,description:`Does not redact any captured input`,isPaidOnly:!1}]}),L=c({items:[{label:`Redacted to All`,value:P.ProjectSensitiveDataVisibilityLevel.REDACTED_TO_ALL,description:`Redacts captured output for all users`,isPaidOnly:!0},{label:`Visible to Admin`,value:P.ProjectSensitiveDataVisibilityLevel.VISIBLE_TO_ADMIN,description:`Redacts captured output for all users except admins`,isPaidOnly:!0},{label:`Visible to All`,value:P.ProjectSensitiveDataVisibilityLevel.VISIBLE_TO_ALL,description:`Does not redact any captured output`,isPaidOnly:!1}]}),{hasPermission:R}=T({redirectToOnboarding:!1}),z=R(`project:manage`),B={name:e.name,language:e.language,framework:e.framework,userLinkTemplate:e.userLinkTemplate??``,s3Endpoint:e.s3Endpoint??``,s3AccessKeyId:e.s3AccessKeyId??``,s3SecretAccessKey:e.s3SecretAccessKey??``,s3Bucket:e.s3Bucket??``,piiRedactionLevel:e.piiRedactionLevel,capturedInputVisibility:e.capturedInputVisibility,capturedOutputVisibility:e.capturedOutputVisibility,traceSharingEnabled:e.traceSharingEnabled},[V,H]=(0,F.useState)(B),U=E({defaultValues:B}),{register:W,handleSubmit:G,control:K,formState:q}=U,J=C.project.update.useMutation(),Y=C.useContext(),[X,Z]=(0,F.useState)(!1),[te,Q]=(0,F.useState)(!1),ne=e=>{U.setValue(`traceSharingEnabled`,e)},re=()=>{Q(!1),G($)()},ie=()=>{Q(!1)},$=t=>{if(!r(t,V)){if(t.traceSharingEnabled===!1&&e.traceSharingEnabled===!0){Q(!0);return}H(t),J.mutate({projectId:e.id,...t,userLinkTemplate:t.userLinkTemplate??``,s3Endpoint:t.s3Endpoint??``,s3AccessKeyId:t.s3AccessKeyId??``,s3SecretAccessKey:t.s3SecretAccessKey??``,s3Bucket:t.s3Bucket??``,capturedInputVisibility:z?t.capturedInputVisibility:void 0,capturedOutputVisibility:z?t.capturedOutputVisibility:void 0,traceSharingEnabled:z?t.traceSharingEnabled:void 0},{onSuccess:()=>{Y.organization.getAll.refetch(),p.create({title:`Project updated`,description:`Your project settings have been saved`,type:`success`,meta:{closable:!0}})},onError:()=>{p.create({title:`Failed to update project`,description:`Please make sure you have filled out all fields related to S3`,type:`error`,meta:{closable:!0}})}})}};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(b,{width:`full`,marginTop:6,children:[(0,I.jsx)(g,{as:`h2`,children:`Project-level Settings`}),(0,I.jsx)(x,{}),J.isLoading&&(0,I.jsx)(d,{}),i&&(0,I.jsx)(o,{organizations:i,project:e})]}),(0,I.jsxs)(`form`,{onSubmit:G($),style:{width:`100%`},children:[(0,I.jsxs)(S,{gap:0,width:`full`,children:[(0,I.jsxs)(O,{label:`Name`,helper:`The name of the project`,invalid:!!q.errors.name,children:[(0,I.jsx)(y,{width:`full`,type:`text`,...W(`name`,{required:!0,validate:e=>{if(!e.trim())return!1}})}),(0,I.jsx)(v,{children:`Name is required`})]}),(0,I.jsx)(O,{label:`Tech Stack`,helper:`The project language and framework`,invalid:!!q.errors.language||!!q.errors.framework,children:X?(0,I.jsx)(M,{form:U}):(0,I.jsxs)(b,{children:[(0,I.jsx)(N,{project:e}),(0,I.jsxs)(_,{children:[e.language,` / `,e.framework]}),(0,I.jsx)(u,{variant:`ghost`,textDecoration:`underline`,onClick:()=>Z(!0),children:`(change)`})]})}),(0,I.jsx)(O,{label:`PII Redaction Level`,helper:`The level of redaction for PII`,invalid:!!q.errors.piiRedactionLevel,children:(0,I.jsx)(D,{control:K,name:`piiRedactionLevel`,rules:{required:`PII Redaction Level is required`},render:({field:e})=>(0,I.jsxs)(s.Root,{collection:A,...e,onChange:void 0,value:[e.value],onValueChange:t=>{e.onChange(t.value[0])},children:[(0,I.jsx)(s.Trigger,{width:`full`,children:(0,I.jsx)(s.ValueText,{placeholder:`Select PII redaction level`})}),(0,I.jsx)(s.Content,{width:`300px`,paddingY:2,children:A.items.map(e=>(0,I.jsx)(s.Item,{item:e,children:(0,I.jsxs)(S,{align:`start`,gap:0,children:[(0,I.jsx)(_,{children:e.label}),(0,I.jsx)(_,{fontSize:`13px`,color:`fg.muted`,children:e.description})]})},e.value))})]})})}),(0,I.jsx)(O,{label:`Show Captured Input Data`,helper:(0,I.jsxs)(S,{align:`start`,gap:1,children:[(0,I.jsx)(_,{children:`Manage who can see input data on traces and spans`}),!z&&(0,I.jsx)(m,{colorPalette:`blue`,variant:`surface`,size:`xs`,children:(0,I.jsx)(f,{content:`Contact your admin to change this setting`,children:(0,I.jsxs)(b,{children:[(0,I.jsx)(n,{size:10}),(0,I.jsx)(_,{children:`Admin only`})]})})})]}),invalid:!!q.errors.capturedInputVisibility,children:(0,I.jsx)(D,{control:K,name:`capturedInputVisibility`,rules:{required:z?`Captured input visibility is required`:void 0},render:({field:e})=>(0,I.jsxs)(s.Root,{collection:j,...e,onChange:void 0,value:[e.value],onValueChange:t=>{j.items.find(e=>e.value===t.value[0])?.isPaidOnly&&w||e.onChange(t.value[0])},disabled:!z,children:[(0,I.jsx)(s.Trigger,{width:`full`,children:(0,I.jsx)(s.ValueText,{placeholder:`Select captured input visibility`})}),(0,I.jsx)(s.Content,{width:`300px`,paddingY:2,children:j.items.map(e=>{let t=e.isPaidOnly&&w;return(0,I.jsx)(s.Item,{item:e,opacity:t?.5:1,cursor:t?`not-allowed`:`pointer`,children:(0,I.jsxs)(S,{align:`start`,gap:0,children:[(0,I.jsxs)(b,{children:[(0,I.jsx)(_,{children:e.label}),e.isPaidOnly&&w&&(0,I.jsx)(m,{colorPalette:`orange`,size:`xs`,children:`Paid`})]}),(0,I.jsx)(_,{fontSize:`13px`,color:`fg.muted`,children:e.description})]})},e.value)})})]})})}),(0,I.jsx)(O,{label:`Show Captured Output Data`,helper:(0,I.jsxs)(S,{align:`start`,gap:1,children:[(0,I.jsx)(_,{children:`Manage who can see output data on traces and spans`}),!z&&(0,I.jsx)(m,{colorPalette:`blue`,variant:`surface`,size:`xs`,children:(0,I.jsx)(f,{content:`Contact your admin to change this setting`,children:(0,I.jsxs)(b,{children:[(0,I.jsx)(n,{size:10}),(0,I.jsx)(_,{children:`Admin only`})]})})})]}),invalid:!!q.errors.capturedOutputVisibility,children:(0,I.jsx)(D,{control:K,name:`capturedOutputVisibility`,rules:{required:z?`Captured output visibility is required`:void 0},render:({field:e})=>(0,I.jsxs)(s.Root,{collection:L,...e,onChange:void 0,value:[e.value],onValueChange:t=>{L.items.find(e=>e.value===t.value[0])?.isPaidOnly&&w||e.onChange(t.value[0])},disabled:!z,children:[(0,I.jsx)(s.Trigger,{width:`full`,children:(0,I.jsx)(s.ValueText,{placeholder:`Select captured output visibility`})}),(0,I.jsx)(s.Content,{width:`300px`,paddingY:2,children:L.items.map(e=>{let t=e.isPaidOnly&&w;return(0,I.jsx)(s.Item,{item:e,opacity:t?.5:1,cursor:t?`not-allowed`:`pointer`,children:(0,I.jsxs)(S,{align:`start`,gap:0,children:[(0,I.jsxs)(b,{children:[(0,I.jsx)(_,{children:e.label}),e.isPaidOnly&&w&&(0,I.jsx)(m,{colorPalette:`orange`,size:`xs`,children:`Paid`})]}),(0,I.jsx)(_,{fontSize:`13px`,color:`fg.muted`,children:e.description})]})},e.value)})})]})})}),(0,I.jsx)(O,{label:`Trace Sharing`,helper:(0,I.jsxs)(S,{align:`start`,gap:1,children:[(0,I.jsx)(_,{children:`Allow users to share traces with public links`}),!z&&(0,I.jsx)(m,{colorPalette:`blue`,variant:`surface`,size:`xs`,children:(0,I.jsx)(f,{content:`Contact your admin to change this setting`,children:(0,I.jsxs)(b,{children:[(0,I.jsx)(n,{size:10}),(0,I.jsx)(_,{children:`Admin only`})]})})})]}),invalid:!!q.errors.traceSharingEnabled,children:(0,I.jsx)(D,{control:K,name:`traceSharingEnabled`,render:({field:e})=>(0,I.jsx)(a,{checked:e.value,onChange:e=>ne(e.target.checked),disabled:!z})})}),t?.useCustomS3&&(0,I.jsx)(O,{label:`S3 Storage`,helper:`Configure project-specific S3 storage settings for datasets. If left empty, organization-level settings will be used.`,children:(0,I.jsxs)(S,{width:`full`,align:`start`,gap:3,children:[(0,I.jsx)(y,{width:`full`,type:`text`,placeholder:`S3 Endpoint`,...W(`s3Endpoint`)}),(0,I.jsx)(y,{width:`full`,type:`text`,placeholder:`Access Key ID`,...W(`s3AccessKeyId`)}),(0,I.jsx)(y,{width:`full`,type:`password`,placeholder:`Secret Access Key`,...W(`s3SecretAccessKey`)}),(0,I.jsx)(y,{width:`full`,type:`text`,placeholder:`S3 Bucket Name`,...W(`s3Bucket`)})]})})]}),(0,I.jsx)(b,{width:`full`,justify:`flex-end`,paddingTop:4,children:(0,I.jsx)(u,{type:`submit`,colorPalette:`blue`,loading:J.isLoading,children:`Save Changes`})})]}),(0,I.jsx)(h.Root,{open:te,onOpenChange:({open:e})=>Q(e),children:(0,I.jsxs)(h.Content,{children:[(0,I.jsx)(h.Header,{children:(0,I.jsx)(h.Title,{children:`Disable Trace Sharing?`})}),(0,I.jsx)(h.Body,{children:(0,I.jsxs)(S,{align:`start`,gap:4,children:[(0,I.jsx)(_,{children:`Are you sure you want to save these changes and disable trace sharing for this project?`}),(0,I.jsxs)(S,{align:`start`,gap:2,padding:4,backgroundColor:`orange.subtle`,borderWidth:`1px`,borderColor:`orange.muted`,borderRadius:`md`,children:[(0,I.jsx)(b,{gap:2,children:(0,I.jsx)(_,{fontWeight:`semibold`,color:`orange.fg`,children:`⚠️ Warning`})}),(0,I.jsxs)(_,{fontSize:`sm`,color:`orange.fg`,children:[`This action will `,(0,I.jsx)(`b`,{children:`immediately revoke`}),` all existing shared trace links. Anyone with previously shared trace URLs will`,` `,(0,I.jsx)(`b`,{children:`no longer be able to access them`}),`.`]})]})]})}),(0,I.jsx)(h.Footer,{children:(0,I.jsxs)(b,{gap:2,children:[(0,I.jsx)(u,{variant:`outline`,onClick:ie,children:`Cancel`}),(0,I.jsx)(u,{colorPalette:`red`,onClick:re,children:`Save & Disable Trace Sharing`})]})})]})})]})}export{R as default};
2
- //# sourceMappingURL=settings-9giNiAQQ.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$o as n,Hi as r,Un as i,fa as a,hn as o,na as s,sc as c}from"./command-bar-DUK45yin.js";import{j as l,n as u,r as d}from"./stack-oJ9iWdbl.js";import{t as f}from"./tooltip-AEm0YeiF.js";import{n as p}from"./toaster-C_DYALhL.js";import{an as m,f as h}from"./dist-Cds4Mqhj.js";import{t as g}from"./heading-D90dlSnH.js";import{t as _}from"./text-CwTrMF8x.js";import{t as v}from"./field-CnUiixMS.js";import{t as y}from"./input-C7emsUCL.js";import{t as b}from"./h-stack-BKLDJ2vg.js";import{t as x}from"./spacer-2LJJGbo8.js";import{t as S}from"./v-stack-EOPQ57OZ.js";import{s as C}from"./auth-client-D3UhxhQi.js";import{t as ee}from"./usePublicEnv-1QvVAhAk.js";import{c as w,t as T}from"./useOrganizationTeamProject-DC0iozx2.js";import{s as E,t as D}from"./index.esm-X7lxUoP1.js";import{t as O}from"./HorizontalFormControl-BCD7-fcT.js";import{n as k,t as A}from"./SettingsLayout--1gdEuhv.js";import{t as j}from"./WithPermissionGuard-B4Jo8E5-.js";import{i as M,r as N}from"./project-zSxGdatx.js";var P=w(),F=e(t()),I=l();function L(){let{organization:e,project:t}=T();return!e||!t?null:(0,I.jsx)(z,{organization:e,project:t})}var R=j(`organization:view`,{layoutComponent:A})(L);function z({organization:e,project:t}){let{hasPermission:n}=T(),{isLiteMember:a}=i(),[o,s]=(0,F.useState)({name:e.name,s3Endpoint:e.s3Endpoint??``,s3AccessKeyId:e.s3AccessKeyId??``,s3SecretAccessKey:e.s3SecretAccessKey??``,elasticsearchNodeUrl:e.elasticsearchNodeUrl??``,elasticsearchApiKey:e.elasticsearchApiKey??``,s3Bucket:e.s3Bucket??``}),{register:c,handleSubmit:l,getFieldState:f}=E({defaultValues:o}),m=C.organization.update.useMutation(),h=C.useContext();return(0,I.jsx)(A,{children:(0,I.jsxs)(S,{gap:6,width:`full`,align:`start`,children:[(0,I.jsxs)(b,{width:`full`,children:[(0,I.jsx)(g,{as:`h2`,children:`Organization Settings`}),(0,I.jsx)(x,{}),m.isLoading&&(0,I.jsx)(d,{})]}),(0,I.jsx)(`form`,{onSubmit:l(t=>{r(t,o)||(s(t),m.mutate({organizationId:e.id,name:t.name,s3Endpoint:t.s3Endpoint,s3AccessKeyId:t.s3AccessKeyId,s3SecretAccessKey:t.s3SecretAccessKey,elasticsearchNodeUrl:t.elasticsearchNodeUrl,elasticsearchApiKey:t.elasticsearchApiKey,s3Bucket:t.s3Bucket},{onSuccess:()=>{h.organization.getAll.refetch(),p.create({title:`Organization updated`,description:`Your organization settings have been saved`,type:`success`,meta:{closable:!0}})},onError:()=>{p.create({title:`Failed to update organization`,description:`Please make sure you have filled out all fields related to either S3 or Elasticsearch`,type:`error`,meta:{closable:!0}})}}))}),style:{width:`100%`},children:(0,I.jsxs)(S,{gap:0,children:[(0,I.jsxs)(S,{gap:0,width:`full`,children:[(0,I.jsx)(O,{label:`Name`,helper:`The name of your organization`,invalid:!!f(`name`).error,children:n(`organization:manage`)?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(y,{width:`full`,type:`text`,...c(`name`,{required:!0,validate:e=>{if(!e.trim())return!1}})}),(0,I.jsx)(v,{children:`Name is required`})]}):(0,I.jsx)(_,{children:e.name})}),(0,I.jsx)(O,{label:`Slug`,helper:`The unique ID of your organization`,children:n(`organization:manage`)?(0,I.jsx)(y,{width:`full`,disabled:!0,type:`text`,value:e.slug}):(0,I.jsx)(_,{children:e.slug})}),(0,I.jsx)(O,{label:`Project ID`,helper:`Use this ID when authenticating with Personal Access Tokens`,children:(0,I.jsx)(y,{width:`full`,disabled:!0,type:`text`,value:t.id})}),e.useCustomS3&&(0,I.jsx)(O,{label:`S3 Storage`,helper:`Configure S3 storage to host data on your own infrastructure. Leave empty to use LangWatch's managed storage.`,children:n(`organization:manage`)?(0,I.jsxs)(S,{width:`full`,align:`start`,gap:3,children:[(0,I.jsx)(y,{width:`full`,type:`text`,placeholder:`S3 Endpoint`,...c(`s3Endpoint`)}),(0,I.jsx)(y,{width:`full`,type:`text`,placeholder:`Access Key ID`,...c(`s3AccessKeyId`)}),(0,I.jsx)(y,{width:`full`,type:`password`,placeholder:`Secret Access Key`,...c(`s3SecretAccessKey`)}),(0,I.jsx)(y,{width:`full`,type:`text`,placeholder:`S3 Bucket Name`,...c(`s3Bucket`)})]}):(0,I.jsx)(_,{children:`S3 storage configuration is only visible to organization managers`})}),e.useCustomElasticsearch&&(0,I.jsx)(O,{label:`Elasticsearch`,helper:`Configure your Elasticsearch instance for advanced search capabilities`,children:n(`organization:manage`)?(0,I.jsxs)(S,{width:`full`,align:`start`,gap:3,children:[(0,I.jsx)(y,{width:`full`,type:`text`,placeholder:`Elasticsearch Node URL`,...c(`elasticsearchNodeUrl`)}),(0,I.jsx)(y,{width:`full`,type:`password`,placeholder:`Elasticsearch API Key`,...c(`elasticsearchApiKey`)})]}):(0,I.jsx)(_,{children:`Elasticsearch configuration is only visible to organization managers`})})]}),!a&&(0,I.jsx)(b,{width:`full`,justify:`flex-end`,paddingTop:4,children:(0,I.jsx)(u,{type:`submit`,colorPalette:`blue`,loading:m.isLoading,children:`Save Changes`})})]})}),n(`project:update`)&&(0,I.jsx)(B,{project:t})]})})}function B({project:e}){let{organization:t,organizations:i}=T(),l=ee(),{isFree:w}=k(),A=c({items:[{label:`Strict`,value:P.PIIRedactionLevel.STRICT,description:`Redacts all PII data including names and addresses`},{label:`Essential`,value:P.PIIRedactionLevel.ESSENTIAL,description:`Redacts only essential PII data like email addresses, phone numbers, credit card numbers and IP addresses`},...t?.signedDPA||!l.data?.IS_SAAS||l.data?.NODE_ENV===`development`?[{label:`Disabled`,value:P.PIIRedactionLevel.DISABLED,description:`PII data will not be redacted`}]:[]]}),j=c({items:[{label:`Redacted to All`,value:P.ProjectSensitiveDataVisibilityLevel.REDACTED_TO_ALL,description:`Redacts captured input for all users`,isPaidOnly:!0},{label:`Visible to Admin`,value:P.ProjectSensitiveDataVisibilityLevel.VISIBLE_TO_ADMIN,description:`Redacts captured input for all users except admins`,isPaidOnly:!0},{label:`Visible to All`,value:P.ProjectSensitiveDataVisibilityLevel.VISIBLE_TO_ALL,description:`Does not redact any captured input`,isPaidOnly:!1}]}),L=c({items:[{label:`Redacted to All`,value:P.ProjectSensitiveDataVisibilityLevel.REDACTED_TO_ALL,description:`Redacts captured output for all users`,isPaidOnly:!0},{label:`Visible to Admin`,value:P.ProjectSensitiveDataVisibilityLevel.VISIBLE_TO_ADMIN,description:`Redacts captured output for all users except admins`,isPaidOnly:!0},{label:`Visible to All`,value:P.ProjectSensitiveDataVisibilityLevel.VISIBLE_TO_ALL,description:`Does not redact any captured output`,isPaidOnly:!1}]}),{hasPermission:R}=T({redirectToOnboarding:!1}),z=R(`project:manage`),B={name:e.name,language:e.language,framework:e.framework,userLinkTemplate:e.userLinkTemplate??``,s3Endpoint:e.s3Endpoint??``,s3AccessKeyId:e.s3AccessKeyId??``,s3SecretAccessKey:e.s3SecretAccessKey??``,s3Bucket:e.s3Bucket??``,piiRedactionLevel:e.piiRedactionLevel,capturedInputVisibility:e.capturedInputVisibility,capturedOutputVisibility:e.capturedOutputVisibility,traceSharingEnabled:e.traceSharingEnabled},[V,H]=(0,F.useState)(B),U=E({defaultValues:B}),{register:W,handleSubmit:G,control:K,formState:q}=U,J=C.project.update.useMutation(),Y=C.useContext(),[X,Z]=(0,F.useState)(!1),[te,Q]=(0,F.useState)(!1),ne=e=>{U.setValue(`traceSharingEnabled`,e)},re=()=>{Q(!1),G($)()},ie=()=>{Q(!1)},$=t=>{if(!r(t,V)){if(t.traceSharingEnabled===!1&&e.traceSharingEnabled===!0){Q(!0);return}H(t),J.mutate({projectId:e.id,...t,userLinkTemplate:t.userLinkTemplate??``,s3Endpoint:t.s3Endpoint??``,s3AccessKeyId:t.s3AccessKeyId??``,s3SecretAccessKey:t.s3SecretAccessKey??``,s3Bucket:t.s3Bucket??``,capturedInputVisibility:z?t.capturedInputVisibility:void 0,capturedOutputVisibility:z?t.capturedOutputVisibility:void 0,traceSharingEnabled:z?t.traceSharingEnabled:void 0},{onSuccess:()=>{Y.organization.getAll.refetch(),p.create({title:`Project updated`,description:`Your project settings have been saved`,type:`success`,meta:{closable:!0}})},onError:()=>{p.create({title:`Failed to update project`,description:`Please make sure you have filled out all fields related to S3`,type:`error`,meta:{closable:!0}})}})}};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(b,{width:`full`,marginTop:6,children:[(0,I.jsx)(g,{as:`h2`,children:`Project-level Settings`}),(0,I.jsx)(x,{}),J.isLoading&&(0,I.jsx)(d,{}),i&&(0,I.jsx)(o,{organizations:i,project:e})]}),(0,I.jsxs)(`form`,{onSubmit:G($),style:{width:`100%`},children:[(0,I.jsxs)(S,{gap:0,width:`full`,children:[(0,I.jsxs)(O,{label:`Name`,helper:`The name of the project`,invalid:!!q.errors.name,children:[(0,I.jsx)(y,{width:`full`,type:`text`,...W(`name`,{required:!0,validate:e=>{if(!e.trim())return!1}})}),(0,I.jsx)(v,{children:`Name is required`})]}),(0,I.jsx)(O,{label:`Tech Stack`,helper:`The project language and framework`,invalid:!!q.errors.language||!!q.errors.framework,children:X?(0,I.jsx)(M,{form:U}):(0,I.jsxs)(b,{children:[(0,I.jsx)(N,{project:e}),(0,I.jsxs)(_,{children:[e.language,` / `,e.framework]}),(0,I.jsx)(u,{variant:`ghost`,textDecoration:`underline`,onClick:()=>Z(!0),children:`(change)`})]})}),(0,I.jsx)(O,{label:`PII Redaction Level`,helper:`The level of redaction for PII`,invalid:!!q.errors.piiRedactionLevel,children:(0,I.jsx)(D,{control:K,name:`piiRedactionLevel`,rules:{required:`PII Redaction Level is required`},render:({field:e})=>(0,I.jsxs)(s.Root,{collection:A,...e,onChange:void 0,value:[e.value],onValueChange:t=>{e.onChange(t.value[0])},children:[(0,I.jsx)(s.Trigger,{width:`full`,children:(0,I.jsx)(s.ValueText,{placeholder:`Select PII redaction level`})}),(0,I.jsx)(s.Content,{width:`300px`,paddingY:2,children:A.items.map(e=>(0,I.jsx)(s.Item,{item:e,children:(0,I.jsxs)(S,{align:`start`,gap:0,children:[(0,I.jsx)(_,{children:e.label}),(0,I.jsx)(_,{fontSize:`13px`,color:`fg.muted`,children:e.description})]})},e.value))})]})})}),(0,I.jsx)(O,{label:`Show Captured Input Data`,helper:(0,I.jsxs)(S,{align:`start`,gap:1,children:[(0,I.jsx)(_,{children:`Manage who can see input data on traces and spans`}),!z&&(0,I.jsx)(m,{colorPalette:`blue`,variant:`surface`,size:`xs`,children:(0,I.jsx)(f,{content:`Contact your admin to change this setting`,children:(0,I.jsxs)(b,{children:[(0,I.jsx)(n,{size:10}),(0,I.jsx)(_,{children:`Admin only`})]})})})]}),invalid:!!q.errors.capturedInputVisibility,children:(0,I.jsx)(D,{control:K,name:`capturedInputVisibility`,rules:{required:z?`Captured input visibility is required`:void 0},render:({field:e})=>(0,I.jsxs)(s.Root,{collection:j,...e,onChange:void 0,value:[e.value],onValueChange:t=>{j.items.find(e=>e.value===t.value[0])?.isPaidOnly&&w||e.onChange(t.value[0])},disabled:!z,children:[(0,I.jsx)(s.Trigger,{width:`full`,children:(0,I.jsx)(s.ValueText,{placeholder:`Select captured input visibility`})}),(0,I.jsx)(s.Content,{width:`300px`,paddingY:2,children:j.items.map(e=>{let t=e.isPaidOnly&&w;return(0,I.jsx)(s.Item,{item:e,opacity:t?.5:1,cursor:t?`not-allowed`:`pointer`,children:(0,I.jsxs)(S,{align:`start`,gap:0,children:[(0,I.jsxs)(b,{children:[(0,I.jsx)(_,{children:e.label}),e.isPaidOnly&&w&&(0,I.jsx)(m,{colorPalette:`orange`,size:`xs`,children:`Paid`})]}),(0,I.jsx)(_,{fontSize:`13px`,color:`fg.muted`,children:e.description})]})},e.value)})})]})})}),(0,I.jsx)(O,{label:`Show Captured Output Data`,helper:(0,I.jsxs)(S,{align:`start`,gap:1,children:[(0,I.jsx)(_,{children:`Manage who can see output data on traces and spans`}),!z&&(0,I.jsx)(m,{colorPalette:`blue`,variant:`surface`,size:`xs`,children:(0,I.jsx)(f,{content:`Contact your admin to change this setting`,children:(0,I.jsxs)(b,{children:[(0,I.jsx)(n,{size:10}),(0,I.jsx)(_,{children:`Admin only`})]})})})]}),invalid:!!q.errors.capturedOutputVisibility,children:(0,I.jsx)(D,{control:K,name:`capturedOutputVisibility`,rules:{required:z?`Captured output visibility is required`:void 0},render:({field:e})=>(0,I.jsxs)(s.Root,{collection:L,...e,onChange:void 0,value:[e.value],onValueChange:t=>{L.items.find(e=>e.value===t.value[0])?.isPaidOnly&&w||e.onChange(t.value[0])},disabled:!z,children:[(0,I.jsx)(s.Trigger,{width:`full`,children:(0,I.jsx)(s.ValueText,{placeholder:`Select captured output visibility`})}),(0,I.jsx)(s.Content,{width:`300px`,paddingY:2,children:L.items.map(e=>{let t=e.isPaidOnly&&w;return(0,I.jsx)(s.Item,{item:e,opacity:t?.5:1,cursor:t?`not-allowed`:`pointer`,children:(0,I.jsxs)(S,{align:`start`,gap:0,children:[(0,I.jsxs)(b,{children:[(0,I.jsx)(_,{children:e.label}),e.isPaidOnly&&w&&(0,I.jsx)(m,{colorPalette:`orange`,size:`xs`,children:`Paid`})]}),(0,I.jsx)(_,{fontSize:`13px`,color:`fg.muted`,children:e.description})]})},e.value)})})]})})}),(0,I.jsx)(O,{label:`Trace Sharing`,helper:(0,I.jsxs)(S,{align:`start`,gap:1,children:[(0,I.jsx)(_,{children:`Allow users to share traces with public links`}),!z&&(0,I.jsx)(m,{colorPalette:`blue`,variant:`surface`,size:`xs`,children:(0,I.jsx)(f,{content:`Contact your admin to change this setting`,children:(0,I.jsxs)(b,{children:[(0,I.jsx)(n,{size:10}),(0,I.jsx)(_,{children:`Admin only`})]})})})]}),invalid:!!q.errors.traceSharingEnabled,children:(0,I.jsx)(D,{control:K,name:`traceSharingEnabled`,render:({field:e})=>(0,I.jsx)(a,{checked:e.value,onChange:e=>ne(e.target.checked),disabled:!z})})}),t?.useCustomS3&&(0,I.jsx)(O,{label:`S3 Storage`,helper:`Configure project-specific S3 storage settings for datasets. If left empty, organization-level settings will be used.`,children:(0,I.jsxs)(S,{width:`full`,align:`start`,gap:3,children:[(0,I.jsx)(y,{width:`full`,type:`text`,placeholder:`S3 Endpoint`,...W(`s3Endpoint`)}),(0,I.jsx)(y,{width:`full`,type:`text`,placeholder:`Access Key ID`,...W(`s3AccessKeyId`)}),(0,I.jsx)(y,{width:`full`,type:`password`,placeholder:`Secret Access Key`,...W(`s3SecretAccessKey`)}),(0,I.jsx)(y,{width:`full`,type:`text`,placeholder:`S3 Bucket Name`,...W(`s3Bucket`)})]})})]}),(0,I.jsx)(b,{width:`full`,justify:`flex-end`,paddingTop:4,children:(0,I.jsx)(u,{type:`submit`,colorPalette:`blue`,loading:J.isLoading,children:`Save Changes`})})]}),(0,I.jsx)(h.Root,{open:te,onOpenChange:({open:e})=>Q(e),children:(0,I.jsxs)(h.Content,{children:[(0,I.jsx)(h.Header,{children:(0,I.jsx)(h.Title,{children:`Disable Trace Sharing?`})}),(0,I.jsx)(h.Body,{children:(0,I.jsxs)(S,{align:`start`,gap:4,children:[(0,I.jsx)(_,{children:`Are you sure you want to save these changes and disable trace sharing for this project?`}),(0,I.jsxs)(S,{align:`start`,gap:2,padding:4,backgroundColor:`orange.subtle`,borderWidth:`1px`,borderColor:`orange.muted`,borderRadius:`md`,children:[(0,I.jsx)(b,{gap:2,children:(0,I.jsx)(_,{fontWeight:`semibold`,color:`orange.fg`,children:`⚠️ Warning`})}),(0,I.jsxs)(_,{fontSize:`sm`,color:`orange.fg`,children:[`This action will `,(0,I.jsx)(`b`,{children:`immediately revoke`}),` all existing shared trace links. Anyone with previously shared trace URLs will`,` `,(0,I.jsx)(`b`,{children:`no longer be able to access them`}),`.`]})]})]})}),(0,I.jsx)(h.Footer,{children:(0,I.jsxs)(b,{gap:2,children:[(0,I.jsx)(u,{variant:`outline`,onClick:ie,children:`Cancel`}),(0,I.jsx)(u,{colorPalette:`red`,onClick:re,children:`Save & Disable Trace Sharing`})]})})]})})]})}export{R as default};
2
+ //# sourceMappingURL=settings-CDzdoYVK.js.map
@@ -1,2 +1,2 @@
1
- import{mn as e}from"./command-bar-CaJygoez.js";import{j as t}from"./stack-oJ9iWdbl.js";import{t as n}from"./WithPermissionGuard-DD8uo3UK.js";import{t as r}from"./WelcomeLayout-C-NpTCD2.js";var i=t();function a(){return(0,i.jsx)(e,{children:(0,i.jsx)(r,{})})}var o=n(`project:view`,{layoutComponent:e})(a);export{o as default};
2
- //# sourceMappingURL=setup-HxXKoVKG.js.map
1
+ import{mn as e}from"./command-bar-DUK45yin.js";import{j as t}from"./stack-oJ9iWdbl.js";import{t as n}from"./WithPermissionGuard-B4Jo8E5-.js";import{t as r}from"./WelcomeLayout-C-NpTCD2.js";var i=t();function a(){return(0,i.jsx)(e,{children:(0,i.jsx)(r,{})})}var o=n(`project:view`,{layoutComponent:e})(a);export{o as default};
2
+ //# sourceMappingURL=setup-nEvn2rjN.js.map
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SubscriptionPage-J8b2Zaj6.js","assets/chunk-Bj-mKKzh.js","assets/command-bar-CaJygoez.js","assets/preload-helper-rov5CBGT.js","assets/terminal-CfM0q99k.js","assets/code-FF_ibTVI.js","assets/prop-types-DifpXm68.js","assets/react-C7JcuhbW.js","assets/stack-oJ9iWdbl.js","assets/createLucideIcon-BJKFyRLS.js","assets/toaster-C_DYALhL.js","assets/h-stack-BKLDJ2vg.js","assets/create-slot-recipe-context-B6DU0msX.js","assets/tooltip-AEm0YeiF.js","assets/dist-frWhjLir.js","assets/text-CwTrMF8x.js","assets/tabs-DwV1cIZB.js","assets/resize-observer-DYemxxJj.js","assets/radio-group.anatomy-1s_fCJ3y.js","assets/tracking-DbhAKeey.js","assets/field-CnUiixMS.js","assets/input-C7emsUCL.js","assets/icon-BwEPrfAc.js","assets/native-select-B51i56CE.js","assets/dist-SwV3YZv3.js","assets/auth-client-D3UhxhQi.js","assets/box-BsM8YLGl.js","assets/lu-Bf6j_N19.js","assets/dialog.anatomy-hrluUh9u.js","assets/group-Bwj__Orb.js","assets/heading-D90dlSnH.js","assets/link-CwZhwOLq.js","assets/next-link-DuYeiiEe.js","assets/chunk-OE4NN4TA-VhKiHPk0.js","assets/v-stack-EOPQ57OZ.js","assets/useOrganizationTeamProject-DC0iozx2.js","assets/types-B5pOLKPA.js","assets/usePublicEnv-1QvVAhAk.js","assets/useRequiredSession-DE4JSglk.js","assets/next-router-C6sliiV7.js","assets/src-COIGcvxD.js","assets/value-BjB45jgo.js","assets/isObjectLike-Bu248tFs.js","assets/now-DJRfNbvM.js","assets/isSymbol-j0dCIlP_.js","assets/__vite-browser-external-BYi-AMuK.js","assets/OpenAI-D5IXT9Yw.js","assets/alert-SnQmACl1.js","assets/card-CMtKVPVl.js","assets/LoadingScreen--vgXk5-2.js","assets/container-Ccm3vB5X.js","assets/spacer-2LJJGbo8.js","assets/HorizontalFormControl-BCD7-fcT.js","assets/index.esm-X7lxUoP1.js","assets/html-void-elements-BETCRsX6.js","assets/linear-C6bd9xc7.js","assets/defaultLocale-W5QLRj7w.js","assets/init-DZrHjWil.js","assets/time-D9KKpbLy.js","assets/band-CYOoy1UR.js","assets/ordinal-CVb2xJha.js","assets/path-D1IpFPna.js","assets/array-D0DyKZdT.js","assets/step-e0O7qByF.js","assets/memoize-jcS02u9d.js","assets/line-CNmjiw8d.js","assets/math-BkUaofPe.js","assets/emoji-picker-react.esm-Bobloulg.js","assets/_baseEach-DkU-DtFA.js","assets/_getTag-CZgI7cQJ.js","assets/cloneDeep-BExNqdAC.js","assets/_baseClone-Bo1ONtKZ.js","assets/posthogErrorCapture-50j08Hs1.js","assets/next-navigation-CufL4Tjj.js","assets/next-dynamic-CldmZdeI.js","assets/next-head-CO-qV_vi.js","assets/command-bar-D2UBHeGQ.css","assets/billing-plans-FUqEPN62.js","assets/planTypes-Cig7WlCp.js","assets/constants-BT2q4NNM.js","assets/simple-grid-C3IW90zo.js","assets/arrow-right-B3ZN8yal.js","assets/download-X34ozaiD.js","assets/SettingsLayout-CLCGxMAe.js","assets/MenuLink-b_JZtGfc.js","assets/ContactSalesBlock-CijLBwRC.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-rov5CBGT.js";import{j as t}from"./stack-oJ9iWdbl.js";import{t as n}from"./heading-D90dlSnH.js";import{t as r}from"./text-CwTrMF8x.js";import{t as i}from"./h-stack-BKLDJ2vg.js";import{t as a}from"./link-CwZhwOLq.js";import{t as o}from"./v-stack-EOPQ57OZ.js";import{t as s}from"./usePublicEnv-1QvVAhAk.js";import{t as c}from"./next-dynamic-CldmZdeI.js";import{t as l}from"./SettingsLayout-CLCGxMAe.js";var u=t(),d=c(()=>e(()=>import(`./SubscriptionPage-J8b2Zaj6.js`).then(e=>e.SubscriptionPage),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85])),{ssr:!1});function f(){return s().data?.IS_SAAS?(0,u.jsx)(d,{}):(0,u.jsx)(l,{children:(0,u.jsxs)(o,{gap:6,width:`full`,align:`start`,children:[(0,u.jsx)(i,{width:`full`,marginTop:2,children:(0,u.jsx)(n,{as:`h2`,children:`Change Subscription`})}),(0,u.jsx)(o,{width:`full`,gap:4,align:`start`,children:(0,u.jsxs)(r,{children:[`This is the self-hosted version of LangWatch and all the costs and maintenance are managed by yourself. If you want to use the cloud version, please visit`,` `,(0,u.jsx)(a,{href:`https://langwatch.ai`,isExternal:!0,children:`langwatch.ai`})]})})]})})}export{f as default};
3
- //# sourceMappingURL=subscription-DhyswDze.js.map
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SubscriptionPage-B0ox_4kM.js","assets/chunk-Bj-mKKzh.js","assets/command-bar-DUK45yin.js","assets/preload-helper-rov5CBGT.js","assets/terminal-CfM0q99k.js","assets/code-FF_ibTVI.js","assets/prop-types-DifpXm68.js","assets/react-C7JcuhbW.js","assets/stack-oJ9iWdbl.js","assets/createLucideIcon-BJKFyRLS.js","assets/toaster-C_DYALhL.js","assets/h-stack-BKLDJ2vg.js","assets/create-slot-recipe-context-B6DU0msX.js","assets/tooltip-AEm0YeiF.js","assets/dist-frWhjLir.js","assets/text-CwTrMF8x.js","assets/tabs-DwV1cIZB.js","assets/resize-observer-DYemxxJj.js","assets/radio-group.anatomy-1s_fCJ3y.js","assets/tracking-DbhAKeey.js","assets/field-CnUiixMS.js","assets/input-C7emsUCL.js","assets/icon-BwEPrfAc.js","assets/native-select-B51i56CE.js","assets/dist-Cds4Mqhj.js","assets/auth-client-D3UhxhQi.js","assets/box-BsM8YLGl.js","assets/lu-Bf6j_N19.js","assets/dialog.anatomy-hrluUh9u.js","assets/group-Bwj__Orb.js","assets/heading-D90dlSnH.js","assets/link-CwZhwOLq.js","assets/next-link-DuYeiiEe.js","assets/chunk-OE4NN4TA-VhKiHPk0.js","assets/v-stack-EOPQ57OZ.js","assets/useOrganizationTeamProject-DC0iozx2.js","assets/types-B5pOLKPA.js","assets/usePublicEnv-1QvVAhAk.js","assets/useRequiredSession-DE4JSglk.js","assets/next-router-C6sliiV7.js","assets/src-COIGcvxD.js","assets/value-BjB45jgo.js","assets/isObjectLike-Bu248tFs.js","assets/now-DJRfNbvM.js","assets/isSymbol-j0dCIlP_.js","assets/__vite-browser-external-BYi-AMuK.js","assets/OpenAI-D5IXT9Yw.js","assets/alert-SnQmACl1.js","assets/card-CMtKVPVl.js","assets/LoadingScreen--vgXk5-2.js","assets/container-Ccm3vB5X.js","assets/spacer-2LJJGbo8.js","assets/HorizontalFormControl-BCD7-fcT.js","assets/index.esm-X7lxUoP1.js","assets/html-void-elements-BETCRsX6.js","assets/linear-C6bd9xc7.js","assets/defaultLocale-W5QLRj7w.js","assets/init-DZrHjWil.js","assets/time-D9KKpbLy.js","assets/band-CYOoy1UR.js","assets/ordinal-CVb2xJha.js","assets/path-D1IpFPna.js","assets/array-D0DyKZdT.js","assets/step-e0O7qByF.js","assets/memoize-jcS02u9d.js","assets/line-CNmjiw8d.js","assets/math-BkUaofPe.js","assets/emoji-picker-react.esm-Bobloulg.js","assets/_baseEach-DkU-DtFA.js","assets/_getTag-CZgI7cQJ.js","assets/cloneDeep-BExNqdAC.js","assets/_baseClone-Bo1ONtKZ.js","assets/posthogErrorCapture-50j08Hs1.js","assets/next-navigation-CufL4Tjj.js","assets/next-dynamic-CldmZdeI.js","assets/next-head-CO-qV_vi.js","assets/command-bar-D2UBHeGQ.css","assets/billing-plans-BUQp08MI.js","assets/planTypes-Cig7WlCp.js","assets/constants-BT2q4NNM.js","assets/simple-grid-C3IW90zo.js","assets/arrow-right-B3ZN8yal.js","assets/download-X34ozaiD.js","assets/SettingsLayout--1gdEuhv.js","assets/MenuLink-b_JZtGfc.js","assets/ContactSalesBlock-CnnuZ8iI.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-rov5CBGT.js";import{j as t}from"./stack-oJ9iWdbl.js";import{t as n}from"./heading-D90dlSnH.js";import{t as r}from"./text-CwTrMF8x.js";import{t as i}from"./h-stack-BKLDJ2vg.js";import{t as a}from"./link-CwZhwOLq.js";import{t as o}from"./v-stack-EOPQ57OZ.js";import{t as s}from"./usePublicEnv-1QvVAhAk.js";import{t as c}from"./next-dynamic-CldmZdeI.js";import{t as l}from"./SettingsLayout--1gdEuhv.js";var u=t(),d=c(()=>e(()=>import(`./SubscriptionPage-B0ox_4kM.js`).then(e=>e.SubscriptionPage),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85])),{ssr:!1});function f(){return s().data?.IS_SAAS?(0,u.jsx)(d,{}):(0,u.jsx)(l,{children:(0,u.jsxs)(o,{gap:6,width:`full`,align:`start`,children:[(0,u.jsx)(i,{width:`full`,marginTop:2,children:(0,u.jsx)(n,{as:`h2`,children:`Change Subscription`})}),(0,u.jsx)(o,{width:`full`,gap:4,align:`start`,children:(0,u.jsxs)(r,{children:[`This is the self-hosted version of LangWatch and all the costs and maintenance are managed by yourself. If you want to use the cloud version, please visit`,` `,(0,u.jsx)(a,{href:`https://langwatch.ai`,isExternal:!0,children:`langwatch.ai`})]})})]})})}export{f as default};
3
+ //# sourceMappingURL=subscription-BPNl_6jF.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{an as _}from"./dist-SwV3YZv3.js";import{n as v,r as y,t as b}from"./native-select-B51i56CE.js";import{t as x}from"./heading-D90dlSnH.js";import{t as S}from"./text-CwTrMF8x.js";import{a as C,r as w}from"./field-CnUiixMS.js";import{t as T}from"./input-C7emsUCL.js";import{t as E}from"./h-stack-BKLDJ2vg.js";import{t as D}from"./simple-grid-C3IW90zo.js";import{t as O}from"./spacer-2LJJGbo8.js";import{t as k}from"./v-stack-EOPQ57OZ.js";import{c as A}from"./useOrganizationTeamProject-DC0iozx2.js";import{a as j,c as M,n as N,o as P,r as F,s as I,t as L,u as R}from"./useAdminResource-SPC5iBHM.js";var z=A(),B=e(t()),V=p(),H=25,U={ACTIVE:`green`,PENDING:`yellow`,FAILED:`red`,CANCELLED:`gray`},W=[{key:`maxMembers`,label:`Max members`,group:`Members`},{key:`maxMembersLite`,label:`Max lite members`,group:`Members`},{key:`maxTeams`,label:`Max teams`,group:`Members`},{key:`maxProjects`,label:`Max projects`,group:`Resources`},{key:`maxWorkflows`,label:`Max workflows`,group:`Resources`},{key:`maxPrompts`,label:`Max prompts`,group:`Resources`},{key:`maxAgents`,label:`Max agents`,group:`Resources`},{key:`maxScenarios`,label:`Max scenarios`,group:`Resources`},{key:`maxEvaluators`,label:`Max evaluators`,group:`Evaluation`},{key:`maxExperiments`,label:`Max experiments`,group:`Evaluation`},{key:`maxOnlineEvaluations`,label:`Max online evaluations`,group:`Evaluation`},{key:`maxMessagesPerMonth`,label:`Max traces per month`,group:`Observability`},{key:`maxRetentionDays`,label:`Max retention days`,group:`Observability`},{key:`maxDatasets`,label:`Max datasets`,group:`Observability`},{key:`maxDashboards`,label:`Max dashboards`,group:`Analytics`},{key:`maxCustomGraphs`,label:`Max custom graphs`,group:`Analytics`},{key:`maxAutomations`,label:`Max automations`,group:`Analytics`}];function G(){let[e,t]=(0,B.useState)(1),[n,p]=(0,B.useState)(``),[m]=c(n,300),[g,v]=(0,B.useState)(null),[y,b]=(0,B.useState)(!1),x=N(`subscription`,{pagination:{page:e,perPage:H},sort:{field:`createdAt`,order:`DESC`},filter:m?{query:m}:{}});return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(j,{title:`Subscriptions`,searchValue:n,onSearchChange:e=>{p(e),t(1)},searchPlaceholder:`Search by ID, Stripe ID, org, plan, or status`,isLoading:x.isLoading,isFetching:x.isFetching,error:x.error,pagination:{page:e,perPage:H,total:x.data?.total??0,onPageChange:t},onCreate:()=>b(!0),createLabel:`New subscription`,children:(0,V.jsxs)(d,{variant:`line`,size:`md`,width:`full`,children:[(0,V.jsx)(s,{children:(0,V.jsxs)(i,{children:[(0,V.jsx)(f,{children:`Organization`}),(0,V.jsx)(f,{children:`Plan`}),(0,V.jsx)(f,{children:`Status`}),(0,V.jsx)(f,{children:`Stripe ID`}),(0,V.jsx)(f,{children:`Start`}),(0,V.jsx)(f,{children:`End`}),(0,V.jsx)(f,{width:`60px`,textAlign:`right`})]})}),(0,V.jsxs)(o,{children:[x.data?.data.length===0&&(0,V.jsx)(i,{children:(0,V.jsx)(u,{colSpan:7,children:(0,V.jsx)(S,{color:`fg.muted`,textAlign:`center`,paddingY:6,children:`No subscriptions match your search.`})})}),x.data?.data.map(e=>(0,V.jsxs)(i,{children:[(0,V.jsx)(u,{children:e.organization?.name??(0,V.jsx)(S,{fontSize:`xs`,color:`fg.muted`,children:e.organizationId})}),(0,V.jsx)(u,{children:(0,V.jsx)(_,{size:`sm`,variant:`subtle`,children:e.plan})}),(0,V.jsx)(u,{children:(0,V.jsx)(_,{size:`sm`,colorPalette:U[e.status],children:e.status})}),(0,V.jsx)(u,{children:e.stripeSubscriptionId??(0,V.jsx)(P,{})}),(0,V.jsx)(u,{children:M(e.startDate)}),(0,V.jsx)(u,{children:M(e.endDate)}),(0,V.jsx)(u,{textAlign:`right`,children:(0,V.jsx)(h,{width:`full`,height:`full`,display:`flex`,justifyContent:`end`,children:(0,V.jsxs)(l.Root,{children:[(0,V.jsx)(l.Trigger,{children:(0,V.jsx)(a,{size:16})}),(0,V.jsx)(l.Content,{children:(0,V.jsxs)(l.Item,{value:`edit`,onClick:()=>v(e),children:[(0,V.jsx)(r,{size:16}),`Edit`]})})]})})})]},e.id))]})]})}),(0,V.jsx)(Y,{mode:`edit`,subscription:g,onClose:()=>v(null)}),(0,V.jsx)(Y,{mode:`create`,subscription:y?null:void 0,onClose:()=>b(!1)})]})}var K={organizationId:``,plan:`FREE`,status:`PENDING`,stripeSubscriptionId:``,startDate:``,endDate:``,...W.reduce((e,t)=>(e[t.key]=``,e),{})};function q(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,10)}function J(e){if(e===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}function Y({mode:e,subscription:t,onClose:r}){let i=F(`subscription`),a=L(`subscription`),o=e===`edit`?i:a,[s,c]=(0,B.useState)(K),l=e===`edit`?!!t:t!==void 0;(0,B.useEffect)(()=>{if(l)if(e===`edit`&&t){let e=W.reduce((e,n)=>{let r=t[n.key];return e[n.key]=typeof r==`number`?r.toString():``,e},{});c({organizationId:t.organizationId,plan:t.plan,status:t.status,stripeSubscriptionId:t.stripeSubscriptionId??``,startDate:q(t.startDate),endDate:q(t.endDate),...e})}else e===`create`&&c(K)},[l,e,t]);let u=(e,t)=>c(n=>({...n,[e]:t})),d=e===`edit`?`Edit Subscription`:`New Subscription`,f=()=>{if(!s.organizationId){g.create({title:`Organization is required`,type:`error`,duration:3e3,meta:{closable:!0}});return}let n={organizationId:s.organizationId,plan:s.plan,status:s.status,stripeSubscriptionId:s.stripeSubscriptionId||null,startDate:I(s.startDate),endDate:I(s.endDate)};for(let e of W)n[e.key]=J(s[e.key]);let o=()=>{g.create({title:e===`edit`?`Subscription updated`:`Subscription created`,type:`success`,duration:3e3,meta:{closable:!0}}),r()},c=t=>g.create({title:e===`edit`?`Update failed`:`Create 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})},p=(0,B.useMemo)(()=>{let e=new Map;for(let t of W){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return Array.from(e.entries())},[]);return(0,V.jsx)(n.Root,{open:l,onOpenChange:({open:e})=>{e||r()},size:`lg`,children:(0,V.jsxs)(n.Content,{children:[(0,V.jsx)(n.Header,{children:(0,V.jsx)(n.Title,{children:d})}),(0,V.jsx)(n.CloseTrigger,{}),(0,V.jsx)(n.Body,{children:(0,V.jsxs)(k,{gap:4,align:`stretch`,children:[(0,V.jsx)(X,{children:`Subscription`}),(0,V.jsx)(Q,{value:s.organizationId,onChange:e=>u(`organizationId`,e),currentName:t?.organization?.name}),(0,V.jsxs)(E,{gap:3,align:`start`,children:[(0,V.jsxs)(C,{children:[(0,V.jsx)(w,{children:`Plan`}),(0,V.jsx)(Z,{value:s.plan,options:Object.values(z.PlanTypes),onChange:e=>u(`plan`,e)})]}),(0,V.jsxs)(C,{children:[(0,V.jsx)(w,{children:`Status`}),(0,V.jsx)(Z,{value:s.status,options:Object.values(z.SubscriptionStatus),onChange:e=>u(`status`,e)})]})]}),(0,V.jsxs)(C,{children:[(0,V.jsx)(w,{children:`Stripe subscription ID`}),(0,V.jsx)(T,{value:s.stripeSubscriptionId,onChange:e=>u(`stripeSubscriptionId`,e.target.value)})]}),(0,V.jsxs)(E,{gap:3,children:[(0,V.jsxs)(C,{children:[(0,V.jsx)(w,{children:`Start date`}),(0,V.jsx)(T,{type:`date`,value:s.startDate,onChange:e=>u(`startDate`,e.target.value)})]}),(0,V.jsxs)(C,{children:[(0,V.jsx)(w,{children:`End date`}),(0,V.jsx)(T,{type:`date`,value:s.endDate,onChange:e=>u(`endDate`,e.target.value)})]})]}),p.map(([e,t])=>(0,V.jsxs)(k,{gap:3,align:`stretch`,children:[(0,V.jsxs)(X,{children:[e,` limits`]}),(0,V.jsx)(D,{columns:2,gap:3,children:t.map(e=>(0,V.jsxs)(C,{children:[(0,V.jsx)(w,{children:e.label}),(0,V.jsx)(T,{type:`number`,value:s[e.key],onChange:t=>u(e.key,t.target.value),placeholder:`—`})]},e.key))})]},e)),e===`edit`&&t&&(0,V.jsxs)(k,{align:`start`,gap:0,pt:2,children:[(0,V.jsxs)(S,{fontSize:`xs`,color:`fg.muted`,children:[`Subscription ID: `,t.id]}),t.lastPaymentFailedDate&&(0,V.jsxs)(S,{fontSize:`xs`,color:`red.500`,children:[`Last payment failed:`,` `,M(t.lastPaymentFailedDate)]})]})]})}),(0,V.jsx)(n.Footer,{children:(0,V.jsxs)(E,{width:`full`,children:[(0,V.jsx)(O,{}),(0,V.jsx)(m,{variant:`ghost`,onClick:r,children:`Cancel`}),(0,V.jsx)(m,{loading:o.isPending,onClick:f,children:e===`edit`?`Save`:`Create`})]})})]})})}function X({children:e}){return(0,V.jsx)(x,{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,V.jsxs)(y,{size:`sm`,width:`full`,children:[(0,V.jsx)(b,{value:e,onChange:e=>n(e.target.value),children:t.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))}),(0,V.jsx)(v,{})]})}function Q({value:e,onChange:t,currentName:n}){let[r,i]=(0,B.useState)(``),[a]=c(r,250),o=N(`organization`,{pagination:{page:1,perPage:50},sort:{field:`name`,order:`ASC`},filter:a?{query:a}:{}}),s=(0,B.useMemo)(()=>o.data?.data??[],[o.data]);return(0,V.jsxs)(C,{required:!0,children:[(0,V.jsx)(w,{children:`Organization`}),e&&!r&&n&&(0,V.jsxs)(S,{fontSize:`xs`,color:`fg.muted`,children:[`Currently: `,n]}),(0,V.jsx)(T,{placeholder:`Type to search organizations`,value:r,onChange:e=>i(e.target.value)}),(0,V.jsxs)(y,{size:`sm`,width:`full`,mt:1,children:[(0,V.jsxs)(b,{value:e,onChange:e=>t(e.target.value),children:[(0,V.jsx)(`option`,{value:``,children:`Select organization…`}),s.map(e=>(0,V.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.slug,`)`]},e.id))]}),(0,V.jsx)(v,{})]})]})}function $(){return(0,V.jsx)(R,{children:(0,V.jsx)(G,{})})}export{$ as default};
2
- //# sourceMappingURL=subscriptions-Dyyau22a.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{an as _}from"./dist-Cds4Mqhj.js";import{n as v,r as y,t as b}from"./native-select-B51i56CE.js";import{t as x}from"./heading-D90dlSnH.js";import{t as S}from"./text-CwTrMF8x.js";import{a as C,r as w}from"./field-CnUiixMS.js";import{t as T}from"./input-C7emsUCL.js";import{t as E}from"./h-stack-BKLDJ2vg.js";import{t as D}from"./simple-grid-C3IW90zo.js";import{t as O}from"./spacer-2LJJGbo8.js";import{t as k}from"./v-stack-EOPQ57OZ.js";import{c as A}from"./useOrganizationTeamProject-DC0iozx2.js";import{a as j,c as M,n as N,o as P,r as F,s as I,t as L,u as R}from"./useAdminResource-SmnnHro6.js";var z=A(),B=e(t()),V=p(),H=25,U={ACTIVE:`green`,PENDING:`yellow`,FAILED:`red`,CANCELLED:`gray`},W=[{key:`maxMembers`,label:`Max members`,group:`Members`},{key:`maxMembersLite`,label:`Max lite members`,group:`Members`},{key:`maxTeams`,label:`Max teams`,group:`Members`},{key:`maxProjects`,label:`Max projects`,group:`Resources`},{key:`maxWorkflows`,label:`Max workflows`,group:`Resources`},{key:`maxPrompts`,label:`Max prompts`,group:`Resources`},{key:`maxAgents`,label:`Max agents`,group:`Resources`},{key:`maxScenarios`,label:`Max scenarios`,group:`Resources`},{key:`maxEvaluators`,label:`Max evaluators`,group:`Evaluation`},{key:`maxExperiments`,label:`Max experiments`,group:`Evaluation`},{key:`maxOnlineEvaluations`,label:`Max online evaluations`,group:`Evaluation`},{key:`maxMessagesPerMonth`,label:`Max traces per month`,group:`Observability`},{key:`maxRetentionDays`,label:`Max retention days`,group:`Observability`},{key:`maxDatasets`,label:`Max datasets`,group:`Observability`},{key:`maxDashboards`,label:`Max dashboards`,group:`Analytics`},{key:`maxCustomGraphs`,label:`Max custom graphs`,group:`Analytics`},{key:`maxAutomations`,label:`Max automations`,group:`Analytics`}];function G(){let[e,t]=(0,B.useState)(1),[n,p]=(0,B.useState)(``),[m]=c(n,300),[g,v]=(0,B.useState)(null),[y,b]=(0,B.useState)(!1),x=N(`subscription`,{pagination:{page:e,perPage:H},sort:{field:`createdAt`,order:`DESC`},filter:m?{query:m}:{}});return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(j,{title:`Subscriptions`,searchValue:n,onSearchChange:e=>{p(e),t(1)},searchPlaceholder:`Search by ID, Stripe ID, org, plan, or status`,isLoading:x.isLoading,isFetching:x.isFetching,error:x.error,pagination:{page:e,perPage:H,total:x.data?.total??0,onPageChange:t},onCreate:()=>b(!0),createLabel:`New subscription`,children:(0,V.jsxs)(d,{variant:`line`,size:`md`,width:`full`,children:[(0,V.jsx)(s,{children:(0,V.jsxs)(i,{children:[(0,V.jsx)(f,{children:`Organization`}),(0,V.jsx)(f,{children:`Plan`}),(0,V.jsx)(f,{children:`Status`}),(0,V.jsx)(f,{children:`Stripe ID`}),(0,V.jsx)(f,{children:`Start`}),(0,V.jsx)(f,{children:`End`}),(0,V.jsx)(f,{width:`60px`,textAlign:`right`})]})}),(0,V.jsxs)(o,{children:[x.data?.data.length===0&&(0,V.jsx)(i,{children:(0,V.jsx)(u,{colSpan:7,children:(0,V.jsx)(S,{color:`fg.muted`,textAlign:`center`,paddingY:6,children:`No subscriptions match your search.`})})}),x.data?.data.map(e=>(0,V.jsxs)(i,{children:[(0,V.jsx)(u,{children:e.organization?.name??(0,V.jsx)(S,{fontSize:`xs`,color:`fg.muted`,children:e.organizationId})}),(0,V.jsx)(u,{children:(0,V.jsx)(_,{size:`sm`,variant:`subtle`,children:e.plan})}),(0,V.jsx)(u,{children:(0,V.jsx)(_,{size:`sm`,colorPalette:U[e.status],children:e.status})}),(0,V.jsx)(u,{children:e.stripeSubscriptionId??(0,V.jsx)(P,{})}),(0,V.jsx)(u,{children:M(e.startDate)}),(0,V.jsx)(u,{children:M(e.endDate)}),(0,V.jsx)(u,{textAlign:`right`,children:(0,V.jsx)(h,{width:`full`,height:`full`,display:`flex`,justifyContent:`end`,children:(0,V.jsxs)(l.Root,{children:[(0,V.jsx)(l.Trigger,{children:(0,V.jsx)(a,{size:16})}),(0,V.jsx)(l.Content,{children:(0,V.jsxs)(l.Item,{value:`edit`,onClick:()=>v(e),children:[(0,V.jsx)(r,{size:16}),`Edit`]})})]})})})]},e.id))]})]})}),(0,V.jsx)(Y,{mode:`edit`,subscription:g,onClose:()=>v(null)}),(0,V.jsx)(Y,{mode:`create`,subscription:y?null:void 0,onClose:()=>b(!1)})]})}var K={organizationId:``,plan:`FREE`,status:`PENDING`,stripeSubscriptionId:``,startDate:``,endDate:``,...W.reduce((e,t)=>(e[t.key]=``,e),{})};function q(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,10)}function J(e){if(e===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}function Y({mode:e,subscription:t,onClose:r}){let i=F(`subscription`),a=L(`subscription`),o=e===`edit`?i:a,[s,c]=(0,B.useState)(K),l=e===`edit`?!!t:t!==void 0;(0,B.useEffect)(()=>{if(l)if(e===`edit`&&t){let e=W.reduce((e,n)=>{let r=t[n.key];return e[n.key]=typeof r==`number`?r.toString():``,e},{});c({organizationId:t.organizationId,plan:t.plan,status:t.status,stripeSubscriptionId:t.stripeSubscriptionId??``,startDate:q(t.startDate),endDate:q(t.endDate),...e})}else e===`create`&&c(K)},[l,e,t]);let u=(e,t)=>c(n=>({...n,[e]:t})),d=e===`edit`?`Edit Subscription`:`New Subscription`,f=()=>{if(!s.organizationId){g.create({title:`Organization is required`,type:`error`,duration:3e3,meta:{closable:!0}});return}let n={organizationId:s.organizationId,plan:s.plan,status:s.status,stripeSubscriptionId:s.stripeSubscriptionId||null,startDate:I(s.startDate),endDate:I(s.endDate)};for(let e of W)n[e.key]=J(s[e.key]);let o=()=>{g.create({title:e===`edit`?`Subscription updated`:`Subscription created`,type:`success`,duration:3e3,meta:{closable:!0}}),r()},c=t=>g.create({title:e===`edit`?`Update failed`:`Create 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})},p=(0,B.useMemo)(()=>{let e=new Map;for(let t of W){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return Array.from(e.entries())},[]);return(0,V.jsx)(n.Root,{open:l,onOpenChange:({open:e})=>{e||r()},size:`lg`,children:(0,V.jsxs)(n.Content,{children:[(0,V.jsx)(n.Header,{children:(0,V.jsx)(n.Title,{children:d})}),(0,V.jsx)(n.CloseTrigger,{}),(0,V.jsx)(n.Body,{children:(0,V.jsxs)(k,{gap:4,align:`stretch`,children:[(0,V.jsx)(X,{children:`Subscription`}),(0,V.jsx)(Q,{value:s.organizationId,onChange:e=>u(`organizationId`,e),currentName:t?.organization?.name}),(0,V.jsxs)(E,{gap:3,align:`start`,children:[(0,V.jsxs)(C,{children:[(0,V.jsx)(w,{children:`Plan`}),(0,V.jsx)(Z,{value:s.plan,options:Object.values(z.PlanTypes),onChange:e=>u(`plan`,e)})]}),(0,V.jsxs)(C,{children:[(0,V.jsx)(w,{children:`Status`}),(0,V.jsx)(Z,{value:s.status,options:Object.values(z.SubscriptionStatus),onChange:e=>u(`status`,e)})]})]}),(0,V.jsxs)(C,{children:[(0,V.jsx)(w,{children:`Stripe subscription ID`}),(0,V.jsx)(T,{value:s.stripeSubscriptionId,onChange:e=>u(`stripeSubscriptionId`,e.target.value)})]}),(0,V.jsxs)(E,{gap:3,children:[(0,V.jsxs)(C,{children:[(0,V.jsx)(w,{children:`Start date`}),(0,V.jsx)(T,{type:`date`,value:s.startDate,onChange:e=>u(`startDate`,e.target.value)})]}),(0,V.jsxs)(C,{children:[(0,V.jsx)(w,{children:`End date`}),(0,V.jsx)(T,{type:`date`,value:s.endDate,onChange:e=>u(`endDate`,e.target.value)})]})]}),p.map(([e,t])=>(0,V.jsxs)(k,{gap:3,align:`stretch`,children:[(0,V.jsxs)(X,{children:[e,` limits`]}),(0,V.jsx)(D,{columns:2,gap:3,children:t.map(e=>(0,V.jsxs)(C,{children:[(0,V.jsx)(w,{children:e.label}),(0,V.jsx)(T,{type:`number`,value:s[e.key],onChange:t=>u(e.key,t.target.value),placeholder:`—`})]},e.key))})]},e)),e===`edit`&&t&&(0,V.jsxs)(k,{align:`start`,gap:0,pt:2,children:[(0,V.jsxs)(S,{fontSize:`xs`,color:`fg.muted`,children:[`Subscription ID: `,t.id]}),t.lastPaymentFailedDate&&(0,V.jsxs)(S,{fontSize:`xs`,color:`red.500`,children:[`Last payment failed:`,` `,M(t.lastPaymentFailedDate)]})]})]})}),(0,V.jsx)(n.Footer,{children:(0,V.jsxs)(E,{width:`full`,children:[(0,V.jsx)(O,{}),(0,V.jsx)(m,{variant:`ghost`,onClick:r,children:`Cancel`}),(0,V.jsx)(m,{loading:o.isPending,onClick:f,children:e===`edit`?`Save`:`Create`})]})})]})})}function X({children:e}){return(0,V.jsx)(x,{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,V.jsxs)(y,{size:`sm`,width:`full`,children:[(0,V.jsx)(b,{value:e,onChange:e=>n(e.target.value),children:t.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))}),(0,V.jsx)(v,{})]})}function Q({value:e,onChange:t,currentName:n}){let[r,i]=(0,B.useState)(``),[a]=c(r,250),o=N(`organization`,{pagination:{page:1,perPage:50},sort:{field:`name`,order:`ASC`},filter:a?{query:a}:{}}),s=(0,B.useMemo)(()=>o.data?.data??[],[o.data]);return(0,V.jsxs)(C,{required:!0,children:[(0,V.jsx)(w,{children:`Organization`}),e&&!r&&n&&(0,V.jsxs)(S,{fontSize:`xs`,color:`fg.muted`,children:[`Currently: `,n]}),(0,V.jsx)(T,{placeholder:`Type to search organizations`,value:r,onChange:e=>i(e.target.value)}),(0,V.jsxs)(y,{size:`sm`,width:`full`,mt:1,children:[(0,V.jsxs)(b,{value:e,onChange:e=>t(e.target.value),children:[(0,V.jsx)(`option`,{value:``,children:`Select organization…`}),s.map(e=>(0,V.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.slug,`)`]},e.id))]}),(0,V.jsx)(v,{})]})]})}function $(){return(0,V.jsx)(R,{children:(0,V.jsx)(G,{})})}export{$ as default};
2
+ //# sourceMappingURL=subscriptions-D0G-OE5C.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Fa as n,Ma as r,Ra as i,Xr as a,ao as o,ho as s,io as c,na as l,r as u,sc as d,ya as f}from"./command-bar-CaJygoez.js";import{j as p,n as m,r as h}from"./stack-oJ9iWdbl.js";import{t as g}from"./box-BsM8YLGl.js";import{n as _}from"./toaster-C_DYALhL.js";import{an as v,f as y}from"./dist-SwV3YZv3.js";import{t as b}from"./heading-D90dlSnH.js";import{t as x}from"./text-CwTrMF8x.js";import{a as S,r as C}from"./field-CnUiixMS.js";import{t as w}from"./h-stack-BKLDJ2vg.js";import{r as T,t as E}from"./card-CMtKVPVl.js";import{t as D}from"./link-CwZhwOLq.js";import{t as O}from"./spacer-2LJJGbo8.js";import{t as k}from"./v-stack-EOPQ57OZ.js";import{s as A}from"./auth-client-D3UhxhQi.js";import{t as j}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as M}from"./SettingsLayout-CLCGxMAe.js";import{t as N}from"./WithPermissionGuard-DD8uo3UK.js";var P=e(t()),F=p(),I=[{label:`Admin`,value:`ADMIN`},{label:`Member`,value:`MEMBER`},{label:`Viewer`,value:`VIEWER`}];function L(e){return e===`ADMIN`?`red`:e===`MEMBER`?`blue`:`gray`}function R({value:e,customRoleId:t,organizationId:n,onChange:r,size:i=`sm`}){let a=A.role.getAll.useQuery({organizationId:n}),o=[...I,...(a.data??[]).map(e=>({label:e.name,value:`CUSTOM:${e.id}`}))],s=d({items:o}),c=e===`CUSTOM`&&t?`CUSTOM:${t}`:e;return(0,F.jsxs)(l.Root,{collection:s,value:[c],onValueChange:t=>{let n=t.value[0]??e;n.startsWith(`CUSTOM:`)?r(`CUSTOM`,n.slice(7)):r(n,void 0)},disabled:a.isLoading,size:i,width:`140px`,children:[(0,F.jsx)(l.Trigger,{children:(0,F.jsx)(l.ValueText,{})}),(0,F.jsx)(l.Content,{paddingY:2,children:o.map(e=>(0,F.jsx)(l.Item,{item:e,children:e.label},e.value))})]})}function z({teamId:e,teamName:t,organizationId:n,existingMemberIds:r,open:i,onClose:a}){let[o,s]=(0,P.useState)(``),[c,u]=(0,P.useState)(`MEMBER`),[f,p]=(0,P.useState)(void 0),h=A.useContext(),g=A.organization.getOrganizationWithMembersAndTheirTeams.useQuery({organizationId:n,includeDeactivated:!1},{enabled:i}),v=A.role.getAll.useQuery({organizationId:n},{enabled:i}),b=A.roleBinding.create.useMutation({onSuccess:()=>{_.create({title:`Member added`,type:`success`}),h.team.getTeamsWithRoleBindings.invalidate(),a()},onError:e=>{_.create({title:e.message,type:`error`})}}),w=(0,P.useMemo)(()=>(g.data?.members??[]).filter(e=>!r.includes(e.userId)).map(e=>({label:`${e.user.name??e.user.email} (${e.user.email})`,value:e.userId})),[g.data,r]),T=(0,P.useMemo)(()=>d({items:w}),[w]),E=(0,P.useMemo)(()=>[...I,...(v.data??[]).map(e=>({label:e.name,value:`CUSTOM:${e.id}`}))],[v.data]),D=(0,P.useMemo)(()=>d({items:E}),[E]);return(0,F.jsx)(y.Root,{open:i,onOpenChange:e=>!e.open&&a(),children:(0,F.jsxs)(y.Content,{maxWidth:`440px`,children:[(0,F.jsx)(y.Header,{children:(0,F.jsxs)(y.Title,{children:[`Add member to `,t]})}),(0,F.jsx)(y.CloseTrigger,{}),(0,F.jsx)(y.Body,{children:(0,F.jsxs)(k,{gap:4,align:`stretch`,children:[(0,F.jsxs)(S,{children:[(0,F.jsx)(C,{children:`Person`}),(0,F.jsxs)(l.Root,{collection:T,value:o?[o]:[],onValueChange:e=>s(e.value[0]??``),size:`md`,children:[(0,F.jsx)(l.Trigger,{children:(0,F.jsx)(l.ValueText,{placeholder:`Select person...`})}),(0,F.jsx)(l.Content,{children:w.map(e=>(0,F.jsx)(l.Item,{item:e,children:e.label},e.value))})]})]}),(0,F.jsxs)(S,{children:[(0,F.jsx)(C,{children:`Role on this team`}),(0,F.jsxs)(l.Root,{collection:D,value:[f?`CUSTOM:${f}`:c],onValueChange:e=>{let t=e.value[0]??`MEMBER`;t.startsWith(`CUSTOM:`)?(u(`CUSTOM`),p(t.slice(7))):(u(t),p(void 0))},size:`md`,children:[(0,F.jsx)(l.Trigger,{children:(0,F.jsx)(l.ValueText,{})}),(0,F.jsx)(l.Content,{children:E.map(e=>(0,F.jsx)(l.Item,{item:e,children:e.label},e.value))})]})]}),(0,F.jsx)(x,{fontSize:`sm`,color:`gray.500`,children:`This gives them access to all projects in the team at this role level.`})]})}),(0,F.jsxs)(y.Footer,{children:[(0,F.jsx)(m,{variant:`ghost`,onClick:a,children:`Cancel`}),(0,F.jsx)(m,{disabled:!o,loading:b.isPending,onClick:()=>b.mutate({organizationId:n,userId:o,role:f?`CUSTOM`:c,customRoleId:f,scopeType:`TEAM`,scopeId:e}),children:`Add member`})]})]})})}function B({projectId:e,projectName:t,organizationId:n,open:r,onClose:i}){let[a,o]=(0,P.useState)(``),[s,c]=(0,P.useState)(`VIEWER`),[u,f]=(0,P.useState)(void 0),p=A.useContext(),h=A.organization.getOrganizationWithMembersAndTheirTeams.useQuery({organizationId:n,includeDeactivated:!1},{enabled:r}),g=A.role.getAll.useQuery({organizationId:n},{enabled:r}),v=A.roleBinding.create.useMutation({onSuccess:()=>{_.create({title:`Access added`,type:`success`}),p.team.getTeamsWithRoleBindings.invalidate(),i()},onError:e=>{_.create({title:e.message,type:`error`})}}),b=(h.data?.members??[]).map(e=>({label:`${e.user.name??e.user.email} (${e.user.email})`,value:e.userId})),w=d({items:b}),T=[...I,...(g.data??[]).map(e=>({label:e.name,value:`CUSTOM:${e.id}`}))],E=d({items:T});return(0,F.jsx)(y.Root,{open:r,onOpenChange:e=>!e.open&&i(),children:(0,F.jsxs)(y.Content,{maxWidth:`440px`,children:[(0,F.jsx)(y.Header,{children:(0,F.jsxs)(y.Title,{children:[`Add access to `,t]})}),(0,F.jsx)(y.CloseTrigger,{}),(0,F.jsx)(y.Body,{children:(0,F.jsxs)(k,{gap:4,align:`stretch`,children:[(0,F.jsxs)(S,{children:[(0,F.jsx)(C,{children:`Person`}),(0,F.jsxs)(l.Root,{collection:w,value:a?[a]:[],onValueChange:e=>o(e.value[0]??``),size:`md`,children:[(0,F.jsx)(l.Trigger,{children:(0,F.jsx)(l.ValueText,{placeholder:`Select person...`})}),(0,F.jsx)(l.Content,{children:b.map(e=>(0,F.jsx)(l.Item,{item:e,children:e.label},e.value))})]})]}),(0,F.jsxs)(S,{children:[(0,F.jsx)(C,{children:`Role on this project`}),(0,F.jsxs)(l.Root,{collection:E,value:[u?`CUSTOM:${u}`:s],onValueChange:e=>{let t=e.value[0]??`VIEWER`;t.startsWith(`CUSTOM:`)?(c(`CUSTOM`),f(t.slice(7))):(c(t),f(void 0))},size:`md`,children:[(0,F.jsx)(l.Trigger,{children:(0,F.jsx)(l.ValueText,{})}),(0,F.jsx)(l.Content,{children:T.map(e=>(0,F.jsx)(l.Item,{item:e,children:e.label},e.value))})]})]}),(0,F.jsx)(x,{fontSize:`sm`,color:`gray.500`,children:`If they're already on the team, this overrides their team role for this project only.`})]})}),(0,F.jsxs)(y.Footer,{children:[(0,F.jsx)(m,{variant:`ghost`,onClick:i,children:`Cancel`}),(0,F.jsx)(m,{disabled:!a,loading:v.isPending,onClick:()=>v.mutate({organizationId:n,userId:a,role:u?`CUSTOM`:s,customRoleId:u,scopeType:`PROJECT`,scopeId:e}),children:`Add access`})]})]})})}function V({project:e,access:t,organizationId:i,canManage:a}){let[l,u]=(0,P.useState)(!1),[d,p]=(0,P.useState)(!1),h=A.useContext(),y=A.roleBinding.delete.useMutation({onSuccess:()=>{h.team.getTeamsWithRoleBindings.invalidate()},onError:e=>_.create({title:e.message,type:`error`})}),b=t.filter(e=>e.source===`team`),S=t.filter(e=>e.source!==`team`),C=S.length>0;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(g,{borderWidth:`1px`,borderRadius:`md`,mb:2,overflow:`hidden`,children:[(0,F.jsxs)(w,{px:3,py:2,cursor:`pointer`,onClick:()=>u(e=>!e),_hover:{bg:`gray.50`,_dark:{bg:`gray.800`}},children:[l?(0,F.jsx)(o,{size:14}):(0,F.jsx)(c,{size:14}),(0,F.jsxs)(x,{fontSize:`sm`,fontWeight:`medium`,children:[`📁 `,e.name]}),C&&(0,F.jsx)(v,{colorPalette:`orange`,size:`sm`,children:`has overrides`}),(0,F.jsx)(O,{}),(0,F.jsxs)(x,{fontSize:`xs`,color:`gray.500`,children:[t.length,` with access`]})]}),l&&(0,F.jsxs)(g,{px:3,pb:3,borderTopWidth:`1px`,children:[b.length>0&&(0,F.jsxs)(g,{mt:3,children:[(0,F.jsx)(x,{fontSize:`xs`,fontWeight:`semibold`,color:`gray.500`,textTransform:`uppercase`,letterSpacing:`wider`,mb:2,children:`Inherited from team`}),b.map((e,t)=>(0,F.jsxs)(w,{py:1,opacity:.5,fontSize:`sm`,children:[(0,F.jsx)(s,{name:e.name,size:`xs`}),(0,F.jsx)(x,{flex:1,children:e.name}),(0,F.jsx)(v,{colorPalette:L(e.role),size:`sm`,children:e.customRoleName??e.role}),e.viaGroupName?(0,F.jsxs)(D,{href:`/settings/groups`,fontSize:`xs`,color:`purple.400`,children:[`via `,e.viaGroupName]}):(0,F.jsx)(x,{fontSize:`xs`,color:`gray.400`,children:`from team`})]},t))]}),S.length>0&&(0,F.jsxs)(g,{mt:3,children:[(0,F.jsx)(x,{fontSize:`xs`,fontWeight:`semibold`,color:`gray.500`,textTransform:`uppercase`,letterSpacing:`wider`,mb:2,children:`Project-level access`}),S.map((e,t)=>(0,F.jsxs)(w,{py:1,fontSize:`sm`,children:[(0,F.jsx)(s,{name:e.name,size:`xs`}),(0,F.jsxs)(g,{flex:1,children:[(0,F.jsx)(x,{display:`inline`,children:e.name}),e.source===`override`&&e.teamRole&&(0,F.jsxs)(x,{as:`span`,fontSize:`xs`,color:`gray.400`,ml:2,children:[`team role: `,e.teamRole]})]}),e.source===`override`&&(0,F.jsx)(v,{colorPalette:`orange`,size:`sm`,children:`override`}),(0,F.jsx)(v,{colorPalette:L(e.role),size:`sm`,children:e.role}),a&&e.bindingId&&(0,F.jsx)(m,{size:`xs`,variant:`ghost`,color:e.source===`override`?`orange.400`:`gray.400`,title:e.source===`override`?`Remove override, revert to team role`:`Remove project access`,loading:y.isPending,onClick:()=>y.mutate({organizationId:i,bindingId:e.bindingId}),children:e.source===`override`?(0,F.jsxs)(w,{gap:1,children:[(0,F.jsx)(r,{size:12}),(0,F.jsx)(x,{children:`revert`})]}):(0,F.jsx)(f,{size:14})})]},t))]}),S.length===0&&b.length>0&&(0,F.jsx)(x,{fontSize:`xs`,color:`gray.400`,fontStyle:`italic`,mt:2,children:`No project-level overrides. Everyone uses their team role.`}),a&&(0,F.jsx)(w,{mt:3,gap:2,flexWrap:`wrap`,children:(0,F.jsxs)(m,{size:`xs`,variant:`outline`,onClick:()=>p(!0),children:[(0,F.jsx)(n,{size:12}),`Add person to this project`]})})]})]}),d&&(0,F.jsx)(B,{projectId:e.id,projectName:e.name,organizationId:i,open:d,onClose:()=>p(!1)})]})}function H({team:e,organizationId:t,canManage:r}){let[a,l]=(0,P.useState)(!1),[d,p]=(0,P.useState)(!1),{openDrawer:h}=u(),{hasPermission:y}=j(),b=A.useContext(),S=A.roleBinding.delete.useMutation({onSuccess:()=>{b.team.getTeamsWithRoleBindings.invalidate()},onError:e=>_.create({title:e.message,type:`error`})}),C=A.roleBinding.update.useMutation({onSuccess:()=>{b.team.getTeamsWithRoleBindings.invalidate()},onError:e=>_.create({title:e.message,type:`error`})}),k=e.directMembers.flatMap(e=>e.userId?[e.userId]:[]);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(T,{overflow:`hidden`,children:[(0,F.jsxs)(w,{px:4,py:3,cursor:`pointer`,onClick:()=>l(e=>!e),_hover:{bg:`gray.50`,_dark:{bg:`gray.800`}},children:[a?(0,F.jsx)(o,{size:16}):(0,F.jsx)(c,{size:16}),(0,F.jsx)(x,{fontWeight:`semibold`,children:e.name}),(0,F.jsx)(O,{}),(0,F.jsxs)(x,{fontSize:`sm`,color:`gray.500`,children:[e.projects.length,` `,e.projects.length===1?`project`:`projects`,` · `,e.directMembers.length,` `,e.directMembers.length===1?`member`:`members`,e.projectOnlyAccess.length>0&&` · ${e.projectOnlyAccess.length} via projects`]}),r&&(0,F.jsx)(D,{href:`/settings/teams/${e.slug}`,onClick:e=>e.stopPropagation(),children:(0,F.jsxs)(m,{size:`xs`,variant:`ghost`,color:`gray.400`,children:[(0,F.jsx)(i,{size:13}),`Edit`]})})]}),a&&(0,F.jsxs)(E,{pt:0,borderTopWidth:`1px`,children:[(0,F.jsxs)(g,{mt:4,children:[(0,F.jsxs)(w,{mb:3,children:[(0,F.jsx)(x,{fontSize:`xs`,fontWeight:`semibold`,color:`gray.500`,textTransform:`uppercase`,letterSpacing:`wider`,children:`Team members`}),(0,F.jsx)(O,{}),r&&(0,F.jsxs)(m,{size:`xs`,variant:`outline`,onClick:e=>{e.stopPropagation(),p(!0)},children:[(0,F.jsx)(n,{size:12}),`Add to team`]})]}),e.directMembers.length===0?(0,F.jsx)(x,{fontSize:`sm`,color:`gray.400`,fontStyle:`italic`,children:`No members yet.`}):e.directMembers.map((e,n,i)=>(0,F.jsxs)(w,{py:2,borderBottomWidth:n<i.length-1?`1px`:`0`,borderColor:`gray.100`,_dark:{borderColor:`gray.700`},opacity:e.viaGroupId?.7:1,children:[(0,F.jsx)(s,{name:e.name,size:`xs`}),(0,F.jsx)(x,{fontSize:`sm`,flex:1,children:e.name}),e.viaGroupId?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(v,{colorPalette:L(e.role),size:`sm`,children:e.customRoleName??e.role}),(0,F.jsxs)(D,{href:`/settings/groups`,fontSize:`xs`,color:`purple.400`,children:[`via `,e.viaGroupName]})]}):r&&e.bindingId?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(R,{value:e.role,customRoleId:e.customRoleId,organizationId:t,onChange:(n,r)=>C.mutate({organizationId:t,bindingId:e.bindingId,role:n,customRoleId:r})}),(0,F.jsx)(m,{size:`xs`,variant:`ghost`,color:`gray.400`,loading:S.isPending,onClick:()=>S.mutate({organizationId:t,bindingId:e.bindingId}),children:(0,F.jsx)(f,{size:14})})]}):(0,F.jsx)(v,{colorPalette:L(e.role),size:`sm`,children:e.customRoleName??e.role})]},n)),(0,F.jsx)(x,{fontSize:`xs`,color:`gray.400`,mt:2,children:`Editing a role here changes their team-level access, inherited by all projects below.`})]}),e.projectOnlyAccess.length>0&&(0,F.jsxs)(g,{mt:5,children:[(0,F.jsx)(x,{fontSize:`xs`,fontWeight:`semibold`,color:`gray.500`,textTransform:`uppercase`,letterSpacing:`wider`,mb:3,children:`Also has access via projects`}),e.projectOnlyAccess.map((t,n)=>(0,F.jsxs)(w,{py:2,fontSize:`sm`,borderBottomWidth:n<e.projectOnlyAccess.length-1?`1px`:`0`,borderColor:`gray.100`,_dark:{borderColor:`gray.700`},children:[(0,F.jsx)(s,{name:t.name,size:`xs`}),(0,F.jsx)(x,{flex:1,children:t.name}),(0,F.jsx)(v,{colorPalette:L(t.role),size:`sm`,children:t.role}),(0,F.jsx)(x,{fontSize:`xs`,color:`gray.400`,children:`on`}),(0,F.jsxs)(v,{colorPalette:`green`,size:`sm`,children:[`📁 `,t.projectName]}),(0,F.jsx)(D,{fontSize:`xs`,color:`purple.400`,href:`#`,onClick:e=>{e.preventDefault(),l(!0)},children:`Edit in project →`})]},n))]}),(0,F.jsxs)(g,{mt:5,children:[(0,F.jsxs)(w,{mb:3,children:[(0,F.jsx)(x,{fontSize:`xs`,fontWeight:`semibold`,color:`gray.500`,textTransform:`uppercase`,letterSpacing:`wider`,children:`Projects`}),(0,F.jsx)(O,{}),y(`project:create`)&&(0,F.jsxs)(m,{size:`xs`,variant:`outline`,onClick:e=>{e.stopPropagation(),h(`createProject`)},children:[(0,F.jsx)(n,{size:12}),`Add project`]})]}),e.projects.length===0?(0,F.jsx)(x,{fontSize:`sm`,color:`gray.400`,fontStyle:`italic`,children:`No projects yet.`}):e.projects.map(n=>(0,F.jsx)(V,{project:n,access:e.projectAccess[n.id]??[],organizationId:t,canManage:r},n.id))]})]})]}),d&&(0,F.jsx)(z,{teamId:e.id,teamName:e.name,organizationId:t,existingMemberIds:k,open:d,onClose:()=>p(!1)})]})}function U(){let{organization:e,hasPermission:t}=j(),{openDrawer:r}=u(),i=A.team.getTeamsWithRoleBindings.useQuery({organizationId:e?.id??``},{enabled:!!e}),o=t(`team:manage`);return e?(0,F.jsx)(M,{children:(0,F.jsxs)(k,{gap:6,width:`full`,align:`start`,children:[(0,F.jsxs)(w,{width:`full`,children:[(0,F.jsxs)(g,{children:[(0,F.jsx)(b,{size:`md`,children:`Teams & Projects`}),(0,F.jsx)(x,{fontSize:`sm`,color:`gray.500`,mt:1,children:`People on a team inherit access to all its projects. Expand a project to add overrides or direct access.`})]}),(0,F.jsx)(O,{}),t(`project:create`)&&(0,F.jsxs)(a.HeaderButton,{onClick:()=>r(`createProject`),children:[(0,F.jsx)(n,{size:16}),`Add project`]}),o&&(0,F.jsxs)(a.HeaderButton,{onClick:()=>r(`createTeam`),children:[(0,F.jsx)(n,{size:16}),`New team`]})]}),i.isLoading&&(0,F.jsx)(h,{}),i.data?.length===0&&(0,F.jsx)(x,{color:`gray.500`,children:`No teams yet.`}),(0,F.jsx)(k,{gap:3,width:`full`,align:`stretch`,children:i.data?.map(t=>(0,F.jsx)(H,{team:t,organizationId:e.id,canManage:o},t.id))})]})}):(0,F.jsx)(M,{})}var W=N(`team:view`,{layoutComponent:M})(U);export{W as default};
2
- //# sourceMappingURL=teams-DRmeAxzf.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Fa as n,Ma as r,Ra as i,Xr as a,ao as o,ho as s,io as c,na as l,r as u,sc as d,ya as f}from"./command-bar-DUK45yin.js";import{j as p,n as m,r as h}from"./stack-oJ9iWdbl.js";import{t as g}from"./box-BsM8YLGl.js";import{n as _}from"./toaster-C_DYALhL.js";import{an as v,f as y}from"./dist-Cds4Mqhj.js";import{t as b}from"./heading-D90dlSnH.js";import{t as x}from"./text-CwTrMF8x.js";import{a as S,r as C}from"./field-CnUiixMS.js";import{t as w}from"./h-stack-BKLDJ2vg.js";import{r as T,t as E}from"./card-CMtKVPVl.js";import{t as D}from"./link-CwZhwOLq.js";import{t as O}from"./spacer-2LJJGbo8.js";import{t as k}from"./v-stack-EOPQ57OZ.js";import{s as A}from"./auth-client-D3UhxhQi.js";import{t as j}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as M}from"./SettingsLayout--1gdEuhv.js";import{t as N}from"./WithPermissionGuard-B4Jo8E5-.js";var P=e(t()),F=p(),I=[{label:`Admin`,value:`ADMIN`},{label:`Member`,value:`MEMBER`},{label:`Viewer`,value:`VIEWER`}];function L(e){return e===`ADMIN`?`red`:e===`MEMBER`?`blue`:`gray`}function R({value:e,customRoleId:t,organizationId:n,onChange:r,size:i=`sm`}){let a=A.role.getAll.useQuery({organizationId:n}),o=[...I,...(a.data??[]).map(e=>({label:e.name,value:`CUSTOM:${e.id}`}))],s=d({items:o}),c=e===`CUSTOM`&&t?`CUSTOM:${t}`:e;return(0,F.jsxs)(l.Root,{collection:s,value:[c],onValueChange:t=>{let n=t.value[0]??e;n.startsWith(`CUSTOM:`)?r(`CUSTOM`,n.slice(7)):r(n,void 0)},disabled:a.isLoading,size:i,width:`140px`,children:[(0,F.jsx)(l.Trigger,{children:(0,F.jsx)(l.ValueText,{})}),(0,F.jsx)(l.Content,{paddingY:2,children:o.map(e=>(0,F.jsx)(l.Item,{item:e,children:e.label},e.value))})]})}function z({teamId:e,teamName:t,organizationId:n,existingMemberIds:r,open:i,onClose:a}){let[o,s]=(0,P.useState)(``),[c,u]=(0,P.useState)(`MEMBER`),[f,p]=(0,P.useState)(void 0),h=A.useContext(),g=A.organization.getOrganizationWithMembersAndTheirTeams.useQuery({organizationId:n,includeDeactivated:!1},{enabled:i}),v=A.role.getAll.useQuery({organizationId:n},{enabled:i}),b=A.roleBinding.create.useMutation({onSuccess:()=>{_.create({title:`Member added`,type:`success`}),h.team.getTeamsWithRoleBindings.invalidate(),a()},onError:e=>{_.create({title:e.message,type:`error`})}}),w=(0,P.useMemo)(()=>(g.data?.members??[]).filter(e=>!r.includes(e.userId)).map(e=>({label:`${e.user.name??e.user.email} (${e.user.email})`,value:e.userId})),[g.data,r]),T=(0,P.useMemo)(()=>d({items:w}),[w]),E=(0,P.useMemo)(()=>[...I,...(v.data??[]).map(e=>({label:e.name,value:`CUSTOM:${e.id}`}))],[v.data]),D=(0,P.useMemo)(()=>d({items:E}),[E]);return(0,F.jsx)(y.Root,{open:i,onOpenChange:e=>!e.open&&a(),children:(0,F.jsxs)(y.Content,{maxWidth:`440px`,children:[(0,F.jsx)(y.Header,{children:(0,F.jsxs)(y.Title,{children:[`Add member to `,t]})}),(0,F.jsx)(y.CloseTrigger,{}),(0,F.jsx)(y.Body,{children:(0,F.jsxs)(k,{gap:4,align:`stretch`,children:[(0,F.jsxs)(S,{children:[(0,F.jsx)(C,{children:`Person`}),(0,F.jsxs)(l.Root,{collection:T,value:o?[o]:[],onValueChange:e=>s(e.value[0]??``),size:`md`,children:[(0,F.jsx)(l.Trigger,{children:(0,F.jsx)(l.ValueText,{placeholder:`Select person...`})}),(0,F.jsx)(l.Content,{children:w.map(e=>(0,F.jsx)(l.Item,{item:e,children:e.label},e.value))})]})]}),(0,F.jsxs)(S,{children:[(0,F.jsx)(C,{children:`Role on this team`}),(0,F.jsxs)(l.Root,{collection:D,value:[f?`CUSTOM:${f}`:c],onValueChange:e=>{let t=e.value[0]??`MEMBER`;t.startsWith(`CUSTOM:`)?(u(`CUSTOM`),p(t.slice(7))):(u(t),p(void 0))},size:`md`,children:[(0,F.jsx)(l.Trigger,{children:(0,F.jsx)(l.ValueText,{})}),(0,F.jsx)(l.Content,{children:E.map(e=>(0,F.jsx)(l.Item,{item:e,children:e.label},e.value))})]})]}),(0,F.jsx)(x,{fontSize:`sm`,color:`gray.500`,children:`This gives them access to all projects in the team at this role level.`})]})}),(0,F.jsxs)(y.Footer,{children:[(0,F.jsx)(m,{variant:`ghost`,onClick:a,children:`Cancel`}),(0,F.jsx)(m,{disabled:!o,loading:b.isPending,onClick:()=>b.mutate({organizationId:n,userId:o,role:f?`CUSTOM`:c,customRoleId:f,scopeType:`TEAM`,scopeId:e}),children:`Add member`})]})]})})}function B({projectId:e,projectName:t,organizationId:n,open:r,onClose:i}){let[a,o]=(0,P.useState)(``),[s,c]=(0,P.useState)(`VIEWER`),[u,f]=(0,P.useState)(void 0),p=A.useContext(),h=A.organization.getOrganizationWithMembersAndTheirTeams.useQuery({organizationId:n,includeDeactivated:!1},{enabled:r}),g=A.role.getAll.useQuery({organizationId:n},{enabled:r}),v=A.roleBinding.create.useMutation({onSuccess:()=>{_.create({title:`Access added`,type:`success`}),p.team.getTeamsWithRoleBindings.invalidate(),i()},onError:e=>{_.create({title:e.message,type:`error`})}}),b=(h.data?.members??[]).map(e=>({label:`${e.user.name??e.user.email} (${e.user.email})`,value:e.userId})),w=d({items:b}),T=[...I,...(g.data??[]).map(e=>({label:e.name,value:`CUSTOM:${e.id}`}))],E=d({items:T});return(0,F.jsx)(y.Root,{open:r,onOpenChange:e=>!e.open&&i(),children:(0,F.jsxs)(y.Content,{maxWidth:`440px`,children:[(0,F.jsx)(y.Header,{children:(0,F.jsxs)(y.Title,{children:[`Add access to `,t]})}),(0,F.jsx)(y.CloseTrigger,{}),(0,F.jsx)(y.Body,{children:(0,F.jsxs)(k,{gap:4,align:`stretch`,children:[(0,F.jsxs)(S,{children:[(0,F.jsx)(C,{children:`Person`}),(0,F.jsxs)(l.Root,{collection:w,value:a?[a]:[],onValueChange:e=>o(e.value[0]??``),size:`md`,children:[(0,F.jsx)(l.Trigger,{children:(0,F.jsx)(l.ValueText,{placeholder:`Select person...`})}),(0,F.jsx)(l.Content,{children:b.map(e=>(0,F.jsx)(l.Item,{item:e,children:e.label},e.value))})]})]}),(0,F.jsxs)(S,{children:[(0,F.jsx)(C,{children:`Role on this project`}),(0,F.jsxs)(l.Root,{collection:E,value:[u?`CUSTOM:${u}`:s],onValueChange:e=>{let t=e.value[0]??`VIEWER`;t.startsWith(`CUSTOM:`)?(c(`CUSTOM`),f(t.slice(7))):(c(t),f(void 0))},size:`md`,children:[(0,F.jsx)(l.Trigger,{children:(0,F.jsx)(l.ValueText,{})}),(0,F.jsx)(l.Content,{children:T.map(e=>(0,F.jsx)(l.Item,{item:e,children:e.label},e.value))})]})]}),(0,F.jsx)(x,{fontSize:`sm`,color:`gray.500`,children:`If they're already on the team, this overrides their team role for this project only.`})]})}),(0,F.jsxs)(y.Footer,{children:[(0,F.jsx)(m,{variant:`ghost`,onClick:i,children:`Cancel`}),(0,F.jsx)(m,{disabled:!a,loading:v.isPending,onClick:()=>v.mutate({organizationId:n,userId:a,role:u?`CUSTOM`:s,customRoleId:u,scopeType:`PROJECT`,scopeId:e}),children:`Add access`})]})]})})}function V({project:e,access:t,organizationId:i,canManage:a}){let[l,u]=(0,P.useState)(!1),[d,p]=(0,P.useState)(!1),h=A.useContext(),y=A.roleBinding.delete.useMutation({onSuccess:()=>{h.team.getTeamsWithRoleBindings.invalidate()},onError:e=>_.create({title:e.message,type:`error`})}),b=t.filter(e=>e.source===`team`),S=t.filter(e=>e.source!==`team`),C=S.length>0;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(g,{borderWidth:`1px`,borderRadius:`md`,mb:2,overflow:`hidden`,children:[(0,F.jsxs)(w,{px:3,py:2,cursor:`pointer`,onClick:()=>u(e=>!e),_hover:{bg:`gray.50`,_dark:{bg:`gray.800`}},children:[l?(0,F.jsx)(o,{size:14}):(0,F.jsx)(c,{size:14}),(0,F.jsxs)(x,{fontSize:`sm`,fontWeight:`medium`,children:[`📁 `,e.name]}),C&&(0,F.jsx)(v,{colorPalette:`orange`,size:`sm`,children:`has overrides`}),(0,F.jsx)(O,{}),(0,F.jsxs)(x,{fontSize:`xs`,color:`gray.500`,children:[t.length,` with access`]})]}),l&&(0,F.jsxs)(g,{px:3,pb:3,borderTopWidth:`1px`,children:[b.length>0&&(0,F.jsxs)(g,{mt:3,children:[(0,F.jsx)(x,{fontSize:`xs`,fontWeight:`semibold`,color:`gray.500`,textTransform:`uppercase`,letterSpacing:`wider`,mb:2,children:`Inherited from team`}),b.map((e,t)=>(0,F.jsxs)(w,{py:1,opacity:.5,fontSize:`sm`,children:[(0,F.jsx)(s,{name:e.name,size:`xs`}),(0,F.jsx)(x,{flex:1,children:e.name}),(0,F.jsx)(v,{colorPalette:L(e.role),size:`sm`,children:e.customRoleName??e.role}),e.viaGroupName?(0,F.jsxs)(D,{href:`/settings/groups`,fontSize:`xs`,color:`purple.400`,children:[`via `,e.viaGroupName]}):(0,F.jsx)(x,{fontSize:`xs`,color:`gray.400`,children:`from team`})]},t))]}),S.length>0&&(0,F.jsxs)(g,{mt:3,children:[(0,F.jsx)(x,{fontSize:`xs`,fontWeight:`semibold`,color:`gray.500`,textTransform:`uppercase`,letterSpacing:`wider`,mb:2,children:`Project-level access`}),S.map((e,t)=>(0,F.jsxs)(w,{py:1,fontSize:`sm`,children:[(0,F.jsx)(s,{name:e.name,size:`xs`}),(0,F.jsxs)(g,{flex:1,children:[(0,F.jsx)(x,{display:`inline`,children:e.name}),e.source===`override`&&e.teamRole&&(0,F.jsxs)(x,{as:`span`,fontSize:`xs`,color:`gray.400`,ml:2,children:[`team role: `,e.teamRole]})]}),e.source===`override`&&(0,F.jsx)(v,{colorPalette:`orange`,size:`sm`,children:`override`}),(0,F.jsx)(v,{colorPalette:L(e.role),size:`sm`,children:e.role}),a&&e.bindingId&&(0,F.jsx)(m,{size:`xs`,variant:`ghost`,color:e.source===`override`?`orange.400`:`gray.400`,title:e.source===`override`?`Remove override, revert to team role`:`Remove project access`,loading:y.isPending,onClick:()=>y.mutate({organizationId:i,bindingId:e.bindingId}),children:e.source===`override`?(0,F.jsxs)(w,{gap:1,children:[(0,F.jsx)(r,{size:12}),(0,F.jsx)(x,{children:`revert`})]}):(0,F.jsx)(f,{size:14})})]},t))]}),S.length===0&&b.length>0&&(0,F.jsx)(x,{fontSize:`xs`,color:`gray.400`,fontStyle:`italic`,mt:2,children:`No project-level overrides. Everyone uses their team role.`}),a&&(0,F.jsx)(w,{mt:3,gap:2,flexWrap:`wrap`,children:(0,F.jsxs)(m,{size:`xs`,variant:`outline`,onClick:()=>p(!0),children:[(0,F.jsx)(n,{size:12}),`Add person to this project`]})})]})]}),d&&(0,F.jsx)(B,{projectId:e.id,projectName:e.name,organizationId:i,open:d,onClose:()=>p(!1)})]})}function H({team:e,organizationId:t,canManage:r}){let[a,l]=(0,P.useState)(!1),[d,p]=(0,P.useState)(!1),{openDrawer:h}=u(),{hasPermission:y}=j(),b=A.useContext(),S=A.roleBinding.delete.useMutation({onSuccess:()=>{b.team.getTeamsWithRoleBindings.invalidate()},onError:e=>_.create({title:e.message,type:`error`})}),C=A.roleBinding.update.useMutation({onSuccess:()=>{b.team.getTeamsWithRoleBindings.invalidate()},onError:e=>_.create({title:e.message,type:`error`})}),k=e.directMembers.flatMap(e=>e.userId?[e.userId]:[]);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(T,{overflow:`hidden`,children:[(0,F.jsxs)(w,{px:4,py:3,cursor:`pointer`,onClick:()=>l(e=>!e),_hover:{bg:`gray.50`,_dark:{bg:`gray.800`}},children:[a?(0,F.jsx)(o,{size:16}):(0,F.jsx)(c,{size:16}),(0,F.jsx)(x,{fontWeight:`semibold`,children:e.name}),(0,F.jsx)(O,{}),(0,F.jsxs)(x,{fontSize:`sm`,color:`gray.500`,children:[e.projects.length,` `,e.projects.length===1?`project`:`projects`,` · `,e.directMembers.length,` `,e.directMembers.length===1?`member`:`members`,e.projectOnlyAccess.length>0&&` · ${e.projectOnlyAccess.length} via projects`]}),r&&(0,F.jsx)(D,{href:`/settings/teams/${e.slug}`,onClick:e=>e.stopPropagation(),children:(0,F.jsxs)(m,{size:`xs`,variant:`ghost`,color:`gray.400`,children:[(0,F.jsx)(i,{size:13}),`Edit`]})})]}),a&&(0,F.jsxs)(E,{pt:0,borderTopWidth:`1px`,children:[(0,F.jsxs)(g,{mt:4,children:[(0,F.jsxs)(w,{mb:3,children:[(0,F.jsx)(x,{fontSize:`xs`,fontWeight:`semibold`,color:`gray.500`,textTransform:`uppercase`,letterSpacing:`wider`,children:`Team members`}),(0,F.jsx)(O,{}),r&&(0,F.jsxs)(m,{size:`xs`,variant:`outline`,onClick:e=>{e.stopPropagation(),p(!0)},children:[(0,F.jsx)(n,{size:12}),`Add to team`]})]}),e.directMembers.length===0?(0,F.jsx)(x,{fontSize:`sm`,color:`gray.400`,fontStyle:`italic`,children:`No members yet.`}):e.directMembers.map((e,n,i)=>(0,F.jsxs)(w,{py:2,borderBottomWidth:n<i.length-1?`1px`:`0`,borderColor:`gray.100`,_dark:{borderColor:`gray.700`},opacity:e.viaGroupId?.7:1,children:[(0,F.jsx)(s,{name:e.name,size:`xs`}),(0,F.jsx)(x,{fontSize:`sm`,flex:1,children:e.name}),e.viaGroupId?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(v,{colorPalette:L(e.role),size:`sm`,children:e.customRoleName??e.role}),(0,F.jsxs)(D,{href:`/settings/groups`,fontSize:`xs`,color:`purple.400`,children:[`via `,e.viaGroupName]})]}):r&&e.bindingId?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(R,{value:e.role,customRoleId:e.customRoleId,organizationId:t,onChange:(n,r)=>C.mutate({organizationId:t,bindingId:e.bindingId,role:n,customRoleId:r})}),(0,F.jsx)(m,{size:`xs`,variant:`ghost`,color:`gray.400`,loading:S.isPending,onClick:()=>S.mutate({organizationId:t,bindingId:e.bindingId}),children:(0,F.jsx)(f,{size:14})})]}):(0,F.jsx)(v,{colorPalette:L(e.role),size:`sm`,children:e.customRoleName??e.role})]},n)),(0,F.jsx)(x,{fontSize:`xs`,color:`gray.400`,mt:2,children:`Editing a role here changes their team-level access, inherited by all projects below.`})]}),e.projectOnlyAccess.length>0&&(0,F.jsxs)(g,{mt:5,children:[(0,F.jsx)(x,{fontSize:`xs`,fontWeight:`semibold`,color:`gray.500`,textTransform:`uppercase`,letterSpacing:`wider`,mb:3,children:`Also has access via projects`}),e.projectOnlyAccess.map((t,n)=>(0,F.jsxs)(w,{py:2,fontSize:`sm`,borderBottomWidth:n<e.projectOnlyAccess.length-1?`1px`:`0`,borderColor:`gray.100`,_dark:{borderColor:`gray.700`},children:[(0,F.jsx)(s,{name:t.name,size:`xs`}),(0,F.jsx)(x,{flex:1,children:t.name}),(0,F.jsx)(v,{colorPalette:L(t.role),size:`sm`,children:t.role}),(0,F.jsx)(x,{fontSize:`xs`,color:`gray.400`,children:`on`}),(0,F.jsxs)(v,{colorPalette:`green`,size:`sm`,children:[`📁 `,t.projectName]}),(0,F.jsx)(D,{fontSize:`xs`,color:`purple.400`,href:`#`,onClick:e=>{e.preventDefault(),l(!0)},children:`Edit in project →`})]},n))]}),(0,F.jsxs)(g,{mt:5,children:[(0,F.jsxs)(w,{mb:3,children:[(0,F.jsx)(x,{fontSize:`xs`,fontWeight:`semibold`,color:`gray.500`,textTransform:`uppercase`,letterSpacing:`wider`,children:`Projects`}),(0,F.jsx)(O,{}),y(`project:create`)&&(0,F.jsxs)(m,{size:`xs`,variant:`outline`,onClick:e=>{e.stopPropagation(),h(`createProject`)},children:[(0,F.jsx)(n,{size:12}),`Add project`]})]}),e.projects.length===0?(0,F.jsx)(x,{fontSize:`sm`,color:`gray.400`,fontStyle:`italic`,children:`No projects yet.`}):e.projects.map(n=>(0,F.jsx)(V,{project:n,access:e.projectAccess[n.id]??[],organizationId:t,canManage:r},n.id))]})]})]}),d&&(0,F.jsx)(z,{teamId:e.id,teamName:e.name,organizationId:t,existingMemberIds:k,open:d,onClose:()=>p(!1)})]})}function U(){let{organization:e,hasPermission:t}=j(),{openDrawer:r}=u(),i=A.team.getTeamsWithRoleBindings.useQuery({organizationId:e?.id??``},{enabled:!!e}),o=t(`team:manage`);return e?(0,F.jsx)(M,{children:(0,F.jsxs)(k,{gap:6,width:`full`,align:`start`,children:[(0,F.jsxs)(w,{width:`full`,children:[(0,F.jsxs)(g,{children:[(0,F.jsx)(b,{size:`md`,children:`Teams & Projects`}),(0,F.jsx)(x,{fontSize:`sm`,color:`gray.500`,mt:1,children:`People on a team inherit access to all its projects. Expand a project to add overrides or direct access.`})]}),(0,F.jsx)(O,{}),t(`project:create`)&&(0,F.jsxs)(a.HeaderButton,{onClick:()=>r(`createProject`),children:[(0,F.jsx)(n,{size:16}),`Add project`]}),o&&(0,F.jsxs)(a.HeaderButton,{onClick:()=>r(`createTeam`),children:[(0,F.jsx)(n,{size:16}),`New team`]})]}),i.isLoading&&(0,F.jsx)(h,{}),i.data?.length===0&&(0,F.jsx)(x,{color:`gray.500`,children:`No teams yet.`}),(0,F.jsx)(k,{gap:3,width:`full`,align:`stretch`,children:i.data?.map(t=>(0,F.jsx)(H,{team:t,organizationId:e.id,canManage:o},t.id))})]})}):(0,F.jsx)(M,{})}var W=N(`team:view`,{layoutComponent:M})(U);export{W as default};
2
+ //# sourceMappingURL=teams-DThgDQvB.js.map
@@ -1,2 +1,2 @@
1
- import{Ba as e,Ga as t,Sa as n,Ta as r,Va as i,Wa as a,oo as o,so as s}from"./command-bar-CaJygoez.js";import{j as c}from"./stack-oJ9iWdbl.js";import{a as l,u}from"./terminal-CfM0q99k.js";import{t as d}from"./createLucideIcon-BJKFyRLS.js";var f=d(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),p=d(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),m=c(),h=({type:c,size:d=12})=>{let h={size:d,strokeWidth:2.5};switch(c){case`string`:return(0,m.jsx)(n,{...h,color:`var(--chakra-colors-blue-500)`});case`number`:return(0,m.jsx)(t,{...h,color:`var(--chakra-colors-green-500)`});case`boolean`:return(0,m.jsx)(r,{size:d+2,strokeWidth:2.5,color:`var(--chakra-colors-teal-500)`});case`json`:return(0,m.jsx)(s,{...h,color:`var(--chakra-colors-purple-500)`});case`chat_messages`:return(0,m.jsx)(l,{...h,color:`var(--chakra-colors-orange-500)`});case`image`:return(0,m.jsx)(a,{...h,color:`var(--chakra-colors-gray-400)`});case`date`:return(0,m.jsx)(o,{...h,color:`var(--chakra-colors-yellow-600)`});case`list`:return(0,m.jsx)(e,{...h,color:`var(--chakra-colors-purple-400)`});case`rag_contexts`:return(0,m.jsx)(u,{...h,color:`var(--chakra-colors-cyan-500)`});case`spans`:return(0,m.jsx)(i,{...h,color:`var(--chakra-colors-gray-500)`});case`annotations`:return(0,m.jsx)(p,{...h,color:`var(--chakra-colors-yellow-500)`});case`evaluations`:return(0,m.jsx)(f,{...h,color:`var(--chakra-colors-green-600)`});default:return(0,m.jsx)(n,{...h,color:`var(--chakra-colors-gray-400)`})}},g=e=>{if(e==null)return{status:`pending`};if(e===`running`||typeof e==`object`&&e.status===`running`)return{status:`running`};if(typeof e==`boolean`)return{status:e?`passed`:`failed`};if(typeof e==`object`){let t=e,n={status:`pending`};return`error`in t&&t.error?(n.status=`error`,n.details=typeof t.error==`string`?t.error:JSON.stringify(t.error),n):`status`in t&&t.status===`error`?(n.status=`error`,`details`in t&&typeof t.details==`string`&&(n.details=t.details),n):`status`in t&&t.status===`skipped`?(n.status=`skipped`,`details`in t&&typeof t.details==`string`&&(n.details=t.details),n):`status`in t&&t.status===`running`?{status:`running`}:(`score`in t&&typeof t.score==`number`&&(n.score=t.score),`label`in t&&typeof t.label==`string`&&(n.label=t.label),`details`in t&&typeof t.details==`string`&&(n.details=t.details),`passed`in t&&t.passed!==null&&t.passed!==void 0?n.status=t.passed?`passed`:`failed`:(n.score!==void 0||n.label!==void 0||n.details!==void 0)&&(n.status=`processed`),n)}return{status:`pending`}},_={pending:`gray.400`,running:`blue.400`,passed:`green.500`,failed:`red.500`,processed:`blue.500`,error:`red.500`,skipped:`yellow.500`},v=e=>{switch(e){case`running`:return`Running`;case`passed`:return`Passed`;case`failed`:return`Failed`;case`processed`:return`Processed`;case`error`:return`Error`;case`skipped`:return`Skipped`;default:return`Pending`}},y=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.keys(e);return t.length===1&&t[0]===`output`},b=e=>{if(e==null)return``;if(typeof e!=`object`)return String(e);if(Array.isArray(e))return JSON.stringify(e,null,2);if(y(e)){let t=e.output;return t==null?``:typeof t==`object`?JSON.stringify(t,null,2):String(t)}return JSON.stringify(e,null,2)},x=(e,t=500,n=62)=>{let r=(e.match(/\n/g)||[]).length;return e.length+r*n>t};export{g as a,v as i,b as n,h as o,_ as r,x as t};
2
- //# sourceMappingURL=textOverflowHeuristic-JibhpzDV.js.map
1
+ import{Ba as e,Ga as t,Sa as n,Ta as r,Va as i,Wa as a,oo as o,so as s}from"./command-bar-DUK45yin.js";import{j as c}from"./stack-oJ9iWdbl.js";import{a as l,u}from"./terminal-CfM0q99k.js";import{t as d}from"./createLucideIcon-BJKFyRLS.js";var f=d(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),p=d(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),m=c(),h=({type:c,size:d=12})=>{let h={size:d,strokeWidth:2.5};switch(c){case`string`:return(0,m.jsx)(n,{...h,color:`var(--chakra-colors-blue-500)`});case`number`:return(0,m.jsx)(t,{...h,color:`var(--chakra-colors-green-500)`});case`boolean`:return(0,m.jsx)(r,{size:d+2,strokeWidth:2.5,color:`var(--chakra-colors-teal-500)`});case`json`:return(0,m.jsx)(s,{...h,color:`var(--chakra-colors-purple-500)`});case`chat_messages`:return(0,m.jsx)(l,{...h,color:`var(--chakra-colors-orange-500)`});case`image`:return(0,m.jsx)(a,{...h,color:`var(--chakra-colors-gray-400)`});case`date`:return(0,m.jsx)(o,{...h,color:`var(--chakra-colors-yellow-600)`});case`list`:return(0,m.jsx)(e,{...h,color:`var(--chakra-colors-purple-400)`});case`rag_contexts`:return(0,m.jsx)(u,{...h,color:`var(--chakra-colors-cyan-500)`});case`spans`:return(0,m.jsx)(i,{...h,color:`var(--chakra-colors-gray-500)`});case`annotations`:return(0,m.jsx)(p,{...h,color:`var(--chakra-colors-yellow-500)`});case`evaluations`:return(0,m.jsx)(f,{...h,color:`var(--chakra-colors-green-600)`});default:return(0,m.jsx)(n,{...h,color:`var(--chakra-colors-gray-400)`})}},g=e=>{if(e==null)return{status:`pending`};if(e===`running`||typeof e==`object`&&e.status===`running`)return{status:`running`};if(typeof e==`boolean`)return{status:e?`passed`:`failed`};if(typeof e==`object`){let t=e,n={status:`pending`};return`error`in t&&t.error?(n.status=`error`,n.details=typeof t.error==`string`?t.error:JSON.stringify(t.error),n):`status`in t&&t.status===`error`?(n.status=`error`,`details`in t&&typeof t.details==`string`&&(n.details=t.details),n):`status`in t&&t.status===`skipped`?(n.status=`skipped`,`details`in t&&typeof t.details==`string`&&(n.details=t.details),n):`status`in t&&t.status===`running`?{status:`running`}:(`score`in t&&typeof t.score==`number`&&(n.score=t.score),`label`in t&&typeof t.label==`string`&&(n.label=t.label),`details`in t&&typeof t.details==`string`&&(n.details=t.details),`passed`in t&&t.passed!==null&&t.passed!==void 0?n.status=t.passed?`passed`:`failed`:(n.score!==void 0||n.label!==void 0||n.details!==void 0)&&(n.status=`processed`),n)}return{status:`pending`}},_={pending:`gray.400`,running:`blue.400`,passed:`green.500`,failed:`red.500`,processed:`blue.500`,error:`red.500`,skipped:`yellow.500`},v=e=>{switch(e){case`running`:return`Running`;case`passed`:return`Passed`;case`failed`:return`Failed`;case`processed`:return`Processed`;case`error`:return`Error`;case`skipped`:return`Skipped`;default:return`Pending`}},y=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.keys(e);return t.length===1&&t[0]===`output`},b=e=>{if(e==null)return``;if(typeof e!=`object`)return String(e);if(Array.isArray(e))return JSON.stringify(e,null,2);if(y(e)){let t=e.output;return t==null?``:typeof t==`object`?JSON.stringify(t,null,2):String(t)}return JSON.stringify(e,null,2)},x=(e,t=500,n=62)=>{let r=(e.match(/\n/g)||[]).length;return e.length+r*n>t};export{g as a,v as i,b as n,h as o,_ as r,x as t};
2
+ //# sourceMappingURL=textOverflowHeuristic-DTC8-Ffx.js.map