unleash-server 7.0.3 → 7.0.4

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 (225) hide show
  1. package/dist/lib/addons/slack-app-definition.js +6 -6
  2. package/dist/lib/addons/slack-app-definition.js.map +1 -1
  3. package/dist/lib/addons/slack-definition.js +2 -2
  4. package/dist/lib/addons/slack-definition.js.map +1 -1
  5. package/dist/lib/create-config.d.ts.map +1 -1
  6. package/dist/lib/create-config.js +3 -0
  7. package/dist/lib/create-config.js.map +1 -1
  8. package/dist/lib/db/client-instance-store.d.ts +0 -5
  9. package/dist/lib/db/client-instance-store.d.ts.map +1 -1
  10. package/dist/lib/db/client-instance-store.js +0 -21
  11. package/dist/lib/db/client-instance-store.js.map +1 -1
  12. package/dist/lib/db/event-store.d.ts +1 -1
  13. package/dist/lib/db/event-store.d.ts.map +1 -1
  14. package/dist/lib/db/event-store.js +1 -1
  15. package/dist/lib/db/event-store.js.map +1 -1
  16. package/dist/lib/db/index.js +1 -1
  17. package/dist/lib/db/index.js.map +1 -1
  18. package/dist/lib/db/transaction.d.ts +5 -1
  19. package/dist/lib/db/transaction.d.ts.map +1 -1
  20. package/dist/lib/db/transaction.js +10 -4
  21. package/dist/lib/db/transaction.js.map +1 -1
  22. package/dist/lib/db/transaction.test.d.ts +2 -0
  23. package/dist/lib/db/transaction.test.d.ts.map +1 -0
  24. package/dist/lib/db/transaction.test.js +161 -0
  25. package/dist/lib/db/transaction.test.js.map +1 -0
  26. package/dist/lib/events/index.d.ts +4 -1
  27. package/dist/lib/events/index.d.ts.map +1 -1
  28. package/dist/lib/events/index.js +2 -0
  29. package/dist/lib/events/index.js.map +1 -1
  30. package/dist/lib/features/client-feature-toggles/delta/createClientFeatureToggleDelta.js +1 -1
  31. package/dist/lib/features/client-feature-toggles/delta/createClientFeatureToggleDelta.js.map +1 -1
  32. package/dist/lib/features/events/createEventsService.js +1 -1
  33. package/dist/lib/features/events/createEventsService.js.map +1 -1
  34. package/dist/lib/features/events/event-created-by-migration.test.js +1 -1
  35. package/dist/lib/features/events/event-created-by-migration.test.js.map +1 -1
  36. package/dist/lib/features/events/event-service.d.ts.map +1 -1
  37. package/dist/lib/features/events/event-service.js +6 -1
  38. package/dist/lib/features/events/event-service.js.map +1 -1
  39. package/dist/lib/features/events/event-store.d.ts +3 -1
  40. package/dist/lib/features/events/event-store.d.ts.map +1 -1
  41. package/dist/lib/features/events/event-store.js +10 -3
  42. package/dist/lib/features/events/event-store.js.map +1 -1
  43. package/dist/lib/features/events/event-store.test.js +1 -1
  44. package/dist/lib/features/events/event-store.test.js.map +1 -1
  45. package/dist/lib/features/feature-lifecycle/createFeatureLifecycle.js +1 -1
  46. package/dist/lib/features/feature-lifecycle/createFeatureLifecycle.js.map +1 -1
  47. package/dist/lib/features/feature-links/feature-link-service.d.ts +2 -1
  48. package/dist/lib/features/feature-links/feature-link-service.d.ts.map +1 -1
  49. package/dist/lib/features/feature-links/feature-link-service.js +4 -1
  50. package/dist/lib/features/feature-links/feature-link-service.js.map +1 -1
  51. package/dist/lib/features/feature-links/feature-link-service.test.js +11 -0
  52. package/dist/lib/features/feature-links/feature-link-service.test.js.map +1 -1
  53. package/dist/lib/features/feature-links/feature-link.e2e.test.js +1 -7
  54. package/dist/lib/features/feature-links/feature-link.e2e.test.js.map +1 -1
  55. package/dist/lib/features/feature-toggle/feature-toggle-controller.d.ts.map +1 -1
  56. package/dist/lib/features/feature-toggle/feature-toggle-controller.js +0 -8
  57. package/dist/lib/features/feature-toggle/feature-toggle-controller.js.map +1 -1
  58. package/dist/lib/features/instance-stats/createInstanceStatsService.js +1 -1
  59. package/dist/lib/features/instance-stats/createInstanceStatsService.js.map +1 -1
  60. package/dist/lib/features/metrics/client-metrics/metrics-service-v2.d.ts +3 -0
  61. package/dist/lib/features/metrics/client-metrics/metrics-service-v2.d.ts.map +1 -1
  62. package/dist/lib/features/metrics/client-metrics/metrics-service-v2.js +14 -1
  63. package/dist/lib/features/metrics/client-metrics/metrics-service-v2.js.map +1 -1
  64. package/dist/lib/features/metrics/impact/define-impact-metrics.d.ts +7 -0
  65. package/dist/lib/features/metrics/impact/define-impact-metrics.d.ts.map +1 -0
  66. package/dist/lib/features/metrics/impact/define-impact-metrics.js +11 -0
  67. package/dist/lib/features/metrics/impact/define-impact-metrics.js.map +1 -0
  68. package/dist/lib/features/metrics/impact/impact-metrics.e2e.test.d.ts +2 -0
  69. package/dist/lib/features/metrics/impact/impact-metrics.e2e.test.d.ts.map +1 -0
  70. package/dist/lib/features/metrics/impact/impact-metrics.e2e.test.js +131 -0
  71. package/dist/lib/features/metrics/impact/impact-metrics.e2e.test.js.map +1 -0
  72. package/dist/lib/features/metrics/impact/metrics-translator.d.ts +2 -3
  73. package/dist/lib/features/metrics/impact/metrics-translator.d.ts.map +1 -1
  74. package/dist/lib/features/metrics/instance/instance-service.d.ts.map +1 -1
  75. package/dist/lib/features/metrics/instance/instance-service.js +6 -16
  76. package/dist/lib/features/metrics/instance/instance-service.js.map +1 -1
  77. package/dist/lib/features/metrics/instance/metrics.d.ts +2 -0
  78. package/dist/lib/features/metrics/instance/metrics.d.ts.map +1 -1
  79. package/dist/lib/features/metrics/instance/metrics.js +15 -4
  80. package/dist/lib/features/metrics/instance/metrics.js.map +1 -1
  81. package/dist/lib/features/metrics/shared/schema.d.ts +3 -0
  82. package/dist/lib/features/metrics/shared/schema.d.ts.map +1 -1
  83. package/dist/lib/features/metrics/shared/schema.js +23 -0
  84. package/dist/lib/features/metrics/shared/schema.js.map +1 -1
  85. package/dist/lib/features/personal-dashboard/createPersonalDashboardService.js +1 -1
  86. package/dist/lib/features/personal-dashboard/createPersonalDashboardService.js.map +1 -1
  87. package/dist/lib/features/private-project/privateProjectStore.d.ts.map +1 -1
  88. package/dist/lib/features/private-project/privateProjectStore.js +10 -0
  89. package/dist/lib/features/private-project/privateProjectStore.js.map +1 -1
  90. package/dist/lib/features/project/createProjectService.js +1 -1
  91. package/dist/lib/features/project/createProjectService.js.map +1 -1
  92. package/dist/lib/features/project-status/createProjectStatusService.js +1 -1
  93. package/dist/lib/features/project-status/createProjectStatusService.js.map +1 -1
  94. package/dist/lib/metrics.d.ts.map +1 -1
  95. package/dist/lib/metrics.js +2 -0
  96. package/dist/lib/metrics.js.map +1 -1
  97. package/dist/lib/middleware/request-logger.d.ts.map +1 -1
  98. package/dist/lib/middleware/request-logger.js +8 -0
  99. package/dist/lib/middleware/request-logger.js.map +1 -1
  100. package/dist/lib/openapi/spec/addon-type-schema.d.ts +4 -4
  101. package/dist/lib/openapi/spec/addon-type-schema.js +4 -4
  102. package/dist/lib/openapi/spec/addon-type-schema.js.map +1 -1
  103. package/dist/lib/openapi/spec/addons-schema.d.ts +4 -4
  104. package/dist/lib/openapi/spec/bulk-metrics-schema.d.ts +61 -0
  105. package/dist/lib/openapi/spec/bulk-metrics-schema.d.ts.map +1 -1
  106. package/dist/lib/openapi/spec/bulk-metrics-schema.js +9 -0
  107. package/dist/lib/openapi/spec/bulk-metrics-schema.js.map +1 -1
  108. package/dist/lib/openapi/spec/event-schema.d.ts +11 -1
  109. package/dist/lib/openapi/spec/event-schema.d.ts.map +1 -1
  110. package/dist/lib/openapi/spec/event-schema.js +10 -0
  111. package/dist/lib/openapi/spec/event-schema.js.map +1 -1
  112. package/dist/lib/openapi/spec/event-search-query-parameters.d.ts +18 -0
  113. package/dist/lib/openapi/spec/event-search-query-parameters.d.ts.map +1 -1
  114. package/dist/lib/openapi/spec/event-search-query-parameters.js +20 -0
  115. package/dist/lib/openapi/spec/event-search-query-parameters.js.map +1 -1
  116. package/dist/lib/openapi/spec/event-search-response-schema.d.ts +11 -1
  117. package/dist/lib/openapi/spec/event-search-response-schema.d.ts.map +1 -1
  118. package/dist/lib/openapi/spec/events-schema.d.ts +11 -1
  119. package/dist/lib/openapi/spec/events-schema.d.ts.map +1 -1
  120. package/dist/lib/openapi/spec/feature-events-schema.d.ts +11 -1
  121. package/dist/lib/openapi/spec/feature-events-schema.d.ts.map +1 -1
  122. package/dist/lib/openapi/spec/impact-metrics-schema.d.ts +57 -0
  123. package/dist/lib/openapi/spec/impact-metrics-schema.d.ts.map +1 -0
  124. package/dist/lib/openapi/spec/impact-metrics-schema.js +55 -0
  125. package/dist/lib/openapi/spec/impact-metrics-schema.js.map +1 -0
  126. package/dist/lib/openapi/spec/index.d.ts +1 -0
  127. package/dist/lib/openapi/spec/index.d.ts.map +1 -1
  128. package/dist/lib/openapi/spec/index.js +1 -0
  129. package/dist/lib/openapi/spec/index.js.map +1 -1
  130. package/dist/lib/openapi/spec/integration-event-schema.d.ts +11 -1
  131. package/dist/lib/openapi/spec/integration-event-schema.d.ts.map +1 -1
  132. package/dist/lib/openapi/spec/integration-events-schema.d.ts +22 -2
  133. package/dist/lib/openapi/spec/integration-events-schema.d.ts.map +1 -1
  134. package/dist/lib/server-impl.d.ts +1 -1
  135. package/dist/lib/server-impl.d.ts.map +1 -1
  136. package/dist/lib/server-impl.js +21 -14
  137. package/dist/lib/server-impl.js.map +1 -1
  138. package/dist/lib/services/email-service.d.ts +7 -0
  139. package/dist/lib/services/email-service.d.ts.map +1 -1
  140. package/dist/lib/services/email-service.js +35 -0
  141. package/dist/lib/services/email-service.js.map +1 -1
  142. package/dist/lib/types/experimental.d.ts +9 -1
  143. package/dist/lib/types/experimental.d.ts.map +1 -1
  144. package/dist/lib/types/experimental.js +3 -2
  145. package/dist/lib/types/experimental.js.map +1 -1
  146. package/dist/lib/types/option.d.ts +2 -0
  147. package/dist/lib/types/option.d.ts.map +1 -1
  148. package/dist/lib/types/stores/client-instance-store.d.ts +0 -5
  149. package/dist/lib/types/stores/client-instance-store.d.ts.map +1 -1
  150. package/dist/lib/types/stores/event-store.d.ts +3 -0
  151. package/dist/lib/types/stores/event-store.d.ts.map +1 -1
  152. package/dist/lib/util/flag-resolver.d.ts +2 -1
  153. package/dist/lib/util/flag-resolver.d.ts.map +1 -1
  154. package/dist/lib/util/flag-resolver.js +3 -0
  155. package/dist/lib/util/flag-resolver.js.map +1 -1
  156. package/dist/mailtemplates/requested-cr-approval/requested-cr-approval.html.mustache +39 -0
  157. package/dist/mailtemplates/requested-cr-approval/requested-cr-approval.plain.mustache +3 -0
  158. package/dist/migrations/20250618090103-create-cr-requested-approvals.d.ts +6 -0
  159. package/dist/migrations/20250618090103-create-cr-requested-approvals.d.ts.map +1 -0
  160. package/dist/migrations/20250618090103-create-cr-requested-approvals.js +19 -0
  161. package/dist/migrations/20250618090103-create-cr-requested-approvals.js.map +1 -0
  162. package/dist/migrations/20250623100820-cr-requested-approvals-add-notified-at-column.d.ts +3 -0
  163. package/dist/migrations/20250623100820-cr-requested-approvals-add-notified-at-column.d.ts.map +1 -0
  164. package/dist/migrations/20250623100820-cr-requested-approvals-add-notified-at-column.js +11 -0
  165. package/dist/migrations/20250623100820-cr-requested-approvals-add-notified-at-column.js.map +1 -0
  166. package/dist/migrations/20250630114145-add-transaction-context-to-events.d.ts +3 -0
  167. package/dist/migrations/20250630114145-add-transaction-context-to-events.d.ts.map +1 -0
  168. package/dist/migrations/20250630114145-add-transaction-context-to-events.js +16 -0
  169. package/dist/migrations/20250630114145-add-transaction-context-to-events.js.map +1 -0
  170. package/dist/migrator.d.ts +1 -0
  171. package/dist/migrator.d.ts.map +1 -1
  172. package/dist/migrator.js +17 -0
  173. package/dist/migrator.js.map +1 -1
  174. package/dist/server-dev.js +4 -0
  175. package/dist/server-dev.js.map +1 -1
  176. package/dist/test/e2e/api/admin/event-search.e2e.test.js +175 -0
  177. package/dist/test/e2e/api/admin/event-search.e2e.test.js.map +1 -1
  178. package/dist/test/e2e/stores/event-store.e2e.test.js +224 -0
  179. package/dist/test/e2e/stores/event-store.e2e.test.js.map +1 -1
  180. package/dist/test/fixtures/fake-client-instance-store.d.ts +0 -1
  181. package/dist/test/fixtures/fake-client-instance-store.d.ts.map +1 -1
  182. package/dist/test/fixtures/fake-client-instance-store.js +0 -3
  183. package/dist/test/fixtures/fake-client-instance-store.js.map +1 -1
  184. package/dist/test/fixtures/fake-impact-metrics.d.ts +15 -0
  185. package/dist/test/fixtures/fake-impact-metrics.d.ts.map +1 -0
  186. package/dist/test/fixtures/fake-impact-metrics.js +27 -0
  187. package/dist/test/fixtures/fake-impact-metrics.js.map +1 -0
  188. package/frontend/build/index.html +1 -1
  189. package/frontend/build/static/AdvancedPlayground-D-6uZDZr.js +3 -0
  190. package/frontend/build/static/BackendConnections-C-DXtgIJ.js +1 -0
  191. package/frontend/build/static/{CreateProject-9XUQN1SU.js → CreateProject-C8ofwZq1.js} +1 -1
  192. package/frontend/build/static/FeatureMetricsChart-uzxl5gXR.js +2 -0
  193. package/frontend/build/static/{FeatureStaleDialog-Q5amMPCM.js → FeatureStaleDialog-BKCmTzFV.js} +2 -2
  194. package/frontend/build/static/FeatureViewLazyExport-CobGy6XS.js +10 -0
  195. package/frontend/build/static/{FlagMetricsChart-d-DcBEd3.js → FlagMetricsChart-VYTYbbQS.js} +2 -2
  196. package/frontend/build/static/FrontendNetworkTrafficUsage-CFIzAiX3.js +1 -0
  197. package/frontend/build/static/{LazyAdminExport-6l0-2zFb.js → LazyAdminExport-CRoU3u-1.js} +12 -12
  198. package/frontend/build/static/{LazyProjectExport-CPe5in4-.js → LazyProjectExport-DwhYVXhl.js} +35 -35
  199. package/frontend/build/static/{LifecycleChartComponent-B2yYCoKI.js → LifecycleChartComponent-CqpS04x5.js} +2 -2
  200. package/frontend/build/static/{LineChartComponent-D27zBmU-.js → LineChartComponent-B4SCTZZg.js} +1 -1
  201. package/frontend/build/static/MarkCompletedDialogue-BKJahqUx.js +1 -0
  202. package/frontend/build/static/{NetworkConnectedEdges-1WVw8Eu8.js → NetworkConnectedEdges-Ki1G9nG8.js} +1 -1
  203. package/frontend/build/static/{NetworkOverview-CVDK-eSI.js → NetworkOverview-CDZIrvNW.js} +1 -1
  204. package/frontend/build/static/{NetworkPrometheusAPIWarning-DmpG0G0j.js → NetworkPrometheusAPIWarning-DPJmw0yM.js} +1 -1
  205. package/frontend/build/static/{NetworkTraffic-CyPjdgMv.js → NetworkTraffic-Sq_m8XpD.js} +1 -1
  206. package/frontend/build/static/{NetworkTrafficUsage-C8VwLm0h.js → NetworkTrafficUsage-D8jRHO10.js} +1 -1
  207. package/frontend/build/static/{ReactJSONEditor-DseXcTHD.js → ReactJSONEditor-BCSMMPUN.js} +32 -32
  208. package/frontend/build/static/RoleCell-ndjYcZ1T.js +1 -0
  209. package/frontend/build/static/{aggregateFeatureMetrics-COQ_COHJ.js → aggregateFeatureMetrics-CFI2n6i7.js} +1 -1
  210. package/frontend/build/static/{formatTickValue-D_CAvIVf.js → formatTickValue-D9avlj7O.js} +2 -2
  211. package/frontend/build/static/{index-CKXZ0XnY.js → index-Bj8wwcOa.js} +10 -10
  212. package/frontend/build/static/index-DvDCZTAu.js +538 -0
  213. package/frontend/build/static/useApiTokens-BZGgHseg.js +1 -0
  214. package/frontend/build/static/{useChartDataSelection-BfTrFKbU.js → useChartDataSelection-OwfBPL7x.js} +1 -1
  215. package/frontend/package.json +10 -10
  216. package/package.json +13 -13
  217. package/frontend/build/static/AdvancedPlayground-BoqY20Mb.js +0 -3
  218. package/frontend/build/static/BackendConnections-BspEzNo_.js +0 -1
  219. package/frontend/build/static/FeatureMetricsChart-LENYZ5kx.js +0 -2
  220. package/frontend/build/static/FeatureViewLazyExport-BU9aw-MC.js +0 -10
  221. package/frontend/build/static/FrontendNetworkTrafficUsage-7YK-sjpZ.js +0 -1
  222. package/frontend/build/static/MarkCompletedDialogue-SyWeA6AL.js +0 -1
  223. package/frontend/build/static/RoleCell-DJbKzxr1.js +0 -4
  224. package/frontend/build/static/index-Yy9_7TKN.js +0 -535
  225. package/frontend/build/static/useApiTokens-DE54gK5i.js +0 -1
@@ -1,10 +0,0 @@
1
- import{aG as fs,aH as ys,_ as jt,aI as bn,a as J,aJ as We,j as t,s as g,aK as vn,aL as we,r as x,aM as ms,b as Pe,aN as pt,aO as $e,aP as js,aQ as A,aR as W,aS as Sn,V as Z,A as Cn,m as bs,l as vs,n as Tn,o as wn,aT as Ss,u as Cs,h as q,as as ie,aU as pe,aV as ce,e as H,aW as bt,aX as te,aY as ue,B as z,T as L,C as B,aZ as kn,L as ae,D as xe,J as Rn,y as ee,a_ as vt,a$ as Dn,M as ve,b0 as De,b1 as He,b2 as Se,b3 as Ts,b4 as Ue,b5 as K,b6 as ws,b7 as zt,b8 as Ge,b9 as Fe,ba as ks,bb as Oe,bc as Te,bd as Rs,be as An,bf as Ye,bg as En,bh as Ds,bi as Ce,t as As,bj as Es,bk as Is,bl as In,v as $n,bm as Pn,bn as Fn,i as ne,bo as On,bp as _n,bq as Bn,br as zn,bs as $s,bt as le,am as Ln,bu as Mn,bv as Vn,bw as St,bx as Ct,by as Ve,bz as Nn,bA as qn,N as Ae,bB as Lt,bC as Wn,bD as Hn,bE as Un,bF as Gn,bG as _e,bH as Yn,bI as Jn,bJ as Kn,bK as Ps,bL as Qn,bM as Xn,bN as Zn,bO as ea,bP as be,bQ as ta,bR as sa,bS as Tt,bT as na,bU as aa,bV as oa,bW as ra,bX as ia,bY as Fs,bZ as Os,b_ as _s,b$ as Be,O as ca,a3 as la,c0 as da,K as wt,c1 as ua,c2 as Bs,c3 as pa,c4 as ga,c5 as Je,c6 as ha,c7 as xa,c8 as zs,c9 as fa,ca as kt,cb as ya,cc as Ne,cd as Ls,ce as ma,al as Ke,cf as ja,cg as Ms,ch as ba,ci as va,cj as Sa,ck as Ca,cl as Ta,cm as Qe,cn as wa,co as Vs,cp as ka,cq as gt,cr as Ns,cs as Ra,ct as Da,cu as Aa,cv as Ea,cw as Ia,cx as $a,cy as Pa,cz as Fa,cA as Re,cB as Oa,cC as _a,a8 as Ba,a9 as Xe,aa as Mt,cD as za,cE as La,cF as Ma,cG as Va,cH as Na,cI as qs,cJ as qa,G as Ee,H as Ie,cK as Wa,cL as Ha,cM as Ua,cN as Ga,cO as Ya,cP as Ja,cQ as Ws,cR as Ka,cS as Hs,cT as Qa,cU as Xa,cV as Us,cW as je,cX as ht,cY as Za,cZ as Gs,E as Ys,c_ as eo,c$ as to,f as so,d0 as no,d1 as Ze,d2 as Vt,aF as ao,d3 as ke,d4 as Nt,d5 as oo,d6 as ro,d7 as io,aC as Rt,aD as co,ax as qt,d8 as lo,d9 as uo,da as po,db as Wt,ak as qe,dc as go,ac as et,ao as ho,ae as xo,af as fo,ag as yo,ah as mo,ai as jo,aj as bo,dd as he,de as vo,df as So,dg as Ht,dh as Co,di as To,dj as tt,dk as wo,dl as ko,dm as Ro,x as Js,dn as Do,dp as Ut,dq as Ao,dr as Eo,ds as Io,d as $o,dt as Po,du as Fo,dv as Oo,dw as _o,dx as Bo,dy as zo,dz as Lo,dA as Mo,dB as Vo,au as No}from"./index-Yy9_7TKN.js";import{u as qo,a as Wo,F as Dt,M as Ks}from"./MarkCompletedDialogue-SyWeA6AL.js";import{F as At,a as xt,u as Qs,b as Ho,c as Uo}from"./aggregateFeatureMetrics-COQ_COHJ.js";import{u as Go,a as Yo,T as Jo,b as Ko,c as Qo,d as Xo,F as Zo,C as er,e as tr,E as sr,f as nr}from"./FeatureStaleDialog-Q5amMPCM.js";function ar(e){return ys("MuiPagination",e)}fs("MuiPagination",["root","ul","outlined","text"]);const or=["boundaryCount","componentName","count","defaultPage","disabled","hideNextButton","hidePrevButton","onChange","page","showFirstButton","showLastButton","siblingCount"];function rr(e={}){const{boundaryCount:s=1,componentName:n="usePagination",count:a=1,defaultPage:o=1,disabled:r=!1,hideNextButton:i=!1,hidePrevButton:l=!1,onChange:c,page:p,showFirstButton:u=!1,showLastButton:d=!1,siblingCount:m=1}=e,j=jt(e,or),[h,v]=bn({controlled:p,default:o,name:n,state:"page"}),y=(R,M)=>{p||v(M),c&&c(R,M)},f=(R,M)=>{const G=M-R+1;return Array.from({length:G},(Q,C)=>R+C)},w=f(1,Math.min(s,a)),E=f(Math.max(a-s+1,s+1),a),O=Math.max(Math.min(h-m,a-s-m*2-1),s+2),_=Math.min(Math.max(h+m,s+m*2+2),E.length>0?E[0]-2:a-1),$=[...u?["first"]:[],...l?[]:["previous"],...w,...O>s+2?["start-ellipsis"]:s+1<a-s?[s+1]:[],...f(O,_),..._<a-s-1?["end-ellipsis"]:a-s>s?[a-s]:[],...E,...i?[]:["next"],...d?["last"]:[]],D=R=>{switch(R){case"first":return 1;case"previous":return h-1;case"next":return h+1;case"last":return a;default:return null}},I=$.map(R=>typeof R=="number"?{onClick:M=>{y(M,R)},type:"page",page:R,selected:R===h,disabled:r,"aria-current":R===h?"true":void 0}:{onClick:M=>{y(M,D(R))},type:R,page:D(R),selected:!1,disabled:r||R.indexOf("ellipsis")===-1&&(R==="next"||R==="last"?h>=a:h<=1)});return J({items:I},j)}function ir(e){return ys("MuiPaginationItem",e)}const se=fs("MuiPaginationItem",["root","page","sizeSmall","sizeLarge","text","textPrimary","textSecondary","outlined","outlinedPrimary","outlinedSecondary","rounded","ellipsis","firstLast","previousNext","focusVisible","disabled","selected","icon"]),Gt=We(t.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"}),"FirstPage"),Yt=We(t.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"}),"LastPage"),Jt=We(t.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"}),"NavigateBefore"),Kt=We(t.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}),"NavigateNext"),cr=["className","color","component","components","disabled","page","selected","shape","size","slots","type","variant"],Xs=(e,s)=>{const{ownerState:n}=e;return[s.root,s[n.variant],s[`size${$e(n.size)}`],n.variant==="text"&&s[`text${$e(n.color)}`],n.variant==="outlined"&&s[`outlined${$e(n.color)}`],n.shape==="rounded"&&s.rounded,n.type==="page"&&s.page,(n.type==="start-ellipsis"||n.type==="end-ellipsis")&&s.ellipsis,(n.type==="previous"||n.type==="next")&&s.previousNext,(n.type==="first"||n.type==="last")&&s.firstLast]},lr=e=>{const{classes:s,color:n,disabled:a,selected:o,size:r,shape:i,type:l,variant:c}=e,p={root:["root",`size${$e(r)}`,c,i,n!=="standard"&&`${c}${$e(n)}`,a&&"disabled",o&&"selected",{page:"page",first:"firstLast",last:"firstLast","start-ellipsis":"ellipsis","end-ellipsis":"ellipsis",previous:"previousNext",next:"previousNext"}[l]],icon:["icon"]};return js(p,ir,s)},dr=g("div",{name:"MuiPaginationItem",slot:"Root",overridesResolver:Xs})(({theme:e,ownerState:s})=>J({},e.typography.body2,{borderRadius:32/2,textAlign:"center",boxSizing:"border-box",minWidth:32,padding:"0 6px",margin:"0 3px",color:(e.vars||e).palette.text.primary,height:"auto",[`&.${se.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity}},s.size==="small"&&{minWidth:26,borderRadius:26/2,margin:"0 1px",padding:"0 4px"},s.size==="large"&&{minWidth:40,borderRadius:40/2,padding:"0 10px",fontSize:e.typography.pxToRem(15)})),ur=g(vn,{name:"MuiPaginationItem",slot:"Root",overridesResolver:Xs})(({theme:e,ownerState:s})=>J({},e.typography.body2,{borderRadius:32/2,textAlign:"center",boxSizing:"border-box",minWidth:32,height:32,padding:"0 6px",margin:"0 3px",color:(e.vars||e).palette.text.primary,[`&.${se.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${se.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},transition:e.transitions.create(["color","background-color"],{duration:e.transitions.duration.short}),"&:hover":{backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${se.selected}`]:{backgroundColor:(e.vars||e).palette.action.selected,"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette.action.selectedChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.hoverOpacity}))`:we(e.palette.action.selected,e.palette.action.selectedOpacity+e.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:(e.vars||e).palette.action.selected}},[`&.${se.focusVisible}`]:{backgroundColor:e.vars?`rgba(${e.vars.palette.action.selectedChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.focusOpacity}))`:we(e.palette.action.selected,e.palette.action.selectedOpacity+e.palette.action.focusOpacity)},[`&.${se.disabled}`]:{opacity:1,color:(e.vars||e).palette.action.disabled,backgroundColor:(e.vars||e).palette.action.selected}}},s.size==="small"&&{minWidth:26,height:26,borderRadius:26/2,margin:"0 1px",padding:"0 4px"},s.size==="large"&&{minWidth:40,height:40,borderRadius:40/2,padding:"0 10px",fontSize:e.typography.pxToRem(15)},s.shape==="rounded"&&{borderRadius:(e.vars||e).shape.borderRadius}),({theme:e,ownerState:s})=>J({},s.variant==="text"&&{[`&.${se.selected}`]:J({},s.color!=="standard"&&{color:(e.vars||e).palette[s.color].contrastText,backgroundColor:(e.vars||e).palette[s.color].main,"&:hover":{backgroundColor:(e.vars||e).palette[s.color].dark,"@media (hover: none)":{backgroundColor:(e.vars||e).palette[s.color].main}},[`&.${se.focusVisible}`]:{backgroundColor:(e.vars||e).palette[s.color].dark}},{[`&.${se.disabled}`]:{color:(e.vars||e).palette.action.disabled}})},s.variant==="outlined"&&{border:e.vars?`1px solid rgba(${e.vars.palette.common.onBackgroundChannel} / 0.23)`:`1px solid ${e.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)"}`,[`&.${se.selected}`]:J({},s.color!=="standard"&&{color:(e.vars||e).palette[s.color].main,border:`1px solid ${e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / 0.5)`:we(e.palette[s.color].main,.5)}`,backgroundColor:e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / ${e.vars.palette.action.activatedOpacity})`:we(e.palette[s.color].main,e.palette.action.activatedOpacity),"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / calc(${e.vars.palette.action.activatedOpacity} + ${e.vars.palette.action.focusOpacity}))`:we(e.palette[s.color].main,e.palette.action.activatedOpacity+e.palette.action.focusOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${se.focusVisible}`]:{backgroundColor:e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / calc(${e.vars.palette.action.activatedOpacity} + ${e.vars.palette.action.focusOpacity}))`:we(e.palette[s.color].main,e.palette.action.activatedOpacity+e.palette.action.focusOpacity)}},{[`&.${se.disabled}`]:{borderColor:(e.vars||e).palette.action.disabledBackground,color:(e.vars||e).palette.action.disabled}})})),pr=g("div",{name:"MuiPaginationItem",slot:"Icon",overridesResolver:(e,s)=>s.icon})(({theme:e,ownerState:s})=>J({fontSize:e.typography.pxToRem(20),margin:"0 -8px"},s.size==="small"&&{fontSize:e.typography.pxToRem(18)},s.size==="large"&&{fontSize:e.typography.pxToRem(22)})),gr=x.forwardRef(function(s,n){const a=ms({props:s,name:"MuiPaginationItem"}),{className:o,color:r="standard",component:i,components:l={},disabled:c=!1,page:p,selected:u=!1,shape:d="circular",size:m="medium",slots:j={},type:h="page",variant:v="text"}=a,y=jt(a,cr),f=J({},a,{color:r,disabled:c,selected:u,shape:d,size:m,type:h,variant:v}),w=Pe(),E=lr(f),_=(w.direction==="rtl"?{previous:j.next||l.next||Kt,next:j.previous||l.previous||Jt,last:j.first||l.first||Gt,first:j.last||l.last||Yt}:{previous:j.previous||l.previous||Jt,next:j.next||l.next||Kt,first:j.first||l.first||Gt,last:j.last||l.last||Yt})[h];return h==="start-ellipsis"||h==="end-ellipsis"?t.jsx(dr,{ref:n,ownerState:f,className:pt(E.root,o),children:"…"}):t.jsxs(ur,J({ref:n,ownerState:f,component:i,disabled:c,className:pt(E.root,o)},y,{children:[h==="page"&&p,_?t.jsx(pr,{as:_,ownerState:f,className:E.icon}):null]}))}),hr=["boundaryCount","className","color","count","defaultPage","disabled","getItemAriaLabel","hideNextButton","hidePrevButton","onChange","page","renderItem","shape","showFirstButton","showLastButton","siblingCount","size","variant"],xr=e=>{const{classes:s,variant:n}=e;return js({root:["root",n],ul:["ul"]},ar,s)},fr=g("nav",{name:"MuiPagination",slot:"Root",overridesResolver:(e,s)=>{const{ownerState:n}=e;return[s.root,s[n.variant]]}})({}),yr=g("ul",{name:"MuiPagination",slot:"Ul",overridesResolver:(e,s)=>s.ul})({display:"flex",flexWrap:"wrap",alignItems:"center",padding:0,margin:0,listStyle:"none"});function mr(e,s,n){return e==="page"?`${n?"":"Go to "}page ${s}`:`Go to ${e} page`}const jr=x.forwardRef(function(s,n){const a=ms({props:s,name:"MuiPagination"}),{boundaryCount:o=1,className:r,color:i="standard",count:l=1,defaultPage:c=1,disabled:p=!1,getItemAriaLabel:u=mr,hideNextButton:d=!1,hidePrevButton:m=!1,renderItem:j=I=>t.jsx(gr,J({},I)),shape:h="circular",showFirstButton:v=!1,showLastButton:y=!1,siblingCount:f=1,size:w="medium",variant:E="text"}=a,O=jt(a,hr),{items:_}=rr(J({},a,{componentName:"Pagination"})),$=J({},a,{boundaryCount:o,color:i,count:l,defaultPage:c,disabled:p,getItemAriaLabel:u,hideNextButton:d,hidePrevButton:m,renderItem:j,shape:h,showFirstButton:v,showLastButton:y,siblingCount:f,size:w,variant:E}),D=xr($);return t.jsx(fr,J({"aria-label":"pagination navigation",className:pt(D.root,r),ownerState:$,ref:n},O,{children:t.jsx(yr,{className:D.ul,ownerState:$,children:_.map((I,R)=>t.jsx("li",{children:j(J({},I,{color:i,"aria-label":u(I.type,I.page,I.selected),shape:h,size:w,variant:E}))},R))})}))}),br=()=>{const e=A("projectId"),s=A("featureId"),{feature:n}=W(e,s);return n.name?t.jsx(Sn,{title:"Event log",feature:s}):null},vr=()=>t.jsxs(Z,{severity:"warning",children:["Remember to update your Unleash client! Feature dependencies require new SDK versions. Read more about ",t.jsx(Sr,{}),"."]}),Sr=()=>t.jsx("a",{href:"https://docs.getunleash.io/reference/feature-toggles#feature-flag-dependencies",target:"_blank",rel:"noreferrer",children:"Client SDK support for feature dependencies"}),Cr=g(Cn)(({theme:e})=>({marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),Tr=({project:e,parent:s,onSelect:n,selectedValues:a})=>{const{parentVariantOptions:o}=qo(e,s),r=t.jsx(Tn,{fontSize:"small"}),i=t.jsx(wn,{fontSize:"small"});return t.jsx(Cr,{multiple:!0,id:"parent-variant-options",options:o,disableCloseOnSelect:!0,renderOption:(l,c,{selected:p})=>t.jsxs("li",{...l,children:[t.jsx(bs,{icon:r,checkedIcon:i,style:{marginRight:8},checked:p}),c]}),renderInput:l=>t.jsx(vs,{...l,placeholder:"Select values"}),fullWidth:!0,value:a,onChange:(l,c)=>{n(c)}})},de={key:"none (remove dependency)",label:"none (remove dependency)"},Zs=g(Ss)(({theme:e})=>({marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),wr=({onSelect:e,parentValue:s})=>t.jsx(Zs,{fullWidth:!0,options:[{key:"enabled",label:"enabled"},{key:"enabled_with_variants",label:"enabled with variants"},{key:"disabled",label:"disabled"}],value:s.status,onChange:e}),en=e=>{const{makeRequest:s,createRequest:n,errors:a,loading:o}=Cs({propagateErrors:!0}),r=async(p,u)=>{const d=n(`/api/admin/projects/${e}/features/${p}/dependencies`,{method:"POST",body:JSON.stringify(u)});await s(d.caller,d.id)},i=async(p,u)=>{const d=n(`/api/admin/projects/${e}/features/${p}/dependencies/${u}`,{method:"DELETE"});await s(d.caller,d.id)},l=async p=>{const u=n(`/api/admin/projects/${e}/features/${p}/dependencies`,{method:"DELETE"});await s(u.caller,u.id)},c=[n,s,q,e];return{addDependency:x.useCallback(r,c),removeDependency:x.useCallback(i,c),removeDependencies:x.useCallback(l,c),errors:a,loading:o}},kr=(e,s,n,a,o)=>{const{trackEvent:r}=ie(),{addChange:i}=pe(),{refetch:l}=ce(e),{setToastData:c,setToastApiError:p}=H(),{refetchFeature:u}=W(e,s),d=bt(e)(),{isChangeRequestConfiguredInAnyEnv:m}=te(e),{addDependency:j,removeDependencies:h}=en(e),v=async y=>{if(!d){console.error("No change request environment");return}y==="addDependency"&&(await i(e,d,[{action:y,feature:s,payload:{feature:n,enabled:a.status!=="disabled",variants:a.status==="enabled_with_variants"?a.variants:[]}}]),r("dependent_features",{props:{eventType:"dependency added"}})),y==="deleteDependency"&&await i(e,d,[{action:y,feature:s,payload:void 0}]),l(),c({type:"success",text:"Change added to draft"})};return async()=>{try{if(m()){const y=n===de.key?"deleteDependency":"addDependency";await v(y),r("dependent_features",{props:{eventType:y==="addDependency"?"add dependency added to change request":"delete dependency added to change request"}})}else n===de.key?(await h(s),r("dependent_features",{props:{eventType:"dependency removed"}}),c({text:"Dependency removed",type:"success"})):(await j(s,{feature:n,enabled:a.status!=="disabled",variants:a.status==="enabled_with_variants"?a.variants:[]}),r("dependent_features",{props:{eventType:"dependency added"}}),c({text:"Dependency added",type:"success"}))}catch(y){p(q(y))}u(),o()}},Rr=({project:e,featureId:s,parent:n,onSelect:a})=>{const{parentOptions:o}=Wo(e,s),r=o?[de,...o.map(i=>({key:i,label:i}))]:[de];return t.jsx(Zs,{fullWidth:!0,options:r,value:n,onChange:a})},Dr=({project:e,featureId:s,parentDependency:n,showDependencyDialogue:a,onClose:o})=>{const[r,i]=x.useState((n==null?void 0:n.feature)||de.key),l=()=>{var f;return n?(f=n.variants)!=null&&f.length?{status:"enabled_with_variants",variants:n.variants}:n.enabled===!1?{status:"disabled"}:{status:"enabled"}:{status:"enabled"}},[c,p]=x.useState(l),u=()=>{i((n==null?void 0:n.feature)||de.key),p(l())};x.useEffect(()=>{u()},[JSON.stringify(n)]);const d=kr(e,s,r,c,o),{isChangeRequestConfiguredInAnyEnv:m}=te(e),j=r!==de.key,h=r!==de.key&&c.status==="enabled_with_variants",v=f=>{(f==="enabled"||f==="disabled")&&p({status:f}),f==="enabled_with_variants"&&p({status:f,variants:[]})},y=f=>{p({status:"enabled_with_variants",variants:f})};return t.jsx(ue,{open:a,title:"Add parent flag dependency",onClose:o,onClick:d,primaryButtonText:m()?"Add change to draft":r===de.key?"Remove":"Add",secondaryButtonText:"Cancel",children:t.jsxs(z,{children:[t.jsx(vr,{}),t.jsxs(z,{sx:{mt:2,mb:4},children:["Your feature will be evaluated only when the selected parent feature is"," ",t.jsx("b",{children:c.status==="disabled"?"disabled":"enabled"})," ","in the same environment."]}),t.jsxs(L,{children:["What ",t.jsx("b",{children:"feature"})," do you want to depend on?"]}),t.jsx(B,{condition:a,show:t.jsx(Rr,{project:e,featureId:s,parent:r,onSelect:f=>{p({status:"enabled"}),i(f)}})}),t.jsx(B,{condition:j,show:t.jsxs(z,{sx:{mt:2},children:[t.jsxs(L,{children:["What ",t.jsx("b",{children:"feature status"})," do you want to depend on?"]}),t.jsx(wr,{parentValue:c,onSelect:v})]})}),t.jsx(B,{condition:h,show:c.status==="enabled_with_variants"&&t.jsxs(z,{sx:{mt:2},children:[t.jsxs(L,{children:["What ",t.jsx("b",{children:"variant"})," do you want to depend on?"]}),t.jsx(Tr,{parent:r,project:e,selectedValues:c.variants,onSelect:y})]})})]})})};g("div")({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"});g("div")(({theme:e})=>({justifyContent:"center",paddingTop:e.spacing(.75),...kn}));g("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)}));const Et=g(ae)(({theme:e})=>({maxWidth:"100%",textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}})),Ar=g(xe)(({theme:e})=>({height:e.spacing(3.5),width:e.spacing(3.5)})),Er=g(Rn)(({theme:e})=>({borderRadius:e.shape.borderRadiusLarge,padding:e.spacing(1,1.5)})),tn=({capabilityId:e,feature:s,onEdit:n,onDelete:a})=>{const o=`${e}-${s}-actions`,r=`${o}-menu`,[i,l]=x.useState(null),c=!!i,p=d=>{l(d.currentTarget)},u=()=>{l(null)};return t.jsxs(z,{children:[t.jsx(ee,{title:"Dependency actions",arrow:!0,describeChild:!0,children:t.jsx(Ar,{id:o,"aria-controls":c?r:void 0,"aria-haspopup":"true","aria-expanded":c?"true":void 0,onClick:p,type:"button",children:t.jsx(vt,{})})}),t.jsx(Er,{id:r,anchorEl:i,open:c,onClose:u,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,children:t.jsxs(Dn,{"aria-labelledby":o,children:[t.jsxs(ve,{onClick:()=>{n(),u()},children:[t.jsx(De,{children:t.jsx(He,{})}),t.jsx(Se,{children:t.jsx(L,{variant:"body2",children:"Edit"})})]}),t.jsxs(ve,{onClick:()=>{a(),u()},children:[t.jsx(De,{children:t.jsx(Ts,{})}),t.jsx(Se,{children:t.jsx(L,{variant:"body2",children:"Delete"})})]})]})})]})},Ir=({childFeatures:e,project:s})=>t.jsx(Ue,{tooltip:t.jsx(t.Fragment,{children:e.map(n=>t.jsx(Et,{to:`/projects/${s}/features/${n}`,children:t.jsx("div",{children:n})},`${s}-${n}`))}),children:e.length===1?"1 feature":`${e.length} features`}),$r=({variants:e})=>e.length===1&&e[0].length<20?t.jsx("span",{children:e[0]}):t.jsx(Ue,{tooltip:t.jsx(t.Fragment,{children:e.map((s,n)=>t.jsx("div",{children:s},n))}),children:e.length===1?"1 variant":`${e.length} variants`}),Pr=g(K)(({theme:e})=>({fontSize:e.fontSizes.smallBody,lineHeight:e.typography.body1.lineHeight})),Fr=(e,s)=>{const{trackEvent:n}=ie(),{addChange:a}=pe(),{refetch:o}=ce(e),{setToastData:r,setToastApiError:i}=H(),{refetchFeature:l}=W(e,s),c=bt(e)(),{isChangeRequestConfiguredInAnyEnv:p}=te(e),{removeDependencies:u}=en(e),d=async()=>{if(!c){console.error("No change request environment");return}await a(e,c,[{action:"deleteDependency",feature:s,payload:void 0}])};return async()=>{try{p()?(await d(),n("dependent_features",{props:{eventType:"delete dependency added to change request"}}),r({type:"success",text:"Change added to draft"}),await o()):(await u(s),n("dependent_features",{props:{eventType:"dependency removed"}}),r({text:"Dependency removed",type:"success"}),await l())}catch(j){i(q(j))}}},Or=({feature:e})=>{var p,u,d,m,j,h,v;const[s,n]=x.useState(!1),a=!!e.project&&e.dependencies.length===0&&e.children.length===0,o=!!e.project&&e.dependencies.length>0,r=!!e.project&&e.children.length>0,i=bt(e.project)(),l=ws(e.project),c=Fr(e.project,e.name);return t.jsxs(t.Fragment,{children:[a?t.jsxs(X,{children:[t.jsx(re,{children:"Dependency:"}),t.jsx("div",{children:t.jsx(Pr,{size:"small",permission:zt,projectId:e.project,variant:"text",onClick:()=>{n(!0)},children:"Add parent flag"})})]}):null,o?t.jsxs(X,{children:[t.jsx(re,{children:"Dependency:"}),t.jsxs(yt,{children:[t.jsx(Et,{to:`/projects/${e.project}/features/${(p=e.dependencies[0])==null?void 0:p.feature}`,children:t.jsx(Ge,{title:(u=e.dependencies[0])==null?void 0:u.feature,children:(d=e.dependencies[0])==null?void 0:d.feature})}),l(zt,i)?t.jsx(tn,{capabilityId:"dependency",feature:e.name,onEdit:()=>n(!0),onDelete:c}):null]})]}):null,o&&!((m=e.dependencies[0])!=null&&m.enabled)?t.jsxs(X,{children:[t.jsx(re,{children:"Dependency value:"}),t.jsx("span",{children:"disabled"})]}):null,o&&((h=(j=e.dependencies[0])==null?void 0:j.variants)!=null&&h.length)?t.jsxs(X,{children:[t.jsx(re,{children:"Dependency value:"}),t.jsx($r,{variants:((v=e.dependencies[0])==null?void 0:v.variants)||[]})]}):null,r?t.jsxs(X,{children:[t.jsx(re,{children:"Children:"}),t.jsx(Ir,{childFeatures:e.children,project:e.project})]}):null,e.project?t.jsx(Dr,{project:e.project,featureId:e.name,parentDependency:e.dependencies[0],onClose:()=>n(!1),showDependencyDialogue:s}):null]})},_r=(e,s={})=>{const n=Fe(`/api/admin/projects/${e}/dependencies`),{data:a,error:o}=ks(e,!1,n,Br,s);return{dependenciesExist:a,error:o,loading:!o&&!a}},Br=async e=>await(await fetch(e).then(Oe("Dependencies exist check"))).json(),zr=e=>{const{dependenciesExist:s}=_r(e),{isOss:n}=Te();return!!e&&!!(!n()||s)},sn=(e,s={})=>{const n=async()=>{const p=Fe(`api/admin/features/${e}/tags`);return(await fetch(p,{method:"GET"}).then(Oe("Tags"))).json()},a=`api/admin/features/${e}/tags`,{data:o,error:r}=ks(!!e,{tags:[]},a,n,s),[i,l]=x.useState(!r&&!o),c=()=>{Rs(a)};return x.useEffect(()=>{l(!r&&!o)},[o,r]),{tags:(o==null?void 0:o.tags)||[],error:r,loading:i,refetch:c}},Lr=g("section")(({theme:e})=>({"& > *":{margin:e.spacing(1,0)}})),st=e=>e.map(s=>({title:s.value})),Qt=(e,s)=>e.map(n=>({value:n.title,type:s})),nn=({open:e,setOpen:s})=>{const{tagTypes:n}=An(),a=A("featureId"),{createTag:o}=Go(),{updateFeatureTags:r,loading:i}=Ye(),{tags:l,refetch:c,loading:p}=sn(a),{setToastData:u}=H(),d=n&&n.length>0?n[0]:{name:"simple",description:"Simple tag to get you started",icon:""},[m,j]=x.useState(d),h=i||p,[v,y]=x.useState(0),{trackEvent:f}=ie(),[w,E]=x.useState(st(l.filter(b=>b.type===m.name))),{tags:O,refetch:_}=Yo(m.name),$=x.useMemo(()=>st(O),[O]);x.useEffect(()=>{l&&m&&E(st(l.filter(b=>b.type===m.name)))},[JSON.stringify(l),m,e]);const D=()=>{s(!1),E([])};function I(b,S){const F=b.filter(N=>N.type===m.name).filter(N=>!S.find(k=>N.value===k.value&&N.type===k.type)),V=S.filter(N=>N.type===m.name).filter(N=>!b.find(k=>N.value===k.value&&N.type===k.type));return y(F.length+V.length),{added:F,removed:V}}const R=b=>b.filter(S=>!S.title.startsWith("Create")),M=async(b,S)=>{try{await r(a,{addedTags:b,removedTags:S}),await c()}catch{u({type:"error",text:"Failed to add tag"})}},G=async b=>{b.preventDefault();const S=Qt(R(w),m.name),{added:F,removed:V}=I(S,l);v>0&&(await M(F,V),v>1&&f("suggest_tags",{props:{eventType:"multiple_tags_added"}}),v>0&&u({type:"success",text:`Updated tag${F.length>1?"s":""} to flag`})),y(0),E([]),s(!1)},Q=(b,S)=>{S!=null&&typeof S!="string"&&(b.preventDefault(),j(S),E([]),y(0))},C=(b,S,F)=>{const V=En(S);F==="selectOption"&&S.forEach((k,oe)=>{if(typeof k!="string"&&k.inputValue&&k.inputValue!==""){const ge={value:k.inputValue,type:m.name};o(ge).then(()=>{f("suggest_tags",{props:{eventType:"tag_created"}}),_()}),k.title=k.inputValue,k.inputValue="",V[oe]=k}});const N=Qt(R(V),m.name);I(N,l),E(V)},P="add-tag-form";return t.jsx(ue,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update feature flag tags",onClick:G,disabledPrimaryButton:h||v===0,onClose:D,formId:P,children:t.jsxs(t.Fragment,{children:[t.jsx(L,{paragraph:!0,sx:{marginBottom:b=>b.spacing(2.5)},children:"Tags allow you to group features together"}),t.jsx("form",{id:P,onSubmit:G,children:t.jsxs(Lr,{children:[t.jsx(Jo,{options:n,value:m,onChange:Q}),t.jsx(Ko,{options:$,existingTags:l,tagType:m,selectedOptions:w,onChange:C})]})})]})})},Mr=g(K)(({theme:e})=>({lineHeight:e.typography.body1.lineHeight,borderRadius:e.shape.borderRadiusExtraLarge,background:e.palette.secondary.light,padding:e.spacing(.5,1),height:e.spacing(3.5)})),Vr=g(Ds)(({theme:e})=>({fontSize:e.typography.body2.fontSize})),Xt=({project:e,onClick:s})=>t.jsx(Mr,{size:"small",permission:Ce,projectId:e,variant:"text",onClick:s,startIcon:t.jsx(Vr,{}),"data-loading":!0,children:"Add tag"}),Zt=g("span")(({theme:e})=>({marginTop:e.spacing(1),color:e.palette.text.secondary,marginRight:e.spacing(1)})),Nr=g("div")(({theme:e})=>({display:"flex",justifyContent:"space-between",flexWrap:"wrap",minHeight:e.spacing(4.5),fontSize:e.fontSizes.smallBody})),es=g("div")(({theme:e})=>({display:"flex",overflow:"hidden",gap:e.spacing(1),flexWrap:"wrap",marginTop:e.spacing(.75)}));g(As)(({theme:e})=>({overflowWrap:"anywhere",lineHeight:e.typography.body1.lineHeight,backgroundColor:e.palette.neutral.light,color:e.palette.text.primary,padding:e.spacing(.25),height:e.spacing(3.5)}));g("span")(({theme:e})=>({color:e.palette.text.secondary}));const qr=({feature:e})=>{const{tags:s,refetch:n}=sn(e.name),{deleteTagFromFeature:a}=Ye(),[o,r]=x.useState(!1),[i,l]=x.useState(!1),[c,p]=x.useState(),{setToastData:u,setToastApiError:d}=H(),{hasAccess:m}=x.useContext(Es),j=m(Ce,e.project),h=()=>{r(!0)},v=async()=>{if(c)try{await a(e.name,c.type,c.value),n(),u({type:"success",text:"Tag removed"})}catch(y){d(q(y))}};return t.jsxs(t.Fragment,{children:[s.length?t.jsxs(Nr,{children:[t.jsx(Zt,{children:"Tags:"}),t.jsxs(es,{children:[s.map(y=>t.jsx(Wr,{tag:y,canUpdateTags:j,onTagRemove:f=>{l(!0),p(f)}},Is(y))),j?t.jsx(Xt,{project:e.project,onClick:h}):null]})]}):t.jsxs(X,{children:[t.jsx(Zt,{children:"Tags:"}),t.jsx(es,{children:t.jsx(Xt,{project:e.project,onClick:h})})]}),t.jsx(nn,{open:o,setOpen:r}),t.jsxs(ue,{open:i,primaryButtonText:"Remove tag",secondaryButtonText:"Cancel",onClose:()=>{l(!1),p(void 0),n()},onClick:()=>{l(!1),v(),p(void 0)},title:"Remove tag",children:["You are about to remove tag:"," ",t.jsxs("strong",{children:[c==null?void 0:c.type,":",c==null?void 0:c.value]})]})]})},Wr=({tag:e,canUpdateTags:s,onTagRemove:n})=>{const a=Is(e),o=a.length>25,r=s?()=>n(e):void 0,i=t.jsx(ee,{title:"Remove tag",arrow:!0,children:t.jsx($n,{sx:{height:"20px",width:"20px"}})});return t.jsx(ee,{title:o?a:"",arrow:!0,children:t.jsx("span",{children:t.jsx(In,{tag:e,onDelete:r,deleteIcon:i})})},a)},Hr=g(Pn)(({theme:e})=>({width:e.spacing(2.5),height:e.spacing(2.5)})),Ur=g(Fn)({flexWrap:"nowrap"}),Gr=({collaborators:e})=>!e||e.length===0?null:t.jsx(Ur,{users:e,avatarLimit:9,AvatarComponent:Hr}),Yr="environment-visibility-button",ts="environment-visibility-menu",Jr=g("div")(({theme:e})=>({display:"flex",justifyContent:"center",paddingTop:e.spacing(4)})),Kr=({environments:e,hiddenEnvironments:s,onChange:n})=>{const[a,o]=x.useState(null),r=!!a,i=d=>{o(d.currentTarget)},l=()=>{o(null)},c=e.map(d=>d.name),p=new Set(c.filter(d=>!s.includes(d))),u=d=>{n(d)};return t.jsxs(Jr,{children:[t.jsx(ne,{onClick:i,endIcon:r?t.jsx(On,{}):t.jsx(_n,{}),variant:"outlined",id:Yr,"aria-controls":ts,"aria-haspopup":"true","aria-expanded":r?"true":void 0,"data-loading":!0,children:"Hide/show environments"}),t.jsx(Bn,{id:ts,open:!!a,anchorEl:a,onClose:l,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:t.jsx(zn,{multiselect:{selectedOptions:p},onChange:u,options:c.map(d=>({label:d,value:d})),search:{label:"Filter environments",placeholder:"Filter environments"}})})]})},an=(e,s)=>{const{makeRequest:n,createRequest:a,errors:o,loading:r}=Cs({propagateErrors:!0}),i=async u=>{const d=a(`/api/admin/projects/${e}/features/${s}/link`,{method:"POST",body:JSON.stringify(u)});await n(d.caller,d.id)},l=async(u,d)=>{const m=a(`/api/admin/projects/${e}/features/${s}/link/${u}`,{method:"PUT",body:JSON.stringify(d)});await n(m.caller,m.id)},c=async u=>{const d=a(`/api/admin/projects/${e}/features/${s}/link/${u}`,{method:"DELETE"});await n(d.caller,d.id)},p=[a,n,q,e];return{addLink:x.useCallback(i,p),editLink:x.useCallback(l,p),deleteLink:x.useCallback(c,p),errors:o,loading:r}},ss=g(vs)(({theme:e})=>({width:"100%",marginTop:e.spacing(1),marginBottom:e.spacing(1)})),on=({showDialogue:e,onClose:s,project:n,featureId:a,mode:o,link:r})=>{const[i,l]=x.useState(""),[c,p]=x.useState(""),[u,d]=x.useState(""),{addLink:m,editLink:j,loading:h}=an(n,a),{refetchFeature:v}=W(n,a),{setToastData:y,setToastApiError:f}=H(),w=o==="edit",E=w?"Edit link":"Add link",O=w?"Link updated":"Link added",{trackEvent:_}=ie();x.useEffect(()=>{w&&r?(l(r.url||""),p(r.title||""),d(r.id||"")):w||(l(""),p(""),d(""))},[w,r]);const $=async()=>{try{w?(await j(u,{url:i,title:c||null}),_("feature-links",{props:{eventType:"edit-link"}})):(await m({url:i,title:c||null}),_("feature-links",{props:{eventType:"add-link"}})),y({text:O,type:"success"}),s(),v(),p(""),l("")}catch(I){f(q(I))}},D=w?r!==null:e;return t.jsx(ue,{open:D,title:E,onClose:s,disabledPrimaryButton:i.trim()===""||h,onClick:$,primaryButtonText:"Save",secondaryButtonText:"Cancel",children:t.jsxs(z,{children:[t.jsx(ss,{label:"Link",variant:"outlined",value:i,onChange:I=>l(I.target.value)}),t.jsx(ss,{label:"Title (optional)",variant:"outlined",value:c,onChange:I=>p(I.target.value)})]})})},Qr=e=>t.jsx(on,{...e,mode:"add",link:null}),Xr=e=>t.jsx(on,{...e,mode:"edit",showDialogue:e.link!==null}),rn=g("div")(({theme:e})=>({padding:e.spacing(3),borderRadius:e.shape.borderRadiusLarge,backgroundColor:e.palette.background.paper,display:"flex",flexDirection:"column",gap:e.spacing(2),width:"350px",border:`1px solid ${e.palette.divider}`,[e.breakpoints.down("md")]:{width:"100%"},marginBottom:e.spacing(2)})),ft=g("h2")(({theme:e})=>({fontSize:e.typography.body1.fontSize,fontWeight:e.typography.fontWeightBold,marginBottom:e.spacing(.5)})),Zr=g("div")({display:"flex",flexDirection:"column"}),X=g("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",minHeight:e.spacing(4.5),fontSize:e.fontSizes.smallBody})),re=g("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)})),ze=g("span")({overflowWrap:"anywhere"}),yt=g("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1)})),ei=g(De)(({theme:e})=>({minWidth:e.spacing(5)})),ti=({links:e,project:s,feature:n})=>{const[a,o]=x.useState(!1),[r,i]=x.useState(null),{deleteLink:l,loading:c}=an(s,n),{setToastData:p,setToastApiError:u}=H(),{refetchFeature:d}=W(s,n),m=t.jsx(K,{size:"small",startIcon:t.jsx(Ds,{}),permission:Ce,disabled:e.length>=10,projectId:s,variant:"text",onClick:()=>o(!0),children:"Add link"}),j=()=>t.jsx(Ct,{children:e.map(y=>t.jsx(Ve,{secondaryAction:t.jsx(tn,{capabilityId:"link",feature:n,onEdit:()=>{i(y)},onDelete:async()=>{try{await l(y.id),p({text:"Link removed",type:"success"}),d()}catch(f){u(q(f))}}}),disablePadding:!0,dense:!0,children:t.jsxs(Nn,{component:"a",href:y.url,target:"_blank",rel:"noopener noreferrer",disableGutters:!0,children:[t.jsx(ei,{children:t.jsx(qn,{color:"primary"})}),t.jsx(Se,{primary:y.title,secondary:y.url,secondaryTypographyProps:{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block"}}})]})},y.id))}),h=t.jsxs(t.Fragment,{children:[t.jsxs(ft,{children:["You can now add links"," ",t.jsx(Ae,{color:"success",sx:{ml:1},children:"New"})]}),t.jsx(X,{children:"Gather relevant links for external resources such as issue trackers, code repositories or analytics tooling"}),t.jsx("div",{children:m})]}),v=t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:"Resources"}),j(),t.jsx("div",{children:m})]});return t.jsxs(t.Fragment,{children:[t.jsx(rn,{children:e.length===0?h:v}),t.jsx(Qr,{project:s,featureId:n,showDialogue:a,onClose:()=>o(!1)}),t.jsx(Xr,{project:s,featureId:n,link:r,onClose:()=>i(null)})]})},si=({hiddenEnvironments:e,onEnvironmentVisibilityChange:s,feature:n,onChange:a})=>{var h,v,y,f;const{locationSettings:o}=$s(),r=le(),[i,l]=x.useState(!1),[c,p]=x.useState(!1),{project:u,description:d,type:m}=n,j=zr(u);return t.jsxs(t.Fragment,{children:[t.jsx(ti,{links:n.links||[],project:n.project,feature:n.name}),t.jsxs(rn,{children:[t.jsxs("div",{children:[t.jsx(ft,{children:"Flag details"}),d?t.jsx(X,{"data-loading":!0,children:t.jsx(ze,{children:t.jsx(Ge,{arrow:!0,lines:5,title:d,children:d})})}):null]}),t.jsxs(Zr,{children:[t.jsxs(X,{children:[t.jsx(re,{children:"Flag type:"}),t.jsxs(ze,{"data-loading":!0,children:[Ln(m||" ")," flag"]})]}),n.lifecycle?t.jsxs(X,{"data-loading":!0,children:[t.jsx(re,{children:"Lifecycle:"}),t.jsx(Mn,{feature:n,onArchive:()=>l(!0),onComplete:()=>p(!0),onUncomplete:a})]}):null,t.jsxs(X,{children:[t.jsx(re,{children:"Created:"}),t.jsx(ze,{"data-loading":!0,children:Vn(St(n.createdAt),o.locale)})]}),n.createdBy?t.jsxs(X,{children:[t.jsx(re,{children:"Created by:"}),t.jsx(yt,{children:t.jsx(ze,{"data-loading":!0,children:(h=n.createdBy)==null?void 0:h.name})})]}):null,(v=n.collaborators)!=null&&v.users&&((y=n.collaborators)==null?void 0:y.users.length)>0?t.jsxs(X,{children:[t.jsx(re,{children:"Collaborators:"}),t.jsx(yt,{children:t.jsx(Gr,{collaborators:(f=n.collaborators)==null?void 0:f.users})})]}):null,j?t.jsx(Or,{feature:n}):null,t.jsx(qr,{feature:n}),s?t.jsx(Kr,{environments:n.environments||[],hiddenEnvironments:e||[],onChange:s}):null]})]}),n.children.length>0?t.jsx(At,{features:n.children,project:n.project,isOpen:i,onClose:()=>l(!1)}):t.jsx(Dt,{isOpen:i,onConfirm:()=>{r(`/projects/${n.project}`)},onClose:()=>l(!1),projectId:n.project,featureIds:[n.name]}),n.project?t.jsx(Ks,{isOpen:c,setIsOpen:p,projectId:n.project,featureId:n.name,onComplete:a}):null]})},ni=e=>{var o;const{uiConfig:s}=Te(),n=((o=s.resourceLimits)==null?void 0:o.featureEnvironmentStrategies)||100,a=e>=n;return{limit:n,limitReached:a}},ai=()=>{const[e,s]=x.useState(0),n=A("projectId"),a=A("featureId"),o=Lt("environmentId"),r=Lt("strategyName"),{strategy:i,defaultStrategyFallback:l}=Qo(n,o),c=JSON.parse(Wn().get("defaultStrategy")||"false"),{segments:p}=Hn(),u=(p||[]).filter(Y=>{var me;return(me=i==null?void 0:i.segments)==null?void 0:me.includes(Y.id)}),[d,m]=x.useState({}),[j,h]=x.useState(c?u:[]),{strategyDefinition:v}=Un(r),y=Gn(),{addStrategyToFeature:f,loading:w}=_e(),{addChange:E}=pe(),{setToastData:O,setToastApiError:_}=H(),{uiConfig:$}=Te(),{unleashUrl:D}=$,I=le(),{feature:R,refetchFeature:M}=W(n,a),G=R==null?void 0:R.environments.find(Y=>Y.name===o),Q=(G==null?void 0:G.strategies.length)||0,{limit:C,limitReached:P}=ni(Q),b=x.useRef(R),{isChangeRequestConfigured:S}=te(n),{refetch:F}=ce(n),{trackEvent:V}=ie(),{data:N,staleDataNotification:k,forceRefreshCache:oe}=Yn({unleashGetter:W,params:[n,a],dataKey:"feature",refetchFunctionKey:"refetchFeature",options:{}},R,{afterSubmitAction:M},na);x.useEffect(()=>{b.current.name===""&&R.name&&(oe(R),b.current=R)},[R.name]),x.useEffect(()=>{var Y;if(c){const me=i||l;((Y=me.parameters)==null?void 0:Y.groupId)===""&&a?m({...me,parameters:{...me.parameters,groupId:a}}):m(me)}else v&&m(Jn(a,v))},[a,JSON.stringify(v),JSON.stringify(i),c]);const ge=async Y=>{await f(n,a,o,Y),O({text:"Strategy created",type:"success"})},fe=async Y=>{await E(n,o,{action:"addStrategy",feature:a,payload:Y}),O({text:"Strategy added to draft",type:"success"}),F()},T=Kn(d,j),U=async()=>{V("strategyTitle",{props:{hasTitle:!!d.title,on:"create"}});try{S(o)?await fe(T):await ge(T),M(),I(Tt(n,a))}catch(Y){_(q(Y))}};return!N||!N.project?null:t.jsxs(Ps,{modal:!0,description:Qn,documentationLink:Xn,documentationLinkLabel:Zn,disablePadding:!0,formatApiCode:()=>oi(n,a,o,T,D),children:[t.jsx(ea,{projectId:n,feature:N,strategy:d,setStrategy:m,segments:j,setSegments:h,environmentId:o,onSubmit:U,loading:w,permission:be,errors:y,isChangeRequest:S(o),tab:e,setTab:s,StrategyVariants:t.jsx(ta,{strategy:d,setStrategy:m,environment:o,projectId:n,editable:!0}),Limit:t.jsx(sa,{name:"strategies in this environment",shortName:"strategies",currentValue:Q,limit:C}),disabled:P}),k]})},cn=(e,s,n,a,o=!1)=>{const r=new URLSearchParams({environmentId:n,strategyName:a,defaultStrategy:String(o)});return`/projects/${e}/features/${s}/strategies/create?${r}`},oi=(e,s,n,a,o)=>{if(!o)return"";const r=`${o}/api/admin/projects/${e}/features/${s}/environments/${n}/strategies`,i=JSON.stringify(a,void 0,2);return`curl --location --request POST '${r}' \\
2
- --header 'Authorization: INSERT_API_KEY' \\
3
- --header 'Content-Type: application/json' \\
4
- --data-raw '${i}'`},ns=3,ln=e=>Array.isArray(e)?e.filter(s=>s.featureId&&s.projectId):[],as=e=>ln(ra(e)||[]),ri=()=>{const e=`${ia}:unleash-lastViewedFlags`,[s,n]=x.useState(()=>as(e)),{emitEvent:a}=aa("lastViewedFlagsUpdated",x.useCallback(()=>{n(as(e))},[e]));x.useEffect(()=>{s&&(oa(e,s),a())},[JSON.stringify(s),e,a]);const o=x.useCallback(r=>{if(!r.featureId||!r.projectId||s.find(l=>l.featureId===r.featureId))return;const i=ln([...s,r]);n(i.length>ns?i.slice(-ns):i)},[JSON.stringify(s)]);return{lastViewed:s,setLastViewed:o}},ii=g("div")(({theme:e})=>({width:e.spacing(3),"& > svg":{width:e.spacing(2.25),height:e.spacing(2.25),fill:e.palette.primary.main}})),ci=g(Fs)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,fontSize:e.typography.caption.fontSize,display:"block",marginBottom:e.spacing(.5)})),li=g(ae)(({theme:e})=>({display:"flex",flexDirection:"column",width:"100%",maxWidth:"30rem",padding:e.spacing(1.5,2),color:"inherit",textDecoration:"inherit",lineHeight:1.25,borderWidth:"1px",borderStyle:"solid",borderColor:e.palette.divider,borderRadius:e.spacing(1),overflow:"hidden","&:hover, &:focus":{borderColor:e.palette.primary.main}})),di=g("div")(({theme:e})=>({display:"flex",flexDirection:"row",alignItems:"center",width:"100%"})),nt=({projectId:e,featureId:s,environmentId:n,strategy:a,defaultStrategy:o,onClose:r})=>{const i=Os(a.name),l=_s(a.name),{trackEvent:c}=ie(),p=cn(e,s,n,a.name,o),u=()=>{c("strategy-add",{props:{buttonTitle:a.displayName||l}}),r()};return t.jsxs(li,{to:p,onClick:u,children:[t.jsxs(di,{children:[t.jsx(ii,{children:t.jsx(i,{})}),t.jsx(ci,{text:a.displayName||l,maxWidth:"200",maxLength:25})]}),t.jsx(Ge,{lines:1,title:a.description,arrow:!0,sx:{fontSize:d=>d.typography.caption.fontSize,width:"100%"},children:a.description})]})},ui=g("div")(({theme:e})=>({width:e.spacing(3),"& > svg":{width:e.spacing(2.25),height:e.spacing(2.25),fill:e.palette.primary.main}})),pi=g(Fs)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,fontSize:e.typography.caption.fontSize,display:"block",marginBottom:e.spacing(.5)})),gi=g("div")(({theme:e})=>({width:"100%",transition:"opacity 0.2s ease-in-out"})),hi=g("div")(({theme:e})=>({position:"absolute",right:e.spacing(2),display:"flex",gap:e.spacing(1),opacity:0,transition:"opacity 0.1s ease-in-out"})),xi=g("div")(({theme:e})=>({display:"flex",flexDirection:"column",width:"100%",height:"100%",maxWidth:"30rem",padding:e.spacing(1.5,2),color:"inherit",textDecoration:"inherit",lineHeight:1.25,borderWidth:"1px",borderStyle:"solid",borderColor:e.palette.divider,borderRadius:e.spacing(1),textAlign:"left",overflow:"hidden",position:"relative","&:hover .cardContent, &:focus-within .cardContent":{opacity:.5},"&:hover .buttonContainer, &:focus-within .buttonContainer":{opacity:1}})),fi=g("div")(({theme:e})=>({display:"flex",flexDirection:"row",alignItems:"center",width:"100%"})),yi=({template:{name:e,description:s},onClick:n,onPreviewClick:a})=>{const o=Os("releasePlanTemplate"),r=l=>{l.stopPropagation(),n()},i=l=>{l.stopPropagation(),a(l)};return t.jsxs(xi,{children:[t.jsxs(gi,{className:"cardContent",children:[t.jsxs(fi,{children:[t.jsx(ui,{children:t.jsx(o,{})}),t.jsx(pi,{text:e,maxWidth:"200",maxLength:25})]}),t.jsx(Ge,{lines:1,title:s,arrow:!0,sx:{fontSize:l=>l.typography.caption.fontSize,fontWeight:l=>l.typography.fontWeightRegular,width:"100%"},children:s})]}),t.jsxs(hi,{className:"buttonContainer",children:[t.jsx(ne,{variant:"contained",size:"small",onClick:r,tabIndex:0,children:"Use"}),t.jsx(ne,{variant:"outlined",size:"small",onClick:i,children:"Preview"})]})]})},mi=g(L)(({theme:e})=>({fontSize:e.fontSizes.smallBody,padding:e.spacing(1,4),width:"100%"})),ji=g(Be)(({theme:e})=>({fontSize:e.fontSizes.smallBody,cursor:"pointer"})),bi=g(z)(()=>({width:"100%",display:"flex",flexDirection:"column"})),vi=g(z)(({theme:e})=>({width:"100%",maxHeight:"70vh",overflowY:"auto",padding:e.spacing(1,0,1,0)})),at=g(z)(({theme:e})=>({display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:e.spacing(1.5),padding:e.spacing(0,4),marginBottom:e.spacing(3),width:"100%"})),Le=g(z)(()=>({width:"100%",minWidth:0})),Si=g(z)(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",padding:e.spacing(4,4,2,4)})),Ci=g(L)(({theme:e})=>({fontSize:e.typography.body1.fontSize,fontWeight:e.typography.fontWeightBold,margin:0})),ot=g(z)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(.5),padding:e.spacing(0,4,1,4),width:"100%"})),rt=g(ca)(({theme:e})=>({fontSize:e.typography.body2.fontSize,color:e.palette.text.secondary})),Ti=g("span")(({theme:e})=>({width:e.spacing(3),"& > svg":{fill:e.palette.primary.main,width:e.spacing(2.25),height:e.spacing(2.25)},display:"flex",alignItems:"center"})),wi=g(z)(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",backgroundColor:e.palette.neutral.light,borderRadius:e.shape.borderRadiusMedium,padding:e.spacing(3),margin:e.spacing(0,4),width:"auto"})),ki=g(L)(({theme:e})=>({fontSize:e.typography.caption.fontSize,fontWeight:e.typography.fontWeightBold,marginBottom:e.spacing(1),display:"flex",alignItems:"center"})),Ri=g(L)(({theme:e})=>({fontSize:e.typography.caption.fontSize,color:e.palette.text.secondary})),Di=g(Be)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,cursor:"pointer","&:hover":{textDecoration:"underline"}})),Ai=({projectId:e,featureId:s,environmentId:n,onlyReleasePlans:a,onAddReleasePlan:o,onReviewReleasePlan:r,onClose:i})=>{const{strategies:l}=la(),{templates:c}=da(),p=le(),u=!a,d=l.filter(h=>!h.deprecated&&!h.editable),m=l.filter(h=>!h.deprecated&&h.editable),j={name:"flexibleRollout",displayName:"Default strategy",description:"This is the default strategy defined for this environment in the project"};return t.jsxs(bi,{children:[t.jsxs(Si,{children:[t.jsx(Ci,{variant:"h2",children:a?"Select template":"Select strategy"}),t.jsx(xe,{size:"small",onClick:i,edge:"end","aria-label":"close",children:t.jsx(wt,{fontSize:"small"})})]}),t.jsxs(vi,{children:[u?t.jsxs(t.Fragment,{children:[t.jsxs(ot,{children:[t.jsx(L,{color:"inherit",variant:"body2",children:"Pre-defined strategy types"}),t.jsx(ee,{title:"Select a starting setup, and customize the strategy to your need with targeting and variants",arrow:!0,children:t.jsx(rt,{})})]}),t.jsxs(at,{children:[t.jsx(Le,{children:t.jsx(nt,{projectId:e,featureId:s,environmentId:n,strategy:j,defaultStrategy:!0,onClose:i})},j.name),d.map(h=>t.jsx(Le,{children:t.jsx(nt,{projectId:e,featureId:s,environmentId:n,strategy:h,onClose:i})},h.name))]})]}):null,t.jsx(B,{condition:c.length>0,show:t.jsxs(t.Fragment,{children:[t.jsxs(ot,{children:[t.jsx(L,{color:"inherit",variant:"body2",children:"Apply a release template"}),t.jsx(ee,{title:"Use one of the pre-defined templates defined in your company for rolling out features to users",arrow:!0,children:t.jsx(rt,{})})]}),t.jsx(at,{children:c.map(h=>t.jsx(Le,{children:t.jsx(yi,{template:h,onClick:()=>o(h),onPreviewClick:()=>r(h)})},h.id))})]}),elseShow:t.jsxs(wi,{children:[t.jsxs(ki,{children:[t.jsx(Ti,{children:t.jsx(ua,{})}),"Create your own templates"]}),t.jsxs(Ri,{children:["Standardize how you do rollouts and make it more efficient without having to set up the same stategies from time to time. You find it in the sidemenu under"," ",t.jsx(Di,{onClick:()=>p("/release-templates"),children:"Configure > Release templates"})]})]})}),t.jsx(B,{condition:c.length===0&&a,show:t.jsx(t.Fragment,{children:t.jsxs(mi,{color:"textSecondary",sx:{padding:h=>h.spacing(1,2,0,2)},children:[t.jsx("p",{children:"No templates created."}),t.jsxs("p",{children:["Go to ",t.jsx(ji,{onClick:()=>p("/release-templates"),children:"Release templates"})," to get started"]})]})})}),u?t.jsx(t.Fragment,{children:t.jsx(B,{condition:m.length>0,show:t.jsxs(t.Fragment,{children:[t.jsxs(ot,{children:[t.jsx(L,{color:"inherit",variant:"body2",children:"Custom strategies"}),t.jsx(ee,{title:"Custom strategies you have defined in Unleash",arrow:!0,children:t.jsx(rt,{})})]}),t.jsx(at,{children:m.map(h=>t.jsx(Le,{children:t.jsx(nt,{projectId:e,featureId:s,environmentId:n,strategy:h,onClose:i})},h.name))})]})})}):null]})]})},Ei=g(Bs)(({theme:e})=>({"& .MuiDialog-paper":{borderRadius:e.shape.borderRadiusLarge,maxWidth:e.spacing(85)}})),Ii=g(pa)(({theme:e})=>({padding:e.spacing(2,4,4)})),$i=g(z)(({theme:e})=>({display:"flex",justifyContent:"space-between",marginBottom:e.spacing(2)})),Pi=g(z)(({theme:e})=>({display:"flex",alignItems:"center",cursor:"pointer"})),Fi=g(ga)(({theme:e})=>({marginRight:e.spacing(1),color:e.palette.primary.main,display:"flex",alignSelf:"center"})),Oi=g(L)(({theme:e})=>({fontWeight:e.typography.fontWeightMedium,display:"flex",alignItems:"center",lineHeight:1})),_i=({open:e,setOpen:s,onConfirm:n,template:a,projectId:o,featureName:r,environment:i,crProtected:l})=>{const{feature:c}=W(o,r),{releasePlans:p}=Je(o,r,i),u=p[0],d=c==null?void 0:c.environments.find(({name:v})=>v===i),m=d==null?void 0:d.enabled,j=ha(a.id,r,i),h=()=>s(!1);return t.jsxs(Ei,{open:e,onClose:h,fullWidth:!0,maxWidth:"md",children:[t.jsxs(xa,{children:[t.jsxs($i,{children:[t.jsxs(Pi,{onClick:h,children:[t.jsx(Fi,{}),t.jsx(Oi,{variant:"body2",color:"primary",children:"Go back"})]}),t.jsx(xe,{size:"small",onClick:h,edge:"end","aria-label":"close",children:t.jsx(wt,{fontSize:"small"})})]}),u&&t.jsxs(Z,{severity:"error",sx:{mb:1},children:["This feature environment currently has"," ",t.jsx("strong",{children:u.name})," -"," ",t.jsx("strong",{children:u.milestones[0].name}),m?" running":" paused",". Adding a new release plan will replace the existing release plan."]}),t.jsx("div",{children:t.jsx(zs,{plan:j,readonly:!0})}),l&&t.jsxs(L,{sx:{mt:4},children:[t.jsx("strong",{children:"Adding"})," release template"," ",t.jsx("strong",{children:a==null?void 0:a.name})," to"," ",t.jsx("strong",{children:r})," in"," ",t.jsx("strong",{children:i}),"."]})]}),t.jsx(Ii,{children:t.jsx(ne,{variant:"contained",color:"primary",onClick:n,children:l?"Add suggestion to draft":"Use template"})})]})},Bi=g("div")(({theme:e})=>({display:"flex",flexFlow:"row",justifyContent:"flex-end",gap:e.spacing(1)})),zi=g(K)(({theme:e})=>({minWidth:0,width:e.spacing(4.5),alignSelf:"stretch",paddingBlock:0})),os=({label:e,projectId:s,featureId:n,environmentId:a,variant:o,size:r,matchWidth:i,disableReason:l})=>{const[c,p]=x.useState(!1),[u,d]=x.useState(!1),m=le(),{trackEvent:j}=ie(),[h,v]=x.useState(),[y,f]=x.useState(!1),w=c?"FeatureStrategyMenuDialog":void 0,{setToastApiError:E,setToastData:O}=H(),{isChangeRequestConfigured:_}=te(s),{addChange:$}=pe(),{refetch:D}=ce(s),{refetch:I}=Je(s,n,a),{addReleasePlanToFeature:R}=fa(),{isOss:M}=Te(),G=kt("releasePlans"),Q=!M()&&G,C=G&&_(a),P=()=>{p(!1)},b=k=>{j("strategy-add",{props:{buttonTitle:e}}),m(N)},S=k=>{d(!1),p(!0)},F=k=>{d(!0),p(!0)},V=async k=>{try{C?(await $(s,a,{feature:n,action:"addReleasePlan",payload:{templateId:k.id}}),O({type:"success",text:"Added to draft"}),D()):(await R(n,k.id,s,a),O({type:"success",text:"Release plan added"}),I()),j("release-management",{props:{eventType:"add-plan",plan:k.name}})}catch(oe){E(q(oe))}finally{f(!1),v(void 0),P()}},N=cn(s,n,a,"flexibleRollout",!0);return t.jsxs(Bi,{onClick:k=>k.stopPropagation(),children:[Q?t.jsx(K,{"data-testid":"ADD_TEMPLATE_BUTTON",permission:be,projectId:s,environmentId:a,onClick:F,"aria-labelledby":w,variant:"outlined",sx:{minWidth:i?"282px":"auto"},disabled:!!l,tooltipProps:{title:l||void 0},children:"Use template"}):null,t.jsx(K,{"data-testid":"ADD_STRATEGY_BUTTON",permission:be,projectId:s,environmentId:a,onClick:b,"aria-labelledby":w,variant:o,sx:{minWidth:i?"282px":"auto"},disabled:!!l,tooltipProps:{title:l||void 0},children:e}),t.jsx(zi,{permission:be,projectId:s,environmentId:a,onClick:S,variant:"outlined",hideLockIcon:!0,disabled:!!l,tooltipProps:{title:l||"More strategies"},children:t.jsx(vt,{})}),t.jsx(Bs,{open:c,onClose:P,maxWidth:"md",PaperProps:{sx:{borderRadius:"12px"}},children:t.jsx(Ai,{projectId:s,featureId:n,environmentId:a,onlyReleasePlans:u,onAddReleasePlan:k=>{v(k),V(k)},onReviewReleasePlan:k=>{v(k),f(!0),P()},onClose:P})}),h&&t.jsx(_i,{open:y,setOpen:k=>{f(k),k||p(!0)},onConfirm:()=>{V(h)},template:h,projectId:s,featureName:n,environment:a,crProtected:C})]})},dn=(e,s)=>e===0?0:Math.round(s/e*100),Li=g("div")(()=>({display:"flex",alignItems:"center",justifyContent:"center",position:"relative",margin:0})),Mi=g("div",{shouldForwardProp:e=>e!=="color"})(({theme:e,color:s})=>({position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:s,fontSize:e.fontSizes.smallerBody,margin:0})),Vi=({percentage:e,size:s="4rem",disabled:n=!1,children:a})=>{const o=Pe(),r={display:"block",borderRadius:"100%",transform:"rotate(-90deg)",height:s,width:s},i=100/(2*Math.PI),l=2*i,c=l*.2,p=n?o.palette.neutral.border:o.palette.primary.light;return t.jsxs(Li,{children:[t.jsxs("svg",{viewBox:`0 0 ${l} ${l}`,style:r,"aria-hidden":!0,children:[t.jsx("circle",{r:i,cx:i,cy:i,fill:"none",stroke:o.palette.background.elevation2,strokeWidth:c}),t.jsx("circle",{r:i,cx:i,cy:i,fill:"none",stroke:p,strokeWidth:c,strokeDasharray:`${e} 100`})]}),t.jsx(Mi,{color:p,children:a})]})},Ni=g("figure")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"flex-end",margin:0,padding:0})),qi=g("figcaption")(({theme:e})=>({fontSize:e.typography.body2.fontSize,textAlign:"right",[e.breakpoints.down("xl")]:{display:"none"},display:"flex",flexDirection:"column",flexGrow:1,margin:0,padding:0,span:{textWrap:"nowrap"}})),Wi=g("div")(({theme:e})=>({marginRight:e.spacing(1),marginLeft:e.spacing(1.5),[e.breakpoints.down(500)]:{display:"none"}})),Hi=g(({className:e,...s})=>t.jsx(ee,{...s,classes:{popper:e}}))({[`& .${ya.tooltip}`]:{maxWidth:200}}),Ui=({environmentMetric:e,collapsed:s})=>{if(!e)return null;const n=e.yes+e.no,a=dn(n,e==null?void 0:e.yes),o=!e||e.yes===0&&e.no===0,r=o?t.jsxs(t.Fragment,{children:["No evaluation metrics",t.jsx("br",{}),"received in the last hour"]}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:["The flag has been evaluated"," ",t.jsxs("b",{children:[t.jsx(Ne,{value:n})," times"]})]})," ",t.jsxs("span",{children:["and enabled"," ",t.jsxs("b",{children:[t.jsx(Ne,{value:e.yes})," times"]})," ","in the last hour"]})]});return t.jsxs(Ni,{children:[s?null:t.jsx(qi,{children:r}),t.jsx(Hi,{title:s?r:"",arrow:!0,children:t.jsx(Wi,{"data-loading":!0,children:t.jsx(Vi,{percentage:a,size:"3rem",children:o?null:`${a}%`})})})]})},Gi=g("div")(({theme:e})=>({order:-1,flex:0})),Yi=({environment:{name:e,type:s,strategies:n,enabled:a}})=>{const o=A("projectId"),r=A("featureId"),{refetchFeature:i}=W(o,r),{isChangeRequestConfigured:l}=te(o),{onToggle:c,modals:p}=Xo(o),u=(d,m)=>c(d,{projectId:o,featureId:r,environmentName:e,environmentType:s,hasStrategies:n.length>0,hasEnabledStrategies:n.some(j=>!j.disabled),isChangeRequestEnabled:l(e),onRollback:m,onSuccess:i});return t.jsxs(Gi,{onClick:d=>d.stopPropagation(),children:[t.jsx(Zo,{projectId:o,value:a,featureId:r,environmentName:e,onToggle:u}),p]})},Ji=(e,s)=>{const n=[];let a=0;if(e.length<=a)return e;for(;a<e.length;)if(a===0){a+=s;const o=e.slice(0,a);n.push(o)}else{const o=e.slice(a,a+s);a+=s,n.push(o)}return n},Ki=(e,s,n)=>{const[a,o]=x.useState([[]]),[r,i]=x.useState(0);x.useEffect(()=>{const m=Ji(e,s);o(m)},[JSON.stringify(e),s]);const l=()=>{r<a.length-1&&i(d=>d+1)},c=()=>{r>0&&i(d=>d-1)},p=()=>{i(a.length-1)},u=()=>{i(0)};return{page:a[r]||[],pages:a,nextPage:l,prevPage:c,lastPage:p,firstPage:u,setPageIndex:i,pageIndex:r}},Qi=e=>fetch(e).then(Oe("ChangeRequest")).then(s=>s.json()),un=(e,s)=>{const{data:n,error:a,mutate:o}=Ls([],Fe(`api/admin/projects/${e}/change-requests/pending/${s}`),Qi);return{changeRequests:n,loading:!a&&!n,refetch:o,error:a}},Xi=(e,s,n,a)=>{const{user:o}=ma(),{changeRequests:r}=un(e,s),i=[],l=r==null?void 0:r.filter(c=>c.environment===n);return l==null||l.forEach(c=>{const p=c==null?void 0:c.features.find(d=>d.name===s),u=p==null?void 0:p.changes.find(d=>d.action==="updateStrategy"||d.action==="deleteStrategy"?d.payload.id===a:!1);if(u){const d=c.state==="Scheduled",m=!d&&c.createdBy.id===(o==null?void 0:o.id);d&&i.push({changeRequestId:c.id,change:u,isScheduledChange:d}),m&&i.push({changeRequestId:c.id,change:u,isScheduledChange:d})}}),i},pn=({scheduledChangeRequestIds:e})=>{const s=Pe(),n=Ke(s.breakpoints.down("sm")),a=A("projectId");return n?null:t.jsx(z,{sx:{mr:1.5},children:t.jsx(Ue,{tooltip:t.jsx(t.Fragment,{children:e==null?void 0:e.map((o,r)=>t.jsxs(Et,{to:`/projects/${a}/change-requests/${o}`,children:["Change request #",o]},`${a}-${r}`))}),children:t.jsx(Ae,{color:"warning",children:"Changes Scheduled"})})})},Zi=({changeAction:e,sx:s})=>{switch(e){case"updateStrategy":return t.jsx(Ae,{color:"warning",sx:s,children:"Modified in draft"});case"deleteStrategy":return t.jsx(Ae,{color:"error",sx:s,children:"Deleted in draft"});default:return null}},ec=e=>(s,n,a)=>(a.revalidateOnFocus=!1,a.revalidateIfStale=!1,a.revalidateOnReconnect=!1,e(s,n,a)),tc=ja(Ms,ec),sc=(e,s)=>{const{refetchFeature:n}=W(e,s),a=ba(e,s),{data:o,error:r,mutate:i}=tc(["useFeatureImmutable",a],()=>va(a)),l=x.useCallback(async()=>{await i(),await n()},[i,n]);return{feature:(o==null?void 0:o.body)||Sa,refetchFeature:l,loading:!r&&!o,status:o==null?void 0:o.status,error:r}},nc=(e,s,n)=>{const{setToastData:a,setToastApiError:o}=H(),{addChange:r}=pe(),{refetch:i}=ce(e),[l,c]=x.useState({isOpen:!1}),p=x.useCallback((h,v,y)=>{c({featureName:s,environment:h,fromEnvironment:y,strategy:v,isOpen:!0})},[]),u=x.useCallback((h,v,y)=>{c({featureName:s,environment:h,fromEnvironment:y,strategies:v,isOpen:!0})},[]),d=x.useCallback(()=>{c({isOpen:!1})},[]),m=x.useCallback(async()=>{try{await r(e,l.environment,{feature:l.featureName,action:n,payload:l.strategy}),i(),c({isOpen:!1}),a({type:"success",text:"Changes added to draft"})}catch(h){o(q(h)),c({isOpen:!1})}},[r]),j=x.useCallback(async()=>{try{await Promise.all(l.strategies.map(h=>r(e,l.environment,{feature:l.featureName,action:n,payload:h}))),i(),c({isOpen:!1}),a({type:"success",text:"Changes added to draft"})}catch(h){o(q(h)),c({isOpen:!1})}},[r]);return{onChangeRequestAddStrategy:p,onChangeRequestAddStrategies:u,onChangeRequestAddStrategyClose:d,onChangeRequestAddStrategyConfirm:m,onChangeRequestAddStrategiesConfirm:j,changeRequestDialogDetails:l}},ac=({payload:e,fromEnvironment:s,environment:n})=>t.jsxs(L,{children:[t.jsxs("strong",{children:["Copy ",_s((e==null?void 0:e.name)||"")," strategy"," "]})," ","from ",s," to ",n]}),oc=({environmentId:e,environments:s,strategy:n})=>{const a=A("projectId"),o=A("featureId"),[r,i]=x.useState(null),l=!!r,{addStrategyToFeature:c}=_e(),{setToastData:p,setToastApiError:u}=H(),{refetchFeature:d}=W(a,o),{refetchFeature:m}=sc(a,o),j=()=>{i(null)},h=ws(a),{isChangeRequestConfigured:v}=te(a),{changeRequestDialogDetails:y,onChangeRequestAddStrategyClose:f,onChangeRequestAddStrategy:w,onChangeRequestAddStrategyConfirm:E}=nc(a,o,"addStrategy"),O=async D=>{const{id:I,...R}={...n,targetEnvironment:D};if(v(D)){await w(D,R,e);return}try{await c(a,o,D,n),d(),m(),p({text:`Strategy copied to ${D}`,type:"success"})}catch(M){u(q(M))}j()},_=[...s,e].some(D=>h(be,D)),$=`Copy to environment${_?"":` (Access denied, missing ${be} permission)`}`;return t.jsxs("div",{children:[t.jsx(er,{isOpen:y.isOpen,onClose:f,environment:y==null?void 0:y.environment,onConfirm:E,messageComponent:t.jsx(ac,{fromEnvironment:y.fromEnvironment,payload:y.strategy})}),t.jsx(ee,{title:$,children:t.jsx("div",{children:t.jsx(xe,{size:"large",id:`copy-strategy-icon-menu-${n.id}`,"aria-label":$,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,onClick:D=>{i(D.currentTarget)},"data-testid":Ca,disabled:!_,children:t.jsx(Ta,{})})})}),t.jsx(Qe,{id:"basic-menu",anchorEl:r,open:l,onClose:j,MenuListProps:{"aria-labelledby":`copy-strategy-icon-menu-${n.id}`},children:[...s,e].map(D=>{const I=h(be,D);return t.jsx(ee,{title:I?"":"You don't have access to add a strategy to this environment",children:t.jsx("div",{children:t.jsxs(ve,{onClick:()=>O(D),disabled:!I,children:[t.jsx(B,{condition:!I,show:t.jsx(De,{children:t.jsx(wa,{fontSize:"small"})})}),t.jsx(Se,{children:D===e?"Duplicate in current":`Copy to ${D}`})]})})},D)})})]})},rc=()=>t.jsx(Z,{severity:"error",children:"Removing the strategy will change which users receive access to the feature."}),ic=g("div")(({theme:e})=>({"> * + *":{marginTop:e.spacing(1)}})),cc=({changeRequests:e,projectId:s})=>e&&e.length>0?t.jsxs(Z,{severity:"warning",children:[t.jsx("p",{children:"This strategy is in use by at least one scheduled change request. If you remove it, those change requests can no longer be applied."}),t.jsx("p",{children:"The following scheduled change requests use this strategy:"}),t.jsx("ul",{children:e.map(({id:n,title:a})=>{const o=a?`#${n} (${a})`:`#${n}`;return t.jsx("li",{children:t.jsx(ae,{to:`/projects/${s}/change-requests/${n}`,target:"_blank",rel:"noopener noreferrer",title:`Change request ${n}`,children:o})},n)})})]}):e===void 0?t.jsx(Z,{severity:"warning",children:t.jsx("p",{children:"This strategy may be in use by one or more scheduled change requests. If you remove it, those change requests can no longer be applied."})}):null,gn=({scheduledChangeRequestsForStrategy:e})=>t.jsxs(ic,{children:[t.jsx(rc,{}),t.jsx(cc,{projectId:e.projectId,changeRequests:e.changeRequests})]}),lc=({onRemove:e,onClose:s,isOpen:n,scheduledChangeRequestsForStrategy:a})=>t.jsx(ue,{title:"Are you sure you want to delete this strategy?",open:n,primaryButtonText:"Remove strategy",secondaryButtonText:"Cancel",onClick:e,onClose:s,children:t.jsx(gn,{scheduledChangeRequestsForStrategy:a})}),dc=g("div")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1)})),uc=({onRemove:e,onClose:s,isOpen:n,scheduledChangeRequestsForStrategy:a})=>t.jsxs(ue,{title:"Suggest changes",open:n,primaryButtonText:"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:e,onClose:s,children:[t.jsx(gn,{scheduledChangeRequestsForStrategy:a}),t.jsx(dc,{children:t.jsx(L,{variant:"body2",color:"text.secondary",children:"Your suggestion:"})}),t.jsx(L,{fontWeight:"bold",children:"Remove strategy"})]}),pc=({projectId:e,featureId:s,environmentId:n,strategyId:a})=>{const{deleteStrategyFromFeature:o}=_e(),{setToastData:r,setToastApiError:i}=H(),l=le(),{refetchFeature:c}=W(e,s);return async u=>{try{u.preventDefault(),await o(e,s,n,a),r({text:"Strategy deleted",type:"success"}),c(),l(Tt(e,s))}catch(d){i(q(d))}}},gc=({projectId:e,featureId:s,environmentId:n,strategyId:a})=>{const{addChange:o}=pe(),{refetch:r}=ce(e),{setToastData:i,setToastApiError:l}=H();return async p=>{try{p.preventDefault(),await o(e,n,{action:"deleteStrategy",feature:s,payload:{id:a}}),i({text:"Changes added to draft",type:"success"}),await r()}catch(u){l(q(u))}}},hc=({projectId:e,featureId:s,environmentId:n,strategyId:a,isOpen:o,onClose:r})=>{const{isChangeRequestConfigured:i}=te(e),{changeRequests:l}=Vs(e,a),c={changeRequests:l,projectId:e},p=pc({featureId:s,projectId:e,strategyId:a,environmentId:n}),u=gc({featureId:s,projectId:e,strategyId:a,environmentId:n});return i(n)?t.jsx(uc,{isOpen:o,onClose:()=>r(),onRemove:async d=>{await u(d),r()},scheduledChangeRequestsForStrategy:c}):t.jsx(lc,{isOpen:o,onClose:()=>r(),onRemove:p,scheduledChangeRequestsForStrategy:c})},xc=({projectId:e,environmentId:s,featureId:n,strategy:a})=>{const{refetchFeature:o}=W(e,n),{setStrategyDisabledState:r}=_e(),{setToastData:i,setToastApiError:l}=H(),c=p=>async()=>{try{await r(e,n,s,a.id,!p),i({text:`Strategy ${p?"enabled":"disabled"}`,type:"success"}),o()}catch(u){l(q(u))}};return{onDisable:c(!1),onEnable:c(!0)}},fc=({projectId:e,environmentId:s,featureId:n,strategy:a})=>{const{addChange:o}=pe(),{refetch:r}=ce(e),{setToastData:i,setToastApiError:l}=H(),c=p=>async()=>{try{await o(e,s,{action:"updateStrategy",feature:n,payload:{...a,disabled:!p}}),i({text:"Changes added to draft",type:"success"}),await r()}catch(u){l(q(u))}};return{onSuggestDisable:c(!1),onSuggestEnable:c(!0)}},yc=({isOpen:e,onClose:s,...n})=>{var j;const{projectId:a,environmentId:o}=n,{isChangeRequestConfigured:r}=te(a),i=r(o),{onSuggestEnable:l,onSuggestDisable:c}=fc({...n}),{onEnable:p,onDisable:u}=xc({...n}),d=!!((j=n.strategy)!=null&&j.disabled),m=h=>{h.preventDefault(),i?d?l():c():d?p():u(),s()};return t.jsx(ue,{title:i?`Add ${d?"enable":"disable"} strategy to change request?`:`Are you sure you want to ${d?"enable":"disable"} this strategy?`,open:e,primaryButtonText:i?"Add to draft":`${d?"Enable":"Disable"} strategy`,secondaryButtonText:"Cancel",onClick:m,onClose:()=>s(),children:t.jsx(B,{condition:i,show:t.jsx(ka,{environment:o}),elseShow:t.jsxs(Z,{severity:"error",children:[d?"Enabling":"Disabling"," the strategy will change which users receive access to the feature."]})})})},mc=({projectId:e,strategy:s,featureId:n,environmentId:a})=>{const[o,r]=x.useState(null),[i,l]=x.useState(!1),[c,p]=x.useState(!1),u=!!o,d=v=>{r(v.currentTarget)},m=v=>{r(null),v.stopPropagation()},j=gt(Ns,e,a),h=gt(Ra,e,a);return t.jsxs(t.Fragment,{children:[t.jsx(z,{sx:{display:"flex",alignItems:"center",textAlign:"center"},children:t.jsx(ee,{title:"More actions",children:t.jsx(xe,{onClick:d,size:"small","aria-controls":u?"actions-menu":void 0,"aria-haspopup":"true","aria-expanded":u?"true":void 0,"data-testid":Da,children:t.jsx(vt,{sx:{width:32,height:32}})})})}),t.jsxs(Qe,{anchorEl:o,id:"actions-menu",open:u,onClose:m,onClick:m,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},"data-testid":Aa,children:[t.jsx(ee,{title:s.disabled?"Enable strategy":"Disable strategy",arrow:!0,placement:"left",children:t.jsxs(ve,{disabled:!j,onClick:()=>l(!0),children:[t.jsx(De,{children:s.disabled?t.jsx(Ea,{}):t.jsx(Ia,{})}),t.jsx(Se,{children:s.disabled?"Enable":"Disable"})]})}),t.jsx(ee,{title:"Remove strategy",arrow:!0,placement:"left",children:t.jsxs(ve,{disabled:!h,onClick:()=>p(!0),"data-testid":$a,children:[t.jsx(De,{children:t.jsx(Ts,{})}),t.jsx(Se,{children:"Remove"})]})})]}),t.jsx(yc,{isOpen:i,onClose:()=>l(!1),projectId:e,featureId:n,environmentId:a,strategy:s}),t.jsx(hc,{isOpen:c,onClose:()=>p(!1),projectId:e,featureId:n,environmentId:a,strategyId:s.id})]})},rs=({strategy:e,index:s,environmentName:n,otherEnvironments:a,isDragging:o,onDragStartRef:r,onDragOver:i,onDragEnd:l})=>{const c=A("projectId"),p=A("featureId");x.useRef(null);const u=Xi(c,p,n,e.id),{changeRequests:d}=Vs(c,e.id),m=Pa(c,p,n,e.id),j=u==null?void 0:u.find(({isScheduledChange:y})=>!y),h=Pe(),v=Ke(h.breakpoints.down("sm"));return t.jsx(Fa,{strategy:e,onDragEnd:l,onDragStartRef:r,onDragOver:i,index:s,isDragging:o,headerItemsRight:t.jsxs(t.Fragment,{children:[j&&!v?t.jsx(Zi,{sx:{mr:1.5},changeAction:j.change.action}):null,d&&d.length>0&&!v?t.jsx(pn,{scheduledChangeRequestIds:(d??[]).map(y=>y.id)}):null,a&&(a==null?void 0:a.length)>0?t.jsx(oc,{environmentId:n,environments:a,strategy:e}):null,t.jsx(Re,{permission:Ns,environmentId:n,projectId:c,component:ae,to:m,tooltipProps:{title:"Edit strategy"},"data-testid":`STRATEGY_EDIT-${e.name}`,children:t.jsx(He,{})}),t.jsx(mc,{projectId:c,featureId:p,environmentId:n,strategy:e})]})})},jc=g("div")(({theme:e})=>({borderBottom:`1px solid ${e.palette.divider}`})),bc=g("div")(({theme:e})=>({padding:e.spacing(2),paddingBottom:e.spacing(0),backgroundColor:Oa(e),':has(+ ol>li[data-type="release-plan"])':{backgroundColor:_a(e)}})),vc=({featureEnvironment:e,isDisabled:s,otherEnvironments:n})=>{const a=A("projectId"),o=A("featureId"),{setStrategiesSortOrder:r}=_e(),{addChange:i}=pe(),{isChangeRequestConfigured:l}=te(a),{refetch:c}=ce(a),{setToastData:p,setToastApiError:u}=H(),{refetchFeature:d}=W(a,o),m=kt("manyStrategiesPagination"),[j,h]=x.useState((e==null?void 0:e.strategies)||[]),{releasePlans:v}=Je(a,o,e==null?void 0:e.name),{trackEvent:y}=ie(),[f,w]=x.useState(null);x.useEffect(()=>{h((e==null?void 0:e.strategies)||[])},[e==null?void 0:e.strategies]),x.useEffect(()=>{j.length>50&&y("many-strategies")},[]);const E=20,{page:O,pages:_,setPageIndex:$,pageIndex:D}=Ki(j,E);if(!e)return null;const I=async b=>{try{await r(a,o,e.name,b),d(),p({text:"Order of strategies updated",type:"success"})}catch(S){u(q(S))}},R=async b=>{await i(a,e.name,{action:"reorderStrategy",feature:o,payload:b}),p({text:"Strategy execution order added to draft",type:"success"}),c()},M=async b=>{try{l(e.name)?await R(b):await I(b)}catch(S){u(q(S))}},G=(b,S)=>F=>{var V;w({id:j[S].id,index:S,height:((V=b.current)==null?void 0:V.offsetHeight)||0}),b!=null&&b.current&&(F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/html",b.current.outerHTML),F.dataTransfer.setDragImage(b.current,20,20))},Q=b=>(S,F)=>V=>{if(f===null||S.current===null||f.index===F||b===f.id)return;const{top:N,bottom:k}=S.current.getBoundingClientRect(),oe=V.clientY-N<f.height,ge=k-V.clientY<f.height,fe=f.index>F;if(oe&&fe||ge&&!fe){const T=[...j],U=T.splice(f.index,1)[0];T.splice(F,0,U),h(T),w({...f,index:F})}},C=()=>{w(null),M(j.map((b,S)=>({id:b.id,sortOrder:S})))},P=j.length>=50&&m;return t.jsxs(jc,{children:[P?t.jsx(bc,{children:t.jsx(Z,{severity:"warning",children:"We noticed you're using a high number of activation strategies. To ensure a more targeted approach, consider leveraging constraints or segments."})}):null,t.jsxs(Ba,{children:[v.map(b=>t.jsx(Xe,{"data-type":"release-plan",children:t.jsx(zs,{plan:b,environmentIsDisabled:s})},b.id)),P?t.jsx(t.Fragment,{children:O.map((b,S)=>t.jsxs(Xe,{children:[S>0||v.length>0?t.jsx(Mt,{}):null,t.jsx(rs,{strategy:b,index:S+D*E,environmentName:e.name,otherEnvironments:n})]},b.id))}):t.jsx(t.Fragment,{children:j.map((b,S)=>t.jsxs(Xe,{children:[S>0||v.length>0?t.jsx(Mt,{}):null,t.jsx(rs,{strategy:b,index:S,environmentName:e.name,otherEnvironments:n,isDragging:(f==null?void 0:f.id)===b.id,onDragStartRef:G,onDragOver:Q(b.id),onDragEnd:C})]},b.id))})]}),P?t.jsx(jr,{count:_.length,shape:"rounded",page:D+1,onChange:(b,S)=>$(S-1)}):null]})},Sc=g(Be)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),color:e.palette.links,fontWeight:e.typography.fontWeightMedium,textDecoration:"none",marginRight:"auto"})),Cc=()=>t.jsx(Sc,{component:"a",href:za,underline:"hover",rel:"noopener noreferrer",target:"_blank",children:"Give feedback to release templates"}),Tc=g("div")(({theme:e})=>({borderRadius:e.shape.borderRadiusLarge,backgroundColor:e.palette.background.paper,border:`1px solid ${e.palette.divider}`})),wc=g(La)(({theme:e})=>({boxShadow:"none",background:"none",[`&:has(.${tr}:focus-visible)`]:{background:e.palette.table.headerHover}})),kc=g(Ma)(({theme:e})=>({padding:0,background:e.palette.background.elevation1,borderBottomLeftRadius:e.shape.borderRadiusLarge,borderBottomRightRadius:e.shape.borderRadiusLarge,boxShadow:e.boxShadows.accordionFooter})),Rc=g("footer")(({theme:e})=>({padding:e.spacing(2,3,3),display:"flex",flexDirection:"column",gap:e.spacing(2)})),Dc=g("div")(({theme:e})=>({width:"100%",position:"relative"})),Ac=({environment:e,metrics:s={yes:0,no:0},otherEnvironments:n=[],onToggleEnvOpen:a=()=>{}})=>{var u,d;const[o,r]=x.useState(!1),i=A("projectId"),l=A("featureId"),{isOss:c}=Te(),p=!!(e!=null&&e.enabled||e!=null&&e.strategies&&(e==null?void 0:e.strategies.length)>0||e!=null&&e.releasePlans&&(e==null?void 0:e.releasePlans.length)>0);return t.jsx(Tc,{children:t.jsxs(wc,{TransitionProps:{mountOnEnter:!0,unmountOnExit:!0},"data-testid":`${Va}_${e.name}`,expanded:o&&p,onChange:()=>{const m=o?!o:p;a(m),r(m)},children:[t.jsxs(sr,{environmentMetadata:{strategyCount:((u=e.strategies)==null?void 0:u.length)??0,releasePlanCount:((d=e.releasePlans)==null?void 0:d.length)??0},environmentId:e.name,expandable:p,children:[t.jsx(Yi,{environment:e}),p?t.jsx(Ui,{environmentMetric:s}):t.jsx(os,{label:"Add strategy",projectId:i,featureId:l,environmentId:e.name,variant:"outlined",size:"small"})]}),t.jsxs(kc,{children:[t.jsx(Dc,{children:t.jsx(vc,{featureEnvironment:e,isDisabled:!e.enabled,otherEnvironments:n})}),t.jsxs(Rc,{children:[t.jsxs(z,{sx:{display:"flex",flexDirection:"row"},children:[t.jsx(Cc,{}),t.jsx(z,{ml:"auto",children:t.jsx(os,{label:"Add strategy",projectId:i,featureId:l,environmentId:e.name})})]}),c()&&(e==null?void 0:e.type)==="production"?t.jsx(Na,{}):null]})]})]})})},is={lastHourUsage:[],seenApplications:[]},Ec=(e,s,n={})=>{const a=async()=>{const u=Fe(`api/admin/client-metrics/features/${s}`),d=await fetch(u,{method:"GET"}).then(Oe("feature metrics"));return d.ok?d.json():is},o=`${e}_${s}_metrics`,{data:r,error:i}=Ms(o,a,{...n}),[l,c]=x.useState(!i&&!r),p=()=>{Rs(o)};return x.useEffect(()=>{c(!i&&!r)},[r,i]),{metrics:r||is,error:i,loading:l,refetch:p,FEATURE_METRICS_CACHE_KEY:o}},Ic=e=>({yes:0,no:0,environment:e,timestamp:""}),$c=(e,s)=>e.map(n=>s.lastHourUsage.find(o=>o.environment===n.name)||Ic(n.name)),Pc=({environment:e,...s})=>{const n=A("projectId"),a=A("featureId"),{releasePlans:o}=Je(n,a,e==null?void 0:e.name);return t.jsx(Ac,{...s,environment:{...e,releasePlans:o}})},Fc=({hiddenEnvironments:e=[],onToggleEnvOpen:s})=>{var l;const n=A("projectId"),a=A("featureId"),{feature:o}=W(n,a),{metrics:r}=Ec(n,a),i=$c(o==null?void 0:o.environments,r);return o?(l=o.environments)==null?void 0:l.filter(c=>!e.includes(c.name)).map(c=>{var p;return t.jsx(Pc,{onToggleEnvOpen:s,environment:c,metrics:i.find(u=>u.environment===(c==null?void 0:c.name)),otherEnvironments:((p=o.environments)==null?void 0:p.map(u=>u.name).filter(u=>u!==c.name&&!e.includes(u)))||[]},c.name)}):null},Oc=()=>{const[e,s]=qs("environment-visibiilty",[]),{trackEvent:n}=ie();return{hiddenEnvironments:e,onEnvironmentVisibilityChange:o=>{e.includes(o)?(s(e.filter(r=>r!==o)),n("hidden_environment",{props:{eventType:"environment unhidden"}})):(s([...e,o]),n("hidden_environment",{props:{eventType:"environment hidden"}}))}}},_c=g(z)(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(1),maxWidth:"300px",background:"#201e42",borderRadius:e.shape.borderRadiusMedium,color:e.palette.common.white,padding:e.spacing(2),paddingRight:e.spacing(1),fontSize:e.typography.body2.fontSize})),Bc=g(ne)(({theme:e})=>({color:e.palette.secondary.border,alignSelf:"start",marginLeft:e.spacing(-1)})),zc=g(xe)(({theme:e})=>({color:e.palette.common.white,background:"none",border:"none",position:"absolute",top:e.spacing(1),right:e.spacing(1),svg:{width:e.spacing(2),height:e.spacing(2)}})),Lc=g("p")(({theme:e})=>({fontSize:e.typography.body1.fontSize,fontWeight:"bold"})),Mc=({closeProps:e})=>t.jsxs(_c,{component:"article",children:[t.jsx(zc,{type:"button",...e,children:t.jsx(wt,{})}),t.jsx(Lc,{children:"Decide the order evaluation"}),t.jsx("p",{children:"Strategies are evaluated in the order presented here. Drag and rearrange the strategies to get the order you prefer."}),t.jsx(Bc,{type:"button","data-action":e["data-action"],onClick:e.onClick,children:"Ok, got it!"})]}),Vc=({show:e,onClose:s})=>t.jsx(qa,{callback:({action:n})=>{n==="close"&&s()},floaterProps:{styles:{arrow:{color:"#201e42",spread:16,length:10}}},run:e,disableOverlay:!0,disableScrolling:!0,tooltipComponent:Mc,steps:[{disableBeacon:!0,offset:0,target:".strategy-drag-handle",content:t.jsx(t.Fragment,{})}]});var It={},Nc=Ie;Object.defineProperty(It,"__esModule",{value:!0});var mt=It.default=void 0,qc=Nc(Ee()),Wc=t,Hc=(0,qc.default)((0,Wc.jsx)("path",{d:"M16 11h-1V3c0-1.1-.9-2-2-2h-2c-1.1 0-2 .9-2 2v8H8c-2.76 0-5 2.24-5 5v7h18v-7c0-2.76-2.24-5-5-5zm3 10h-2v-3c0-.55-.45-1-1-1s-1 .45-1 1v3h-2v-3c0-.55-.45-1-1-1s-1 .45-1 1v3H9v-3c0-.55-.45-1-1-1s-1 .45-1 1v3H5v-5c0-1.65 1.35-3 3-3h8c1.65 0 3 1.35 3 3v5z"}),"CleaningServices");mt=It.default=Hc;const Uc="flag-reminders:v1",Gc=50,Yc=7,Jc=({days:e=Yc,maxReminders:s=Gc}={})=>{const[n,a]=qs(Uc,{});return{shouldShowReminder:i=>{const l=n[i];return!l||Wa(new Date,new Date(l))},snoozeReminder:(i,l=e)=>{const c=Ha(new Date,l).getTime();a(p=>{const u={...p,[i]:c},d=Object.entries(u);if(d.length>s){d.sort((j,h)=>j[1]-h[1]);const m=d.slice(d.length-s);return Object.fromEntries(m)}return u})}}},Kc=g(z)(({theme:e})=>({marginBottom:e.spacing(2)})),cs=g(z)(({theme:e})=>({display:"flex",gap:e.spacing(1),alignItems:"center"})),Qc=30,Xc=3,Zc=({feature:e,onChange:s})=>{const n=le(),{trackEvent:a}=ie(),[o,r]=x.useState(!1),[i,l]=x.useState(!1),{onUncompleteHandler:c,loading:p}=Ua({feature:e.name,project:e.project,onChange:s}),u=Ga(e),d=e.type==="release"||e.type==="experiment",m=u==null?void 0:u.enteredStageAt,j=m?Ya(new Date,St(m)):0,{shouldShowReminder:h,snoozeReminder:v}=Jc(),f=(()=>{if(!u||!d)return null;if(u.name==="live"&&j>Qc)return"complete";if(u.name==="completed"&&h(e.name)){if(Ka(u.environments))return"archive";if(j>Xc)return"removeCode"}return null})();return f?t.jsxs(Kc,{children:[f==="complete"&&t.jsxs(t.Fragment,{children:[t.jsxs(Z,{severity:"info",icon:t.jsx(Ja,{}),action:t.jsx(K,{variant:"contained",permission:Ce,size:"medium",onClick:()=>r(!0),projectId:e.project,children:"Mark completed"}),children:[t.jsx("b",{children:"Is this flag ready to be completed?"}),t.jsxs("p",{children:["This flag has been in production for"," ",t.jsxs("b",{children:[j," days"]}),". Can it be removed from the code?"]})]}),t.jsx(Ks,{isOpen:o,setIsOpen:r,projectId:e.project,featureId:e.name,onComplete:s})]}),f==="archive"&&t.jsxs(t.Fragment,{children:[t.jsxs(Z,{severity:"warning",icon:t.jsx(mt,{}),action:t.jsxs(cs,{children:[t.jsx(ne,{size:"medium",onClick:()=>{v(e.name),a("feature-lifecycle",{props:{eventType:"snoozeReminder"}})},children:"Remind me later"}),t.jsx(K,{variant:"contained",permission:Ws,size:"medium",onClick:()=>l(!0),projectId:e.project,children:"Archive flag"})]}),children:[t.jsx("b",{children:"Time to clean up technical debt?"}),t.jsx("p",{children:"We haven't observed any metrics for this flag lately. Can it be archived?"})]}),e.children.length>0?t.jsx(At,{features:e.children,project:e.project,isOpen:i,onClose:()=>l(!1)}):t.jsx(Dt,{isOpen:i,onConfirm:()=>{n(`/projects/${e.project}`)},onClose:()=>l(!1),projectId:e.project,featureIds:[e.name]})]}),f==="removeCode"&&t.jsxs(Z,{severity:"warning",icon:t.jsx(mt,{}),action:t.jsxs(cs,{children:[t.jsx(ne,{size:"medium",onClick:()=>{v(e.name),a("feature-lifecycle",{props:{eventType:"snoozeReminder"}})},children:"Remind me later"}),t.jsx(K,{variant:"outlined",permission:Ce,size:"medium",onClick:c,disabled:p,projectId:e.project,children:"Revert to production"})]}),children:[t.jsx("b",{children:"Time to remove flag from code?"}),t.jsx("p",{children:"This flag was marked as complete and ready for cleanup. We're still seeing it being used within the last 2 days. Have you removed the flag from your code?"})]})]}):null},el=g("div")(({theme:e})=>({display:"flex",width:"100%",gap:e.spacing(2),[e.breakpoints.down("md")]:{flexDirection:"column"}})),tl=g("div")(({theme:e})=>({display:"flex",flexDirection:"column",flexGrow:1,gap:e.spacing(2)})),sl=()=>{const e=le(),s=A("projectId"),n=A("featureId"),a=Tt(s,n),{hiddenEnvironments:o,onEnvironmentVisibilityChange:r}=Oc(),i=()=>e(a);Hs(n);const{setLastViewed:l}=ri();x.useEffect(()=>{l({featureId:n,projectId:s})},[n]);const{setSplashSeen:c}=Qa(),{splash:p}=Xa(),[u,d]=x.useState(!1),[m,j]=x.useState(!1),{feature:h,refetchFeature:v,loading:y}=W(s,n),f="strategy-drag-tooltip",w=!(p!=null&&p[f]),E=_=>{d(!m&&w&&_)},O=()=>{j(!0),c(f)};return t.jsxs("div",{children:[t.jsx(Zc,{feature:h,onChange:v}),t.jsxs(el,{children:[t.jsx("div",{children:y?null:t.jsx(si,{hiddenEnvironments:o,onEnvironmentVisibilityChange:r,feature:h,onChange:v})}),t.jsx(tl,{children:t.jsx(Fc,{onToggleEnvOpen:E,hiddenEnvironments:o})}),t.jsxs(Us,{children:[t.jsx(je,{path:"strategies/create",element:t.jsx(ht,{label:"Create feature strategy",onClose:i,open:!0,children:t.jsx(ai,{})})}),t.jsx(je,{path:"strategies/edit",element:t.jsx(ht,{label:"Edit feature strategy",onClose:i,open:!0,children:t.jsx(Za,{})})})]})]}),t.jsx(Vc,{show:u,onClose:O})]})},nl=g("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"},marginTop:e.spacing(-3.5),marginBottom:e.spacing(2),backgroundColor:e.palette.background.default,paddingTop:e.spacing(2),paddingBottom:e.spacing(2),position:"sticky",top:0,zIndex:2})),al=g(Gs,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:s})=>({color:s?e.palette.neutral.border:e.palette.primary.main})),ol=g("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:s})=>({color:s?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontSize:e.fontSizes.mainHeader,fontWeight:e.fontWeight.bold})),rl=g("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),il=g(Z)(({theme:e})=>({marginBottom:e.spacing(2)})),cl=g(Z)(({theme:e})=>({marginTop:e.spacing(4)})),ll=g("div")({display:"flex",flexDirection:"column"}),dl=g("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),ls=g("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),ul=g(Ys)(({theme:e})=>({margin:e.spacing(4,0)})),pl=g(eo)(({theme:e})=>({minWidth:e.spacing(20),width:"100%"})),gl=g("div")(({theme:e})=>({marginTop:"auto",paddingTop:e.spacing(4),display:"flex",justifyContent:"flex-end"})),hl=g(ne)(({theme:e})=>({marginLeft:e.spacing(3)})),xl=x.memo(to),fl=({environment:e,open:s,setOpen:n,getApiPayload:a,getCrPayload:o,onConfirm:r})=>{const i=A("projectId"),l=A("featureId"),{uiConfig:c}=Te(),{context:p}=so(),{defaultStickiness:u,loading:d}=no(i),{isChangeRequestConfigured:m}=te(i),{data:j}=ce(i),{changeRequestInReviewOrApproved:h,alert:v}=oo(j),y=(e==null?void 0:e.variants)||[],[f,w]=x.useState([]),[E,O]=x.useState();x.useEffect(()=>{d||w(y.length?y.map(T=>({...T,isValid:!0,new:!1,id:Ze()})):[{name:"",weightType:Vt.VARIABLE,weight:0,overrides:[],stickiness:(f==null?void 0:f.length)>0?f[0].stickiness:u,new:!0,isValid:!1,id:Ze()}])},[s,d]);const _=(T,U)=>{w(ye=>Nt(ye.map(Y=>Y.id===U?T:Y),1e3))},$=()=>{const T=Ze();w(U=>[...U,{name:"",weightType:Vt.VARIABLE,weight:0,overrides:[],stickiness:(U==null?void 0:U.length)>0?U[0].stickiness:u,new:!0,isValid:!1,id:T}]),O(T)};x.useEffect(()=>{if(E){const T=document.getElementById(`variant-name-input-${E}`);T==null||T.scrollIntoView({behavior:"smooth",block:"center"}),T==null||T.focus({preventScroll:!0}),O(void 0)}},[E]);const D=f.map(({new:T,isValid:U,id:ye,...Y})=>Y),I=a(y,D),R=o(D),M=async T=>{T.preventDefault(),r(D)},G=()=>b?`curl --location --request POST '${c.unleashUrl}/api/admin/projects/${i}/environments/${e==null?void 0:e.name}/change-requests' \\
5
- --header 'Authorization: INSERT_API_KEY' \\
6
- --header 'Content-Type: application/json' \\
7
- --data-raw '${JSON.stringify(R,void 0,2)}'`:`curl --location --request PATCH '${c.unleashUrl}/api/admin/projects/${i}/features/${l}/environments/${e==null?void 0:e.name}/variants' \\
8
- --header 'Authorization: INSERT_API_KEY' \\
9
- --header 'Content-Type: application/json' \\
10
- --data-raw '${JSON.stringify(I.patch,void 0,2)}'`,Q=f.every(({isValid:T})=>T),C=h((e==null?void 0:e.name)||""),P=C?"Add to existing change request":"Add change to draft",b=m((e==null?void 0:e.name)||""),S=x.useMemo(()=>{var T;return d?"":((T=D[0])==null?void 0:T.stickiness)||u},[d,u,JSON.stringify(D[0]??{})]),F=x.useMemo(()=>["default",...p.filter(T=>T.stickiness).map(T=>T.name)],[p]),V=F.map(T=>({key:T,label:T}));F.includes(S)||V.push({key:S,label:S});const N=async T=>{w(U=>U.map(ye=>({...ye,stickiness:T})))},k=T=>{N(T)},[oe,ge]=x.useState();x.useEffect(()=>{ge(void 0),I.error&&ge(I.error)},[I.error]);const fe=()=>{N(u),n(!1)};return d||S===""?t.jsx(ao,{}):t.jsx(ht,{open:s,onClose:fe,label:"",children:t.jsxs(Ps,{modal:!0,title:"",description:"Variants allow you to return a variant object if the feature flag is considered enabled for the current request.",documentationLink:"https://docs.getunleash.io/reference/feature-toggle-variants",documentationLinkLabel:"Feature flag variants documentation",formatApiCode:G,loading:!s,children:[t.jsxs(nl,{children:[t.jsxs("div",{children:[t.jsx(al,{deprecated:!(e!=null&&e.enabled)}),t.jsx(ol,{deprecated:!(e!=null&&e.enabled),children:e==null?void 0:e.name})]}),t.jsx(K,{"data-testid":"MODAL_ADD_VARIANT_BUTTON",onClick:$,variant:"outlined",permission:ke,projectId:i,environmentId:e==null?void 0:e.name,children:"Add variant"})]}),t.jsxs(rl,{onSubmit:M,children:[t.jsx(B,{condition:C,show:v,elseShow:t.jsx(B,{condition:!!b,show:t.jsxs(il,{severity:"info",children:[t.jsx("strong",{children:"Change requests"})," are enabled",e?` for ${e.name}`:"",". Your changes need to be approved before they will be live. All the changes you do now will be added into a draft that you can submit for review."]})})}),t.jsx(ll,{children:f.map(T=>t.jsx(xl,{variant:T,variants:f,updateVariant:U=>_(U,T.id),removeVariant:()=>w(U=>Nt(U.filter(ye=>ye.id!==T.id),1e3)),error:I.error},T.id))}),t.jsx(K,{onClick:$,variant:"outlined",permission:ke,projectId:i,environmentId:e==null?void 0:e.name,children:"Add variant"}),t.jsx(ul,{}),t.jsx(B,{condition:f.length>0,show:t.jsxs(t.Fragment,{children:[t.jsx(dl,{children:t.jsx("p",{children:"Stickiness"})}),t.jsxs(ls,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t.jsx(Be,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]}),t.jsx("div",{children:t.jsx(pl,{value:S,label:"",editable:!0,onChange:T=>k(T.target.value)})})]}),elseShow:t.jsx(ls,{children:"This environment has no variants. Get started by adding a variant."})}),t.jsxs(cl,{severity:"error",hidden:!oe,children:[t.jsx("strong",{children:"Error: "}),oe]}),t.jsxs(gl,{children:[t.jsx(ne,{"data-testid":"DIALOGUE_CONFIRM_ID",type:"submit",variant:"contained",color:"primary",disabled:!Q,children:b?P:"Save variants"}),t.jsx(hl,{onClick:fe,children:"Cancel"})]})]})]})})},yl=e=>fetch(e).then(Oe("ChangeRequest")).then(s=>s.json()),ml=(e,s)=>{const{data:n,error:a,mutate:o}=Ls([],Fe(`api/admin/projects/${e}/change-requests/scheduled?variantForFlag=${s}`),yl);return{changeRequests:n,loading:!a&&!n,refetch:o,error:a}},jl=(e,s,n)=>{const{changeRequests:a}=ml(e,s),o=a==null?void 0:a.filter(r=>r.environment===n);return o?o.map(r=>r.id):[]},bl=g("div")(({theme:e})=>({padding:e.spacing(3),borderRadius:e.shape.borderRadiusLarge,border:`1px solid ${e.palette.divider}`,"&:not(:last-child)":{marginBottom:e.spacing(3)}})),vl=g("div")({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"}}),Sl=g(Gs,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:s})=>({color:s?e.palette.neutral.border:e.palette.primary.main})),Cl=g("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:s})=>({color:s?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontWeight:e.fontWeight.bold})),Tl=g("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),wl=g("div")(({theme:e})=>({margin:e.spacing(3,0)})),kl=g("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),Rl=({environment:e,searchValue:s,children:n})=>{var c;const a=A("projectId"),o=A("featureId"),r=jl(a,o,e.name),i=e.variants??[],l=((c=i[0])==null?void 0:c.stickiness)||"default";return t.jsxs(bl,{children:[t.jsxs(vl,{children:[t.jsxs("div",{children:[t.jsx(Sl,{deprecated:!e.enabled}),t.jsx(Cl,{deprecated:!e.enabled,children:e.name}),t.jsx(B,{condition:r.length>0,show:t.jsx(ro,{sx:{ml:2},children:t.jsx(pn,{scheduledChangeRequestIds:r})})})]}),n]}),t.jsx(B,{condition:i.length>0,show:t.jsxs(t.Fragment,{children:[t.jsx(wl,{children:t.jsx(io,{variants:i,searchValue:s})}),t.jsx(B,{condition:i.length>1,show:t.jsxs(t.Fragment,{children:[t.jsxs(kl,{children:[t.jsx("p",{children:"Stickiness:"}),t.jsx(Ae,{children:l})]}),t.jsxs(Tl,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t.jsx(Be,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]})]})})]})})]})},Dl=g(Se)(({theme:e})=>({"& span":{fontSize:e.fontSizes.smallBody}})),Al=({environment:e,permission:s,projectId:n,environmentId:a,onCopyVariantsFrom:o,otherEnvsWithVariants:r})=>{const[i,l]=x.useState(null),c=!!i,p=e.variants??[];return t.jsx(B,{condition:r.length>0&&p.length===0,show:t.jsxs(t.Fragment,{children:[t.jsx(K,{onClick:u=>{l(u.currentTarget)},id:`copy-from-menu-${e.name}`,"aria-controls":c?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":c?"true":void 0,variant:"outlined",permission:s,projectId:n,environmentId:a,children:"Copy variants from"}),t.jsx(Qe,{anchorEl:i,open:c,onClose:()=>l(null),MenuListProps:{"aria-labelledby":`copy-from-menu-${e.name}`},children:r.map(u=>t.jsx(ve,{onClick:()=>o(u,e),children:t.jsx(Dl,{children:`Copy from ${u.name}`})},u.name))})]})})},El=({permission:e,projectId:s,environment:n,checked:a,onClick:o,...r})=>{const i=gt(e,s,n);return t.jsxs(ve,{disabled:!i,onClick:o,...r,children:[t.jsx(bs,{checked:a}),n]})},Il=g(Qe)(({theme:e})=>({"& > div > ul":{display:"flex",flexDirection:"column",justifyContent:"center","& > li":{padding:e.spacing(0,1)}}})),$l=g("div")(({theme:e})=>({margin:e.spacing(1,2)})),Pl=g(ne)(({theme:e})=>({marginTop:e.spacing(2)})),Fl=({current:e,environments:s,permission:n,projectId:a,onSubmit:o})=>{var v;const[r,i]=x.useState(null),l=!!r,[c,p]=x.useState([]),u=y=>{p(f=>[...f,y])},d=y=>{p(f=>f.filter(({name:w})=>w!==y.name))},m=y=>{c.includes(y)?d(y):u(y)},j=()=>{p([]),i(null)},h=((v=s.find(y=>y.name===e))==null?void 0:v.variants)??[];return t.jsx(B,{condition:h.length>0&&s.length>1,show:t.jsxs(t.Fragment,{children:[t.jsx(ne,{onClick:y=>{i(y.currentTarget)},id:`push-to-menu-${e}`,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,variant:"outlined",children:"Copy to environment"}),t.jsxs(Il,{anchorEl:r,open:l,onClose:()=>i(null),MenuListProps:{"aria-labelledby":`push-to-menu-${e}`},children:[s.filter(y=>y.name!==e).map(y=>t.jsx(El,{projectId:a,permission:n,environment:y.name,checked:c.includes(y),onClick:()=>m(y)},y.name)),t.jsxs($l,{children:[t.jsx(Ys,{}),t.jsxs(Pl,{variant:"outlined",onClick:()=>{o(c),j()},disabled:c.length===0,children:["Push to selected (",c.length,")"]})]})]})]})})},Ol=g("div")(({theme:e})=>({display:"flex",gap:e.spacing(1.5)})),_l=()=>{const{setToastData:e,setToastApiError:s}=H(),n=Pe(),a=Ke(n.breakpoints.down("md")),o=A("projectId"),r=A("featureId"),{feature:i,refetchFeature:l,loading:c}=W(o,r),{patchFeatureEnvironmentVariants:p,overrideVariantsInEnvironments:u}=Ye(),{refetch:d}=ce(o),{addChange:m}=pe(),{isChangeRequestConfigured:j}=te(o),[h,v]=x.useState(""),[y,f]=x.useState(),[w,E]=x.useState(!1),O=x.useMemo(()=>{var C;return((C=i==null?void 0:i.environments)==null?void 0:C.map(P=>({...P,crEnabled:j(P.name)})))||[]},[i.environments]),_=(C,P)=>po(C,P),$=(C,P)=>{try{const b=uo(P,1e3);return{patch:_(C,b)}}catch(b){return{patch:[],error:q(b)}}},D=C=>({feature:r,action:"patchVariant",payload:{variants:C}}),I=async(C,P)=>{if(C.crEnabled)await m(o,C.name,D(P)),d();else{const b=C.variants??[],{patch:S,error:F}=$(b,P);if(S.length===0)return;if(F){e({type:"error",text:F});return}await p(o,r,C.name,S)}l()},R=async(C,P)=>{try{const b=P.filter(({crEnabled:k})=>k),S=P.filter(({crEnabled:k})=>!k);b.length&&await Promise.all(b.map(k=>m(o,k.name,D(C)))),S.length&&await u(o,r,C,S.map(({name:k})=>k)),d(),l();const F=S.length?`Variants pushed to ${S.length===1?S[0].name:`${S.length} environments`}`:"",V=b.length?`Variants push added to ${b.length===1?`${b[0].name} draft`:`${b.length} drafts`}`:"",N=`${F}${F&&V?". ":""}${V}`;e({text:N,type:"success"})}catch(b){s(q(b))}},M=C=>{f(C),E(!0)},G=async C=>{if(y)try{await I(y,C),E(!1),e({text:y.crEnabled?"Variant changes added to draft":"Variants updated successfully",type:"success"})}catch(P){s(q(P))}},Q=async(C,P)=>{try{const b=C.variants??[];await I(P,b),e({text:P.crEnabled?"Variants copy added to draft":"Variants copied successfully",type:"success"})}catch(b){s(q(b))}};return t.jsxs(Rt,{isLoading:c,header:t.jsx(co,{title:"Variants",actions:t.jsx(B,{condition:!a,show:t.jsx(t.Fragment,{children:t.jsx(qt,{initialValue:h,onChange:v})})}),children:t.jsx(B,{condition:a,show:t.jsx(qt,{initialValue:h,onChange:v})})}),children:[t.jsx(lo,{}),O.map(C=>{var b;const P=O.filter(({name:S,variants:F})=>S!==C.name&&(F==null?void 0:F.length));return t.jsx(Rl,{environment:C,searchValue:h,children:t.jsxs(Ol,{children:[t.jsx(Fl,{current:C.name,environments:O,permission:ke,projectId:o,onSubmit:S=>R(C.variants??[],S)}),t.jsx(Al,{environment:C,permission:ke,projectId:o,environmentId:C.name,onCopyVariantsFrom:Q,otherEnvsWithVariants:P}),t.jsx(B,{condition:!!((b=C.variants)!=null&&b.length),show:t.jsx(Re,{"data-testid":"EDIT_VARIANTS_BUTTON",onClick:()=>M(C),permission:ke,projectId:o,environmentId:C.name,tooltipProps:{title:"Edit variants"},children:t.jsx(He,{})}),elseShow:t.jsx(K,{"data-testid":"ADD_VARIANT_BUTTON",onClick:()=>M(C),variant:"outlined",permission:ke,projectId:o,environmentId:C.name,children:"Add variant"})})]})},C.name)}),t.jsx(fl,{environment:y,open:w,setOpen:E,getApiPayload:$,getCrPayload:D,onConfirm:G})]})},Bl=({value:e,timeZone:s})=>{const{locationSettings:n}=$s(),a=e?e instanceof Date?Wt(e,n.locale,s):Wt(St(e),n.locale,s):void 0;return t.jsx(qe,{lineClamp:1,children:a})};var $t={},zl=Ie;Object.defineProperty($t,"__esModule",{value:!0});var hn=$t.default=void 0,Ll=zl(Ee()),Ml=t,Vl=(0,Ll.default)((0,Ml.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z"}),"Assessment");hn=$t.default=Vl;const Nl=g(L)(({theme:e})=>({fontSize:e.fontSizes.smallerBody})),ql=({row:e})=>e.original.selectedApplications&&e.original.selectedApplications.length>1?t.jsx(qe,{children:t.jsx(Ue,{tooltip:t.jsx(t.Fragment,{children:e.original.selectedApplications.map(s=>t.jsx(Nl,{children:s},s))}),children:e.original.appName})}):t.jsx(qe,{children:e.original.appName}),Wl=({metrics:e,tableSectionId:s})=>{const n=Ke(go.breakpoints.down("md")),a=x.useMemo(()=>({sortBy:[{id:"timestamp"}]}),[]),{getTableProps:o,getTableBodyProps:r,headerGroups:i,rows:l,prepareRow:c,setHiddenColumns:p}=et.useTable({initialState:a,columns:ds,data:e,autoResetHiddenColumns:!1,disableSortRemove:!0,defaultColumn:{Cell:qe}},et.useGlobalFilter,et.useSortBy);return ho([{condition:n,columns:["appName","environment"]}],p,ds),e.length===0?null:t.jsxs(xo,{...o(),rowHeight:"standard",id:s,children:[t.jsx(fo,{headerGroups:i}),t.jsx(yo,{...r(),children:l.map(u=>{c(u);const{key:d,...m}=u.getRowProps();return t.jsx(mo,{hover:!0,...m,children:u.cells.map(j=>{const{key:h,...v}=j.getCellProps();return t.jsx(jo,{...v,children:j.render("Cell")},h)})},d)})})]})},ds=[{id:"Icon",width:"1%",disableSortBy:!0,Cell:()=>t.jsx(bo,{icon:t.jsx(hn,{color:"disabled"})})},{Header:"Time",accessor:"timestamp",Cell:e=>t.jsx(Bl,{value:e.row.original.timestamp,timeZone:e.row.original.timestamp.includes("23:59")?"UTC":void 0})},{Header:"Application",accessor:"appName",Cell:ql},{Header:"Environment",accessor:"environment"},{id:"requested",Header:"Requested",accessor:e=>e.yes+e.no},{Header:"Exposed",accessor:"yes"}],Hl=e=>e>48?`${Math.floor(e/24)} days (UTC)`:`${e} hours (local time)`,it=g("article")(({theme:e})=>({padding:e.spacing(2),background:"transparent",borderRadius:e.spacing(2),textAlign:"center",[e.breakpoints.up("md")]:{padding:e.spacing(4)}})),ct=g("h3")(({theme:e})=>({margin:0,fontSize:e.fontSizes.bodySize,fontWeight:e.fontWeight.thin})),lt=g("p")(({theme:e})=>({fontSize:"2.25rem",fontWeight:e.fontWeight.bold,color:e.palette.primary.main})),dt=g("p")(({theme:e})=>({margin:e.spacing(1,0,0,0),padding:e.spacing(2,0,0,0),borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:e.palette.divider,fontSize:e.fontSizes.smallerBody,color:e.palette.text.secondary})),Ul=({totalYes:e,totalNo:s,hoursBack:n,statsSectionId:a,tableSectionId:o})=>{const r=n===1?"in the last hour":`in the last ${Hl(n)}`;return t.jsxs(he,{container:!0,spacing:2,id:a,"aria-describedby":o,"aria-label":"Feature metrics summary",component:"section",children:[t.jsx(he,{item:!0,xs:12,sm:4,children:t.jsxs(it,{children:[t.jsx(ct,{children:"Exposure"}),t.jsx(lt,{children:t.jsx(Ne,{value:e})}),t.jsxs(dt,{children:["Total exposure of the feature in the environment"," ",r,"."]})]})}),t.jsx(he,{item:!0,xs:12,sm:4,children:t.jsxs(it,{children:[t.jsx(ct,{children:"Exposure %"}),t.jsxs(lt,{children:[dn(e+s,e),"%"]}),t.jsxs(dt,{children:["% total exposure of the feature in the environment"," ",r,"."]})]})}),t.jsx(he,{item:!0,xs:12,sm:4,children:t.jsxs(it,{children:[t.jsx(ct,{children:"Requests"}),t.jsx(lt,{children:t.jsx(Ne,{value:e+s})}),t.jsxs(dt,{children:["Total requests for the feature in the environment"," ",r,"."]})]})})]})},Gl=({metrics:e,...s})=>{const n=x.useMemo(()=>e.reduce((o,r)=>o+r.yes,0),[e]),a=x.useMemo(()=>e.reduce((o,r)=>o+r.no,0),[e]);return t.jsx(Ul,{...s,totalYes:n,totalNo:a})},Yl=({metrics:e,hoursBack:s})=>{const n=Ht(),a=Ht();return e.length===0?t.jsxs(z,{mt:6,children:[t.jsx(L,{variant:"body1",paragraph:!0,children:"We have yet to receive any metrics for this feature flag in the selected time period."}),t.jsx(L,{variant:"body1",paragraph:!0,children:"Please note that, since the SDKs send metrics on an interval, it might take some time before metrics appear."})]}):t.jsxs(x.Suspense,{fallback:null,children:[t.jsx(z,{borderTop:1,pt:2,mt:3,borderColor:"divider",children:t.jsx(Jl,{metrics:e,hoursBack:s,statsSectionId:n})}),t.jsx(z,{mt:4,children:t.jsx(Gl,{metrics:e,hoursBack:s,statsSectionId:n,tableSectionId:a})}),t.jsx(z,{mt:4,children:t.jsx(Wl,{metrics:e,tableSectionId:a})})]})},Jl=vo.lazy(()=>So(()=>import("./FeatureMetricsChart-LENYZ5kx.js"),[])),Kl=g("h2")(({theme:e})=>({margin:0,marginBottom:e.spacing(1.5),fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.thin,color:e.palette.text.secondary})),Ql=g("ul")(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing(1),listStyleType:"none",padding:0,minHeight:"100%",alignItems:"center",maxHeight:"200px",overflowY:"auto"})),Xl=g("li")(({theme:e})=>({"& > [aria-pressed=true]":{backgroundColor:e.palette.background.alternative,color:e.palette.primary.contrastText},"& > [aria-pressed=true]:hover":{backgroundColor:e.palette.primary.light}})),us=({title:e,values:s,selectedValues:n,toggleValue:a,toggleValues:o})=>{const r=c=>()=>{a(c)},i=[...s].every(c=>n.includes(c)),l=x.useMemo(()=>Array.from(s).sort((c,p)=>c.localeCompare(p)),[s]);return t.jsxs("div",{children:[t.jsx(Kl,{children:e}),t.jsxs(Ql,{children:[o&&s.size>1&&t.jsx(ne,{size:"small",onClick:o,"aria-pressed":i,children:i?"Unselect":"Select all"}),l.map(c=>t.jsx(Xl,{children:t.jsx(As,{label:c,onClick:r(c),"aria-pressed":n==null?void 0:n.includes(c),sx:Co})},c))]})]})},Zl=()=>{const e=A("projectId"),s=A("featureId"),n=ed(e,s);Hs("Metrics");const a=Array.from(n)[0],[o,r]=To({environment:tt(wo,a),applications:tt(ko,[]),hoursBack:tt(Ro,xt)}),i=td(s,o.hoursBack||xt),l=Array.from(i),c=l[0],{environment:p,hoursBack:u}=o,d=o.applications.filter(f=>f!==null);x.useEffect(()=>{o.applications&&o.applications.length===0&&r({applications:l})},[JSON.stringify(l)]);const m=[...i].every(f=>d.includes(f)),{featureMetrics:j}=Qs(s,u),[h,v]=x.useState(j);x.useEffect(()=>{j&&v(j)},[j]);const y=x.useMemo(()=>Ho((h==null?void 0:h.filter(f=>p===f.environment).filter(f=>d.includes(f.appName)))||[]).map(f=>({...f,appName:d.length>1?"all selected":f.appName,selectedApplications:d})),[h,p,JSON.stringify(d)]);return y?t.jsxs(Rt,{children:[t.jsxs(he,{container:!0,component:"header",spacing:2,children:[t.jsx(he,{item:!0,xs:12,md:4,children:t.jsx(B,{condition:n.size>0,show:t.jsx(us,{title:"Environments",values:n,selectedValues:[p],toggleValue:f=>{r({environment:f})}})})}),t.jsx(he,{item:!0,xs:12,md:6,children:t.jsx(B,{condition:i.size>0,show:t.jsx(us,{title:"Applications",values:i,selectedValues:d,toggleValues:()=>{r(m?{applications:[c]}:{applications:[...i]})},toggleValue:f=>{d.includes(f)?r({applications:d.filter(w=>w!==f)}):r({applications:[...d,f]})}})})}),t.jsx(he,{item:!0,xs:12,md:2,children:t.jsx(Uo,{hoursBack:u,setHoursBack:f=>r({hoursBack:f})})})]}),t.jsx(Yl,{metrics:y,hoursBack:u})]}):null},ed=(e,s)=>{const{feature:n}=W(e,s),a=n.environments.map(o=>o.name);return new Set(a)},td=(e,s=xt)=>{const{featureMetrics:n=[]}=Qs(e,s),a=n.map(o=>o.appName);return new Set(a)},sd=({enabled:e,value:s,onChange:n,filter:a,...o})=>{const{projects:r}=Js();if(!e)return null;const i=c=>({key:c.id,label:c.name,title:c.description||"",sx:{whiteSpace:"pre-line"}});let l;return a?l=r.filter(c=>a(c.id)).map(i):l=r.map(i),s&&!l.find(c=>c.key===s)&&l.push({key:s,label:s}),t.jsx(Ss,{label:"Project",options:l,value:s,onChange:n,...o})},nd=(e,s)=>{const n=new Set(e),a=new Set(s);return n.size!==a.size?!1:[...n].every(o=>a.has(o))},ps=g("div")(({theme:e})=>({display:"grid",gap:e.spacing(2)})),gs=g(Z)(({theme:e})=>({marginBottom:e.spacing(1)})),ad=g(Ct)({padding:0}),od=({projectId:e,open:s,onClose:n,onClick:a,feature:o,changeRequests:r})=>{const i=A("projectId"),{project:l}=Do(e),{isChangeRequestConfiguredInAnyEnv:c}=te(e),p=c(),u=x.useMemo(()=>{var j;return nd(o.environments.map(h=>h.name),((j=l.environments)==null?void 0:j.map(h=>h.environment))||[])},[o,l]),d=r?r.length>0:!1,m=o.dependencies.length>0||o.children.length>0;return t.jsx(B,{condition:u&&!m&&!d&&!p,show:t.jsx(ue,{open:s,onClose:n,onClick:a,title:"Confirm change project",primaryButtonText:"Change project",secondaryButtonText:"Cancel",children:t.jsxs(ps,{children:[t.jsx(gs,{severity:"success",children:"This feature flag is compatible with the new project."}),t.jsx("p",{children:"Are you sure you want to change the project for this flag?"})]})}),elseShow:t.jsx(ue,{open:s,onClick:n,title:"Confirm change project",primaryButtonText:"Close",children:t.jsxs(ps,{children:[t.jsx(gs,{severity:"warning",children:"Cannot proceed with the move"}),t.jsx(B,{condition:m,show:t.jsxs("p",{children:[t.jsx("span",{children:"The feature flag must not have any dependencies."})," ",t.jsx("br",{}),t.jsx("span",{children:"Please remove feature dependencies first."})]})}),t.jsx(B,{condition:!u,show:t.jsx("p",{children:"In order to move a feature flag between two projects, both projects must have the exact same environments enabled."})}),t.jsx(B,{condition:d,show:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"The feature flag must not have any pending change requests. This feature flag is currently referenced in the following change requests:"}),t.jsx(ad,{children:r==null?void 0:r.map(j=>t.jsx(Ve,{children:t.jsxs(ae,{to:`/projects/${i}/change-requests/${j.id}`,children:["View change request"," ",j.id]})},j.id))})]})}),t.jsx(B,{condition:p,show:t.jsxs("p",{children:["You're not allowed to move the feature to project"," ",t.jsx(ae,{to:`/projects/${e}/settings/change-requests`,children:e}),". This project has change requests enabled."]})})]})})})},rd=()=>{const{hasAccess:e}=x.useContext(Es),s=A("projectId"),n=A("featureId"),{feature:a,refetchFeature:o}=W(s,n),[r,i]=x.useState(!1),{changeFeatureProject:l}=Ye(),{setToastData:c,setToastApiError:p}=H(),[u,d]=x.useState(s),{projects:m}=Js(),j=le(),{changeRequests:h}=un(s,n),v=async()=>{try{u&&(await l(s,n,u),o(),c({text:"Project changed",type:"success"}),i(!1),j(`/projects/${u}/features/${n}/settings`,{replace:!0}))}catch(f){p(q(f))}},y=x.useMemo(()=>m.map(f=>f.id).filter(f=>e(Ut,f)),[m,e]);return y.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx(sd,{value:u,onChange:d,label:"Project",filter:f=>y.includes(f),enabled:!0}),t.jsx(K,{permission:Ut,onClick:()=>i(!0),disabled:u===s,projectId:s,children:"Save"}),t.jsx(od,{changeRequests:h,projectId:u,open:r,feature:a,onClose:()=>i(!1),onClick:v})]})},id=g("div")({display:"flex",alignItems:"center"}),cd=g(L)(({theme:e})=>({fontSize:e.fontSizes.mainHeader})),ld=({projectId:e,featureId:s})=>{var r;const{feature:n}=W(e,s),a=le(),o=()=>{a(`/projects/${e}/features/${s}/edit`)};return t.jsxs(t.Fragment,{children:[t.jsxs(id,{children:[t.jsx(cd,{children:"Feature information"}),t.jsx(Re,{permission:Ce,projectId:e,"data-loading":!0,onClick:o,tooltipProps:{title:"Edit"},children:t.jsx(He,{})})]}),t.jsxs(L,{children:["Name: ",t.jsx("strong",{children:n.name})]}),t.jsxs(L,{children:["Description:"," ",t.jsx("strong",{children:(r=n.description)!=null&&r.length?n.description:"no description"})]}),t.jsxs(L,{children:["Type: ",t.jsx("strong",{children:n.type})]}),t.jsxs(L,{children:["Impression Data:"," ",t.jsx("strong",{children:n.impressionData?"enabled":"disabled"})]})]})},Me="metadata",ut="project",dd=g("div")(({theme:e})=>({width:"20%",borderRight:`1px solid ${e.palette.divider}`,padding:e.spacing(2,0),[e.breakpoints.down("md")]:{width:"35%"}})),ud=g("div")(({theme:e})=>({padding:e.spacing(4),display:"flex",flexDirection:"column",width:400,"& > *":{margin:e.spacing(1,0)}})),pd=()=>{const e=A("projectId"),s=A("featureId"),[n,a]=x.useState(Me),{uiConfig:o}=Te();return t.jsx(Rt,{header:"Settings",sx:{padding:0},children:t.jsxs(z,{sx:{display:"flex"},children:[t.jsx(dd,{children:t.jsxs(Ct,{children:[t.jsx(Ve,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>a(Me),selected:n===Me,children:"Metadata"},0),t.jsx(Ve,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>a(ut),selected:n===ut,hidden:!o.flags.P,children:"Project"},1)]})}),t.jsxs(ud,{children:[t.jsx(B,{condition:n===Me,show:t.jsx(ld,{projectId:e,featureId:s})}),t.jsx(B,{condition:n===ut&&o.flags.P,show:t.jsx(rd,{})})]})]})})},hs=g("strong")({wordBreak:"break-all"}),gd=()=>{const e=A("projectId"),s=A("featureId"),{features:n}=Ao({project:`IS:${e}`,archived:"IS:true"}),a=Eo(e,{name:s});return n?n.some(r=>r.name===s)?t.jsxs("p",{children:["The feature ",t.jsx(hs,{children:s})," has been archived. You can find it on the"," ",t.jsx(ae,{to:`/projects/${e}?archived=IS%3Atrue`,children:"project overview with archived flags filter"}),"."]}):t.jsxs("p",{children:["The feature ",t.jsx(hs,{children:s})," does not exist. Would you like to"," ",t.jsx(ae,{to:a,children:"create it"}),"?"]}):null};var Pt={},hd=Ie;Object.defineProperty(Pt,"__esModule",{value:!0});var xn=Pt.default=void 0,xd=hd(Ee()),fd=t,yd=(0,xd.default)((0,fd.jsx)("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM6.24 5h11.52l.81.97H5.44l.8-.97zM5 19V8h14v11H5zm8.45-9h-2.9v3H8l4 4 4-4h-2.55z"}),"ArchiveOutlined");xn=Pt.default=yd;var Ft={},md=Ie;Object.defineProperty(Ft,"__esModule",{value:!0});var fn=Ft.default=void 0,jd=md(Ee()),bd=t,vd=(0,jd.default)((0,bd.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm.5-13H11v6l5.2 3.2.8-1.3-4.5-2.7V7z"}),"WatchLaterOutlined");fn=Ft.default=vd;var Ot={},Sd=Ie;Object.defineProperty(Ot,"__esModule",{value:!0});var yn=Ot.default=void 0,Cd=Sd(Ee()),Td=t,wd=(0,Cd.default)((0,Td.jsx)("path",{d:"M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H8V4h12v12zm-7-2h2v-3h3V9h-3V6h-2v3h-3v2h3z"}),"LibraryAddOutlined");yn=Ot.default=wd;const kd=({stale:e,showActive:s=!0})=>{if(!e&&!s)return null;const n=e?"Feature flag is deprecated.":"Feature flag is active.",a=e?"Stale":"Active";return t.jsx("div",{"data-loading":!0,children:t.jsx(Ae,{color:e?"error":"success",title:n,children:a})})},Rd=e=>Io({key:"c",modifiers:["ctrl"],preventDefault:!1},()=>{var n;const s=(n=window.getSelection)==null?void 0:n.call(window);s&&(s.type==="None"||s.type==="Caret")&&e()});var _t={},Dd=Ie;Object.defineProperty(_t,"__esModule",{value:!0});var mn=_t.default=void 0,Ad=Dd(Ee()),Ed=t,Id=(0,Ad.default)((0,Ed.jsx)("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4H8c-1.1 0-1.99.9-1.99 2L6 21c0 1.1.89 2 1.99 2H19c1.1 0 2-.9 2-2V11l-6-6zM8 21V7h6v5h5v9H8z"}),"FileCopyOutlined");mn=_t.default=Id;const xs=18/8,$d=({name:e})=>{const[s,n]=x.useState(!1),{setToastData:a}=H(),o=()=>{try{Po(e),n(!0);const i=setTimeout(()=>{n(!1)},3e3);return()=>{clearTimeout(i)}}catch{a({type:"error",text:"Could not copy feature name"})}},r=Rd(o);return t.jsx(ee,{title:s?"Copied!":`Copy name (${r})`,arrow:!0,children:t.jsx(xe,{onClick:o,children:s?t.jsx($o,{sx:i=>({fontSize:i.spacing(xs),color:i.palette.success.main})}):t.jsx(mn,{sx:i=>({fontSize:i.spacing(xs)})})})})},Pd=g("div")(({theme:e})=>({backgroundColor:"none",marginBottom:e.spacing(2),borderBottom:`1px solid ${e.palette.divider}`,containerType:"inline-size"})),Bt=(e,s)=>({"@container (min-width: 650px)":s,"@supports not (container-type: inline-size)":{[e.breakpoints.up("md")]:s}}),jn=g("div")(({theme:e})=>({display:"flex",flexFlow:"row wrap",alignItems:"center",columnGap:e.spacing(1.5)})),Fd=g("div")(({theme:e})=>({display:"flex",alignItems:"center",columnGap:e.spacing(.5)})),Od=g(jn)(({theme:e})=>({justifyContent:"space-between",columnGap:0,flexFlow:"column nowrap",alignItems:"flex-start",...Bt(e,{alignItems:"center",flexFlow:"row nowrap"})})),_d=g("div",{shouldForwardProp:e=>e!=="showOnNarrowScreens"})(({theme:e,showOnNarrowScreens:s})=>({display:s?"flex":"none",flexFlow:"row nowrap",alignItems:"center",...Bt(e,{display:s?"none":"flex"})})),Bd=({children:e,label:s,onClick:n})=>t.jsx(Vo,{title:s,arrow:!0,onClick:a=>a.preventDefault(),children:t.jsx(xe,{"aria-label":s,onClick:n,children:e})}),zd=g(Fo)({minWidth:0,maxWidth:"100%","& .MuiTabs-flexContainer":{minHeight:"unset"}}),Ld=g(Oo)(({theme:e})=>({textTransform:"none",width:"auto",fontSize:e.fontSizes.bodySize,padding:"0 !important",...Bt(e,{minWidth:100})}));g(ae)(()=>({maxWidth:"100%",textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}}));const Md=e=>{const s=kt("enableLegacyVariants"),n=e.some(a=>{var o;return(o=a.variants)==null?void 0:o.length});return s||n},Vd=({showOnNarrowScreens:e,feature:s,onFavorite:n,openStaleDialog:a,openDeleteDialog:o})=>t.jsxs(_d,{showOnNarrowScreens:e,children:[t.jsx(Bd,{label:"Favorite this feature flag",onClick:n,"data-loading":!0,children:s.favorite?t.jsx(zo,{}):t.jsx(Lo,{})}),t.jsx(Re,{permission:Mo,projectId:s.project,"data-loading":!0,component:ae,to:`/projects/${s.project}/features/${s.name}/copy`,tooltipProps:{title:"Clone"},children:t.jsx(yn,{})}),t.jsx(Re,{permission:Ws,projectId:s.project,tooltipProps:{title:"Archive feature flag"},"data-loading":!0,onClick:o,children:t.jsx(xn,{})}),t.jsx(Re,{onClick:a,permission:Ce,projectId:s.project,tooltipProps:{title:"Toggle stale state"},"data-loading":!0,children:t.jsx(fn,{})})]}),Nd=({feature:e})=>{const s=A("projectId"),n=A("featureId"),{favorite:a,unfavorite:o}=_o(),{refetchFeature:r}=W(s,n),{setToastData:i,setToastApiError:l}=H(),[c,p]=x.useState(!1),[u,d]=x.useState(!1),[m,j]=x.useState(!1),h=le(),{pathname:v}=Bo(),y=`/projects/${s}/features/${n}`,f=Md(e.environments),w=[{title:"Overview",path:`${y}`,name:"overview"},{title:"Metrics",path:`${y}/metrics`,name:"Metrics"},...f?[{title:"Variants",path:`${y}/variants`,name:"Variants"}]:[],{title:"Settings",path:`${y}/settings`,name:"Settings"},{title:"Event log",path:`${y}/logs`,name:"Event log"}],E=w.find($=>$.path===v)??w[0],O=async()=>{try{e.favorite?await o(s,e.name):await a(s,e.name),r()}catch{l("Something went wrong, could not update favorite")}},_=({showOnNarrowScreens:$})=>t.jsx(Vd,{showOnNarrowScreens:$,feature:e,onFavorite:O,openStaleDialog:()=>j(!0),openDeleteDialog:()=>d(!0)});return t.jsxs(t.Fragment,{children:[t.jsxs(Pd,{children:[t.jsxs(jn,{children:[t.jsxs(Fd,{children:[t.jsx(L,{variant:"h1",children:e.name}),t.jsx($d,{name:e.name})]}),e.stale?t.jsx(kd,{stale:!0}):null]}),t.jsxs(Od,{children:[t.jsx(_,{showOnNarrowScreens:!0}),t.jsx(zd,{value:E.path,indicatorColor:"primary",textColor:"primary","aria-label":"Feature flag tabs",variant:"scrollable",children:w.map($=>t.jsx(Ld,{label:$.title,value:$.path,onClick:()=>h($.path),"data-testid":`TAB-${$.title}`},$.title))}),t.jsx(_,{})]})]}),e.children.length>0?t.jsx(At,{features:e.children,project:s,isOpen:u,onClose:()=>d(!1)}):t.jsx(Dt,{isOpen:u,onConfirm:()=>{h(`/projects/${s}`)},onClose:()=>d(!1),projectId:s,featureIds:[n]}),t.jsx(nr,{isStale:e.stale,isOpen:m,onClose:()=>{j(!1),r()},featureId:n,projectId:s}),t.jsx(nn,{open:c,setOpen:p})]})};g(ae)(()=>({maxWidth:"100%",textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}}));const qd=()=>{const e=A("projectId"),s=A("featureId"),{feature:n,loading:a,error:o,status:r}=W(e,s),i=No(a);return r===404?t.jsx(gd,{}):o!==void 0?t.jsx("div",{ref:i}):t.jsxs("div",{ref:i,children:[t.jsx(Nd,{feature:n}),t.jsxs(Us,{children:[t.jsx(je,{path:"metrics",element:t.jsx(Zl,{})}),t.jsx(je,{path:"logs",element:t.jsx(br,{})}),t.jsx(je,{path:"variants",element:t.jsx(_l,{})}),t.jsx(je,{path:"settings",element:t.jsx(pd,{})}),t.jsx(je,{path:"*",element:t.jsx(sl,{})})]})]})},Yd=Object.freeze(Object.defineProperty({__proto__:null,default:qd},Symbol.toStringTag,{value:"Module"}));export{Yd as F,Hl as d};
@@ -1 +0,0 @@
1
- import{cS as n,bc as l,j as e,C as c,V as s,B as d,iU as g,iN as h,iO as u,iP as p,iQ as m,iR as x,iS as f,iT as S}from"./index-Yy9_7TKN.js";import{a as j}from"./formatTickValue-D_CAvIVf.js";import{u as C,d as P,S as w,T as y,P as T,c as b,g as B}from"./useChartDataSelection-BfTrFKbU.js";import"./LazyAdminExport-6l0-2zFb.js";import"./RoleCell-DJbKzxr1.js";import"./useApiTokens-DE54gK5i.js";const k=()=>{n("Network - Frontend Traffic Usage");const{isOss:a}=l(),{chartDataSelection:t,setChartDataSelection:i,options:r}=C(),{chartData:o}=P(t);return e.jsx(c,{condition:a(),show:e.jsx(s,{severity:"warning",children:"Not enabled."}),elseShow:e.jsx(e.Fragment,{children:e.jsxs(w,{children:[e.jsxs(y,{children:[e.jsx(d,{children:e.jsx(s,{severity:"info",icon:!1,children:"Frontend traffic is determined by the total SDK requests to the Frontend API"})}),e.jsx(T,{selectedPeriod:t,setPeriod:i})]}),e.jsx(g,{data:o,plugins:[b()],options:r,"aria-label":B(t)})]})})})};h.register(j,u,p,m,x,f,S);export{k as default};
@@ -1 +0,0 @@
1
- import{cd as H,b9 as k,bb as L,j as e,aY as P,C as p,V as m,T as C,L as y,aW as R,aX as D,e as M,bf as W,fJ as E,aU as _,aV as z,h as G,r as f,fm as F,fn as V,s as J,A as N,m as K,l as X,n as Y,o as Q,iV as Z,as as U,B as T,f5 as I,iW as A,f6 as b}from"./index-Yy9_7TKN.js";const ee=t=>fetch(t).then(L("ChangeRequest")).then(s=>s.json()),te=(t,s)=>{const r=s.map(i=>`feature=${i}`).join("&"),{data:n,error:a,mutate:o}=H([],k(`api/admin/projects/${t}/change-requests/scheduled?${r}`),ee);return{changeRequests:n,loading:!a&&!n,refetch:o,error:a}},S=()=>e.jsx(m,{severity:"warning",sx:{m:t=>t.spacing(2,0)},children:"Archiving features with dependencies will also remove those dependencies."}),ne=({ids:t,projectId:s})=>{const r=n=>`/projects/${s}/features/${n}`;return t?e.jsxs(m,{severity:"warning",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(C,{fontWeight:"bold",variant:"body2",display:"inline",children:`${t.length} feature flags `}),e.jsx("span",{children:"have usage from applications. If you archive these feature flags they will not be available to Client SDKs:"}),e.jsx("ul",{children:t==null?void 0:t.map(n=>e.jsx("li",{children:e.jsx(y,{to:r(n),children:n})},n))})]}):null},$=({ids:t,projectId:s})=>{const r=n=>`/projects/${s}/features/${n}`;return t&&t.length>1?e.jsxs(m,{severity:"error",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(C,{fontWeight:"bold",variant:"body2",display:"inline",children:`${t.length} feature flags `}),e.jsx("span",{children:"have child features that depend on them and are not part of the archive operation. These parent features can not be archived:"}),e.jsx("ul",{children:t==null?void 0:t.map(n=>e.jsx("li",{children:e.jsx(y,{to:r(n),children:n})},n))})]}):t&&t.length===1?e.jsxs(m,{severity:"error",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(y,{to:r(t[0]),children:t[0]})," has child features that depend on it and are not part of the archive operation."]}):null},q=({changeRequests:t,projectId:s})=>t&&t.length>0?e.jsxs(m,{severity:"warning",sx:{m:r=>r.spacing(2,0)},children:[e.jsxs("p",{children:["This archive operation would conflict with"," ",t.length," scheduled change request(s). The change request(s) that would be affected by this are:"]}),e.jsx("ul",{children:t.map(({id:r,title:n})=>{const a=n?`#${r} (${n})`:`Change request #${r}`;return e.jsx("li",{children:e.jsx(y,{to:`/projects/${s}/change-requests/${r}`,target:"_blank",rel:"noopener noreferrer",title:`Change request ${r}`,children:a})},r)})})]}):t===void 0?e.jsx(m,{severity:"warning",children:e.jsx("p",{children:"This archive operation might conflict with one or more scheduled change requests. If you complete it, those change requests can no longer be applied."})}):null,se=(t,s)=>{const n=R(t)(),{isChangeRequestConfiguredForReview:a}=D(t);return n&&a(n)&&s?"Add to change request":n&&a(n)?"Add change to draft":s?"Archive flags":"Archive flag"},ae=({projectId:t,featureIds:s,onSuccess:r,onError:n})=>{const{setToastData:a,setToastApiError:o}=M(),{archiveFeatureToggle:i}=W(),{archiveFeatures:c}=E(),{isChangeRequestConfiguredForReview:h}=D(t),{addChange:x}=_(),{refetch:u}=z(t),d=R(t),g=(s==null?void 0:s.length)>1,l=d(),v=async()=>{if(!l){console.error("No change request environment");return}await x(t,l,s.map(w=>({action:"archiveFeature",feature:w,payload:void 0}))),u(),a({type:"success",text:g?"Changes added to a draft":"Change added to a draft"})},j=async()=>{await i(t,s[0]),a({type:"success",text:"Feature flag archived"})},O=async()=>{await c(t,s),a({type:"success",text:"Feature flags archived"})};return async()=>{try{l&&h(l)?await v():g?await O():await j(),r()}catch(w){o(G(w)),n()}}},re=(t,s,r)=>{const[n,a]=f.useState(!0),[o,i]=f.useState([]),[c,h]=f.useState(!1),{verifyArchiveFeatures:x}=E();return f.useEffect(()=>{r&&x(s,t).then(u=>u.json()).then(({hasDeletedDependencies:u,parentsWithChildFeatures:d})=>{d.length===0?(a(!1),i(d)):(a(!0),i(d)),h(u)})},[JSON.stringify(t),r,s,i,a,h]),{disableArchive:n,offendingParents:o,hasDeletedDependencies:c}},ue=({isOpen:t,onClose:s,onConfirm:r,projectId:n,featureIds:a,featuresWithUsage:o})=>{const i=(a==null?void 0:a.length)>1,c=se(n,i),h=i?"Archive feature flags":"Archive feature flag",x=ae({projectId:n,featureIds:a,onSuccess(){r(),s()},onError(){s()}}),{changeRequests:u}=te(n,a),{disableArchive:d,offendingParents:g,hasDeletedDependencies:l}=re(a,n,t),v=g.length===0&&l;return e.jsx(P,{onClick:x,open:t,onClose:s,primaryButtonText:c,secondaryButtonText:"Cancel",title:h,disabledPrimaryButton:d,children:e.jsx(p,{condition:i,show:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Are you sure you want to archive"," ",e.jsx("strong",{children:a==null?void 0:a.length})," feature flags?"]}),e.jsx(p,{condition:!!(o&&(o==null?void 0:o.length)>0),show:e.jsx(ne,{ids:o,projectId:n})}),e.jsx(p,{condition:g.length>0,show:e.jsx($,{ids:g,projectId:n})}),e.jsx(p,{condition:v,show:e.jsx(S,{})}),e.jsx(q,{changeRequests:u,projectId:n}),e.jsx(p,{condition:(a==null?void 0:a.length)<=5,show:e.jsx("ul",{children:a==null?void 0:a.map(j=>e.jsx("li",{children:j},j))})})]}),elseShow:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Are you sure you want to archive"," ",i?"these feature flags":"this feature flag","?"]}),e.jsx(p,{condition:g.length>0,show:e.jsx($,{ids:g,projectId:n})}),e.jsx(p,{condition:v,show:e.jsx(S,{})}),e.jsx(q,{changeRequests:u,projectId:n})]})})})},ie=(t,s)=>`/api/admin/projects/${t}/features/${s}/parents`,ge=(t,s)=>{const r=k(ie(t,s)),{data:n,refetch:a,loading:o,error:i}=F(r,()=>V(r,"Parent Options"));return{parentOptions:n,loading:o,error:i}},oe=(t,s)=>`/api/admin/projects/${t}/features/${s}/parent-variants`,B=(t,s)=>{const r=k(oe(t,s)),{data:n,refetch:a,loading:o,error:i}=F(r,()=>V(r,"Parent Variant Options"));return{parentVariantOptions:n||[],loading:o,error:i}},ce=J(N)(({theme:t})=>({marginTop:t.spacing(2),marginBottom:t.spacing(1.5)})),le=({project:t,parent:s,onSelect:r})=>{const{parentVariantOptions:n}=B(t,s),a=e.jsx(Y,{fontSize:"small"}),o=e.jsx(Q,{fontSize:"small"});return e.jsx(ce,{id:"single-variant-options",options:n,renderOption:(i,c,{selected:h})=>e.jsxs("li",{...i,children:[e.jsx(K,{icon:a,checkedIcon:o,style:{marginRight:8},checked:h}),c]}),renderInput:i=>e.jsx(X,{...i,placeholder:"Select variant"}),fullWidth:!0,onChange:(i,c)=>{r(String(c))}})},de=({projectId:t,featureId:s,isOpen:r,setIsOpen:n,onComplete:a})=>{const{markFeatureCompleted:o}=Z(),{parentVariantOptions:i}=B(t,s),[c,h]=f.useState("kept"),[x,u]=f.useState(void 0),{trackEvent:d}=U(),g=async()=>{const l=c==="kept-with-variant"?"kept":c;await o(s,t,{status:l,statusValue:x}),n(!1),a(),d("feature-lifecycle",{props:{eventType:"complete",status:l}})};return e.jsx(P,{open:r,title:"Mark completed",onClose:()=>{n(!1)},disabledPrimaryButton:c==="kept-with-variant"&&x===null,onClick:g,primaryButtonText:"Mark completed",secondaryButtonText:"Cancel",children:e.jsxs(T,{children:[e.jsxs(T,{sx:{mt:2,mb:4},children:["Marking the feature ",e.jsx("b",{children:s})," as complete does not affect any configuration, but it moves the feature flag into it’s next life cycle stage and is an indication that you have learned what you needed in order to progress with the feature. It serves as a reminder to start cleaning up the feature flag and removing it from the code."]}),e.jsx(C,{sx:{mb:2},children:e.jsx("b",{children:"What was the outcome of this feature?"})}),e.jsxs(I,{"aria-label":"selected-value",name:"selected",sx:{gap:l=>l.spacing(.5)},onChange:(l,v)=>{h(v)},children:[e.jsx(A,{value:"kept",legal:{value:"We decided to keep the feature"},control:e.jsx(b,{})},"kept"),e.jsx(A,{value:"discarded",legal:{value:"We decided to discard the feature"},control:e.jsx(b,{})},"discarded"),e.jsx(p,{condition:i.length>0,show:e.jsx(A,{value:"kept-with-variant",legal:{value:"We decided to keep the feature variant",description:"Choose to specify which feature variant will be kept"},control:e.jsx(b,{})},"kept-with-variant")}),e.jsx(p,{condition:i.length>0&&c==="kept-with-variant",show:e.jsx(le,{parent:s,project:t,onSelect:l=>{u(l)}})})]})]})})};export{ue as F,de as M,ge as a,B as u};
@@ -1,4 +0,0 @@
1
- import{s as g,bc as k,e as L,j as o,V as P,y as K,D as V,fD as D,B as w,dt as te,al as he,dc as ue,ao as me,C as I,az as fe,ap as pe,ay as G,b$ as F,bt as ge,eu as xe,bh as be,iI as ye,L as se,el as ve,ak as M,g2 as N,r as u,em as O,av as je,G as Ce,H as Te,aj as q,fj as Se,an as R,eb as Ee,eD as we,ac as A,ad as Ie,cA as ne,b3 as ke,aY as oe,h as Ae,w as Me,aT as Oe,i as Re,aA as ie,iJ as z,hC as ze,dI as De,dH as Ne,T as _,dY as _e,F as Le,f5 as Pe,dV as Fe,f6 as Be,gH as We,cg as Ue,b9 as re,bb as le,ba as $e,iK as He,A as Ke,b8 as Ve,b4 as Ge,dR as qe}from"./index-Yy9_7TKN.js";import{u as Ye}from"./useApiTokens-DE54gK5i.js";const Je=g("div")(({theme:n})=>({display:"grid",gridTemplateColumns:"auto auto 1fr",gridAutoRows:"min-content",alignItems:"center",gap:n.spacing(1),marginTop:n.spacing(1.5)})),S=w,Qe=()=>{const{uiConfig:n}=k(),{setToastData:r}=L(),e=i=>()=>{te(i),r({type:"success",text:"Copied to clipboard"})},s=`${n.unleashUrl}/api/`,t=`${n.unleashUrl}/api/frontend/`;return o.jsxs(P,{severity:"info",children:[o.jsxs("p",{children:["Read the"," ",o.jsx("a",{href:"https://docs.getunleash.io/reference/sdks",target:"_blank",rel:"noreferrer",children:"SDK overview"})," ","to connect Unleash to your application. Please note it can take up to ",o.jsx("strong",{children:"1 minute"})," before a new API key is activated."]}),o.jsxs(Je,{children:[o.jsx(S,{children:o.jsx("strong",{children:"CLIENT API URL: "})}),o.jsx(S,{children:o.jsx("pre",{style:{display:"inline"},children:s})}),o.jsx(S,{children:o.jsx(K,{title:"Copy URL",arrow:!0,children:o.jsx(V,{onClick:e(s),size:"small",children:o.jsx(D,{})})})}),o.jsx(S,{children:o.jsx("strong",{children:"FRONTEND API URL: "})}),o.jsx(S,{children:o.jsx("pre",{style:{display:"inline"},children:t})}),o.jsx(S,{children:o.jsx(K,{title:"Copy URL",arrow:!0,children:o.jsx(V,{onClick:e(t),size:"small",children:o.jsx(D,{})})})})]})]})},Xe=["Icon","createdAt","seenAt"],Ze=["Icon","project","seenAt"],Bt=({compact:n=!1,setHiddenColumns:r,columns:e,loading:s,rows:t,headerGroups:i,globalFilter:l,prepareRow:a})=>{const c=he(ue.breakpoints.down("xl"));return me([{condition:c,columns:Xe},{condition:n,columns:Ze}],r,e),o.jsxs(o.Fragment,{children:[o.jsx(I,{condition:t.length>0,show:o.jsx(w,{sx:{mb:4},children:o.jsx(Qe,{})})}),o.jsx(w,{sx:{overflowX:"auto"},children:o.jsx(fe,{value:l,children:o.jsx(pe,{rows:t,headerGroups:i,prepareRow:a})})}),o.jsx(I,{condition:t.length===0&&!s,show:o.jsx(I,{condition:(l==null?void 0:l.length)>0,show:o.jsxs(G,{children:["No tokens found matching “",l,"”"]}),elseShow:o.jsx(G,{children:o.jsxs("span",{children:["No tokens available. Read ",o.jsx(F,{href:"https://docs.getunleash.io/how-to/api",target:"_blank",rel:"noreferrer",children:"API How-to guides"})," "," to learn more."]})})})})]})},et=(n,r)=>{const e=r>=n;return{limitReached:e,limitMessage:e?`You have reached the limit of ${n} API tokens`:void 0}},Wt=({path:n,permission:r,project:e})=>{const s=ge(),{tokens:t,loading:i}=Ye(),{uiConfig:l}=k(),{limitReached:a,limitMessage:c}=et(l.resourceLimits.apiTokens,t.length);return o.jsx(xe,{Icon:be,onClick:()=>s(n),"data-testid":ye,permission:r,projectId:e,maxWidth:"700px",disabled:i||a,tooltipProps:{title:c},children:"New API token"})},tt=g(se)(({theme:n})=>({textDecoration:"none",color:n.palette.links,"&:hover, &:focus":{textDecoration:"underline"}})),st=g("div")({display:"flex",alignItems:"center"}),nt=({projects:n,project:r})=>{const{searchQuery:e}=ve(),s=n&&Array.isArray(n)&&n.length>1?n:[];if(s.length>0)return o.jsx(M,{children:o.jsx(N,{title:s.map((t,i)=>o.jsxs(u.Fragment,{children:[i>0&&", ",!t||t==="*"?o.jsx(O,{search:e,children:"*"}):o.jsx(tt,{to:`/projects/${t}`,children:o.jsx(O,{search:e,children:t})})]},t)),placement:"bottom-start",arrow:!0,tabIndex:0,children:o.jsxs("span",{children:[`${s.length}`," projects"]})})});if(s.length===1&&s[0]!=="*"||r&&r!=="*"){const t=r||s[0];return o.jsx(je,{to:`/projects/${t}`,title:t})}return o.jsx(M,{children:o.jsx(N,{title:"ALL current and future projects.",placement:"bottom",arrow:!0,children:o.jsx(st,{children:o.jsx(O,{search:e,children:"*"})})})})};var B={},ot=Te;Object.defineProperty(B,"__esModule",{value:!0});var ae=B.default=void 0,it=ot(Ce()),rt=o,lt=(0,it.default)((0,rt.jsx)("path",{d:"M21 10h-8.35C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H13l2 2 2-2 2 2 4-4.04L21 10zM7 15c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z"}),"Key");ae=B.default=lt;const at=({secret:n,project:r,projects:e})=>{const s=n!=null&&n.includes(":")?"v2":"v1",t=n==null?void 0:n.startsWith("*:"),i=e&&(e==null?void 0:e.length)>1||(e==null?void 0:e.length)===1&&e[0]!=="*"||r&&r!=="*";return s==="v2"&&!t&&!i},ct=({...n})=>at(n)?o.jsx(q,{icon:o.jsx(N,{title:o.jsxs("p",{children:["This is an orphaned token. All of its original projects have been deleted and it now has access to all current and future projects. You should stop using this token and delete it. Read more in"," ",o.jsx(F,{target:"_blank",rel:"noopener noreferrer",href:"https://github.com/Unleash/unleash/releases/tag/v6.1.0",children:"release notes"}),"."]}),placement:"bottom-start",arrow:!0,children:o.jsx(Se,{"aria-label":"Orphaned token",color:"warning","data-testid":"orphaned-token-icon"})})}):o.jsx(q,{icon:o.jsx(ae,{color:"disabled"})}),Ut=(n,r)=>{const e=u.useMemo(()=>({sortBy:[{id:"createdAt",desc:!0}]}),[]),s=u.useMemo(()=>[{id:"Icon",Cell:m=>o.jsx(ct,{secret:m.row.original.secret,project:m.row.original.project,projects:m.row.original.projects}),disableSortBy:!0,disableGlobalFilter:!0,width:50},{Header:"Token name",accessor:"tokenName",Cell:R,minWidth:35},{Header:"Type",accessor:"type",Cell:({value:m})=>o.jsx(R,{value:Y[m.toLowerCase()].label,subtitle:Y[m.toLowerCase()].title,subtitleTooltip:!0}),width:180},{Header:"Project",accessor:"project",Cell:m=>o.jsx(nt,{project:m.row.original.project,projects:m.row.original.projects}),width:160},{Header:"Environment",accessor:"environment",Cell:R,width:120},{Header:"Created",accessor:"createdAt",Cell:Ee,width:150,disableGlobalFilter:!0},{Header:"Last seen",accessor:"seenAt",Cell:we,width:140,disableGlobalFilter:!0},{Header:"Actions",width:120,id:"Actions",align:"center",disableSortBy:!0,disableGlobalFilter:!0,Cell:r}],[]),{getTableProps:t,getTableBodyProps:i,headerGroups:l,rows:a,prepareRow:c,state:h,setGlobalFilter:d,setHiddenColumns:f}=A.useTable({columns:s,data:n,initialState:e,sortTypes:Ie,autoResetHiddenColumns:!1,disableSortRemove:!0},A.useGlobalFilter,A.useSortBy,A.useFlexLayout);return{getTableProps:t,getTableBodyProps:i,headerGroups:l,rows:a,prepareRow:c,state:h,setGlobalFilter:d,setHiddenColumns:f,columns:s}},Y={client:{label:"CLIENT",title:"Connect server-side SDK or Unleash Proxy/Edge"},frontend:{label:"FRONTEND",title:"Connect web and mobile SDK"},admin:{label:"ADMIN",title:"Full access for managing Unleash"}},$t=({token:n,project:r,permission:e,track:s})=>{const{setToastData:t}=L(),i=l=>{te(l)&&(t({type:"success",text:"Token copied to clipboard"}),s&&typeof s=="function"&&s())};return o.jsx(ne,{permission:e,projectId:r,tooltipProps:{title:"Copy token",arrow:!0},onClick:()=>i(n.secret),size:"large",children:o.jsx(D,{})})},dt=g("ul")({marginBottom:0}),Ht=({token:n,permission:r,onRemove:e,project:s})=>{const[t,i]=u.useState(!1),{setToastData:l,setToastApiError:a}=L(),c=async()=>{try{await e(),i(!1),l({type:"success",text:"API token removed"})}catch(h){a(Ae(h))}};return o.jsxs(o.Fragment,{children:[o.jsx(ne,{permission:r,projectId:s,tooltipProps:{title:"Delete token",arrow:!0},onClick:()=>i(!0),size:"large",children:o.jsx(ke,{})}),o.jsx(oe,{open:t,onClick:c,onClose:()=>i(!1),title:"Confirm deletion",children:o.jsxs("div",{children:["Are you sure you want to delete the following API token?",o.jsx("br",{}),o.jsxs(dt,{children:[o.jsxs("li",{children:[o.jsx("strong",{children:"name"}),":"," ",o.jsx("code",{children:n.tokenName})]}),o.jsxs("li",{children:[o.jsx("strong",{children:"type"}),": ",o.jsx("code",{children:n.type})]}),o.jsxs("li",{children:[o.jsx("strong",{children:"environment"}),":"," ",o.jsx("code",{children:n.environment})]})]})]})})]})},ht=g("div")(()=>({maxWidth:"400px"})),ut=g("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),mt=g(Me)(({theme:n})=>({width:"100%",marginBottom:n.spacing(2)})),ft=g(Oe)(({theme:n})=>({marginBottom:n.spacing(2),minWidth:"400px",[n.breakpoints.down("sm")]:{minWidth:"379px"}})),ce=g("p")(({theme:n})=>({marginBottom:n.spacing(1)})),pt=g("label")(({theme:n})=>({marginBottom:n.spacing(1)})),gt=g(Re)(({theme:n})=>({marginLeft:n.spacing(3)})),xt=g(w)({marginTop:"auto",display:"flex",justifyContent:"flex-end"}),Kt=({children:n,actions:r,handleSubmit:e,handleCancel:s})=>{var l;const{uiConfig:t}=k(),i=!!((l=t==null?void 0:t.flags)!=null&&l.UNLEASH_CLOUD);return o.jsxs(ut,{onSubmit:e,children:[o.jsx(I,{condition:i,show:o.jsxs(P,{severity:"info",sx:{mb:4},children:["Please be aware of our"," ",o.jsx(F,{href:"https://www.getunleash.io/fair-use-policy",children:"fair use policy"}),"."]})}),n,o.jsxs(xt,{children:[r,o.jsx(gt,{onClick:s,children:"Cancel"})]})]})};var b=(n=>(n.ADMIN="ADMIN",n.CLIENT="CLIENT",n.FRONTEND="FRONTEND",n))(b||{});const Vt=n=>{var U,$;const{environments:r}=ie(),e=(U=r==null?void 0:r.find(p=>p.enabled))==null?void 0:U.name,s=z(ze,n),t=[{key:b.CLIENT,label:`Server-side SDK (${b.CLIENT})`,title:"Connect server-side SDK or Unleash Proxy/Edge",enabled:z(De)||s},{key:b.FRONTEND,label:`Client-side SDK (${b.FRONTEND})`,title:"Connect web and mobile SDK directly to Unleash",enabled:z(Ne)||s}],i=($=t.find(p=>p.enabled))==null?void 0:$.key,[l,a]=u.useState(""),[c,h]=u.useState(i||b.CLIENT),[d,f]=u.useState([n||"*"]),[m,j]=u.useState(d),[y,x]=u.useState(),[T,v]=u.useState({});return u.useEffect(()=>{x(c==="ADMIN"?"*":e)},[c,e]),{tokenName:l,type:c,apiTokenTypes:t,projects:d,environment:y,setTokenName:a,setTokenType:p=>{p==="ADMIN"?(h(b.ADMIN),j(d),f(["*"]),x("*")):(h(p),f(m),x(e))},setProjects:f,setEnvironment:x,getApiTokenPayload:()=>({tokenName:l,type:c,environment:y,projects:d}),isValid:()=>{const p={};return l||(p.tokenName="Token name is required"),d.length===0&&(p.projects="At least one project is required"),v(p),Object.keys(p).length===0},clearErrors:p=>{if(p){const H={...T};delete H[p],v(H)}else v({})},errors:T}},Gt=({open:n,setOpen:r,closeConfirm:e,token:s,type:t})=>o.jsxs(oe,{open:n,setOpen:r,onClick:e,primaryButtonText:"Close",title:"New token created",children:[o.jsx(_,{variant:"body1",children:"Your new token has been created successfully."}),o.jsx(_e,{token:s}),o.jsx(I,{condition:t===b.FRONTEND,show:o.jsxs(P,{sx:{mt:2},severity:"info",children:["By default, all ",b.FRONTEND," tokens may be used from any CORS origin. If you'd like to configure a strict set of origins, please use the"," ",o.jsx(se,{to:"/admin/cors",target:"_blank",rel:"noreferrer",children:"CORS origins configuration page"}),"."]})})]}),qt=({tokenName:n,setTokenName:r,errors:e,clearErrors:s})=>o.jsxs(o.Fragment,{children:[o.jsx(ce,{children:"What would you like to call this token?"}),o.jsx(mt,{value:n,name:"tokenName",onChange:t=>r(t.target.value),label:"Token name",error:e.tokenName!==void 0,errorText:e.tokenName,onFocus:()=>s("tokenName"),autoFocus:!0})]}),Yt=({type:n,setType:r,apiTokenTypes:e})=>o.jsx(ht,{children:o.jsxs(Le,{sx:{mb:2,width:"100%"},children:[o.jsx(pt,{id:"token-type",children:"What do you want to connect?"}),o.jsx(Pe,{"aria-labelledby":"token-type",defaultValue:"CLIENT",name:"radio-buttons-group",value:n,onChange:(s,t)=>r(t),children:e.map(({key:s,label:t,title:i,enabled:l})=>o.jsx(Fe,{value:s,sx:{mb:1},disabled:!l,control:o.jsx(Be,{sx:{ml:.75,alignSelf:"flex-start"}}),label:o.jsx(w,{children:o.jsxs(w,{children:[o.jsx(_,{children:t}),o.jsx(_,{variant:"body2",color:"text.secondary",children:i})]})})},s))})]})}),Jt=({type:n,environment:r,setEnvironment:e})=>{const{environments:s}=ie(),t=n===b.ADMIN?[{key:"*",label:"ALL"}]:s.map(i=>({key:i.name,label:`${i.name.concat(i.enabled?"":" - deprecated")}`,title:i.name,disabled:!1}));return o.jsxs(o.Fragment,{children:[o.jsx(ce,{children:"Which environment should the token have access to?"}),o.jsx(ft,{disabled:n===b.ADMIN,options:t,value:r,onChange:e,label:"Environment",id:"api_key_environment",name:"environment",IconComponent:We,fullWidth:!0})]})},bt=n=>n.map(r=>({...r.user,joinedAt:new Date(r.joinedAt),createdBy:r.createdBy})),Qt=n=>{const{data:r,error:e,mutate:s}=Ue(re(`api/admin/groups/${n}`),yt);return u.useMemo(()=>({group:r&&{...r,users:bt((r==null?void 0:r.users)??[])},loading:!e&&!r,refetchGroup:()=>s(),error:e}),[r,e,s])},yt=n=>fetch(n).then(le("Group")).then(r=>r.json()),Xt=()=>{const{isEnterprise:n}=k(),{data:r,error:e,mutate:s}=$e(n(),{serviceAccounts:[],rootRoles:[]},re("api/admin/service-account"),vt);return u.useMemo(()=>({serviceAccounts:(r==null?void 0:r.serviceAccounts)??[],roles:(r==null?void 0:r.rootRoles)??[],loading:!e&&!r,refetch:()=>s(),error:e}),[r,e,s])},vt=n=>fetch(n).then(le("Service Accounts")).then(r=>r.json());function E(n,r,e){let s=e.initialDeps??[],t;function i(){var l,a,c,h;let d;e.key&&((l=e.debug)!=null&&l.call(e))&&(d=Date.now());const f=n();if(!(f.length!==s.length||f.some((y,x)=>s[x]!==y)))return t;s=f;let j;if(e.key&&((a=e.debug)!=null&&a.call(e))&&(j=Date.now()),t=r(...f),e.key&&((c=e.debug)!=null&&c.call(e))){const y=Math.round((Date.now()-d)*100)/100,x=Math.round((Date.now()-j)*100)/100,T=x/16,v=(C,W)=>{for(C=String(C);C.length<W;)C=" "+C;return C};console.info(`%c⏱ ${v(x,5)} /${v(y,5)} ms`,`
2
- font-size: .6rem;
3
- font-weight: bold;
4
- color: hsl(${Math.max(0,Math.min(120-120*T,120))}deg 100% 31%);`,e==null?void 0:e.key)}return(h=e==null?void 0:e.onChange)==null||h.call(e,t),t}return i.updateDeps=l=>{s=l},i}function J(n,r){if(n===void 0)throw new Error("Unexpected undefined");return n}const jt=(n,r)=>Math.abs(n-r)<=1,Ct=(n,r,e)=>{let s;return function(...t){n.clearTimeout(s),s=n.setTimeout(()=>r.apply(this,t),e)}},Q=n=>{const{offsetWidth:r,offsetHeight:e}=n;return{width:r,height:e}},Tt=n=>n,St=n=>{const r=Math.max(n.startIndex-n.overscan,0),e=Math.min(n.endIndex+n.overscan,n.count-1),s=[];for(let t=r;t<=e;t++)s.push(t);return s},Et=(n,r)=>{const e=n.scrollElement;if(!e)return;const s=n.targetWindow;if(!s)return;const t=l=>{const{width:a,height:c}=l;r({width:Math.round(a),height:Math.round(c)})};if(t(Q(e)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(l=>{const a=()=>{const c=l[0];if(c!=null&&c.borderBoxSize){const h=c.borderBoxSize[0];if(h){t({width:h.inlineSize,height:h.blockSize});return}}t(Q(e))};n.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(e,{box:"border-box"}),()=>{i.unobserve(e)}},X={passive:!0},Z=typeof window>"u"?!0:"onscrollend"in window,wt=(n,r)=>{const e=n.scrollElement;if(!e)return;const s=n.targetWindow;if(!s)return;let t=0;const i=n.options.useScrollendEvent&&Z?()=>{}:Ct(s,()=>{r(t,!1)},n.options.isScrollingResetDelay),l=d=>()=>{const{horizontal:f,isRtl:m}=n.options;t=f?e.scrollLeft*(m&&-1||1):e.scrollTop,i(),r(t,d)},a=l(!0),c=l(!1);c(),e.addEventListener("scroll",a,X);const h=n.options.useScrollendEvent&&Z;return h&&e.addEventListener("scrollend",c,X),()=>{e.removeEventListener("scroll",a),h&&e.removeEventListener("scrollend",c)}},It=(n,r,e)=>{if(r!=null&&r.borderBoxSize){const s=r.borderBoxSize[0];if(s)return Math.round(s[e.options.horizontal?"inlineSize":"blockSize"])}return n[e.options.horizontal?"offsetWidth":"offsetHeight"]},kt=(n,{adjustments:r=0,behavior:e},s)=>{var t,i;const l=n+r;(i=(t=s.scrollElement)==null?void 0:t.scrollTo)==null||i.call(t,{[s.options.horizontal?"left":"top"]:l,behavior:e})};class At{constructor(r){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let e=null;const s=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(t=>{t.forEach(i=>{const l=()=>{this._measureElement(i.target,i)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var t;(t=s())==null||t.disconnect(),e=null},observe:t=>{var i;return(i=s())==null?void 0:i.observe(t,{box:"border-box"})},unobserve:t=>{var i;return(i=s())==null?void 0:i.unobserve(t)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([s,t])=>{typeof t>"u"&&delete e[s]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Tt,rangeExtractor:St,onChange:()=>{},measureElement:It,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var s,t;(t=(s=this.options).onChange)==null||t.call(s,this,e)},this.maybeNotify=E(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((e=this.scrollElement)==null?void 0:e.window)??null,this.elementsCache.forEach(t=>{this.observer.observe(t)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,t=>{this.scrollRect=t,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(t,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<t?"forward":"backward":null,this.scrollOffset=t,this.isScrolling=i,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,s)=>{const t=new Map,i=new Map;for(let l=s-1;l>=0;l--){const a=e[l];if(t.has(a.lane))continue;const c=i.get(a.lane);if(c==null||a.end>c.end?i.set(a.lane,a):a.end<c.end&&t.set(a.lane,!0),t.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((l,a)=>l.end===a.end?l.index-a.index:l.end-a.end)[0]:void 0},this.getMeasurementOptions=E(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(e,s,t,i,l)=>(this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:s,scrollMargin:t,getItemKey:i,enabled:l}),{key:!1}),this.getMeasurements=E(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:s,scrollMargin:t,getItemKey:i,enabled:l},a)=>{if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(d=>{this.itemSizeCache.set(d.key,d.size)}));const c=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const h=this.measurementsCache.slice(0,c);for(let d=c;d<e;d++){const f=i(d),m=this.options.lanes===1?h[d-1]:this.getFurthestMeasurement(h,d),j=m?m.end+this.options.gap:s+t,y=a.get(f),x=typeof y=="number"?y:this.options.estimateSize(d),T=j+x,v=m?m.lane:d%this.options.lanes;h[d]={index:d,start:j,size:x,end:T,key:f,lane:v}}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=E(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,s,t,i)=>this.range=e.length>0&&s>0?Mt({measurements:e,outerSize:s,scrollOffset:t,lanes:i}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=E(()=>{let e=null,s=null;const t=this.calculateRange();return t&&(e=t.startIndex,s=t.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,s]},(e,s,t,i,l)=>i===null||l===null?[]:e({startIndex:i,endIndex:l,overscan:s,count:t}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{const s=this.options.indexAttribute,t=e.getAttribute(s);return t?parseInt(t,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this._measureElement=(e,s)=>{const t=this.indexFromElement(e),i=this.measurementsCache[t];if(!i)return;const l=i.key,a=this.elementsCache.get(l);a!==e&&(a&&this.observer.unobserve(a),this.observer.observe(e),this.elementsCache.set(l,e)),e.isConnected&&this.resizeItem(t,this.options.measureElement(e,s,this))},this.resizeItem=(e,s)=>{const t=this.measurementsCache[e];if(!t)return;const i=this.itemSizeCache.get(t.key)??t.size,l=s-i;l!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(t,l,this):t.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(t.index),this.itemSizeCache=new Map(this.itemSizeCache.set(t.key,s)),this.notify(!1))},this.measureElement=e=>{if(!e){this.elementsCache.forEach((s,t)=>{s.isConnected||(this.observer.unobserve(s),this.elementsCache.delete(t))});return}this._measureElement(e,void 0)},this.getVirtualItems=E(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,s)=>{const t=[];for(let i=0,l=e.length;i<l;i++){const a=e[i],c=s[a];t.push(c)}return t},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{const s=this.getMeasurements();if(s.length!==0)return J(s[de(0,s.length-1,t=>J(s[t]).start,e)])},this.getOffsetForAlignment=(e,s,t=0)=>{const i=this.getSize(),l=this.getScrollOffset();s==="auto"&&(s=e>=l+i?"end":"start"),s==="center"?e+=(t-i)/2:s==="end"&&(e-=i);const a=this.getTotalSize()-i;return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,s="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));const t=this.measurementsCache[e];if(!t)return;const i=this.getSize(),l=this.getScrollOffset();if(s==="auto")if(t.end>=l+i-this.options.scrollPaddingEnd)s="end";else if(t.start<=l+this.options.scrollPaddingStart)s="start";else return[l,s];const a=s==="end"?t.end+this.options.scrollPaddingEnd:t.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,t.size),s]},this.isDynamicMode=()=>this.elementsCache.size>0,this.cancelScrollToIndex=()=>{this.scrollToIndexTimeoutId!==null&&this.targetWindow&&(this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId),this.scrollToIndexTimeoutId=null)},this.scrollToOffset=(e,{align:s="start",behavior:t}={})=>{this.cancelScrollToIndex(),t==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(e,s),{adjustments:void 0,behavior:t})},this.scrollToIndex=(e,{align:s="auto",behavior:t}={})=>{e=Math.max(0,Math.min(e,this.options.count-1)),this.cancelScrollToIndex(),t==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");const i=this.getOffsetForIndex(e,s);if(!i)return;const[l,a]=i;this._scrollToOffset(l,{adjustments:void 0,behavior:t}),t!=="smooth"&&this.isDynamicMode()&&this.targetWindow&&(this.scrollToIndexTimeoutId=this.targetWindow.setTimeout(()=>{if(this.scrollToIndexTimeoutId=null,this.elementsCache.has(this.options.getItemKey(e))){const h=this.getOffsetForIndex(e,a);if(!h)return;const[d]=h,f=this.getScrollOffset();jt(d,f)||this.scrollToIndex(e,{align:a,behavior:t})}else this.scrollToIndex(e,{align:a,behavior:t})}))},this.scrollBy=(e,{behavior:s}={})=>{this.cancelScrollToIndex(),s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+e,{adjustments:void 0,behavior:s})},this.getTotalSize=()=>{var e;const s=this.getMeasurements();let t;if(s.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=((e=s[s.length-1])==null?void 0:e.end)??0;else{const i=Array(this.options.lanes).fill(null);let l=s.length-1;for(;l>=0&&i.some(a=>a===null);){const a=s[l];i[a.lane]===null&&(i[a.lane]=a.end),l--}t=Math.max(...i.filter(a=>a!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:s,behavior:t})=>{this.options.scrollToFn(e,{behavior:t,adjustments:s},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(r)}}const de=(n,r,e,s)=>{for(;n<=r;){const t=(n+r)/2|0,i=e(t);if(i<s)n=t+1;else if(i>s)r=t-1;else return t}return n>0?n-1:0};function Mt({measurements:n,outerSize:r,scrollOffset:e,lanes:s}){const t=n.length-1,i=c=>n[c].start;if(n.length<=s)return{startIndex:0,endIndex:t};let l=de(0,t,i,e),a=l;if(s===1)for(;a<t&&n[a].end<e+r;)a++;else if(s>1){const c=Array(s).fill(0);for(;a<t&&c.some(d=>d<e+r);){const d=n[a];c[d.lane]=d.end,a++}const h=Array(s).fill(e+r);for(;l>=0&&h.some(d=>d>=e);){const d=n[l];h[d.lane]=d.start,l--}l=Math.max(0,l-l%s),a=Math.min(t,a+(s-1-a%s))}return{startIndex:l,endIndex:a}}const ee=typeof document<"u"?u.useLayoutEffect:u.useEffect;function Ot(n){const r=u.useReducer(()=>({}),{})[1],e={...n,onChange:(t,i)=>{var l;i?He.flushSync(r):r(),(l=n.onChange)==null||l.call(n,t,i)}},[s]=u.useState(()=>new At(e));return s.setOptions(e),ee(()=>s._didMount(),[]),ee(()=>s._willUpdate()),s}function Rt(n){return Ot({observeElementRect:Et,observeElementOffset:wt,scrollToFn:kt,...n})}const zt=u.forwardRef(function(r,e){const{children:s,...t}=r,i=u.useRef(null),l=u.Children.toArray(s),a=Rt({count:u.Children.count(s),getScrollElement:()=>i.current,estimateSize:()=>56,overscan:3});return o.jsx("div",{ref:e,children:o.jsx("div",{ref:i,...t,children:o.jsx("ul",{style:{height:`${a.getTotalSize()}px`,width:"100%",position:"relative"},children:a.getVirtualItems().map(c=>{const h=l[c.index];if(!h)return null;const d={position:"absolute",left:0,width:"100%",top:`${c.start}px`};return u.cloneElement(h,{ref:a.measureElement,key:c.key,"data-index":c.index,style:d})})})})})});function Zt(n){const{virtualThreshold:r=250,getOptionLabel:e,className:s,...t}=n,i=n.options.length>r,l={...t,getOptionLabel:e,disableListWrap:!0,...i&&{ListboxComponent:zt,groupBy:void 0}};return o.jsx(Ke,{...l})}const Dt=g("div")(({theme:n})=>({display:"flex",flexDirection:"column",gap:n.spacing(.5),"& > *:not(:last-child)":{borderBottom:`1px solid ${n.palette.divider}`,paddingBottom:n.spacing(1)}})),Nt=g(Ve)(()=>({display:"block"})),es=({role:n,roles:r,value:e})=>{const{isEnterprise:s}=k();if(s()){const t=r||[n];return o.jsx(M,{children:o.jsx(Ge,{tooltip:o.jsx(Dt,{children:t.map(i=>o.jsx(qe,{roleId:i,tooltip:!0},i))}),children:o.jsx(Nt,{children:e})})})}return o.jsx(M,{children:e})};export{Bt as A,Wt as C,Jt as E,Ht as R,ce as S,b as T,$t as a,Vt as b,Kt as c,qt as d,Yt as e,Gt as f,Xt as g,Zt as h,Qt as i,es as j,ae as k,bt as m,Ut as u};