unleash-server 5.1.0 → 5.1.2

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 (22) hide show
  1. package/dist/lib/db/event-store.js +2 -1
  2. package/dist/lib/db/event-store.js.map +1 -1
  3. package/frontend/build/index.html +1 -1
  4. package/frontend/build/static/{CreateProject-3c093214.js → CreateProject-217f67b6.js} +1 -1
  5. package/frontend/build/static/{Error-10dff66c.js → Error-5606eccd.js} +1 -1
  6. package/frontend/build/static/FeatureArchiveDialog-c311c641.js +4 -0
  7. package/frontend/build/static/{FeatureMetricsChart-d5c6311d.js → FeatureMetricsChart-1c6bb078.js} +1 -1
  8. package/frontend/build/static/{FeatureViewLazyExport-e52ae7b0.js → FeatureViewLazyExport-06cf4baa.js} +2 -2
  9. package/frontend/build/static/{LazyAdminExport-2554e446.js → LazyAdminExport-04c8032d.js} +2 -2
  10. package/frontend/build/static/{LazyProjectExport-682e75c0.js → LazyProjectExport-d9663a8c.js} +1 -1
  11. package/frontend/build/static/{NetworkOverview-4653e26c.js → NetworkOverview-2bce4916.js} +1 -1
  12. package/frontend/build/static/{NetworkTraffic-4332556b.js → NetworkTraffic-7db94d86.js} +1 -1
  13. package/frontend/build/static/{Playground-130e9113.js → Playground-6602cb1a.js} +1 -1
  14. package/frontend/build/static/{StrategyItemContainer-893b13f0.js → StrategyItemContainer-0140b94f.js} +1 -1
  15. package/frontend/build/static/{chartjs-adapter-date-fns.esm-23b8f0d9.js → chartjs-adapter-date-fns.esm-c75aa905.js} +1 -1
  16. package/frontend/build/static/{index-66ec1ba9.js → index-1f392976.js} +2 -2
  17. package/frontend/build/static/{index-4d0a5ffb.js → index-b3def5eb.js} +1 -1
  18. package/frontend/build/static/{index-e7efdb59.js → index-f8439975.js} +1 -1
  19. package/frontend/build/static/{unknownify-6ed6e58e.js → unknownify-6683037a.js} +1 -1
  20. package/frontend/build/static/{useProjectRole-ce09b03e.js → useProjectRole-122ac4bb.js} +1 -1
  21. package/package.json +1 -1
  22. package/frontend/build/static/FeatureArchiveDialog-365cb2af.js +0 -4
@@ -1,4 +1,4 @@
1
- import{c as le,j as n,cC as c0,cE as l0,s as h,cp as d0,cm as et,g as st,r as u,dP as u0,l as o1,d as t1,f as l,S as ct,h as lt,i as dt,k as ut,bZ as p0,b8 as G1,A as w1,aO as de,aP as K1,aQ as J1,dQ as H3,aF as Y,dR as F1,bS as x1,a2 as u1,cg as C1,ar as De,H as p1,dS as h0,R as Ae,cK as l2,dT as W3,dU as k1,al as i1,V as D1,ak as d1,C as w,aL as R1,X as ue,W as S1,ck as m0,K as pt,dV as g0,bb as Re,bc as Fe,bd as Pe,a as E,b1 as Y1,m as M1,bg as f0,P as ht,dl as mt,dW as ae,cq as d2,a8 as N1,dX as jt,b5 as re,dF as v0,b7 as oe,T as $,cs as N3,aK as gt,dY as q1,af as q3,c7 as u2,u as m1,N as b1,dZ as y0,F as G,d_ as U3,ap as P1,a9 as l1,d$ as b0,dk as C0,a4 as h1,bM as S0,bK as p2,ca as ft,bN as G3,aW as Ze,a$ as Ie,aX as je,e0 as K3,di as J3,bC as _0,ao as T1,L as h2,e1 as w0,cn as x0,e2 as T0,e3 as E0,e4 as A0,e5 as Y3,e6 as Q3,O as X3,e7 as k0,cc as vt,Q as yt,cW as D0,cl as R0,bQ as en,Y as bt,e8 as F0,D as P0,aN as Z0,ch as I0,M as tn,e9 as j0,ah as L1,ea as nn,ag as an,eb as rn,ai as O0,ec as $0,ed as B0,aR as on,ee as m2,a1 as z0,ef as sn,eg as V0,eh as M0,ei as L0,ej as H0,bH as cn,ek as ln,el as dn,e as Oe,U as Ct,em as W0,en as N0,aH as q0,br as U0,eo as St,ep as G0,eq as un,er as K0,ay as pe,az as Q1,aI as j1,aA as he,aD as me,aE as ge,es as J0,cd as Ee,bP as pn,et as hn,eu as Y0,bq as X1,an as mn,bm as _t,ev as Q0,ew as X0,ex as ea,ey as ta,ez as na,eA as aa,eB as ra,dA as gn,cb as oa,de as tt,eC as ia,cu as g2,eD as wt,bV as U1,aJ as z1,aM as xt,bl as f2,d6 as v2,ax as V1,as as y2,eE as sa,ad as B2,eF as ca,d3 as Ne,ac as e2,eG as la,eH as da,d4 as ua,d5 as pa,eI as ha,eJ as ma,eK as ga,bT as fe,bU as X,eL as fa,eM as fn,Z as b2,au as va,eN as ya,cO as ba,eO as Ca,eP as Sa,eQ as _a,bo as vn,bp as wa,bz as xa,bA as Ta,bB as Ea,x as Aa,eR as ka,eS as Da,be as Ra,eT as yn,eU as Fa,eV as Pa,eW as Za,eX as Ia,eY as ja,eZ as Oa,e_ as $a,e$ as Ba,f0 as za,aY as Va,f1 as Ma,co as bn,f2 as La,d0 as Cn,f3 as ie,f4 as Q,f5 as Ha,f6 as Wa,f7 as Na,f8 as qa,f9 as Ua,d9 as Ga,fa as Ka,fb as Ja,fc as Ya,fd as Qa}from"./index-66ec1ba9.js";import{e as Sn,W as z2,b as Xa,u as _n,T as er,c as tr,h as nr,F as ar,V as rr,a as or,g as ir,C as sr,i as cr,j as V2,R as M2,k as lr,l as dr,E as ur}from"./FeatureArchiveDialog-365cb2af.js";import{a as pr}from"./index-e7efdb59.js";import{m as hr,h as mr,b as gr,c as fr,d as vr,e as yr,E as br,f as Cr,u as Sr,a as _r,R as wr,C as xr,A as Tr,B as wn}from"./useProjectRole-ce09b03e.js";import{S as Er}from"./StrategyItemContainer-893b13f0.js";import{E as Ar}from"./Error-10dff66c.js";const kr=le(n("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"}),"ArrowUpward"),Dr=le(n("path",{d:"M9 5v2h6.59L4 18.59 5.41 20 17 8.41V15h2V5z"}),"CallMade"),Rr=le(n("path",{d:"M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"}),"FileUpload"),Fr=le(n("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM7 13.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"}),"Pending"),Pr=le(n("path",{d:"M12 5.99 19.53 19H4.47L12 5.99M12 2 1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),Zr=le(n("path",{d:"M19 9h-2v6.59L5.41 4 4 5.41 15.59 17H9v2h10V9z"}),"SouthEast");function Ir(e,t){c0(2,arguments);var a=l0(t);return pr(e,-a)}const L2=h("div")(()=>({display:"flex"})),jr=h("div")(()=>({display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%"}));h("div")(()=>({display:"flex",flexDirection:"column"}));const Or=h("span")(({theme:e})=>({fontSize:e.typography.h1.fontSize,textOverflow:"ellipsis",whiteSpace:"nowrap"})),$r=h("span")(({theme:e})=>({fontSize:e.fontSizes.smallBody,fontWeight:"normal"}));h($r)(({theme:e})=>({color:e.palette.neutral.dark}));const Br=h(d0)(({theme:e})=>({marginLeft:e.spacing(-1.5)})),zr=h("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),Vr=h("div")(({theme:e})=>({padding:e.spacing(2.5,5),display:"flex",flexDirection:"column",alignItems:"start"})),Mr=h("span")(({theme:e})=>({margin:0,width:"100%",fontSize:e.fontSizes.mainHeader,fontWeight:"bold",display:"flex",justifyContent:"space-between",alignItems:"center",gap:e.spacing(2)})),Lr=h("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.divider,height:"1px"})),Hr=h("div")(({theme:e})=>({padding:e.spacing(0,4)})),Wr=h(et)(({theme:e})=>({textTransform:"none",fontSize:e.fontSizes.bodySize,flexGrow:1,flexBasis:0,[e.breakpoints.down("md")]:{paddingLeft:e.spacing(1),paddingRight:e.spacing(1)},[e.breakpoints.up("md")]:{minWidth:160}})),Nr=e=>e.reduce((t,a)=>a.enabled?t+1:t,0),qr=h(st)(({theme:e})=>({marginTop:e.spacing(3)})),Ur=h("p",{shouldForwardProp:e=>e!=="warning"})(({theme:e,warning:t})=>({color:t?e.palette.error.dark:e.palette.text.primary,textAlign:"center"})),Gr=({environment:e,warnEnabledToggles:t})=>{const a=u.useMemo(()=>[{id:"Icon",width:"1%",Cell:({row:{original:d}})=>n(u0,{environment:d})},{Header:"Name",accessor:"name",Cell:o1},{Header:"Type",accessor:"type",Cell:o1},{Header:"Toggles enabled",accessor:"projectEnabledToggleCount",Cell:({value:d})=>n(o1,{children:n(Ur,{warning:d>0,children:d===1?"1 toggle":`${d} toggles`})}),align:"center"}],[t]),{getTableProps:r,getTableBodyProps:o,headerGroups:i,rows:s,prepareRow:c}=t1.useTable({columns:a,data:[e],disableSortBy:!0});return l(qr,{...r(),rowHeight:"compact",children:[n(ct,{headerGroups:i}),n(lt,{...o(),children:s.map(d=>(c(d),n(dt,{hover:!0,...d.getRowProps(),children:d.cells.map(p=>n(ut,{...p.getCellProps(),children:p.render("Cell")}))})))})]})},Kr=h("p")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1.5)})),Jr=h(p0)(()=>({width:"100%"})),Yr=({environment:e,open:t,setOpen:a,onConfirm:r})=>{const[o,i]=u.useState("");return u.useEffect(()=>{i("")},[t]),l(G1,{title:"Hide environment and disable feature toggles?",open:t,primaryButtonText:"Hide environment and disable feature toggles",disabledPrimaryButton:(e==null?void 0:e.name)!==o,secondaryButtonText:"Close",onClick:r,onClose:()=>{a(!1)},children:[l(w1,{severity:"error",children:[n("strong",{children:"Danger!"})," Hiding an environment will disable all the feature toggles that are enabled in this environment and it can impact client applications connected to the environment."]}),n(Gr,{environment:e}),l(Kr,{children:["In order to hide this environment, please enter the id of the environment in the textfield below:"," ",n("strong",{children:e==null?void 0:e.name})]}),n(Jr,{label:"Environment name",value:o,onChange:s=>i(s.target.value)})]})},Qr=e=>{const{data:t,error:a,mutate:r}=de(K1(`api/admin/environments/project/${e}`),Xr),o=u.useMemo(()=>t||[],[t]),i=u.useCallback(async()=>{await r()},[r]);return{environments:o,refetchEnvironments:i,loading:!a&&!t,error:a}},Xr=async e=>(await fetch(e).then(J1("Environments")).then(a=>a.json())).environments.sort((a,r)=>a.sortOrder-r.sortOrder),eo=h(w1)(({theme:e})=>({marginBottom:e.spacing(4)})),to=h("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",[e.breakpoints.down("sm")]:{justifyContent:"center"}})),no=h(H3)(({theme:e})=>({maxWidth:"400px",marginBottom:e.spacing(2)})),xn=()=>{const e=Y("projectId"),t=F1(e);x1(`Project environments – ${t}`);const{setToastData:a,setToastApiError:r}=u1(),{environments:o,loading:i,error:s,refetchEnvironments:c}=Qr(e),{project:d,refetch:p}=C1(e),{removeEnvironmentFromProject:m,addEnvironmentToProject:g}=De(),[f,C]=u.useState(),[S,b]=u.useState(!1),{isOss:R}=p1(),v=u.useMemo(()=>o.map(I=>({...I,projectVisible:d==null?void 0:d.environments.map(q=>q.environment).includes(I.name)})),[o,d==null?void 0:d.environments]),F=()=>{c(),p()},T=()=>n(no,{onClick:F,text:"Error fetching environments"}),j=I=>`Got an API error when trying to set the environment as ${I?"visible":"hidden"}`,M=async I=>{if(I.projectVisible){if(Nr(v)>1){C(I),b(!0);return}a({title:"One environment must be visible",text:"You must always have at least one visible environment per project",type:"error"})}else try{await g(e,I.name),F(),a({title:"Environment set as visible",text:"Environment successfully set as visible.",type:"success"})}catch{r(j(!0))}},_=async()=>{if(f)try{await m(e,f.name),F(),a({title:"Environment set as hidden",text:"Environment successfully set as hidden.",type:"success"})}catch{r(j(!1))}finally{b(!1)}},D=I=>R()&&I==="default",P=u.useMemo(()=>[{Header:"Name",accessor:"name",Cell:({row:{original:I}})=>n(h0,{environment:I})},{Header:"Type",accessor:"type",Cell:Ae},{Header:"Project API tokens",accessor:I=>I.projectApiTokenCount===1?"1 token":`${I.projectApiTokenCount} tokens`,Cell:o1},{Header:"Visible in project",accessor:"enabled",align:"center",width:1,Cell:({row:{original:I}})=>n(l2,{children:n(W3,{tooltip:I.projectVisible?"Hide environment and disable feature toggles":"Make it visible",size:"medium",disabled:D(I.name),projectId:e,permission:k1,checked:I.projectVisible,onChange:()=>M(I)})}),disableGlobalFilter:!0}],[v]),{getTableProps:B,getTableBodyProps:V,headerGroups:O,rows:J,prepareRow:N,state:{globalFilter:L},setGlobalFilter:y}=t1.useTable({columns:P,data:v,disableSortBy:!0},t1.useGlobalFilter),k=n(i1,{title:`Environments (${J.length})`,actions:n(D1,{initialValue:L,onChange:y})});return n(d1,{header:k,isLoading:i,children:l(to,{children:[n(w,{condition:!!s,show:T()}),l(eo,{severity:"info",children:[n("strong",{children:"Important!"})," In order for your application to retrieve configured activation strategies for a specific environment, the application must use an environment specific API token. You can look up the environment-specific"," ",n(R1,{to:"/admin/api",children:"API tokens here"}),".",n("br",{}),n("br",{}),"Your administrator can configure an environment-specific API token to be used in the SDK. If you are an administrator you can ",n(R1,{to:"/admin/api",children:"create a new API token here"}),"."]}),n(ue,{value:L,children:l(st,{...B(),rowHeight:"compact",children:[n(ct,{headerGroups:O}),n(lt,{...V(),children:J.map(I=>(N(I),n(dt,{hover:!0,...I.getRowProps(),children:I.cells.map(q=>n(ut,{...q.getCellProps(),children:q.render("Cell")}))})))})]})}),n(w,{condition:J.length===0,show:n(w,{condition:(L==null?void 0:L.length)>0,show:l(S1,{children:["No environments found matching “",L,"”"]}),elseShow:n(S1,{children:"No environments available. Get started by adding one."})})}),n(Yr,{environment:f,open:S,setOpen:b,onConfirm:_})]})})},ao={id:"archivedAt"},ro=({projectId:e})=>{const{archivedFeatures:t,loading:a,refetchArchived:r}=m0(e),{value:o,setValue:i}=pt(`${e}:ProjectFeaturesArchiveTable`,ao);return n(g0,{title:"Project archive",archivedFeatures:t||[],loading:a,storedParams:o,setStoredParams:i,refetch:r,projectId:e})},oo=()=>{const e=Y("projectId"),t=F1(e);return x1(`Project archive – ${t}`),n(ro,{projectId:e})},io=(e=[])=>{var r;let t=e.map(o=>o.environment);const a=u.useRef(t);return t.join("")!==((r=a.current)==null?void 0:r.join(""))&&(a.current=t),a.current};var C2={},so=Fe;Object.defineProperty(C2,"__esModule",{value:!0});var Tn=C2.default=void 0,co=so(Re()),lo=Pe,uo=(0,co.default)((0,lo.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.27zM12 17.5 6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z"}),"Archive");Tn=C2.default=uo;var S2={},po=Fe;Object.defineProperty(S2,"__esModule",{value:!0});var En=S2.default=void 0,ho=po(Re()),mo=Pe,go=(0,ho.default)((0,mo.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm4.2 14.2L11 13V7h1.5v5.2l4.5 2.7-.8 1.3z"}),"WatchLater");En=S2.default=go;const fo=h(E)(({theme:e})=>({display:"flex",justifyContent:"center",paddingRight:e.spacing(2)})),vo=({projectId:e,row:t,onOpenArchiveDialog:a,onOpenStaleDialog:r})=>{const[o,i]=u.useState(null),{original:{name:s,stale:c}}=t,d=!!o,p=C=>{i(C.currentTarget)},m=()=>{i(null)},g=`feature-${s}-actions`,f=`${g}-menu`;return l(fo,{children:[n(Y1,{title:"Feature toggle actions",arrow:!0,describeChild:!0,children:n(M1,{id:g,"aria-controls":d?f:void 0,"aria-haspopup":"true","aria-expanded":d?"true":void 0,onClick:p,type:"button",children:n(f0,{})})}),n(ht,{id:f,anchorEl:o,open:d,onClose:m,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:C=>({borderRadius:`${C.shape.borderRadius}px`,padding:C.spacing(1,1.5)})},children:l(mt,{"aria-labelledby":g,children:[n(ae,{projectId:e,permission:d2,children:({hasAccess:C})=>l(N1,{sx:jt,onClick:m,disabled:!C,component:R1,to:`/projects/${e}/features/${s}/strategies/copy`,children:[n(re,{children:n(v0,{})}),n(oe,{children:n($,{variant:"body2",children:"Copy"})})]})}),n(ae,{projectId:e,permission:N3,children:({hasAccess:C})=>l(N1,{sx:jt,onClick:()=>{a(s),m()},disabled:!C,children:[n(re,{children:n(Tn,{})}),n(oe,{children:n($,{variant:"body2",children:"Archive"})})]})}),n(ae,{projectId:e,permission:gt,children:({hasAccess:C})=>l(N1,{sx:jt,onClick:()=>{m(),r({featureId:s,stale:c===!0})},disabled:!C,children:[n(re,{children:n(En,{})}),n(oe,{children:l($,{variant:"body2",children:[c?"Un-mark":"Mark"," as stale"]})})]})})]})})]})};var _2={},yo=Fe;Object.defineProperty(_2,"__esModule",{value:!0});var An=_2.default=void 0,bo=yo(Re()),Co=Pe,So=(0,bo.default)((0,Co.jsx)("path",{d:"M5.33 20H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h1.33c1.1 0 2 .9 2 2v12c0 1.1-.89 2-2 2zM22 18V6c0-1.1-.9-2-2-2h-1.33c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2H20c1.11 0 2-.9 2-2zm-7.33 0V6c0-1.1-.9-2-2-2h-1.33c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h1.33c1.1 0 2-.9 2-2z"}),"ViewWeek");An=_2.default=So;const _o=h(E)(()=>({...q1,justifyContent:"center"})),wo=h(M1)(({theme:e})=>({margin:e.spacing(-1,0)})),xo=h(E)(({theme:e})=>({...q1,justifyContent:"space-between",padding:e.spacing(1,1,0,4)})),To=h(N1)(({theme:e})=>({padding:e.spacing(0,2),margin:e.spacing(0,2),borderRadius:e.shape.borderRadius})),H2=h(q3)(({theme:e})=>({"&.MuiDivider-root.MuiDivider-fullWidth":{margin:e.spacing(.75,0)}})),Eo=h(u2)(({theme:e})=>({padding:e.spacing(.75,1)})),Ao={favorite:"Favorite"},ko=({allColumns:e,staticColumns:t=[],dividerBefore:a=[],dividerAfter:r=[],isCustomized:o=!1,setHiddenColumns:i})=>{const[s,c]=u.useState(null),d=m1(),p=b1(d.breakpoints.down("sm")),m=b1(d.breakpoints.down("md")),g=b1(d.breakpoints.down("lg"));u.useEffect(()=>{if(o)return;const v=(F,T=0)=>{const j=e.filter(({id:_})=>_.startsWith("environments.")!==!1).map(({id:_})=>_).slice(0,T),M=e.map(({id:_})=>_).filter(_=>!F.includes(_)).filter(_=>!t.includes(_)).filter(_=>!j.includes(_));i(M)};if(p)return v(["createdAt"]);if(m)return v(["createdAt"],1);if(g)return v(["type","createdAt"],1);v(["lastSeenAt","type","createdAt"],3)},[p,m,g]);const f=v=>{c(v.currentTarget)},C=()=>{c(null)},S=!!s,b="columns-menu",R=`columns-menu-list-${b}`;return l(_o,{children:[n(Y1,{title:"Select columns",arrow:!0,describeChild:!0,children:n(wo,{id:b,"aria-controls":S?R:void 0,"aria-haspopup":"true","aria-expanded":S?"true":void 0,onClick:f,type:"button",size:"large","data-loading":!0,children:n(An,{})})}),l(ht,{id:R,open:S,anchorEl:s,onClose:C,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},disableScrollLock:!0,PaperProps:{sx:v=>({borderRadius:v.shape.borderRadius,paddingBottom:v.spacing(2)})},children:[l(xo,{children:[n($,{variant:"body2",children:n("strong",{children:"Columns"})}),n(M1,{onClick:C,children:n(y0,{})})]}),n(mt,{children:e.filter(({hideInMenu:v})=>!v).map(v=>[n(w,{condition:a.includes(v.id),show:n(H2,{})}),l(To,{onClick:()=>v.toggleHidden(v.isVisible),disabled:t.includes(v.id),children:[n(re,{children:n(Eo,{edge:"start",checked:v.isVisible,disableRipple:!0,inputProps:{"aria-labelledby":v.id},size:"medium"})}),n(oe,{id:v.id,primary:n($,{variant:"body2",children:n(w,{condition:!!(typeof v.Header=="string"&&v.Header),show:()=>n(G,{children:v.Header}),elseShow:()=>Ao[v.id]||v.id})})})]}),n(w,{condition:r.includes(v.id),show:n(H2,{})})])})]})]})},Do=U3()(e=>({container:{boxShadow:"none",marginLeft:"1rem",minHeight:"100%",width:"calc(100% - 1rem)",position:"relative",[e.breakpoints.down("md")]:{marginLeft:"0",paddingBottom:"4rem",width:"inherit"}}})),Ro=({projectId:e,features:t})=>{const{refetch:a}=C1(e),[r,o]=u.useState(!1),{trackEvent:i}=P1();return l(G,{children:[n(ae,{projectId:e,permission:N3,children:({hasAccess:c})=>n(l1,{disabled:!c||r,variant:"outlined",size:"small",onClick:()=>o(!0),children:"Archive"})}),n(Sn,{projectId:e,featureIds:t,onConfirm:async()=>{o(!1),await a(),i("batch_operations",{props:{eventType:"features archived"}})},isOpen:r,onClose:()=>o(!1)})]})},qe="selection-actions-menu",Fo=({projectId:e,data:t})=>{const{refetch:a}=C1(e),[r,o]=u.useState(null),{staleFeatures:i}=De(),{setToastData:s,setToastApiError:c}=u1(),{trackEvent:d}=P1(),p=!!r,m=t.map(({name:v})=>v),g=v=>{o(v.currentTarget)},f=()=>{o(null)},C=t.some(({stale:v})=>v===!0),S=t.some(({stale:v})=>v===!1),b=async()=>{try{f(),await i(e,m),await a(),s({title:"State updated",text:"Feature toggles marked as stale",type:"success"}),d("batch_operations",{props:{eventType:"features staled"}})}catch(v){c(h1(v))}},R=async()=>{try{f(),await i(e,m,!1),await a(),s({title:"State updated",text:"Feature toggles unmarked as stale",type:"success"}),d("batch_operations",{props:{eventType:"features unstaled"}})}catch(v){c(h1(v))}};return l(G,{children:[n(Y1,{title:"More bulk actions",arrow:!0,describeChild:!0,children:n(M1,{id:qe,"aria-controls":p?qe:void 0,"aria-haspopup":"true","aria-expanded":p?"true":void 0,onClick:g,type:"button","data-testid":b0,children:n(C0,{})})}),n(ht,{id:`${qe}-menu`,anchorEl:r,open:p,onClose:f,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:v=>({borderRadius:`${v.shape.borderRadius}px`,padding:v.spacing(1,1.5)})},children:n(mt,{"aria-labelledby":`${qe}-menu`,children:n(ae,{projectId:e,permission:gt,children:({hasAccess:v})=>l(G,{children:[n(w,{condition:S,show:()=>l(N1,{onClick:b,disabled:!v,sx:{borderRadius:F=>`${F.shape.borderRadius}px`},children:[n(re,{children:n(z2,{})}),n(oe,{children:n($,{variant:"body2",children:"Mark as stale"})})]})}),n(w,{condition:C,show:()=>l(N1,{onClick:R,disabled:!v,sx:{borderRadius:F=>`${F.shape.borderRadius}px`},children:[n(re,{children:n(z2,{})}),n(oe,{children:n($,{variant:"body2",children:"Un-mark as stale"})})]})})]})})})})]})},Po=h("section")(({theme:e})=>({["& > *"]:{margin:e.spacing(1,0)}})),W2="manage-tags-form",N2=(e,t)=>[...e,...e.some(a=>a.value===t.value&&a.type===t.type)?[]:[t]],q2=(e,t)=>e.filter(a=>!(a.value===t.value&&a.type===t.type)),Zo=(e,t)=>{switch(t.type){case"add":return{...e,addedTags:N2(e.addedTags,t.payload),removedTags:q2(e.removedTags,t.payload)};case"remove":return{...e,addedTags:q2(e.addedTags,t.payload),removedTags:N2(e.removedTags,t.payload)};case"clear":return{addedTags:[],removedTags:t.payload};default:return e}},U2={name:"",description:"",icon:""},Io=({open:e,initialValues:t,initialIndeterminateValues:a,onCancel:r,onSubmit:o})=>{const{tagTypes:i,loading:s}=S0(),[c,d]=u.useState(U2),[p,m]=u.useState([]),[g,f]=u.useState([]),{tags:C,refetch:S}=Xa(c.name),{createTag:b}=_n(),R=C.map(({value:P})=>({title:P})),[v,F]=u.useReducer(Zo,{addedTags:[],removedTags:[]}),T=(P=i.length>0?i[0]:U2)=>{d(P);const B=a.filter(({type:V})=>V===P.name);m(t.filter(({type:V})=>V===P.name).filter(({type:V,value:O})=>!B.some(J=>J.value===O&&J.type===V)).map(({value:V})=>({title:V}))),f(B.map(({value:V})=>({title:V}))),F({type:"clear",payload:[]})};u.useEffect(()=>{i.length>0&&T()},[s]);const j=(P,B)=>{B!=null&&typeof B!="string"&&(P.preventDefault(),T(B))},M=(P,B)=>b({value:P,type:B}).then(async()=>{await S(),m(V=>[...V,{title:P}]),F({type:"add",payload:{value:P,type:B}})}),_=(P,B,V,O)=>{V==="selectOption"?B.forEach(J=>{if(typeof J!="string"&&typeof J.inputValue=="string"&&J.inputValue&&J.title.startsWith("Create new value"))return M(J.inputValue,c.name);m(B),f(N=>N.filter(({title:L})=>L!==J.title)),O!=null&&O.option&&F({type:"add",payload:{value:O.option.title,type:c.name}})}):V==="clear"?(m([]),F({type:"clear",payload:t})):V==="removeOption"&&(m(B),O!=null&&O.option&&F({type:"remove",payload:{value:O.option.title,type:c.name}}))},D=()=>{T(),r()};return l(G1,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update tags to feature toggle",onClick:()=>o(v),disabledPrimaryButton:v.addedTags.length===0&&v.removedTags.length===0,onClose:D,formId:W2,children:[n($,{paragraph:!0,sx:{marginBottom:P=>P.spacing(2.5)},children:"Tags allow you to group features together"}),n("form",{id:W2,onSubmit:()=>o(v),children:l(Po,{children:[n(er,{options:i,disabled:s||i.length===0,value:c,onChange:j},s?"loading":i.length),n(w,{condition:!s&&i.length===0,show:l($,{variant:"body1",children:["No"," ",n(p2,{component:R1,to:"/tag-types",children:"tag types"})," ","available."]}),elseShow:n(tr,{disabled:s,options:R,existingTags:t,indeterminateOptions:g,tagType:c,selectedOptions:p,onChange:_})})]})})]})},jo=({projectId:e,data:t})=>{const{bulkUpdateTags:a}=_n(),{refetch:r}=C1(e),{setToastData:o,setToastApiError:i}=u1(),{trackEvent:s}=P1(),[c,d]=u.useState(!1),[p,m]=u.useMemo(()=>{const f=t.flatMap(({tags:S})=>S||[]).reduce((S,b)=>[...S,...S.some(R=>R.type===b.type&&R.value===b.value)?[]:[b]],[]),C=f.filter(S=>!t.every(({tags:b})=>b==null?void 0:b.some(R=>R.type===S.type&&R.value===S.value)));return[f,C]},[t]);return l(G,{children:[n(ae,{projectId:e,permission:gt,children:({hasAccess:f})=>n(l1,{disabled:!f||c,variant:"outlined",size:"small",onClick:()=>d(!0),children:"Tags"})}),n(Io,{open:c,onCancel:()=>d(!1),onSubmit:async({addedTags:f,removedTags:C})=>{const S=t.map(({name:R})=>R),b={features:S,tags:{addedTags:f,removedTags:C}};try{await a(b),r();const R=f.length?`Added tags: ${f.map(({type:F,value:T})=>`${F}:${T}`).join(", ")}.`:"",v=C.length?`Removed tags: ${C.map(({type:F,value:T})=>`${F}:${T}`).join(", ")}.`:"";o({title:"Tags updated",text:`${S.length} feature toggles updated. ${R} ${v}`,type:"success",autoHideDuration:12e3}),s("batch_operations",{props:{eventType:"tags updated"}})}catch(R){i(h1(R))}d(!1)},initialValues:p,initialIndeterminateValues:m},t.length)]})},Oo=h(ft)(({theme:e})=>({minWidth:"450px",marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),G2=h(w1)(({theme:e})=>({marginBottom:e.spacing(1.5)})),$o=({showExportDialog:e,data:t,onClose:a,onConfirm:r,environments:o,projectId:i})=>{const[s,c]=u.useState(o[0]),{bulkToggleFeaturesEnvironmentOff:d}=G3(),{addChange:p}=Ze(),{refetch:m}=C1(i),{setToastApiError:g,setToastData:f}=u1(),{isChangeRequestConfigured:C}=Ie(i),{refetch:S}=je(i),b=t.filter(T=>{var j,M;return((M=(j=T.environments)==null?void 0:j.find(_=>s===_.name))==null?void 0:M.enabled)===!1}).length,R=()=>o.map(T=>({key:T,label:T})),v=async()=>{try{C(s)?(await p(i,s,t.map(T=>({action:"updateEnabled",feature:T.name,payload:{enabled:!1}}))),S(),f({text:"Your disabled feature toggles changes have been added to change request",type:"success",title:"Changes added to a draft"})):(await d(i,t.map(T=>T.name),s),m(),f({text:"Your feature toggles have been disabled",type:"success",title:"Features disabled"})),a(),r==null||r()}catch(T){g(h1(T))}},F=C(s)?"Add to change request":"Disable toggles";return n(G1,{open:e,title:"Disable feature toggles",onClose:a,onClick:v,primaryButtonText:F,secondaryButtonText:"Cancel",children:l(E,{children:["You have selected ",n("b",{children:t.length})," feature toggles to disable.",n("br",{}),n("br",{}),n($,{children:"Select which environment to disable the features for:"}),n(Oo,{options:R(),value:s,onChange:T=>c(T)}),n(w,{condition:C(s),show:n(G2,{severity:"warning",children:"Change requests are enabled for this environment."})}),n(w,{condition:b>0,show:l(G2,{severity:"info",children:[b," feature"," ",b>1?"toggles are ":"toggle is ","already disabled."]})})]})})},Bo=h(ft)(({theme:e})=>({minWidth:"450px",marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),K2=h(w1)(({theme:e})=>({marginBottom:e.spacing(1.5)})),zo=({showExportDialog:e,data:t,onClose:a,onConfirm:r,environments:o,projectId:i})=>{const[s,c]=u.useState(o[0]),{bulkToggleFeaturesEnvironmentOn:d}=G3(),{addChange:p}=Ze(),{refetch:m}=C1(i),{setToastApiError:g,setToastData:f}=u1(),{isChangeRequestConfigured:C}=Ie(i),{refetch:S}=je(i),b=t.filter(T=>{var j,M;return((M=(j=T.environments)==null?void 0:j.find(_=>s===_.name))==null?void 0:M.enabled)===!0}).length,R=()=>o.map(T=>({key:T,label:T})),v=async()=>{try{C(s)?(await p(i,s,t.map(T=>({action:"updateEnabled",feature:T.name,payload:{enabled:!0}}))),S(),f({text:"Your enable feature toggles changes have been added to change request",type:"success",title:"Changes added to a draft"})):(await d(i,t.map(T=>T.name),s),m(),f({text:"Your feature toggles have been enabled",type:"success",title:"Features enabled"})),a(),r==null||r()}catch(T){g(h1(T))}},F=C(s)?"Add to change request":"Enable toggles";return n(G1,{open:e,title:"Enable feature toggles",onClose:a,onClick:v,primaryButtonText:F,secondaryButtonText:"Cancel",children:l(E,{children:["You have selected ",n("b",{children:t.length})," feature toggles to enable.",n("br",{}),n("br",{}),n($,{children:"Select which environment to enable the features for:"}),n(Bo,{options:R(),value:s,onChange:T=>c(T)}),n(w,{condition:C(s),show:n(K2,{severity:"warning",children:"Change requests are enabled for this environment."})}),n(w,{condition:b>0,show:l(K2,{severity:"info",children:[b," feature"," ",b>1?"toggles are ":"toggle is ","already enabled."]})})]})})},Vo=({selectedIds:e,data:t,projectId:a})=>{var R,v;const{uiConfig:r}=p1(),[o,i]=u.useState(!1),[s,c]=u.useState(!1),[d,p]=u.useState(!1),{trackEvent:m}=P1(),g=u.useMemo(()=>t.filter(F=>e.includes(F.name)),[t,e]),f=u.useMemo(()=>{const F=g.flatMap(T=>T.environments).map(T=>T==null?void 0:T.name).filter(T=>T!==void 0);return Array.from(new Set(F))},[g]),C=()=>{m("batch_operations",{props:{eventType:"features exported"}})},S=()=>{m("batch_operations",{props:{eventType:"features enabled"}})},b=()=>{m("batch_operations",{props:{eventType:"features disabled"}})};return l(G,{children:[n(w,{condition:!!((R=r==null?void 0:r.flags)!=null&&R.disableBulkToggle),show:null,elseShow:n(l1,{variant:"outlined",size:"small",onClick:()=>c(!0),children:"Enable"})}),n(w,{condition:!!((v=r==null?void 0:r.flags)!=null&&v.disableBulkToggle),show:null,elseShow:n(l1,{variant:"outlined",size:"small",onClick:()=>p(!0),children:"Disable"})}),n(Ro,{projectId:a,features:e}),n(l1,{variant:"outlined",size:"small",onClick:()=>i(!0),children:"Export"}),n(jo,{projectId:a,data:g}),n(Fo,{projectId:a,data:g}),n(K3,{showExportDialog:o,data:g,onClose:()=>i(!1),environments:f,onConfirm:C}),n(zo,{showExportDialog:s,data:g,onClose:()=>c(!1),environments:f,projectId:a,onConfirm:S}),n($o,{showExportDialog:d,data:g,onClose:()=>p(!1),environments:f,projectId:a,onConfirm:b})]})},Mo=h(J3)(()=>({whiteSpace:"nowrap"})),Lo=h("div",{shouldForwardProp:e=>e!=="hasWarning"})(({theme:e,hasWarning:t})=>({flexGrow:0,...q1,justifyContent:"center",...t&&{"::before":{content:'""',display:"block",width:e.spacing(2)}}})),Ue=["Select","Actions","name","favorite"],Ho={id:"createdAt"},Wo=({features:e,loading:t,environments:a=[]})=>{var I1,te;const{classes:r}=Do(),o=m1(),i=b1(o.breakpoints.down("md")),[s,c]=u.useState({open:!1,featureId:"",environmentName:""}),[d,p]=u.useState({}),[m,g]=u.useState(),f=Y("projectId"),{value:C,setValue:S}=pt(`${f}:FeatureToggleListTable:v1`,Ho),{value:b,setValue:R}=_0(),v=T1(),[F,T]=h2(),j=io(t?[{environment:"a"},{environment:"b"},{environment:"c"}]:a),{refetch:M}=C1(f),{isFavoritesPinned:_,sortTypes:D,onChangeIsFavoritePinned:P}=w0(F.has("favorites")?F.get("favorites")==="true":b.favorites),{favorite:B,unfavorite:V}=x0(),{onChangeRequestToggleClose:O,onChangeRequestToggleConfirm:J,changeRequestDialogDetails:N}=nr(f),[L,y]=u.useState(!1),{uiConfig:k}=p1(),I=u.useCallback(async Z=>{Z!=null&&Z.favorite?await V(f,Z.name):await B(f,Z.name),M()},[f,M]),q=u.useMemo(()=>e.some(Z=>{var H;return(H=Z==null?void 0:Z.tags)==null?void 0:H.length}),[e]),x=u.useMemo(()=>[{id:"Select",Header:({getToggleAllRowsSelectedProps:Z})=>n(u2,{...Z()}),Cell:({row:Z})=>{var H;return n(T0,{...(H=Z==null?void 0:Z.getToggleRowSelectedProps)==null?void 0:H.call(Z)})},maxWidth:50,disableSortBy:!0,hideInMenu:!0},{id:"favorite",Header:n(E0,{isActive:_,onClick:P}),accessor:"favorite",Cell:({row:{original:Z}})=>n(A0,{value:Z==null?void 0:Z.favorite,onClick:()=>I(Z)}),maxWidth:50,disableSortBy:!0,hideInMenu:!0},{Header:"Seen",accessor:"lastSeenAt",Cell:Y3,sortType:"date",align:"center",maxWidth:80},{Header:"Type",accessor:"type",Cell:Q3,align:"center",maxWidth:80},{Header:"Name",accessor:"name",Cell:({value:Z})=>n(X3,{title:Z,to:`/projects/${f}/features/${Z}`}),minWidth:100,sortType:"alphanumeric",searchable:!0},...q?[{id:"tags",Header:"Tags",accessor:Z=>{var H;return((H=Z.tags)==null?void 0:H.map(({type:a1,value:U})=>`${a1}:${U}`).join(`
1
+ import{c as le,j as n,cC as c0,cE as l0,s as h,cp as d0,cm as et,g as st,r as u,dP as u0,l as o1,d as t1,f as l,S as ct,h as lt,i as dt,k as ut,bZ as p0,b8 as G1,A as w1,aO as de,aP as K1,aQ as J1,dQ as H3,aF as Y,dR as F1,bS as x1,a2 as u1,cg as C1,ar as De,H as p1,dS as h0,R as Ae,cK as l2,dT as W3,dU as k1,al as i1,V as D1,ak as d1,C as w,aL as R1,X as ue,W as S1,ck as m0,K as pt,dV as g0,bb as Re,bc as Fe,bd as Pe,a as E,b1 as Y1,m as M1,bg as f0,P as ht,dl as mt,dW as ae,cq as d2,a8 as N1,dX as jt,b5 as re,dF as v0,b7 as oe,T as $,cs as N3,aK as gt,dY as q1,af as q3,c7 as u2,u as m1,N as b1,dZ as y0,F as G,d_ as U3,ap as P1,a9 as l1,d$ as b0,dk as C0,a4 as h1,bM as S0,bK as p2,ca as ft,bN as G3,aW as Ze,a$ as Ie,aX as je,e0 as K3,di as J3,bC as _0,ao as T1,L as h2,e1 as w0,cn as x0,e2 as T0,e3 as E0,e4 as A0,e5 as Y3,e6 as Q3,O as X3,e7 as k0,cc as vt,Q as yt,cW as D0,cl as R0,bQ as en,Y as bt,e8 as F0,D as P0,aN as Z0,ch as I0,M as tn,e9 as j0,ah as L1,ea as nn,ag as an,eb as rn,ai as O0,ec as $0,ed as B0,aR as on,ee as m2,a1 as z0,ef as sn,eg as V0,eh as M0,ei as L0,ej as H0,bH as cn,ek as ln,el as dn,e as Oe,U as Ct,em as W0,en as N0,aH as q0,br as U0,eo as St,ep as G0,eq as un,er as K0,ay as pe,az as Q1,aI as j1,aA as he,aD as me,aE as ge,es as J0,cd as Ee,bP as pn,et as hn,eu as Y0,bq as X1,an as mn,bm as _t,ev as Q0,ew as X0,ex as ea,ey as ta,ez as na,eA as aa,eB as ra,dA as gn,cb as oa,de as tt,eC as ia,cu as g2,eD as wt,bV as U1,aJ as z1,aM as xt,bl as f2,d6 as v2,ax as V1,as as y2,eE as sa,ad as B2,eF as ca,d3 as Ne,ac as e2,eG as la,eH as da,d4 as ua,d5 as pa,eI as ha,eJ as ma,eK as ga,bT as fe,bU as X,eL as fa,eM as fn,Z as b2,au as va,eN as ya,cO as ba,eO as Ca,eP as Sa,eQ as _a,bo as vn,bp as wa,bz as xa,bA as Ta,bB as Ea,x as Aa,eR as ka,eS as Da,be as Ra,eT as yn,eU as Fa,eV as Pa,eW as Za,eX as Ia,eY as ja,eZ as Oa,e_ as $a,e$ as Ba,f0 as za,aY as Va,f1 as Ma,co as bn,f2 as La,d0 as Cn,f3 as ie,f4 as Q,f5 as Ha,f6 as Wa,f7 as Na,f8 as qa,f9 as Ua,d9 as Ga,fa as Ka,fb as Ja,fc as Ya,fd as Qa}from"./index-1f392976.js";import{e as Sn,W as z2,b as Xa,u as _n,T as er,c as tr,h as nr,F as ar,V as rr,a as or,g as ir,C as sr,i as cr,j as V2,R as M2,k as lr,l as dr,E as ur}from"./FeatureArchiveDialog-c311c641.js";import{a as pr}from"./index-f8439975.js";import{m as hr,h as mr,b as gr,c as fr,d as vr,e as yr,E as br,f as Cr,u as Sr,a as _r,R as wr,C as xr,A as Tr,B as wn}from"./useProjectRole-122ac4bb.js";import{S as Er}from"./StrategyItemContainer-0140b94f.js";import{E as Ar}from"./Error-5606eccd.js";const kr=le(n("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"}),"ArrowUpward"),Dr=le(n("path",{d:"M9 5v2h6.59L4 18.59 5.41 20 17 8.41V15h2V5z"}),"CallMade"),Rr=le(n("path",{d:"M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"}),"FileUpload"),Fr=le(n("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM7 13.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"}),"Pending"),Pr=le(n("path",{d:"M12 5.99 19.53 19H4.47L12 5.99M12 2 1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),Zr=le(n("path",{d:"M19 9h-2v6.59L5.41 4 4 5.41 15.59 17H9v2h10V9z"}),"SouthEast");function Ir(e,t){c0(2,arguments);var a=l0(t);return pr(e,-a)}const L2=h("div")(()=>({display:"flex"})),jr=h("div")(()=>({display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%"}));h("div")(()=>({display:"flex",flexDirection:"column"}));const Or=h("span")(({theme:e})=>({fontSize:e.typography.h1.fontSize,textOverflow:"ellipsis",whiteSpace:"nowrap"})),$r=h("span")(({theme:e})=>({fontSize:e.fontSizes.smallBody,fontWeight:"normal"}));h($r)(({theme:e})=>({color:e.palette.neutral.dark}));const Br=h(d0)(({theme:e})=>({marginLeft:e.spacing(-1.5)})),zr=h("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),Vr=h("div")(({theme:e})=>({padding:e.spacing(2.5,5),display:"flex",flexDirection:"column",alignItems:"start"})),Mr=h("span")(({theme:e})=>({margin:0,width:"100%",fontSize:e.fontSizes.mainHeader,fontWeight:"bold",display:"flex",justifyContent:"space-between",alignItems:"center",gap:e.spacing(2)})),Lr=h("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.divider,height:"1px"})),Hr=h("div")(({theme:e})=>({padding:e.spacing(0,4)})),Wr=h(et)(({theme:e})=>({textTransform:"none",fontSize:e.fontSizes.bodySize,flexGrow:1,flexBasis:0,[e.breakpoints.down("md")]:{paddingLeft:e.spacing(1),paddingRight:e.spacing(1)},[e.breakpoints.up("md")]:{minWidth:160}})),Nr=e=>e.reduce((t,a)=>a.enabled?t+1:t,0),qr=h(st)(({theme:e})=>({marginTop:e.spacing(3)})),Ur=h("p",{shouldForwardProp:e=>e!=="warning"})(({theme:e,warning:t})=>({color:t?e.palette.error.dark:e.palette.text.primary,textAlign:"center"})),Gr=({environment:e,warnEnabledToggles:t})=>{const a=u.useMemo(()=>[{id:"Icon",width:"1%",Cell:({row:{original:d}})=>n(u0,{environment:d})},{Header:"Name",accessor:"name",Cell:o1},{Header:"Type",accessor:"type",Cell:o1},{Header:"Toggles enabled",accessor:"projectEnabledToggleCount",Cell:({value:d})=>n(o1,{children:n(Ur,{warning:d>0,children:d===1?"1 toggle":`${d} toggles`})}),align:"center"}],[t]),{getTableProps:r,getTableBodyProps:o,headerGroups:i,rows:s,prepareRow:c}=t1.useTable({columns:a,data:[e],disableSortBy:!0});return l(qr,{...r(),rowHeight:"compact",children:[n(ct,{headerGroups:i}),n(lt,{...o(),children:s.map(d=>(c(d),n(dt,{hover:!0,...d.getRowProps(),children:d.cells.map(p=>n(ut,{...p.getCellProps(),children:p.render("Cell")}))})))})]})},Kr=h("p")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1.5)})),Jr=h(p0)(()=>({width:"100%"})),Yr=({environment:e,open:t,setOpen:a,onConfirm:r})=>{const[o,i]=u.useState("");return u.useEffect(()=>{i("")},[t]),l(G1,{title:"Hide environment and disable feature toggles?",open:t,primaryButtonText:"Hide environment and disable feature toggles",disabledPrimaryButton:(e==null?void 0:e.name)!==o,secondaryButtonText:"Close",onClick:r,onClose:()=>{a(!1)},children:[l(w1,{severity:"error",children:[n("strong",{children:"Danger!"})," Hiding an environment will disable all the feature toggles that are enabled in this environment and it can impact client applications connected to the environment."]}),n(Gr,{environment:e}),l(Kr,{children:["In order to hide this environment, please enter the id of the environment in the textfield below:"," ",n("strong",{children:e==null?void 0:e.name})]}),n(Jr,{label:"Environment name",value:o,onChange:s=>i(s.target.value)})]})},Qr=e=>{const{data:t,error:a,mutate:r}=de(K1(`api/admin/environments/project/${e}`),Xr),o=u.useMemo(()=>t||[],[t]),i=u.useCallback(async()=>{await r()},[r]);return{environments:o,refetchEnvironments:i,loading:!a&&!t,error:a}},Xr=async e=>(await fetch(e).then(J1("Environments")).then(a=>a.json())).environments.sort((a,r)=>a.sortOrder-r.sortOrder),eo=h(w1)(({theme:e})=>({marginBottom:e.spacing(4)})),to=h("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",[e.breakpoints.down("sm")]:{justifyContent:"center"}})),no=h(H3)(({theme:e})=>({maxWidth:"400px",marginBottom:e.spacing(2)})),xn=()=>{const e=Y("projectId"),t=F1(e);x1(`Project environments – ${t}`);const{setToastData:a,setToastApiError:r}=u1(),{environments:o,loading:i,error:s,refetchEnvironments:c}=Qr(e),{project:d,refetch:p}=C1(e),{removeEnvironmentFromProject:m,addEnvironmentToProject:g}=De(),[f,C]=u.useState(),[S,b]=u.useState(!1),{isOss:R}=p1(),v=u.useMemo(()=>o.map(I=>({...I,projectVisible:d==null?void 0:d.environments.map(q=>q.environment).includes(I.name)})),[o,d==null?void 0:d.environments]),F=()=>{c(),p()},T=()=>n(no,{onClick:F,text:"Error fetching environments"}),j=I=>`Got an API error when trying to set the environment as ${I?"visible":"hidden"}`,M=async I=>{if(I.projectVisible){if(Nr(v)>1){C(I),b(!0);return}a({title:"One environment must be visible",text:"You must always have at least one visible environment per project",type:"error"})}else try{await g(e,I.name),F(),a({title:"Environment set as visible",text:"Environment successfully set as visible.",type:"success"})}catch{r(j(!0))}},_=async()=>{if(f)try{await m(e,f.name),F(),a({title:"Environment set as hidden",text:"Environment successfully set as hidden.",type:"success"})}catch{r(j(!1))}finally{b(!1)}},D=I=>R()&&I==="default",P=u.useMemo(()=>[{Header:"Name",accessor:"name",Cell:({row:{original:I}})=>n(h0,{environment:I})},{Header:"Type",accessor:"type",Cell:Ae},{Header:"Project API tokens",accessor:I=>I.projectApiTokenCount===1?"1 token":`${I.projectApiTokenCount} tokens`,Cell:o1},{Header:"Visible in project",accessor:"enabled",align:"center",width:1,Cell:({row:{original:I}})=>n(l2,{children:n(W3,{tooltip:I.projectVisible?"Hide environment and disable feature toggles":"Make it visible",size:"medium",disabled:D(I.name),projectId:e,permission:k1,checked:I.projectVisible,onChange:()=>M(I)})}),disableGlobalFilter:!0}],[v]),{getTableProps:B,getTableBodyProps:V,headerGroups:O,rows:J,prepareRow:N,state:{globalFilter:L},setGlobalFilter:y}=t1.useTable({columns:P,data:v,disableSortBy:!0},t1.useGlobalFilter),k=n(i1,{title:`Environments (${J.length})`,actions:n(D1,{initialValue:L,onChange:y})});return n(d1,{header:k,isLoading:i,children:l(to,{children:[n(w,{condition:!!s,show:T()}),l(eo,{severity:"info",children:[n("strong",{children:"Important!"})," In order for your application to retrieve configured activation strategies for a specific environment, the application must use an environment specific API token. You can look up the environment-specific"," ",n(R1,{to:"/admin/api",children:"API tokens here"}),".",n("br",{}),n("br",{}),"Your administrator can configure an environment-specific API token to be used in the SDK. If you are an administrator you can ",n(R1,{to:"/admin/api",children:"create a new API token here"}),"."]}),n(ue,{value:L,children:l(st,{...B(),rowHeight:"compact",children:[n(ct,{headerGroups:O}),n(lt,{...V(),children:J.map(I=>(N(I),n(dt,{hover:!0,...I.getRowProps(),children:I.cells.map(q=>n(ut,{...q.getCellProps(),children:q.render("Cell")}))})))})]})}),n(w,{condition:J.length===0,show:n(w,{condition:(L==null?void 0:L.length)>0,show:l(S1,{children:["No environments found matching “",L,"”"]}),elseShow:n(S1,{children:"No environments available. Get started by adding one."})})}),n(Yr,{environment:f,open:S,setOpen:b,onConfirm:_})]})})},ao={id:"archivedAt"},ro=({projectId:e})=>{const{archivedFeatures:t,loading:a,refetchArchived:r}=m0(e),{value:o,setValue:i}=pt(`${e}:ProjectFeaturesArchiveTable`,ao);return n(g0,{title:"Project archive",archivedFeatures:t||[],loading:a,storedParams:o,setStoredParams:i,refetch:r,projectId:e})},oo=()=>{const e=Y("projectId"),t=F1(e);return x1(`Project archive – ${t}`),n(ro,{projectId:e})},io=(e=[])=>{var r;let t=e.map(o=>o.environment);const a=u.useRef(t);return t.join("")!==((r=a.current)==null?void 0:r.join(""))&&(a.current=t),a.current};var C2={},so=Fe;Object.defineProperty(C2,"__esModule",{value:!0});var Tn=C2.default=void 0,co=so(Re()),lo=Pe,uo=(0,co.default)((0,lo.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.27zM12 17.5 6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z"}),"Archive");Tn=C2.default=uo;var S2={},po=Fe;Object.defineProperty(S2,"__esModule",{value:!0});var En=S2.default=void 0,ho=po(Re()),mo=Pe,go=(0,ho.default)((0,mo.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm4.2 14.2L11 13V7h1.5v5.2l4.5 2.7-.8 1.3z"}),"WatchLater");En=S2.default=go;const fo=h(E)(({theme:e})=>({display:"flex",justifyContent:"center",paddingRight:e.spacing(2)})),vo=({projectId:e,row:t,onOpenArchiveDialog:a,onOpenStaleDialog:r})=>{const[o,i]=u.useState(null),{original:{name:s,stale:c}}=t,d=!!o,p=C=>{i(C.currentTarget)},m=()=>{i(null)},g=`feature-${s}-actions`,f=`${g}-menu`;return l(fo,{children:[n(Y1,{title:"Feature toggle actions",arrow:!0,describeChild:!0,children:n(M1,{id:g,"aria-controls":d?f:void 0,"aria-haspopup":"true","aria-expanded":d?"true":void 0,onClick:p,type:"button",children:n(f0,{})})}),n(ht,{id:f,anchorEl:o,open:d,onClose:m,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:C=>({borderRadius:`${C.shape.borderRadius}px`,padding:C.spacing(1,1.5)})},children:l(mt,{"aria-labelledby":g,children:[n(ae,{projectId:e,permission:d2,children:({hasAccess:C})=>l(N1,{sx:jt,onClick:m,disabled:!C,component:R1,to:`/projects/${e}/features/${s}/strategies/copy`,children:[n(re,{children:n(v0,{})}),n(oe,{children:n($,{variant:"body2",children:"Copy"})})]})}),n(ae,{projectId:e,permission:N3,children:({hasAccess:C})=>l(N1,{sx:jt,onClick:()=>{a(s),m()},disabled:!C,children:[n(re,{children:n(Tn,{})}),n(oe,{children:n($,{variant:"body2",children:"Archive"})})]})}),n(ae,{projectId:e,permission:gt,children:({hasAccess:C})=>l(N1,{sx:jt,onClick:()=>{m(),r({featureId:s,stale:c===!0})},disabled:!C,children:[n(re,{children:n(En,{})}),n(oe,{children:l($,{variant:"body2",children:[c?"Un-mark":"Mark"," as stale"]})})]})})]})})]})};var _2={},yo=Fe;Object.defineProperty(_2,"__esModule",{value:!0});var An=_2.default=void 0,bo=yo(Re()),Co=Pe,So=(0,bo.default)((0,Co.jsx)("path",{d:"M5.33 20H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h1.33c1.1 0 2 .9 2 2v12c0 1.1-.89 2-2 2zM22 18V6c0-1.1-.9-2-2-2h-1.33c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2H20c1.11 0 2-.9 2-2zm-7.33 0V6c0-1.1-.9-2-2-2h-1.33c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h1.33c1.1 0 2-.9 2-2z"}),"ViewWeek");An=_2.default=So;const _o=h(E)(()=>({...q1,justifyContent:"center"})),wo=h(M1)(({theme:e})=>({margin:e.spacing(-1,0)})),xo=h(E)(({theme:e})=>({...q1,justifyContent:"space-between",padding:e.spacing(1,1,0,4)})),To=h(N1)(({theme:e})=>({padding:e.spacing(0,2),margin:e.spacing(0,2),borderRadius:e.shape.borderRadius})),H2=h(q3)(({theme:e})=>({"&.MuiDivider-root.MuiDivider-fullWidth":{margin:e.spacing(.75,0)}})),Eo=h(u2)(({theme:e})=>({padding:e.spacing(.75,1)})),Ao={favorite:"Favorite"},ko=({allColumns:e,staticColumns:t=[],dividerBefore:a=[],dividerAfter:r=[],isCustomized:o=!1,setHiddenColumns:i})=>{const[s,c]=u.useState(null),d=m1(),p=b1(d.breakpoints.down("sm")),m=b1(d.breakpoints.down("md")),g=b1(d.breakpoints.down("lg"));u.useEffect(()=>{if(o)return;const v=(F,T=0)=>{const j=e.filter(({id:_})=>_.startsWith("environments.")!==!1).map(({id:_})=>_).slice(0,T),M=e.map(({id:_})=>_).filter(_=>!F.includes(_)).filter(_=>!t.includes(_)).filter(_=>!j.includes(_));i(M)};if(p)return v(["createdAt"]);if(m)return v(["createdAt"],1);if(g)return v(["type","createdAt"],1);v(["lastSeenAt","type","createdAt"],3)},[p,m,g]);const f=v=>{c(v.currentTarget)},C=()=>{c(null)},S=!!s,b="columns-menu",R=`columns-menu-list-${b}`;return l(_o,{children:[n(Y1,{title:"Select columns",arrow:!0,describeChild:!0,children:n(wo,{id:b,"aria-controls":S?R:void 0,"aria-haspopup":"true","aria-expanded":S?"true":void 0,onClick:f,type:"button",size:"large","data-loading":!0,children:n(An,{})})}),l(ht,{id:R,open:S,anchorEl:s,onClose:C,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},disableScrollLock:!0,PaperProps:{sx:v=>({borderRadius:v.shape.borderRadius,paddingBottom:v.spacing(2)})},children:[l(xo,{children:[n($,{variant:"body2",children:n("strong",{children:"Columns"})}),n(M1,{onClick:C,children:n(y0,{})})]}),n(mt,{children:e.filter(({hideInMenu:v})=>!v).map(v=>[n(w,{condition:a.includes(v.id),show:n(H2,{})}),l(To,{onClick:()=>v.toggleHidden(v.isVisible),disabled:t.includes(v.id),children:[n(re,{children:n(Eo,{edge:"start",checked:v.isVisible,disableRipple:!0,inputProps:{"aria-labelledby":v.id},size:"medium"})}),n(oe,{id:v.id,primary:n($,{variant:"body2",children:n(w,{condition:!!(typeof v.Header=="string"&&v.Header),show:()=>n(G,{children:v.Header}),elseShow:()=>Ao[v.id]||v.id})})})]}),n(w,{condition:r.includes(v.id),show:n(H2,{})})])})]})]})},Do=U3()(e=>({container:{boxShadow:"none",marginLeft:"1rem",minHeight:"100%",width:"calc(100% - 1rem)",position:"relative",[e.breakpoints.down("md")]:{marginLeft:"0",paddingBottom:"4rem",width:"inherit"}}})),Ro=({projectId:e,features:t})=>{const{refetch:a}=C1(e),[r,o]=u.useState(!1),{trackEvent:i}=P1();return l(G,{children:[n(ae,{projectId:e,permission:N3,children:({hasAccess:c})=>n(l1,{disabled:!c||r,variant:"outlined",size:"small",onClick:()=>o(!0),children:"Archive"})}),n(Sn,{projectId:e,featureIds:t,onConfirm:async()=>{o(!1),await a(),i("batch_operations",{props:{eventType:"features archived"}})},isOpen:r,onClose:()=>o(!1)})]})},qe="selection-actions-menu",Fo=({projectId:e,data:t})=>{const{refetch:a}=C1(e),[r,o]=u.useState(null),{staleFeatures:i}=De(),{setToastData:s,setToastApiError:c}=u1(),{trackEvent:d}=P1(),p=!!r,m=t.map(({name:v})=>v),g=v=>{o(v.currentTarget)},f=()=>{o(null)},C=t.some(({stale:v})=>v===!0),S=t.some(({stale:v})=>v===!1),b=async()=>{try{f(),await i(e,m),await a(),s({title:"State updated",text:"Feature toggles marked as stale",type:"success"}),d("batch_operations",{props:{eventType:"features staled"}})}catch(v){c(h1(v))}},R=async()=>{try{f(),await i(e,m,!1),await a(),s({title:"State updated",text:"Feature toggles unmarked as stale",type:"success"}),d("batch_operations",{props:{eventType:"features unstaled"}})}catch(v){c(h1(v))}};return l(G,{children:[n(Y1,{title:"More bulk actions",arrow:!0,describeChild:!0,children:n(M1,{id:qe,"aria-controls":p?qe:void 0,"aria-haspopup":"true","aria-expanded":p?"true":void 0,onClick:g,type:"button","data-testid":b0,children:n(C0,{})})}),n(ht,{id:`${qe}-menu`,anchorEl:r,open:p,onClose:f,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:v=>({borderRadius:`${v.shape.borderRadius}px`,padding:v.spacing(1,1.5)})},children:n(mt,{"aria-labelledby":`${qe}-menu`,children:n(ae,{projectId:e,permission:gt,children:({hasAccess:v})=>l(G,{children:[n(w,{condition:S,show:()=>l(N1,{onClick:b,disabled:!v,sx:{borderRadius:F=>`${F.shape.borderRadius}px`},children:[n(re,{children:n(z2,{})}),n(oe,{children:n($,{variant:"body2",children:"Mark as stale"})})]})}),n(w,{condition:C,show:()=>l(N1,{onClick:R,disabled:!v,sx:{borderRadius:F=>`${F.shape.borderRadius}px`},children:[n(re,{children:n(z2,{})}),n(oe,{children:n($,{variant:"body2",children:"Un-mark as stale"})})]})})]})})})})]})},Po=h("section")(({theme:e})=>({["& > *"]:{margin:e.spacing(1,0)}})),W2="manage-tags-form",N2=(e,t)=>[...e,...e.some(a=>a.value===t.value&&a.type===t.type)?[]:[t]],q2=(e,t)=>e.filter(a=>!(a.value===t.value&&a.type===t.type)),Zo=(e,t)=>{switch(t.type){case"add":return{...e,addedTags:N2(e.addedTags,t.payload),removedTags:q2(e.removedTags,t.payload)};case"remove":return{...e,addedTags:q2(e.addedTags,t.payload),removedTags:N2(e.removedTags,t.payload)};case"clear":return{addedTags:[],removedTags:t.payload};default:return e}},U2={name:"",description:"",icon:""},Io=({open:e,initialValues:t,initialIndeterminateValues:a,onCancel:r,onSubmit:o})=>{const{tagTypes:i,loading:s}=S0(),[c,d]=u.useState(U2),[p,m]=u.useState([]),[g,f]=u.useState([]),{tags:C,refetch:S}=Xa(c.name),{createTag:b}=_n(),R=C.map(({value:P})=>({title:P})),[v,F]=u.useReducer(Zo,{addedTags:[],removedTags:[]}),T=(P=i.length>0?i[0]:U2)=>{d(P);const B=a.filter(({type:V})=>V===P.name);m(t.filter(({type:V})=>V===P.name).filter(({type:V,value:O})=>!B.some(J=>J.value===O&&J.type===V)).map(({value:V})=>({title:V}))),f(B.map(({value:V})=>({title:V}))),F({type:"clear",payload:[]})};u.useEffect(()=>{i.length>0&&T()},[s]);const j=(P,B)=>{B!=null&&typeof B!="string"&&(P.preventDefault(),T(B))},M=(P,B)=>b({value:P,type:B}).then(async()=>{await S(),m(V=>[...V,{title:P}]),F({type:"add",payload:{value:P,type:B}})}),_=(P,B,V,O)=>{V==="selectOption"?B.forEach(J=>{if(typeof J!="string"&&typeof J.inputValue=="string"&&J.inputValue&&J.title.startsWith("Create new value"))return M(J.inputValue,c.name);m(B),f(N=>N.filter(({title:L})=>L!==J.title)),O!=null&&O.option&&F({type:"add",payload:{value:O.option.title,type:c.name}})}):V==="clear"?(m([]),F({type:"clear",payload:t})):V==="removeOption"&&(m(B),O!=null&&O.option&&F({type:"remove",payload:{value:O.option.title,type:c.name}}))},D=()=>{T(),r()};return l(G1,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update tags to feature toggle",onClick:()=>o(v),disabledPrimaryButton:v.addedTags.length===0&&v.removedTags.length===0,onClose:D,formId:W2,children:[n($,{paragraph:!0,sx:{marginBottom:P=>P.spacing(2.5)},children:"Tags allow you to group features together"}),n("form",{id:W2,onSubmit:()=>o(v),children:l(Po,{children:[n(er,{options:i,disabled:s||i.length===0,value:c,onChange:j},s?"loading":i.length),n(w,{condition:!s&&i.length===0,show:l($,{variant:"body1",children:["No"," ",n(p2,{component:R1,to:"/tag-types",children:"tag types"})," ","available."]}),elseShow:n(tr,{disabled:s,options:R,existingTags:t,indeterminateOptions:g,tagType:c,selectedOptions:p,onChange:_})})]})})]})},jo=({projectId:e,data:t})=>{const{bulkUpdateTags:a}=_n(),{refetch:r}=C1(e),{setToastData:o,setToastApiError:i}=u1(),{trackEvent:s}=P1(),[c,d]=u.useState(!1),[p,m]=u.useMemo(()=>{const f=t.flatMap(({tags:S})=>S||[]).reduce((S,b)=>[...S,...S.some(R=>R.type===b.type&&R.value===b.value)?[]:[b]],[]),C=f.filter(S=>!t.every(({tags:b})=>b==null?void 0:b.some(R=>R.type===S.type&&R.value===S.value)));return[f,C]},[t]);return l(G,{children:[n(ae,{projectId:e,permission:gt,children:({hasAccess:f})=>n(l1,{disabled:!f||c,variant:"outlined",size:"small",onClick:()=>d(!0),children:"Tags"})}),n(Io,{open:c,onCancel:()=>d(!1),onSubmit:async({addedTags:f,removedTags:C})=>{const S=t.map(({name:R})=>R),b={features:S,tags:{addedTags:f,removedTags:C}};try{await a(b),r();const R=f.length?`Added tags: ${f.map(({type:F,value:T})=>`${F}:${T}`).join(", ")}.`:"",v=C.length?`Removed tags: ${C.map(({type:F,value:T})=>`${F}:${T}`).join(", ")}.`:"";o({title:"Tags updated",text:`${S.length} feature toggles updated. ${R} ${v}`,type:"success",autoHideDuration:12e3}),s("batch_operations",{props:{eventType:"tags updated"}})}catch(R){i(h1(R))}d(!1)},initialValues:p,initialIndeterminateValues:m},t.length)]})},Oo=h(ft)(({theme:e})=>({minWidth:"450px",marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),G2=h(w1)(({theme:e})=>({marginBottom:e.spacing(1.5)})),$o=({showExportDialog:e,data:t,onClose:a,onConfirm:r,environments:o,projectId:i})=>{const[s,c]=u.useState(o[0]),{bulkToggleFeaturesEnvironmentOff:d}=G3(),{addChange:p}=Ze(),{refetch:m}=C1(i),{setToastApiError:g,setToastData:f}=u1(),{isChangeRequestConfigured:C}=Ie(i),{refetch:S}=je(i),b=t.filter(T=>{var j,M;return((M=(j=T.environments)==null?void 0:j.find(_=>s===_.name))==null?void 0:M.enabled)===!1}).length,R=()=>o.map(T=>({key:T,label:T})),v=async()=>{try{C(s)?(await p(i,s,t.map(T=>({action:"updateEnabled",feature:T.name,payload:{enabled:!1}}))),S(),f({text:"Your disabled feature toggles changes have been added to change request",type:"success",title:"Changes added to a draft"})):(await d(i,t.map(T=>T.name),s),m(),f({text:"Your feature toggles have been disabled",type:"success",title:"Features disabled"})),a(),r==null||r()}catch(T){g(h1(T))}},F=C(s)?"Add to change request":"Disable toggles";return n(G1,{open:e,title:"Disable feature toggles",onClose:a,onClick:v,primaryButtonText:F,secondaryButtonText:"Cancel",children:l(E,{children:["You have selected ",n("b",{children:t.length})," feature toggles to disable.",n("br",{}),n("br",{}),n($,{children:"Select which environment to disable the features for:"}),n(Oo,{options:R(),value:s,onChange:T=>c(T)}),n(w,{condition:C(s),show:n(G2,{severity:"warning",children:"Change requests are enabled for this environment."})}),n(w,{condition:b>0,show:l(G2,{severity:"info",children:[b," feature"," ",b>1?"toggles are ":"toggle is ","already disabled."]})})]})})},Bo=h(ft)(({theme:e})=>({minWidth:"450px",marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),K2=h(w1)(({theme:e})=>({marginBottom:e.spacing(1.5)})),zo=({showExportDialog:e,data:t,onClose:a,onConfirm:r,environments:o,projectId:i})=>{const[s,c]=u.useState(o[0]),{bulkToggleFeaturesEnvironmentOn:d}=G3(),{addChange:p}=Ze(),{refetch:m}=C1(i),{setToastApiError:g,setToastData:f}=u1(),{isChangeRequestConfigured:C}=Ie(i),{refetch:S}=je(i),b=t.filter(T=>{var j,M;return((M=(j=T.environments)==null?void 0:j.find(_=>s===_.name))==null?void 0:M.enabled)===!0}).length,R=()=>o.map(T=>({key:T,label:T})),v=async()=>{try{C(s)?(await p(i,s,t.map(T=>({action:"updateEnabled",feature:T.name,payload:{enabled:!0}}))),S(),f({text:"Your enable feature toggles changes have been added to change request",type:"success",title:"Changes added to a draft"})):(await d(i,t.map(T=>T.name),s),m(),f({text:"Your feature toggles have been enabled",type:"success",title:"Features enabled"})),a(),r==null||r()}catch(T){g(h1(T))}},F=C(s)?"Add to change request":"Enable toggles";return n(G1,{open:e,title:"Enable feature toggles",onClose:a,onClick:v,primaryButtonText:F,secondaryButtonText:"Cancel",children:l(E,{children:["You have selected ",n("b",{children:t.length})," feature toggles to enable.",n("br",{}),n("br",{}),n($,{children:"Select which environment to enable the features for:"}),n(Bo,{options:R(),value:s,onChange:T=>c(T)}),n(w,{condition:C(s),show:n(K2,{severity:"warning",children:"Change requests are enabled for this environment."})}),n(w,{condition:b>0,show:l(K2,{severity:"info",children:[b," feature"," ",b>1?"toggles are ":"toggle is ","already enabled."]})})]})})},Vo=({selectedIds:e,data:t,projectId:a})=>{var R,v;const{uiConfig:r}=p1(),[o,i]=u.useState(!1),[s,c]=u.useState(!1),[d,p]=u.useState(!1),{trackEvent:m}=P1(),g=u.useMemo(()=>t.filter(F=>e.includes(F.name)),[t,e]),f=u.useMemo(()=>{const F=g.flatMap(T=>T.environments).map(T=>T==null?void 0:T.name).filter(T=>T!==void 0);return Array.from(new Set(F))},[g]),C=()=>{m("batch_operations",{props:{eventType:"features exported"}})},S=()=>{m("batch_operations",{props:{eventType:"features enabled"}})},b=()=>{m("batch_operations",{props:{eventType:"features disabled"}})};return l(G,{children:[n(w,{condition:!!((R=r==null?void 0:r.flags)!=null&&R.disableBulkToggle),show:null,elseShow:n(l1,{variant:"outlined",size:"small",onClick:()=>c(!0),children:"Enable"})}),n(w,{condition:!!((v=r==null?void 0:r.flags)!=null&&v.disableBulkToggle),show:null,elseShow:n(l1,{variant:"outlined",size:"small",onClick:()=>p(!0),children:"Disable"})}),n(Ro,{projectId:a,features:e}),n(l1,{variant:"outlined",size:"small",onClick:()=>i(!0),children:"Export"}),n(jo,{projectId:a,data:g}),n(Fo,{projectId:a,data:g}),n(K3,{showExportDialog:o,data:g,onClose:()=>i(!1),environments:f,onConfirm:C}),n(zo,{showExportDialog:s,data:g,onClose:()=>c(!1),environments:f,projectId:a,onConfirm:S}),n($o,{showExportDialog:d,data:g,onClose:()=>p(!1),environments:f,projectId:a,onConfirm:b})]})},Mo=h(J3)(()=>({whiteSpace:"nowrap"})),Lo=h("div",{shouldForwardProp:e=>e!=="hasWarning"})(({theme:e,hasWarning:t})=>({flexGrow:0,...q1,justifyContent:"center",...t&&{"::before":{content:'""',display:"block",width:e.spacing(2)}}})),Ue=["Select","Actions","name","favorite"],Ho={id:"createdAt"},Wo=({features:e,loading:t,environments:a=[]})=>{var I1,te;const{classes:r}=Do(),o=m1(),i=b1(o.breakpoints.down("md")),[s,c]=u.useState({open:!1,featureId:"",environmentName:""}),[d,p]=u.useState({}),[m,g]=u.useState(),f=Y("projectId"),{value:C,setValue:S}=pt(`${f}:FeatureToggleListTable:v1`,Ho),{value:b,setValue:R}=_0(),v=T1(),[F,T]=h2(),j=io(t?[{environment:"a"},{environment:"b"},{environment:"c"}]:a),{refetch:M}=C1(f),{isFavoritesPinned:_,sortTypes:D,onChangeIsFavoritePinned:P}=w0(F.has("favorites")?F.get("favorites")==="true":b.favorites),{favorite:B,unfavorite:V}=x0(),{onChangeRequestToggleClose:O,onChangeRequestToggleConfirm:J,changeRequestDialogDetails:N}=nr(f),[L,y]=u.useState(!1),{uiConfig:k}=p1(),I=u.useCallback(async Z=>{Z!=null&&Z.favorite?await V(f,Z.name):await B(f,Z.name),M()},[f,M]),q=u.useMemo(()=>e.some(Z=>{var H;return(H=Z==null?void 0:Z.tags)==null?void 0:H.length}),[e]),x=u.useMemo(()=>[{id:"Select",Header:({getToggleAllRowsSelectedProps:Z})=>n(u2,{...Z()}),Cell:({row:Z})=>{var H;return n(T0,{...(H=Z==null?void 0:Z.getToggleRowSelectedProps)==null?void 0:H.call(Z)})},maxWidth:50,disableSortBy:!0,hideInMenu:!0},{id:"favorite",Header:n(E0,{isActive:_,onClick:P}),accessor:"favorite",Cell:({row:{original:Z}})=>n(A0,{value:Z==null?void 0:Z.favorite,onClick:()=>I(Z)}),maxWidth:50,disableSortBy:!0,hideInMenu:!0},{Header:"Seen",accessor:"lastSeenAt",Cell:Y3,sortType:"date",align:"center",maxWidth:80},{Header:"Type",accessor:"type",Cell:Q3,align:"center",maxWidth:80},{Header:"Name",accessor:"name",Cell:({value:Z})=>n(X3,{title:Z,to:`/projects/${f}/features/${Z}`}),minWidth:100,sortType:"alphanumeric",searchable:!0},...q?[{id:"tags",Header:"Tags",accessor:Z=>{var H;return((H=Z.tags)==null?void 0:H.map(({type:a1,value:U})=>`${a1}:${U}`).join(`
2
2
  `))||""},Cell:k0,width:80,searchable:!0}]:[],{Header:"Created",accessor:"createdAt",Cell:vt,sortType:"date",minWidth:120},...j.map(Z=>{const H=typeof Z=="string"?Z:Z.environment;return{Header:t?()=>"":H,maxWidth:90,id:`environments.${H}`,accessor:a1=>{var U;return(U=a1.environments[H])==null?void 0:U.enabled},align:"center",Cell:({value:a1,row:{original:U}})=>{const g1=U.someEnabledEnvironmentHasVariants&&U.environments[H].variantCount===0&&U.environments[H].enabled;return l(Lo,{hasWarning:g1,children:[n(ar,{value:a1,projectId:f,featureId:U.name,environmentName:H}),n(w,{condition:g1,show:n(rr,{})})]})},sortType:"boolean",filterName:H,filterParsing:a1=>a1?"enabled":"disabled"}}),{id:"Actions",maxWidth:56,width:56,Cell:Z=>n(vo,{projectId:f,onOpenArchiveDialog:g,onOpenStaleDialog:p,...Z}),disableSortBy:!0,hideInMenu:!0}],[f,j,t]),[W,c1]=u.useState(F.get("search")||""),f1=u.useMemo(()=>e.map(Z=>{var H;return{...Z,environments:Object.fromEntries(j.map(a1=>{const U=Z==null?void 0:Z.environments.find(g1=>(g1==null?void 0:g1.name)===a1);return[a1,{name:a1,enabled:(U==null?void 0:U.enabled)||!1,variantCount:(U==null?void 0:U.variantCount)||0}]})),someEnabledEnvironmentHasVariants:((H=Z.environments)==null?void 0:H.some(a1=>a1.variantCount>0&&a1.enabled))||!1}}),[e,j]),{data:v1,getSearchText:O1,getSearchContext:Se}=yt(x,W,f1),E1=u.useMemo(()=>t?Array(6).fill({type:"-",name:"Feature name",createdAt:new Date,environments:{production:{name:"production",enabled:!1}}}):v1,[t,v1]),Ve=u.useMemo(()=>{var a1;const Z=x.map(U=>(U==null?void 0:U.accessor)||(U==null?void 0:U.id));let H=j.filter((U,g1)=>g1>=3).map(U=>`environments.${U}`);if(F.has("columns")){const U=((a1=F.get("columns"))==null?void 0:a1.split(","))||[],g1=[...Ue,...U];H=Z.filter(A=>!g1.includes(A))}else if(C.columns){const U=[...Ue,...C.columns];H=Z.filter(g1=>!U.includes(g1))}return{sortBy:[{id:F.get("sort")||"createdAt",desc:F.has("order")?F.get("order")==="desc":C.desc}],hiddenColumns:H,selectedRowIds:{}}},[j]),Me=u.useCallback(Z=>Z.name,[]),{allColumns:_e,headerGroups:ee,rows:$1,state:{selectedRowIds:Z1,sortBy:B1,hiddenColumns:H1},prepareRow:Le,setHiddenColumns:He}=t1.useTable({columns:x,data:E1,initialState:Ve,sortTypes:D,autoResetHiddenColumns:!1,disableSortRemove:!0,autoResetSortBy:!1,getRowId:Me},t1.useFlexLayout,t1.useSortBy,t1.useRowSelect);return u.useEffect(()=>{if(t)return;const Z={};Z.sort=B1[0].id,B1[0].desc&&(Z.order="desc"),W&&(Z.search=W),_&&(Z.favorites="true"),Z.columns=_e.map(({id:H})=>H).filter(H=>!Ue.includes(H)&&!(H1!=null&&H1.includes(H))).join(","),T(Z,{replace:!0}),S(H=>({...H,id:B1[0].id,desc:B1[0].desc||!1,columns:Z.columns.split(",")})),R(H=>({...H,favorites:!!_}))},[t,B1,H1,W,T,_]),l(G,{children:[l(d1,{isLoading:t,className:r.container,header:n(i1,{titleElement:`Feature toggles (${$1.length})`,actions:l(G,{children:[n(w,{condition:!i,show:n(D1,{initialValue:W,onChange:c1,hasFilters:!0,getSearchContext:Se})}),n(ko,{allColumns:_e,staticColumns:Ue,dividerAfter:["createdAt"],dividerBefore:["Actions"],isCustomized:!!C.columns,setHiddenColumns:He}),n(i1.Divider,{sx:{marginLeft:0}}),n(w,{condition:!!((I1=k==null?void 0:k.flags)!=null&&I1.featuresExportImport),show:n(Y1,{title:"Export toggles visible in the table below",arrow:!0,children:n(M1,{onClick:()=>y(!0),sx:Z=>({marginRight:Z.spacing(2)}),children:n(D0,{})})})}),n(Mo,{onClick:()=>v(R0(f)),maxWidth:"960px",Icon:en,projectId:f,permission:d2,"data-testid":"NAVIGATE_TO_CREATE_FEATURE",children:"New feature toggle"})]}),children:n(w,{condition:i,show:n(D1,{initialValue:W,onChange:c1,hasFilters:!0,getSearchContext:Se})})}),children:[n(ue,{value:O1(W),children:n(bt,{rows:$1,headerGroups:ee,prepareRow:Le})}),n(w,{condition:$1.length===0,show:n(w,{condition:(W==null?void 0:W.length)>0,show:l(S1,{children:["No feature toggles found matching “",W,"”"]}),elseShow:n(S1,{children:"No feature toggles available. Get started by adding a new feature toggle."})})}),n(or,{onClose:()=>c(Z=>({...Z,open:!1})),projectId:f,...s}),n(ir,{isStale:d.stale===!0,isOpen:!!d.featureId,onClose:()=>{p({}),M()},featureId:d.featureId||"",projectId:f}),n(Sn,{isOpen:!!m,onConfirm:()=>{M()},onClose:()=>{g(void 0)},featureIds:[m||""],projectId:f})," ",n(sr,{isOpen:N.isOpen,onClose:O,environment:N==null?void 0:N.environment,onConfirm:J,messageComponent:n(cr,{featureName:N.featureName,enabled:N.enabled,environment:N==null?void 0:N.environment})}),n(w,{condition:!!((te=k==null?void 0:k.flags)!=null&&te.featuresExportImport)&&!t,show:n(K3,{showExportDialog:L,data:E1,onClose:()=>y(!1),environments:j})})]}),n(F0,{count:Object.keys(Z1).length,children:n(Vo,{selectedIds:Object.keys(Z1),data:e,projectId:f})})]})},$e=h("div")(({theme:e})=>({margin:"0",textAlign:"center",backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,width:"100%",minWidth:225,padding:e.spacing(3),[e.breakpoints.down("md")]:{display:"flex",flexDirection:"column",position:"relative",padding:e.spacing(1.5)}})),Be=h("p")(({theme:e})=>({marginBottom:e.spacing(2.5)})),w2=h("span")(({theme:e})=>({fontSize:e.typography.h2.fontSize,fontWeight:"bold",color:e.palette.text.primary})),Tt=({children:e,to:t})=>n($,{variant:"body2",textAlign:"center",sx:{paddingTop:a=>a.spacing(2.5),marginTop:"auto",justifySelf:"flex-end"},children:n(p2,{component:R1,to:t,children:e})}),No=h("p")(({theme:e})=>({fontSize:"1.5rem",[e.breakpoints.down("md")]:{fontSize:e.fontSizes.bodySize,marginBottom:e.spacing(4)}})),qo=h("p")(({theme:e})=>({fontSize:"1.5rem",[e.breakpoints.down("md")]:{fontSize:e.fontSizes.bodySize}})),Uo=({projectId:e,health:t})=>l($e,{children:[n(Be,{"data-loading":!0,children:"Project health"}),l(E,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:a=>a.spacing(2)},children:[n(qo,{children:n(P0,{percentage:t})}),l(No,{"data-loading":!0,children:[t,"%"]})]}),n(Tt,{to:`/projects/${e}/health`,children:"View project health"})]}),Go=h(w2)(({theme:e})=>({marginLeft:"auto",fontWeight:e.typography.fontWeightRegular,color:e.palette.text.secondary})),Ko=h("div")(({theme:e})=>({display:"flex",gap:e.spacing(1.5),width:"100%",gridTemplateColumns:`${e.spacing(2.5)} auto auto`,margin:e.spacing(1,0),fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,alignItems:"center",[e.breakpoints.down("md")]:{margin:0}})),Jo=({type:e,Icon:t,count:a})=>l(Ko,{"data-loading":!0,children:[n(t,{fontSize:"small","data-loading":!0}),n("div",{children:(o=>o.charAt(0).toUpperCase()+o.slice(1).replace("-"," "))(e)}),n(Go,{children:a})]}),Yo=({features:e})=>{const t=u.useMemo(()=>{const a=(e==null?void 0:e.filter(c=>c.type==="release").length)||0,r=(e==null?void 0:e.filter(c=>c.type==="experiment").length)||0,o=(e==null?void 0:e.filter(c=>c.type==="operational").length)||0,i=(e==null?void 0:e.filter(c=>c.type==="kill-switch").length)||0,s=(e==null?void 0:e.filter(c=>c.type==="permission").length)||0;return{release:a,experiment:r,operational:o,"kill-switch":i,permission:s}},[e]);return l($e,{sx:{padding:a=>a.spacing(3)},children:[n(Be,{children:"Toggle types used"}),Object.keys(t).map(a=>n(Jo,{type:a,Icon:Z0(a),count:t[a]},a))]})},Qo=h("div")(({theme:e})=>({textAlign:"left",borderRadius:`${e.shape.borderRadius}px`,backgroundColor:`${e.palette.background.elevation2}`,padding:e.spacing(.5,2),fontSize:e.typography.body2.fontSize})),Xo=({id:e,description:t})=>l($e,{children:[n(Be,{children:"Project Meta"}),l(Qo,{children:[n($,{component:"span",variant:"body2",color:"text.secondary",children:"ID:"})," ",n("code",{"data-loading":!0,children:e||"__________"})]}),n(w,{condition:!!t,show:n($,{variant:"body2",sx:{marginTop:a=>a.spacing(1.5),marginBottom:0,textAlign:"left"},children:t})}),n(w,{condition:!t,show:n(Tt,{to:`/projects/${e}/edit`,children:"Add description"})})]}),ei=h($)(({theme:e})=>({marginBottom:e.spacing(2.5)})),ti=h(E)(({theme:e})=>({fontSize:e.fontSizes.largeHeader})),Ot=h(E)(({theme:e})=>({...q1,flexDirection:"column",alignItems:"center",marginLeft:e.spacing(2.5)})),J2=h($)(({theme:e})=>({color:e.palette.text.secondary,fontSize:e.typography.body2.fontSize})),ni=h($)(({theme:e})=>({marginLeft:e.spacing(1),fontSize:e.typography.body1.fontSize,fontWeight:e.typography.fontWeightBold})),ai=e=>e>0?n(Dr,{sx:{color:"success.dark",height:20,width:20}}):n(Zr,{sx:{color:"warning.dark",height:20,width:20}}),ri=e=>e>0?"success.dark":"warning.dark",Te=({title:e,boxText:t,change:a,percentage:r,children:o,customChangeElement:i})=>l(G,{children:[n(w,{condition:!!e,show:n(ei,{children:e})}),o,l(E,{sx:{...q1,justifyContent:"center",width:"auto"},children:[n(ti,{children:t}),n(w,{condition:!!i,show:n(Ot,{children:i}),elseShow:n(w,{condition:a!==void 0&&a!==0,show:l(Ot,{children:[l(E,{sx:{...q1},children:[ai(a),l(ni,{color:ri(a),children:[a>0?"+":"",a,r?"%":""]})]}),n(J2,{children:"this month"})]}),elseShow:n(Ot,{children:n(J2,{children:"No change"})})})})]})]}),oi=({projectId:e,memberCount:t,change:a=0})=>{var i,s;const{uiConfig:r}=p1();let o="/admin/users";return(s=(i=r==null?void 0:r.versionInfo)==null?void 0:i.current)!=null&&s.enterprise&&(o=`/projects/${e}/settings/access`),l($e,{children:[n(Be,{"data-loading":!0,children:"Project members"}),n(E,{sx:{display:"flex",justifyContent:"center"},children:n(Te,{boxText:`${t}`,change:a})}),n(Tt,{to:o,children:"View all members"})]})},ii=e=>fetch(e).then(J1("ChangeRequest")).then(t=>t.json()),kn=e=>{const{data:t,error:a,mutate:r}=I0([],K1(`api/admin/projects/${e}/change-requests`),ii);return u.useMemo(()=>({changeRequests:t,loading:!a&&!t,refetch:r,error:a}),[t,a,r])},Je="change-requests-widget",si=h(E)(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing(1.5)})),Y2=h(E)(({theme:e})=>({flex:1,textAlign:"left",padding:e.spacing(1.5),borderRadius:e.shape.borderRadiusMedium,alignItems:"center",minWidth:175})),Q2=h(E)(({theme:e})=>({display:"flex",alignItems:"center"})),ci=h(w2)(({theme:e})=>({background:e.palette.seen.recent,padding:e.spacing(0,1),marginRight:e.spacing(.5),borderRadius:e.shape.borderRadius})),li=h(w2)(({theme:e})=>({background:e.palette.seen.primary,padding:e.spacing(0,1),marginRight:e.spacing(.5),borderRadius:e.shape.borderRadius})),X2=h($)(({theme:e})=>({fontSize:e.typography.body2.fontSize,marginBottom:e.spacing(.5)})),e3=()=>n($,{component:"span",variant:"body2",color:"text.secondary",lineHeight:1,"data-loading":Je,children:"change requests"}),di=({projectId:e})=>{const{changeRequests:t,loading:a}=kn(e),r=tn(a,`[data-loading="${Je}"]`),o=t==null?void 0:t.filter(s=>(s==null?void 0:s.state)==="Approved").length,i=t==null?void 0:t.filter(s=>(s==null?void 0:s.state)==="In review").length;return l($e,{ref:r,children:[n(Be,{children:"Open change requests"}),l(si,{children:[l(Y2,{sx:{background:s=>s.palette.success.light},children:[n(X2,{children:"To be applied"}),l(Q2,{children:[n(ci,{"data-loading":Je,children:o||0})," ",n(e3,{})]})]}),l(Y2,{sx:{background:s=>s.palette.secondary.light},children:[n(X2,{children:"To be reviewed"}),l(Q2,{children:[n(li,{"data-loading":Je,children:i||0})," ",n(e3,{})]})]})]}),n(Tt,{to:`/projects/${e}/change-requests`,children:"View change requests"})]})},ui=h(E)(({theme:e})=>({...q1,width:"225px",flexDirection:"column",gap:e.spacing(2),boxShadow:"none",[e.breakpoints.down("md")]:{display:"grid",width:"100%",alignItems:"stretch",marginBottom:e.spacing(2)},[e.breakpoints.down("sm")]:{display:"flex"}})),pi=({id:e,description:t,memberCount:a,health:r,features:o,stats:i})=>{const{isEnterprise:s}=p1(),c=m1(),d=b1(c.breakpoints.down("md")),{isChangeRequestConfiguredInAnyEnv:p}=Ie(e),m=s()&&p(),g=e!==j0;return n("aside",{children:l(ui,{sx:!m&&!g||d&&m&&g?{gridTemplateColumns:"repeat(auto-fill, minmax(225px, 1fr))"}:{gridTemplateColumns:"repeat(2, 1fr)"},children:[n(w,{condition:m,show:n(E,{sx:{gridColumnStart:g?"span 2":"span 1",flex:1,display:"flex"},children:n(di,{projectId:e})})}),n(Xo,{id:e,description:t}),n(Uo,{projectId:e,health:r}),n(w,{condition:g,show:n(oi,{projectId:e,memberCount:a,change:i==null?void 0:i.projectMembersAddedCurrentWindow})}),n(Yo,{features:o})]})})},hi=h(L1)(({theme:e})=>({padding:e.spacing(3,3),maxWidth:"350px",borderRadius:`${e.shape.borderRadiusMedium}px`,border:`1px solid ${e.palette.neutral.border}`,fontSize:e.typography.body2.fontSize})),t3=({children:e,id:t})=>{const[a,r]=u.useState(null),o=c=>r(c.currentTarget),i=()=>r(null);return l(E,{sx:{position:"absolute",top:c=>c.spacing(.5),right:c=>c.spacing(.5)},children:[n(M1,{onClick:o,"aria-describedby":t,size:"small",children:n(nn,{sx:{fontSize:c=>c.typography.body1.fontSize}})}),n(an,{id:t,open:!!a,anchorEl:a,sx:c=>({zIndex:c.zIndex.tooltip}),children:n(rn,{onClickAway:i,children:l(hi,{elevation:3,children:[n(M1,{onClick:i,sx:{position:"absolute",right:4,top:4},children:n(O0,{sx:{fontSize:c=>c.typography.body1.fontSize}})}),e,n($0,{id:t,eventName:"project_overview",localStorageKey:"ProjectOverviewFeedback"})]})})})]})},mi=h(E)(({theme:e})=>({padding:e.spacing(0,0,2,2),display:"grid",gap:e.spacing(2),gridTemplateColumns:"repeat(4, 1fr)",flexWrap:"wrap",[e.breakpoints.down("lg")]:{gridTemplateColumns:"repeat(2, 1fr)"},[e.breakpoints.down("md")]:{padding:e.spacing(0,0,2)},[e.breakpoints.down("sm")]:{flexDirection:"column"}})),Ge=h(E)(({theme:e})=>({position:"relative",padding:e.spacing(3),backgroundColor:e.palette.background.paper,flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:`${e.shape.borderRadiusLarge}px`,[e.breakpoints.down("lg")]:{padding:e.spacing(2)}})),gi=h($)(({theme:e})=>({color:e.palette.text.secondary,fontSize:e.typography.body2.fontSize,lineHeight:e.typography.body2.lineHeight})),fi=({stats:e})=>{if(Object.keys(e).length===0)return null;const{avgTimeToProdCurrentWindow:t,projectActivityCurrentWindow:a,projectActivityPastWindow:r,createdCurrentWindow:o,createdPastWindow:i,archivedCurrentWindow:s,archivedPastWindow:c}=e;return l(mi,{children:[n(Ge,{children:n(Te,{title:"Total changes",boxText:String(a),change:a-r,children:n(t3,{id:"total-changes",children:"Sum of all configuration and state modifications in the project."})})}),n(Ge,{children:n(Te,{title:"Avg. time to production",boxText:l(E,{sx:{display:"flex",alignItems:"center",gap:d=>d.spacing(1)},children:[t," ",n($,{component:"span",children:"days"})]}),customChangeElement:n(gi,{children:"In project life"}),percentage:!0,children:n(t3,{id:"avg-time-to-prod",children:'How long did it take on average from a feature toggle was created until it was enabled in an environment of type production. This is calculated only from feature toggles with the type of "release".'})})}),n(Ge,{children:n(Te,{title:"Features created",boxText:String(o),change:o-i})}),n(Ge,{children:n(Te,{title:"Features archived",boxText:String(s),change:s-c})})]})},vi=15*1e3,yi=h("div")(({theme:e})=>({display:"flex",[e.breakpoints.down("md")]:{flexDirection:"column"}})),bi=h("div")(()=>({width:"100%",minWidth:0})),Ci=h(E)(()=>({display:"flex",flexDirection:"column",width:"100%",minWidth:0})),Si=()=>{const e=Y("projectId"),t=F1(e),{project:a,loading:r}=C1(e,{refreshInterval:vi}),{members:o,features:i,health:s,description:c,environments:d,stats:p}=a;x1(`Project overview – ${t}`);const{setLastViewed:m}=B0();return u.useEffect(()=>{m(e)},[e,m]),l(yi,{children:[n(pi,{id:e,description:c,memberCount:o,health:s,features:i,stats:p}),l(Ci,{children:[n(fi,{stats:a.stats}),n(bi,{children:n(Wo,{features:i,environments:d,loading:r})})]})]})},_i=(e,t)=>{const a=K1(`api/admin/projects/${e}/health-report`),{data:r,error:o}=de(a,wi,t),i=u.useCallback(()=>{on(a).catch(console.warn)},[a]);return{healthReport:r,refetchHealthReport:i,loading:!o&&!r,error:o}},wi=e=>fetch(e).then(J1("Health report")).then(t=>t.json());var x2={},xi=Fe;Object.defineProperty(x2,"__esModule",{value:!0});var t2=x2.default=void 0,Ti=xi(Re()),Ei=Pe,Ai=(0,Ti.default)((0,Ei.jsx)("path",{d:"M12 5.99 19.53 19H4.47L12 5.99M12 2 1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined");t2=x2.default=Ai;const ki=h(E)(({theme:e})=>({display:"flex",alignItems:"center",color:e.palette.success.dark,"& svg":{color:e.palette.success.main}})),n3=h(E)(({theme:e})=>({display:"flex",alignItems:"center",color:e.palette.warning.dark,"& svg":{color:e.palette.warning.main}})),Di=h(L1)(({theme:e})=>({padding:e.spacing(4),marginBottom:e.spacing(2),borderRadius:e.shape.borderRadiusLarge,boxShadow:"none",display:"flex",justifyContent:"space-between",[e.breakpoints.down("md")]:{flexDirection:"column",gap:e.spacing(2)}})),$t=h("h2")(({theme:e})=>({fontSize:e.fontSizes.mainHeader,marginBottom:e.spacing(1)})),Ri=h("p")(({theme:e})=>({fontSize:"2rem",fontWeight:e.fontWeight.bold})),Fi=h("p")(({theme:e})=>({color:e.palette.text.secondary})),a3=h("ul")(({theme:e})=>({listStyleType:"none",margin:0,padding:0,"& svg":{marginRight:e.spacing(1)}})),r3=h("p")(({theme:e})=>({marginLeft:e.spacing(4)})),Pi=({healthReport:e})=>{const t=e.health<50?"error.main":e.health<75?"warning.main":"success.main",a=()=>l(ki,{children:[n(z0,{}),l("span",{children:[e.activeCount," active toggles"]})]}),r=()=>l(n3,{children:[n(t2,{}),l("span",{children:[e.staleCount," stale toggles"]})]}),o=()=>l(n3,{children:[n(t2,{}),l("span",{children:[e.potentiallyStaleCount," potentially stale toggles"]})]});return l(Di,{children:[l(E,{children:[n($t,{children:"Health rating"}),n(w,{condition:e.health>-1,show:l(G,{children:[l(Ri,{sx:{color:t},children:[e.health,"%"]}),l(Fi,{children:["Last updated:"," ",n(m2,{date:e.updatedAt,live:!1})]})]})})]}),l(E,{children:[n($t,{children:"Toggle report"}),l(a3,{children:[n("li",{children:n(w,{condition:!!e.activeCount,show:a})}),n(w,{condition:!!e.activeCount,show:n(r3,{children:"Also includes potentially stale toggles."})}),n("li",{children:n(w,{condition:!!e.staleCount,show:r})})]})]}),l(E,{sx:{flexBasis:"40%"},children:[n($t,{children:"Potential actions"}),n(a3,{children:n("li",{children:n(w,{condition:!!e.potentiallyStaleCount,show:o})})}),n(w,{condition:!!e.potentiallyStaleCount,show:n(r3,{children:"Review your feature toggles and delete unused toggles."}),elseShow:n("span",{children:"No action is required"})})]})]})},Zi=({row:e})=>{const t=m1();return e.original.expiredAt?n(vt,{value:e.original.expiredAt}):n(o1,{children:n($,{variant:"body2",color:t.palette.text.secondary,children:"N/A"})})},Ii=h("span")(({theme:e})=>({display:"flex",gap:"1ch",alignItems:"center",color:e.palette.warning.dark,"& svg":{color:e.palette.warning.main}})),ji=h("span")(({theme:e})=>({display:"flex",gap:"1ch",alignItems:"center",color:e.palette.success.dark,"& svg":{color:e.palette.success.main}})),Oi=({row:e})=>e.original.status==="potentially-stale"?n(o1,{children:l(Ii,{children:[n(Pr,{}),n("span",{children:"Potentially stale"})]})}):n(o1,{children:l(ji,{children:[n(sn,{}),n("span",{children:"Healthy"})]})}),o3=40,$i=7,Dn={[M0]:o3,[L0]:o3,[H0]:$i},Rn=(e,t)=>Math.abs(V0(e,t)),Fn=(e,t)=>e>=Dn[t],Bi=e=>{const{type:t,createdAt:a}=e,r=cn(a),i=Rn(r,new Date);return Fn(i,t)&&t!==ln&&t!==dn?"potentially-stale":"healthy"},zi=e=>{const{type:t,createdAt:a}=e;if(t===ln||t===dn)return;const r=cn(a),o=new Date,i=Rn(r,o);if(Fn(i,t)){const s=i-Dn[t];return Ir(o,s).toISOString()}},Vi=({projectId:e,features:t})=>{const a=m1(),r=b1(a.breakpoints.down("sm")),o=b1(a.breakpoints.down("md")),i=b1(a.breakpoints.down("lg")),s=u.useMemo(()=>t.map(b=>({project:e,name:b.name,type:b.type,stale:b.stale,status:Bi(b),lastSeenAt:b.lastSeenAt,createdAt:b.createdAt,expiredAt:zi(b)})),[e,t]),c=u.useMemo(()=>({hiddenColumns:[],sortBy:[{id:"createdAt"}]}),[]),{headerGroups:d,rows:p,prepareRow:m,state:{globalFilter:g},setGlobalFilter:f,setHiddenColumns:C}=t1.useTable({columns:i3,data:s,initialState:c,sortTypes:Oe,autoResetGlobalFilter:!1,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0},t1.useGlobalFilter,t1.useFlexLayout,t1.useSortBy);Ct([{condition:r,columns:["stale"]},{condition:o,columns:["expiredAt","lastSeenAt"]},{condition:i,columns:["createdAt"]}],C,i3);const S=p.length<s.length?`Feature toggles (${p.length} of ${s.length})`:`Feature toggles (${s.length})`;return l(d1,{header:n(i1,{title:S,actions:n(D1,{initialValue:g,onChange:f})}),children:[n(ue,{value:g,children:n(bt,{headerGroups:d,prepareRow:m,rows:p})}),n(w,{condition:p.length===0,show:n(w,{condition:(g==null?void 0:g.length)>0,show:l(S1,{children:["No feature toggles found matching “",g,"”"]}),elseShow:n(S1,{children:"No feature toggles available. Get started by adding a new feature toggle."})})})]})},i3=[{Header:"Seen",accessor:"lastSeenAt",sortType:"date",align:"center",Cell:Y3,disableGlobalFilter:!0,maxWidth:85},{Header:"Type",accessor:"type",align:"center",Cell:Q3,disableGlobalFilter:!0,maxWidth:85},{Header:"Name",accessor:"name",sortType:"alphanumeric",Cell:W0,minWidth:120},{Header:"Created",accessor:"createdAt",sortType:"date",Cell:vt,disableGlobalFilter:!0,maxWidth:150},{Header:"Expired",accessor:"expiredAt",Cell:Zi,disableGlobalFilter:!0,maxWidth:150},{Header:"Status",id:"status",accessor:"status",Cell:Oi,disableGlobalFilter:!0,width:180},{Header:"State",accessor:"stale",sortType:"boolean",Cell:N0,disableGlobalFilter:!0,maxWidth:120}],Mi=()=>{const e=Y("projectId"),t=F1(e);x1(`Project health – ${t}`);const{healthReport:a,refetchHealthReport:r,error:o}=_i(e,{refreshInterval:15*1e3});return a?l("div",{children:[n(w,{condition:!!o,show:n(H3,{"data-loading":!0,style:{maxWidth:"500px",marginTop:"1rem"},onClick:r,text:`Could not fetch health rating for ${e}`})}),n(Pi,{healthReport:a}),n(Vi,{projectId:e,features:a.features})]}):null},Li=h("div")(({theme:e})=>({borderRadius:"12.5px",backgroundColor:e.palette.background.paper,padding:"2rem"})),Hi=()=>{const e=Y("projectId");return n(Li,{children:n(q0,{title:"Event Log",project:e,displayInline:!0})})},Pn=(e,t)=>{const{data:a,error:r,mutate:o}=de(K1(`api/admin/projects/${e}/change-requests/${t}`),Wi,{refreshInterval:15e3});return{data:a,loading:!r&&!a,refetchChangeRequest:()=>o(),error:r}},Wi=e=>fetch(e).then(J1("Request changes")).then(t=>t.json()),Ni=h(L1)(({theme:e})=>({padding:e.spacing(3,4),borderRadius:`${e.shape.borderRadiusLarge}px`}));h(E)(({theme:e})=>({display:"flex",alignItems:"center",marginBottom:e.spacing(2)}));const qi=h(E)(({theme:e})=>({display:"flex",alignItems:"center"})),Ui=h($)(({theme:e})=>({display:"flex",alignItems:"center",marginRight:e.spacing(1),fontSize:e.fontSizes.mainHeader})),Gi=h(U0)(({theme:e})=>({padding:e.spacing(.75,1.5),backgroundColor:e.palette.background.elevation2})),Zn=h(St)(({theme:e})=>({height:"24px",width:"24px"})),Ki=({changeRequest:e})=>{var r,o,i;const[t,a]=u.useState(e.title);return l(Ni,{elevation:0,children:[n(G0,{environmentChangeRequest:e,title:t,setTitle:a,children:n(Ui,{variant:"h1",sx:{mr:1.5},children:t})}),l(qi,{children:[n(un,{state:e.state}),l($,{variant:"body2",sx:s=>({margin:s.spacing("auto",0,"auto",2)}),children:["Created"," ",n(m2,{minPeriod:60,date:new Date(e.createdAt)})," ","by"]}),n(E,{sx:s=>({marginLeft:s.spacing(1)}),children:n(Y1,{title:(r=e==null?void 0:e.createdBy)==null?void 0:r.username,children:n(Zn,{src:(o=e==null?void 0:e.createdBy)==null?void 0:o.imageUrl})})}),n($,{variant:"body2",sx:s=>({marginLeft:s.spacing(.5)}),children:(i=e==null?void 0:e.createdBy)==null?void 0:i.username}),n(E,{sx:s=>({marginLeft:s.spacing(1.5)}),children:n(Gi,{variant:"outlined",children:l($,{variant:"body2",sx:{lineHeight:1},children:["Environment:"," ",n($,{display:"inline",fontWeight:"bold",variant:"body2",component:"span",children:e==null?void 0:e.environment})," ",n(K0,{})," Updates:"," ",l($,{variant:"body2",display:"inline",fontWeight:"bold",component:"span",children:[e.features.length," ",e.features.length===1?"feature toggle":"feature toggles"]})]})})})]})]})};function r1(){return r1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},r1.apply(this,arguments)}function ve(e,t){if(e==null)return{};var a={},r=Object.keys(e),o,i;for(i=0;i<r.length;i++)o=r[i],!(t.indexOf(o)>=0)&&(a[o]=e[o]);return a}const Ji=u.createContext({}),nt=Ji;function Yi(e){return pe("MuiTimeline",e)}Q1("MuiTimeline",["root","positionLeft","positionRight","positionAlternate"]);const Qi=["position","className"],Xi=e=>{const{position:t,classes:a}=e,r={root:["root",t&&`position${j1(t)}`]};return ge(r,Yi,a)},e4=h("ul",{name:"MuiTimeline",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:a}=e;return[t.root,a.position&&t[`position${j1(a.position)}`]]}})({display:"flex",flexDirection:"column",padding:"6px 16px",flexGrow:1}),t4=u.forwardRef(function(t,a){const r=he({props:t,name:"MuiTimeline"}),{position:o="right",className:i}=r,s=ve(r,Qi),c=r1({},r,{position:o}),d=Xi(c),p=u.useMemo(()=>({position:o}),[o]);return n(nt.Provider,{value:p,children:n(e4,r1({className:me(d.root,i),ownerState:c,ref:a},s))})}),In=t4;function n4(e){return pe("MuiTimelineContent",e)}const a4=Q1("MuiTimelineContent",["root","positionLeft","positionRight","positionAlternate"]),r4=["className"],o4=e=>{const{position:t,classes:a}=e,r={root:["root",`position${j1(t)}`]};return ge(r,n4,a)},i4=h($,{name:"MuiTimelineContent",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:a}=e;return[t.root,t[`position${j1(a.position)}`]]}})(({ownerState:e})=>r1({flex:1,padding:"6px 16px",textAlign:"left"},e.position==="left"&&{textAlign:"right"})),s4=u.forwardRef(function(t,a){const r=he({props:t,name:"MuiTimelineContent"}),{className:o}=r,i=ve(r,r4),{position:s}=u.useContext(nt),c=r1({},r,{position:s||"right"}),d=o4(c);return n(i4,r1({component:"div",className:me(d.root,o),ownerState:c,ref:a},i))}),jn=s4,c4=Q1("MuiTimelineOppositeContent",["root","positionLeft","positionRight","positionAlternate"]),l4=c4;function d4(e){return pe("MuiTimelineItem",e)}const u4=Q1("MuiTimelineItem",["root","positionLeft","positionRight","positionAlternate","missingOppositeContent"]),On=u4,p4=["position","className"],h4=e=>{const{position:t,classes:a,hasOppositeContent:r}=e,o={root:["root",`position${j1(t)}`,!r&&"missingOppositeContent"]};return ge(o,d4,a)},m4=h("li",{name:"MuiTimelineItem",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:a}=e;return[t.root,t[`position${j1(a.position)}`]]}})(({ownerState:e})=>r1({listStyle:"none",display:"flex",position:"relative",minHeight:70},e.position==="left"&&{flexDirection:"row-reverse"},e.position==="alternate"&&{"&:nth-of-type(even)":{flexDirection:"row-reverse",[`& .${a4.root}`]:{textAlign:"right"},[`& .${l4.root}`]:{textAlign:"left"}}},!e.hasOppositeContent&&{"&:before":{content:'""',flex:1,padding:"6px 16px"}})),g4=u.forwardRef(function(t,a){const r=he({props:t,name:"MuiTimelineItem"}),{position:o,className:i}=r,s=ve(r,p4),{position:c}=u.useContext(nt);let d=!1;u.Children.forEach(r.children,f=>{J0(f,["TimelineOppositeContent"])&&(d=!0)});const p=r1({},r,{position:o||c||"right",hasOppositeContent:d}),m=h4(p),g=u.useMemo(()=>({position:p.position}),[p.position]);return n(nt.Provider,{value:g,children:n(m4,r1({className:me(m.root,i),ownerState:p,ref:a},s))})}),Ye=g4;function f4(e){return pe("MuiTimelineSeparator",e)}Q1("MuiTimelineSeparator",["root"]);const v4=["className"],y4=e=>{const{classes:t}=e;return ge({root:["root"]},f4,t)},b4=h("div",{name:"MuiTimelineSeparator",slot:"Root",overridesResolver:(e,t)=>t.root})({display:"flex",flexDirection:"column",flex:0,alignItems:"center"}),C4=u.forwardRef(function(t,a){const r=he({props:t,name:"MuiTimelineSeparator"}),{className:o}=r,i=ve(r,v4),s=r,c=y4(s);return n(b4,r1({className:me(c.root,o),ownerState:s,ref:a},i))}),Qe=C4;function S4(e){return pe("MuiTimelineDot",e)}Q1("MuiTimelineDot",["root","filled","outlined","filledGrey","outlinedGrey","filledPrimary","outlinedPrimary","filledSecondary","outlinedSecondary"]);const _4=["className","color","variant"],w4=e=>{const{color:t,variant:a,classes:r}=e,o={root:["root",a,t!=="inherit"&&`${a}${j1(t)}`]};return ge(o,S4,r)},x4=h("span",{name:"MuiTimelineDot",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:a}=e;return[t.root,t[a.color!=="inherit"&&`${a.variant}${j1(a.color)}`],t[a.variant]]}})(({ownerState:e,theme:t})=>r1({display:"flex",alignSelf:"baseline",borderStyle:"solid",borderWidth:2,padding:4,borderRadius:"50%",boxShadow:(t.vars||t).shadows[1],margin:"11.5px 0"},e.variant==="filled"&&r1({borderColor:"transparent"},e.color!=="inherit"&&r1({},e.color==="grey"?{color:(t.vars||t).palette.grey[50],backgroundColor:(t.vars||t).palette.grey[400]}:{color:(t.vars||t).palette[e.color].contrastText,backgroundColor:(t.vars||t).palette[e.color].main})),e.variant==="outlined"&&r1({boxShadow:"none",backgroundColor:"transparent"},e.color!=="inherit"&&r1({},e.color==="grey"?{borderColor:(t.vars||t).palette.grey[400]}:{borderColor:(t.vars||t).palette[e.color].main})))),T4=u.forwardRef(function(t,a){const r=he({props:t,name:"MuiTimelineDot"}),{className:o,color:i="grey",variant:s="filled"}=r,c=ve(r,_4),d=r1({},r,{color:i,variant:s}),p=w4(d);return n(x4,r1({className:me(p.root,o),ownerState:d,ref:a},c))}),$n=T4;function E4(e){return pe("MuiTimelineConnector",e)}Q1("MuiTimelineConnector",["root"]);const A4=["className"],k4=e=>{const{classes:t}=e;return ge({root:["root"]},E4,t)},D4=h("span",{name:"MuiTimelineConnector",slot:"Root",overridesResolver:(e,t)=>t.root})(({theme:e})=>({width:2,backgroundColor:(e.vars||e).palette.grey[400],flexGrow:1})),R4=u.forwardRef(function(t,a){const r=he({props:t,name:"MuiTimelineConnector"}),{className:o}=r,i=ve(r,A4),s=r,c=k4(s);return n(D4,r1({className:me(c.root,o),ownerState:s,ref:a},i))}),T2=R4,F4=h(L1)(({theme:e})=>({marginTop:e.spacing(2),borderRadius:`${e.shape.borderRadiusLarge}px`})),P4=h(E)(({theme:e})=>({padding:e.spacing(2),marginBottom:`-${e.spacing(4)}`})),Z4=h(In)(()=>({[`& .${On.root}:before`]:{flex:0,padding:0}})),I4=({state:e})=>{const t=r=>["Draft","In review","Approved","Applied"].map(i=>({title:i,active:i===r}));return n(F4,{elevation:0,children:n(P4,{children:n(Z4,{children:(()=>{const r=t(e),o=r.findIndex(s=>s.active),i=o!==-1?o:null;return e==="Cancelled"?O4(r):j4(r,i)})()})})})},j4=(e,t)=>e.map(({title:a},r)=>{const o=r<e.length-1,i=n(w,{condition:o,show:n(T2,{})});return t!==null&&t>=r?Xe("success",a,i):t!==null&&t+1===r?Xe("primary",a,i,{variant:"outlined"}):Xe("grey",a,i)}),O4=e=>e.map(({title:t},a)=>{const r=a<e.length-1;return Xe("grey",t,n(w,{condition:r,show:n(T2,{})}))}),Xe=(e,t,a,r={})=>l(Ye,{children:[l(Qe,{children:[n($n,{color:e,...r}),a]}),n(jn,{children:t})]},t),$4=h(E)(({theme:e})=>({marginBottom:e.spacing(2)})),B4=({actualApprovals:e,minApprovals:t})=>l(G,{children:["Reviewers"," ",l($,{component:"span",color:"text.secondary",children:["(",e,"/",t," required)"]})]}),z4=({header:e,children:t})=>l(L1,{elevation:0,sx:a=>({marginTop:a.spacing(2),padding:a.spacing(4),borderRadius:r=>`${r.shape.borderRadiusLarge}px`}),children:[n($4,{children:e}),n($,{variant:"body1",color:"text.secondary",children:n(w,{condition:Ee.Children.count(t)>0,show:"Approved by",elseShow:"No approvals yet"})}),t]}),E2=()=>e=>e!=="color"&&e!=="sx"&&e!=="approved"&&e!=="border"&&e!=="bgColor"&&e!=="svgColor",se=h(E)(({theme:e})=>({display:"flex",alignItems:"center"})),V4=h(pn)(({theme:e})=>({color:e.palette.error.main,height:"35px",width:"35px",marginRight:e.spacing(1)})),s3=h(pn)(({theme:e})=>({color:e.palette.warning.main,height:"35px",width:"35px",marginRight:e.spacing(1)})),n2=h(hn)(({theme:e})=>({color:e.palette.success.main,height:"35px",width:"35px",marginRight:e.spacing(1)})),M4=h(E)(({theme:e})=>({display:"flex",marginTop:e.spacing(2)})),L4=h(E,{shouldForwardProp:E2()})(({theme:e,bgColor:t,svgColor:a})=>({borderRadius:`${e.shape.borderRadiusMedium}px`,backgroundColor:t,padding:e.spacing(1,2),marginRight:e.spacing(2),height:"45px",width:"45px",display:"flex",alignItems:"center",justifyContent:"center",svg:{color:a}})),Bn=h(q3)(({theme:e})=>({margin:e.spacing(2.5,0)})),H4=h(E,{shouldForwardProp:E2()})(({theme:e,border:t})=>({borderRadius:`${e.shape.borderRadiusLarge}px`,border:t,padding:e.spacing(3),width:"100%"})),ce=h($,{shouldForwardProp:E2()})(({theme:e,color:t})=>({fontWeight:"bold",color:t})),W4=(e,t)=>e==="Approved"?`2px solid ${t.palette.success.main}`:e==="Applied"?`2px solid ${t.palette.primary.main}`:`1px solid ${t.palette.divider}`,N4=(e,t)=>e==="Approved"?{bgColor:t.palette.success.main,svgColor:t.palette.background.paper}:e==="Applied"?{bgColor:t.palette.primary.main,svgColor:t.palette.background.paper}:{bgColor:t.palette.background.elevation2,svgColor:t.palette.neutral.main},q4=({changeRequest:e})=>{const t=m1();return l(M4,{children:[n(L4,{...N4(e.state,t),children:n(Y0,{style:{transform:"scale(1.5)"}})}),n(H4,{sx:{backgroundColor:e.state==="In review"?t.palette.warning.light:"initial"},border:W4(e.state,t),children:n(U4,{changeRequest:e})})]})},U4=({changeRequest:e})=>{const{state:t}=e;return t?t==="Approved"?n(G4,{}):t==="Applied"?n(J4,{}):t==="Cancelled"?n(Y4,{}):n(K4,{minApprovals:e.minApprovals}):null},G4=()=>{const e=m1();return l(G,{children:[l(se,{children:[n(n2,{}),l(E,{children:[n(ce,{color:e.palette.success.dark,children:"Changes approved"}),n($,{children:"One approving review from requested approvers"})]})]}),n(Bn,{}),l(se,{children:[n(n2,{}),n(E,{children:n(ce,{color:e.palette.success.dark,children:"Changes are ready to be applied"})})]})]})},K4=({minApprovals:e})=>{const t=m1();return l(G,{children:[l(se,{children:[n(s3,{}),l(E,{children:[n(ce,{color:t.palette.warning.dark,children:"Review required"}),l($,{children:["At least ",e," approval(s) must be submitted before changes can be applied"]})]})]}),n(Bn,{}),l(se,{children:[n(s3,{}),n(ce,{color:t.palette.warning.dark,children:"Apply changes is blocked"})]})]})},J4=()=>{const e=m1();return n(G,{children:l(se,{children:[n(n2,{sx:{color:e.palette.primary.main}}),n(E,{children:n(ce,{color:e.palette.primary.main,children:"Changes applied"})})]})})},Y4=()=>{const e=m1();return n(G,{children:l(se,{children:[n(V4,{}),n(E,{children:n(ce,{color:e.palette.error.main,children:"Changes cancelled"})})]})})};var A2={},Q4=Fe;Object.defineProperty(A2,"__esModule",{value:!0});var zn=A2.default=void 0,X4=Q4(Re()),es=Pe,ts=(0,X4.default)((0,es.jsx)("path",{d:"m7 10 5 5 5-5z"}),"ArrowDropDown");zn=A2.default=ts;const ns=({disabled:e})=>{const{isAdmin:t}=u.useContext(X1),a=Y("projectId"),r=Y("id"),{user:o}=mn(),{refetchChangeRequest:i,data:s}=Pn(a,r),{refetch:c}=je(a),{setToastApiError:d,setToastData:p}=u1(),{changeState:m}=Ze(),[g,f]=Ee.useState(!1),C=Ee.useRef(null),S=async()=>{try{await m(a,Number(r),{state:"Approved"}),i(),c(),p({type:"success",title:"Success",text:"Changes approved"})}catch(v){d(h1(v))}},b=()=>{f(v=>!v)},R=v=>{C.current&&C.current.contains(v.target)||f(!1)};return l(Ee.Fragment,{children:[n(_t,{variant:"contained",disabled:e||(s==null?void 0:s.createdBy.id)===(o==null?void 0:o.id)&&!t,"aria-controls":g?"review-options-menu":void 0,"aria-expanded":g?"true":void 0,"aria-label":"review changes","aria-haspopup":"menu",onClick:b,ref:C,endIcon:n(zn,{}),permission:Q0,projectId:a,environmentId:s==null?void 0:s.environment,children:"Review changes"}),n(an,{sx:{zIndex:1},open:g,anchorEl:C.current,role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:v,placement:F})=>n(X0,{...v,style:{transformOrigin:F==="bottom"?"center top":"center bottom"},children:n(L1,{className:"dropdown-outline",children:n(rn,{onClickAway:R,children:n(mt,{id:"review-options-menu",autoFocusItem:!0,children:n(N1,{onClick:S,children:"Approve changes"})})})})})})]})},as=h(E)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"wrap",marginTop:e.spacing(1.5),gap:e.spacing(1)})),rs=h(hn)(({theme:e})=>({color:e.palette.success.main,marginLeft:"auto"})),os=({name:e,imageUrl:t})=>l(as,{children:[n(Zn,{src:t}),n($,{variant:"body1",color:"text.primary",sx:{maxWidth:"170px",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"},children:e}),n(rs,{})]});var Vn={},k2={},D2={};Object.defineProperty(D2,"__esModule",{value:!0});var is=u,ss=cs(is);function cs(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t.default=e,t}D2.default=function(e,t,a){return ss.createElement("a",{href:e,key:a},t)};var R2={};Object.defineProperty(R2,"__esModule",{value:!0});R2.default=function(e){return e};var F2={},Bt,c3;function ls(){return c3||(c3=1,Bt=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/),Bt}var zt,l3;function ds(){return l3||(l3=1,zt=/[\0-\x1F\x7F-\x9F]/),zt}var Vt,d3;function us(){return d3||(d3=1,Vt=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/),Vt}var Mt,u3;function ps(){return u3||(u3=1,Mt=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/),Mt}var Lt,p3;function hs(){return p3||(p3=1,Lt=function(e){var t={};t.src_Any=ls().source,t.src_Cc=ds().source,t.src_Z=us().source,t.src_P=ps().source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join("|"),t.src_ZCc=[t.src_Z,t.src_Cc].join("|");var a="[><|]";return t.src_pseudo_letter="(?:(?!"+a+"|"+t.src_ZPCc+")"+t.src_Any+")",t.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",t.src_auth="(?:(?:(?!"+t.src_ZCc+"|[@/\\[\\]()]).)+@)?",t.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",t.src_host_terminator="(?=$|"+a+"|"+t.src_ZPCc+")(?!-|_|:\\d|\\.-|\\.(?!$|"+t.src_ZPCc+"))",t.src_path="(?:[/?#](?:(?!"+t.src_ZCc+"|"+a+`|[()[\\]{}.,"'?!\\-]).|\\[(?:(?!`+t.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+t.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+t.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+t.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+t.src_ZCc+"|[']).)+\\'|\\'(?="+t.src_pseudo_letter+"|[-]).|\\.{2,4}[a-zA-Z0-9%/]|\\.(?!"+t.src_ZCc+"|[.]).|"+(e&&e["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+"\\,(?!"+t.src_ZCc+").|\\!(?!"+t.src_ZCc+"|[!]).|\\?(?!"+t.src_ZCc+"|[?]).)+|\\/)?",t.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',t.src_xn="xn--[a-z0-9\\-]{1,59}",t.src_domain_root="(?:"+t.src_xn+"|"+t.src_pseudo_letter+"{1,63})",t.src_domain="(?:"+t.src_xn+"|(?:"+t.src_pseudo_letter+")|(?:"+t.src_pseudo_letter+"(?:-|"+t.src_pseudo_letter+"){0,61}"+t.src_pseudo_letter+"))",t.src_host="(?:(?:(?:(?:"+t.src_domain+")\\.)*"+t.src_domain+"))",t.tpl_host_fuzzy="(?:"+t.src_ip4+"|(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%)))",t.tpl_host_no_ip_fuzzy="(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%))",t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+t.src_ZPCc+"|>|$))",t.tpl_email_fuzzy="(^|"+a+'|"|\\(|'+t.src_ZCc+")("+t.src_email_name+"@"+t.tpl_host_fuzzy_strict+")",t.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_fuzzy_strict+t.src_path+")",t.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_no_ip_fuzzy_strict+t.src_path+")",t}),Lt}function a2(e){var t=Array.prototype.slice.call(arguments,1);return t.forEach(function(a){a&&Object.keys(a).forEach(function(r){e[r]=a[r]})}),e}function Et(e){return Object.prototype.toString.call(e)}function ms(e){return Et(e)==="[object String]"}function gs(e){return Et(e)==="[object Object]"}function fs(e){return Et(e)==="[object RegExp]"}function h3(e){return Et(e)==="[object Function]"}function vs(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var Mn={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function ys(e){return Object.keys(e||{}).reduce(function(t,a){return t||Mn.hasOwnProperty(a)},!1)}var bs={"http:":{validate:function(e,t,a){var r=e.slice(t);return a.re.http||(a.re.http=new RegExp("^\\/\\/"+a.re.src_auth+a.re.src_host_port_strict+a.re.src_path,"i")),a.re.http.test(r)?r.match(a.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(e,t,a){var r=e.slice(t);return a.re.no_http||(a.re.no_http=new RegExp("^"+a.re.src_auth+"(?:localhost|(?:(?:"+a.re.src_domain+")\\.)+"+a.re.src_domain_root+")"+a.re.src_port+a.re.src_host_terminator+a.re.src_path,"i")),a.re.no_http.test(r)?t>=3&&e[t-3]===":"||t>=3&&e[t-3]==="/"?0:r.match(a.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,a){var r=e.slice(t);return a.re.mailto||(a.re.mailto=new RegExp("^"+a.re.src_email_name+"@"+a.re.src_host_strict,"i")),a.re.mailto.test(r)?r.match(a.re.mailto)[0].length:0}}},Cs="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",Ss="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function _s(e){e.__index__=-1,e.__text_cache__=""}function ws(e){return function(t,a){var r=t.slice(a);return e.test(r)?r.match(e)[0].length:0}}function m3(){return function(e,t){t.normalize(e)}}function at(e){var t=e.re=hs()(e.__opts__),a=e.__tlds__.slice();e.onCompile(),e.__tlds_replaced__||a.push(Cs),a.push(t.src_xn),t.src_tlds=a.join("|");function r(c){return c.replace("%TLDS%",t.src_tlds)}t.email_fuzzy=RegExp(r(t.tpl_email_fuzzy),"i"),t.link_fuzzy=RegExp(r(t.tpl_link_fuzzy),"i"),t.link_no_ip_fuzzy=RegExp(r(t.tpl_link_no_ip_fuzzy),"i"),t.host_fuzzy_test=RegExp(r(t.tpl_host_fuzzy_test),"i");var o=[];e.__compiled__={};function i(c,d){throw new Error('(LinkifyIt) Invalid schema "'+c+'": '+d)}Object.keys(e.__schemas__).forEach(function(c){var d=e.__schemas__[c];if(d!==null){var p={validate:null,link:null};if(e.__compiled__[c]=p,gs(d)){fs(d.validate)?p.validate=ws(d.validate):h3(d.validate)?p.validate=d.validate:i(c,d),h3(d.normalize)?p.normalize=d.normalize:d.normalize?i(c,d):p.normalize=m3();return}if(ms(d)){o.push(c);return}i(c,d)}}),o.forEach(function(c){e.__compiled__[e.__schemas__[c]]&&(e.__compiled__[c].validate=e.__compiled__[e.__schemas__[c]].validate,e.__compiled__[c].normalize=e.__compiled__[e.__schemas__[c]].normalize)}),e.__compiled__[""]={validate:null,normalize:m3()};var s=Object.keys(e.__compiled__).filter(function(c){return c.length>0&&e.__compiled__[c]}).map(vs).join("|");e.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+s+")","i"),e.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+s+")","ig"),e.re.pretest=RegExp("("+e.re.schema_test.source+")|("+e.re.host_fuzzy_test.source+")|@","i"),_s(e)}function xs(e,t){var a=e.__index__,r=e.__last_index__,o=e.__text_cache__.slice(a,r);this.schema=e.__schema__.toLowerCase(),this.index=a+t,this.lastIndex=r+t,this.raw=o,this.text=o,this.url=o}function g3(e,t){var a=new xs(e,t);return e.__compiled__[a.schema].normalize(a,e),a}function _1(e,t){if(!(this instanceof _1))return new _1(e,t);t||ys(e)&&(t=e,e={}),this.__opts__=a2({},Mn,t),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=a2({},bs,e),this.__compiled__={},this.__tlds__=Ss,this.__tlds_replaced__=!1,this.re={},at(this)}_1.prototype.add=function(t,a){return this.__schemas__[t]=a,at(this),this};_1.prototype.set=function(t){return this.__opts__=a2(this.__opts__,t),this};_1.prototype.test=function(t){if(this.__text_cache__=t,this.__index__=-1,!t.length)return!1;var a,r,o,i,s,c,d,p,m;if(this.re.schema_test.test(t)){for(d=this.re.schema_search,d.lastIndex=0;(a=d.exec(t))!==null;)if(i=this.testSchemaAt(t,a[2],d.lastIndex),i){this.__schema__=a[2],this.__index__=a.index+a[1].length,this.__last_index__=a.index+a[0].length+i;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(p=t.search(this.re.host_fuzzy_test),p>=0&&(this.__index__<0||p<this.__index__)&&(r=t.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(s=r.index+r[1].length,(this.__index__<0||s<this.__index__)&&(this.__schema__="",this.__index__=s,this.__last_index__=r.index+r[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(m=t.indexOf("@"),m>=0&&(o=t.match(this.re.email_fuzzy))!==null&&(s=o.index+o[1].length,c=o.index+o[0].length,(this.__index__<0||s<this.__index__||s===this.__index__&&c>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=s,this.__last_index__=c))),this.__index__>=0};_1.prototype.pretest=function(t){return this.re.pretest.test(t)};_1.prototype.testSchemaAt=function(t,a,r){return this.__compiled__[a.toLowerCase()]?this.__compiled__[a.toLowerCase()].validate(t,r,this):0};_1.prototype.match=function(t){var a=0,r=[];this.__index__>=0&&this.__text_cache__===t&&(r.push(g3(this,a)),a=this.__last_index__);for(var o=a?t.slice(a):t;this.test(o);)r.push(g3(this,a)),o=o.slice(this.__last_index__),a+=this.__last_index__;return r.length?r:null};_1.prototype.tlds=function(t,a){return t=Array.isArray(t)?t:[t],a?(this.__tlds__=this.__tlds__.concat(t).sort().filter(function(r,o,i){return r!==i[o-1]}).reverse(),at(this),this):(this.__tlds__=t.slice(),this.__tlds_replaced__=!0,at(this),this)};_1.prototype.normalize=function(t){t.schema||(t.url="http://"+t.url),t.schema==="mailto:"&&!/^mailto:/i.test(t.url)&&(t.url="mailto:"+t.url)};_1.prototype.onCompile=function(){};var Ts=_1;const Es=["aaa","aarp","abarth","abb","abbott","abbvie","abc","able","abogado","abudhabi","ac","academy","accenture","accountant","accountants","aco","actor","ad","ads","adult","ae","aeg","aero","aetna","af","afl","africa","ag","agakhan","agency","ai","aig","airbus","airforce","airtel","akdn","al","alfaromeo","alibaba","alipay","allfinanz","allstate","ally","alsace","alstom","am","amazon","americanexpress","americanfamily","amex","amfam","amica","amsterdam","analytics","android","anquan","anz","ao","aol","apartments","app","apple","aq","aquarelle","ar","arab","aramco","archi","army","arpa","art","arte","as","asda","asia","associates","at","athleta","attorney","au","auction","audi","audible","audio","auspost","author","auto","autos","avianca","aw","aws","ax","axa","az","azure","ba","baby","baidu","banamex","bananarepublic","band","bank","bar","barcelona","barclaycard","barclays","barefoot","bargains","baseball","basketball","bauhaus","bayern","bb","bbc","bbt","bbva","bcg","bcn","bd","be","beats","beauty","beer","bentley","berlin","best","bestbuy","bet","bf","bg","bh","bharti","bi","bible","bid","bike","bing","bingo","bio","biz","bj","black","blackfriday","blockbuster","blog","bloomberg","blue","bm","bms","bmw","bn","bnpparibas","bo","boats","boehringer","bofa","bom","bond","boo","book","booking","bosch","bostik","boston","bot","boutique","box","br","bradesco","bridgestone","broadway","broker","brother","brussels","bs","bt","build","builders","business","buy","buzz","bv","bw","by","bz","bzh","ca","cab","cafe","cal","call","calvinklein","cam","camera","camp","canon","capetown","capital","capitalone","car","caravan","cards","care","career","careers","cars","casa","case","cash","casino","cat","catering","catholic","cba","cbn","cbre","cbs","cc","cd","center","ceo","cern","cf","cfa","cfd","cg","ch","chanel","channel","charity","chase","chat","cheap","chintai","christmas","chrome","church","ci","cipriani","circle","cisco","citadel","citi","citic","city","cityeats","ck","cl","claims","cleaning","click","clinic","clinique","clothing","cloud","club","clubmed","cm","cn","co","coach","codes","coffee","college","cologne","com","comcast","commbank","community","company","compare","computer","comsec","condos","construction","consulting","contact","contractors","cooking","cookingchannel","cool","coop","corsica","country","coupon","coupons","courses","cpa","cr","credit","creditcard","creditunion","cricket","crown","crs","cruise","cruises","cu","cuisinella","cv","cw","cx","cy","cymru","cyou","cz","dabur","dad","dance","data","date","dating","datsun","day","dclk","dds","de","deal","dealer","deals","degree","delivery","dell","deloitte","delta","democrat","dental","dentist","desi","design","dev","dhl","diamonds","diet","digital","direct","directory","discount","discover","dish","diy","dj","dk","dm","dnp","do","docs","doctor","dog","domains","dot","download","drive","dtv","dubai","dunlop","dupont","durban","dvag","dvr","dz","earth","eat","ec","eco","edeka","edu","education","ee","eg","email","emerck","energy","engineer","engineering","enterprises","epson","equipment","er","ericsson","erni","es","esq","estate","et","etisalat","eu","eurovision","eus","events","exchange","expert","exposed","express","extraspace","fage","fail","fairwinds","faith","family","fan","fans","farm","farmers","fashion","fast","fedex","feedback","ferrari","ferrero","fi","fiat","fidelity","fido","film","final","finance","financial","fire","firestone","firmdale","fish","fishing","fit","fitness","fj","fk","flickr","flights","flir","florist","flowers","fly","fm","fo","foo","food","foodnetwork","football","ford","forex","forsale","forum","foundation","fox","fr","free","fresenius","frl","frogans","frontdoor","frontier","ftr","fujitsu","fun","fund","furniture","futbol","fyi","ga","gal","gallery","gallo","gallup","game","games","gap","garden","gay","gb","gbiz","gd","gdn","ge","gea","gent","genting","george","gf","gg","ggee","gh","gi","gift","gifts","gives","giving","gl","glass","gle","global","globo","gm","gmail","gmbh","gmo","gmx","gn","godaddy","gold","goldpoint","golf","goo","goodyear","goog","google","gop","got","gov","gp","gq","gr","grainger","graphics","gratis","green","gripe","grocery","group","gs","gt","gu","guardian","gucci","guge","guide","guitars","guru","gw","gy","hair","hamburg","hangout","haus","hbo","hdfc","hdfcbank","health","healthcare","help","helsinki","here","hermes","hgtv","hiphop","hisamitsu","hitachi","hiv","hk","hkt","hm","hn","hockey","holdings","holiday","homedepot","homegoods","homes","homesense","honda","horse","hospital","host","hosting","hot","hoteles","hotels","hotmail","house","how","hr","hsbc","ht","hu","hughes","hyatt","hyundai","ibm","icbc","ice","icu","id","ie","ieee","ifm","ikano","il","im","imamat","imdb","immo","immobilien","in","inc","industries","infiniti","info","ing","ink","institute","insurance","insure","int","international","intuit","investments","io","ipiranga","iq","ir","irish","is","ismaili","ist","istanbul","it","itau","itv","jaguar","java","jcb","je","jeep","jetzt","jewelry","jio","jll","jm","jmp","jnj","jo","jobs","joburg","jot","joy","jp","jpmorgan","jprs","juegos","juniper","kaufen","kddi","ke","kerryhotels","kerrylogistics","kerryproperties","kfh","kg","kh","ki","kia","kids","kim","kinder","kindle","kitchen","kiwi","km","kn","koeln","komatsu","kosher","kp","kpmg","kpn","kr","krd","kred","kuokgroup","kw","ky","kyoto","kz","la","lacaixa","lamborghini","lamer","lancaster","lancia","land","landrover","lanxess","lasalle","lat","latino","latrobe","law","lawyer","lb","lc","lds","lease","leclerc","lefrak","legal","lego","lexus","lgbt","li","lidl","life","lifeinsurance","lifestyle","lighting","like","lilly","limited","limo","lincoln","link","lipsy","live","living","lk","llc","llp","loan","loans","locker","locus","lol","london","lotte","lotto","love","lpl","lplfinancial","lr","ls","lt","ltd","ltda","lu","lundbeck","luxe","luxury","lv","ly","ma","madrid","maif","maison","makeup","man","management","mango","map","market","marketing","markets","marriott","marshalls","maserati","mattel","mba","mc","mckinsey","md","me","med","media","meet","melbourne","meme","memorial","men","menu","merckmsd","mg","mh","miami","microsoft","mil","mini","mint","mit","mitsubishi","mk","ml","mlb","mls","mm","mma","mn","mo","mobi","mobile","moda","moe","moi","mom","monash","money","monster","mormon","mortgage","moscow","moto","motorcycles","mov","movie","mp","mq","mr","ms","msd","mt","mtn","mtr","mu","museum","music","mutual","mv","mw","mx","my","mz","na","nab","nagoya","name","natura","navy","nba","nc","ne","nec","net","netbank","netflix","network","neustar","new","news","next","nextdirect","nexus","nf","nfl","ng","ngo","nhk","ni","nico","nike","nikon","ninja","nissan","nissay","nl","no","nokia","northwesternmutual","norton","now","nowruz","nowtv","np","nr","nra","nrw","ntt","nu","nyc","nz","obi","observer","office","okinawa","olayan","olayangroup","oldnavy","ollo","om","omega","one","ong","onl","online","ooo","open","oracle","orange","org","organic","origins","osaka","otsuka","ott","ovh","pa","page","panasonic","paris","pars","partners","parts","party","passagens","pay","pccw","pe","pet","pf","pfizer","pg","ph","pharmacy","phd","philips","phone","photo","photography","photos","physio","pics","pictet","pictures","pid","pin","ping","pink","pioneer","pizza","pk","pl","place","play","playstation","plumbing","plus","pm","pn","pnc","pohl","poker","politie","porn","post","pr","pramerica","praxi","press","prime","pro","prod","productions","prof","progressive","promo","properties","property","protection","pru","prudential","ps","pt","pub","pw","pwc","py","qa","qpon","quebec","quest","racing","radio","re","read","realestate","realtor","realty","recipes","red","redstone","redumbrella","rehab","reise","reisen","reit","reliance","ren","rent","rentals","repair","report","republican","rest","restaurant","review","reviews","rexroth","rich","richardli","ricoh","ril","rio","rip","ro","rocher","rocks","rodeo","rogers","room","rs","rsvp","ru","rugby","ruhr","run","rw","rwe","ryukyu","sa","saarland","safe","safety","sakura","sale","salon","samsclub","samsung","sandvik","sandvikcoromant","sanofi","sap","sarl","sas","save","saxo","sb","sbi","sbs","sc","sca","scb","schaeffler","schmidt","scholarships","school","schule","schwarz","science","scot","sd","se","search","seat","secure","security","seek","select","sener","services","seven","sew","sex","sexy","sfr","sg","sh","shangrila","sharp","shaw","shell","shia","shiksha","shoes","shop","shopping","shouji","show","showtime","si","silk","sina","singles","site","sj","sk","ski","skin","sky","skype","sl","sling","sm","smart","smile","sn","sncf","so","soccer","social","softbank","software","sohu","solar","solutions","song","sony","soy","spa","space","sport","spot","sr","srl","ss","st","stada","staples","star","statebank","statefarm","stc","stcgroup","stockholm","storage","store","stream","studio","study","style","su","sucks","supplies","supply","support","surf","surgery","suzuki","sv","swatch","swiss","sx","sy","sydney","systems","sz","tab","taipei","talk","taobao","target","tatamotors","tatar","tattoo","tax","taxi","tc","tci","td","tdk","team","tech","technology","tel","temasek","tennis","teva","tf","tg","th","thd","theater","theatre","tiaa","tickets","tienda","tiffany","tips","tires","tirol","tj","tjmaxx","tjx","tk","tkmaxx","tl","tm","tmall","tn","to","today","tokyo","tools","top","toray","toshiba","total","tours","town","toyota","toys","tr","trade","trading","training","travel","travelchannel","travelers","travelersinsurance","trust","trv","tt","tube","tui","tunes","tushu","tv","tvs","tw","tz","ua","ubank","ubs","ug","uk","unicom","university","uno","uol","ups","us","uy","uz","va","vacations","vana","vanguard","vc","ve","vegas","ventures","verisign","vermögensberater","vermögensberatung","versicherung","vet","vg","vi","viajes","video","vig","viking","villas","vin","vip","virgin","visa","vision","viva","vivo","vlaanderen","vn","vodka","volkswagen","volvo","vote","voting","voto","voyage","vu","vuelos","wales","walmart","walter","wang","wanggou","watch","watches","weather","weatherchannel","webcam","weber","website","wed","wedding","weibo","weir","wf","whoswho","wien","wiki","williamhill","win","windows","wine","winners","wme","wolterskluwer","woodside","work","works","world","wow","ws","wtc","wtf","xbox","xerox","xfinity","xihuan","xin","xxx","xyz","yachts","yahoo","yamaxun","yandex","ye","yodobashi","yoga","yokohama","you","youtube","yt","yun","za","zappos","zara","zero","zip","zm","zone","zuerich","zw","ελ","ευ","бг","бел","дети","ею","католик","ком","мкд","мон","москва","онлайн","орг","рус","рф","сайт","срб","укр","қаз","հայ","ישראל","קום","ابوظبي","اتصالات","ارامكو","الاردن","البحرين","الجزائر","السعودية","العليان","المغرب","امارات","ایران","بارت","بازار","بيتك","بھارت","تونس","سودان","سورية","شبكة","عراق","عرب","عمان","فلسطين","قطر","كاثوليك","كوم","مصر","مليسيا","موريتانيا","موقع","همراه","پاکستان","ڀارت","कॉम","नेट","भारत","भारतम्","भारोत","संगठन","বাংলা","ভারত","ভাৰত","ਭਾਰਤ","ભારત","ଭାରତ","இந்தியா","இலங்கை","சிங்கப்பூர்","భారత్","ಭಾರತ","ഭാരതം","ලංකා","คอม","ไทย","ລາວ","გე","みんな","アマゾン","クラウド","グーグル","コム","ストア","セール","ファッション","ポイント","世界","中信","中国","中國","中文网","亚马逊","企业","佛山","信息","健康","八卦","公司","公益","台湾","台灣","商城","商店","商标","嘉里","嘉里大酒店","在线","大拿","天主教","娱乐","家電","广东","微博","慈善","我爱你","手机","招聘","政务","政府","新加坡","新闻","时尚","書籍","机构","淡马锡","游戏","澳門","点看","移动","组织机构","网址","网店","网站","网络","联通","谷歌","购物","通販","集团","電訊盈科","飞利浦","食品","餐厅","香格里拉","香港","닷넷","닷컴","삼성","한국"];Object.defineProperty(F2,"__esModule",{value:!0});var As=Ts,ks=Ln(As),Ds=Es,Rs=Ln(Ds);function Ln(e){return e&&e.__esModule?e:{default:e}}var Hn=new ks.default;Hn.tlds(Rs.default);F2.default=function(e){return Hn.match(e)};var P2={};Object.defineProperty(P2,"__esModule",{value:!0});P2.default=function(e){return e};Object.defineProperty(k2,"__esModule",{value:!0});var Fs=function(){function e(t,a){for(var r=0;r<a.length;r++){var o=a[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(t,a,r){return a&&e(t.prototype,a),r&&e(t,r),t}}(),Ps=u,xe=Ms(Ps),Zs=D2,Is=At(Zs),js=R2,Os=At(js),$s=F2,Bs=At($s),zs=P2,Vs=At(zs);function At(e){return e&&e.__esModule?e:{default:e}}function Ms(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t.default=e,t}function Ls(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Hs(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t&&(typeof t=="object"||typeof t=="function")?t:e}function Ws(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var Wn=function(e){Ws(t,e);function t(){return Ls(this,t),Hs(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return Fs(t,[{key:"parseString",value:function(r){var o=this;if(r==="")return r;var i=this.props.matchDecorator(r);if(!i)return r;var s=[],c=0;return i.forEach(function(d,p){d.index>c&&s.push(r.substring(c,d.index));var m=o.props.hrefDecorator(d.url),g=o.props.textDecorator(d.text),f=o.props.componentDecorator(m,g,p);s.push(f),c=d.lastIndex}),r.length>c&&s.push(r.substring(c)),s.length===1?s[0]:s}},{key:"parse",value:function(r){var o=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return typeof r=="string"?this.parseString(r):xe.isValidElement(r)&&r.type!=="a"&&r.type!=="button"?xe.cloneElement(r,{key:i},this.parse(r.props.children)):Array.isArray(r)?r.map(function(s,c){return o.parse(s,c)}):r}},{key:"render",value:function(){return xe.createElement(xe.Fragment,null,this.parse(this.props.children))}}]),t}(xe.Component);Wn.defaultProps={componentDecorator:Is.default,hrefDecorator:Os.default,matchDecorator:Bs.default,textDecorator:Vs.default};k2.default=Wn;Object.defineProperty(Vn,"__esModule",{value:!0});var Ns=k2,qs=Us(Ns);function Us(e){return e&&e.__esModule?e:{default:e}}var Gs=Vn.default=qs.default;const Ks=h(E)(({theme:e})=>({display:"flex",marginTop:e.spacing(2)})),Js=h(L1)(({theme:e})=>({width:"100%",padding:e.spacing(1.5,3,2.5,3),backgroundColor:e.palette.neutral.light,borderRadius:e.shape.borderRadiusLarge,borderColor:e.palette.divider})),Ys=h(E)(({theme:e})=>({display:"flex",borderBottom:"1px solid",borderColor:e.palette.divider,paddingBottom:e.spacing(1.5)})),Qs=({comment:e})=>l(Ks,{children:[n(Y1,{title:e.createdBy.username,children:n(ea,{src:e.createdBy.imageUrl})}),l(Js,{variant:"outlined",children:[n(Ys,{children:l(E,{children:[n("strong",{children:e.createdBy.username})," ",l($,{color:"text.secondary",component:"span",children:["commented"," ",n(m2,{minPeriod:60,date:new Date(e.createdAt)})]})]})}),n(E,{sx:{paddingTop:2.5},children:n(Gs,{children:e.text})})]})]}),Xs=h(E)(({theme:e})=>({width:"30%",display:"flex",flexDirection:"column",[e.breakpoints.down("sm")]:{width:"100%"}})),ec=h(L1)(({theme:e})=>({marginTop:e.spacing(2),marginLeft:e.spacing(2),width:"70%",padding:e.spacing(1,2),borderRadius:e.shape.borderRadiusLarge,[e.breakpoints.down("sm")]:{marginLeft:0,width:"100%"}})),tc=h(E)(({theme:e})=>({marginTop:e.spacing(3),display:"flex",justifyContent:"flex-end"})),nc=h(E)(({theme:e})=>({padding:e.spacing(2)})),ac=h(E)(({theme:e})=>({display:"flex",[e.breakpoints.down("sm")]:{flexDirection:"column"}})),rc=()=>{var B,V;const e=Y("projectId"),[t,a]=u.useState(!1),{user:r}=mn(),{isAdmin:o}=u.useContext(X1),[i,s]=u.useState(""),c=Y("id"),{data:d,refetchChangeRequest:p}=Pn(e,c),{changeState:m,addComment:g,loading:f}=Ze(),{refetch:C}=je(e),{setToastData:S,setToastApiError:b}=u1(),{isChangeRequestConfigured:R}=Ie(e);if(!d)return null;const v=R(d.environment),F=async()=>{try{await m(e,Number(c),{state:"Applied"}),p(),C(),S({type:"success",title:"Success",text:"Changes applied"})}catch(O){b(h1(O))}},T=async()=>{try{await g(e,c,i),s(""),p(),S({type:"success",title:"Success",text:"Comment added"})}catch(O){b(h1(O))}},j=async()=>{try{await m(e,Number(c),{state:"Cancelled"}),a(!1),p(),C(),S({type:"success",title:"Success",text:"Changes cancelled"})}catch(O){b(h1(O))}},M=()=>a(!0),_=()=>a(!1),D=(d==null?void 0:d.createdBy.id)===(r==null?void 0:r.id)&&d.state==="In review"&&!o,P=d.approvals.some(O=>O.createdBy.id===(r==null?void 0:r.id));return l(G,{children:[n(Ki,{changeRequest:d}),l(ac,{children:[l(Xs,{children:[n(I4,{state:d.state}),n(z4,{header:n(B4,{actualApprovals:d.approvals.length,minApprovals:d.minApprovals}),children:(B=d.approvals)==null?void 0:B.map(O=>n(os,{name:O.createdBy.username||"Unknown user",imageUrl:O.createdBy.imageUrl},O.createdBy.username))})]}),n(ec,{elevation:0,children:l(nc,{children:["Requested Changes (",ta(d),")",n(na,{changeRequest:d,onRefetch:p}),(V=d.comments)==null?void 0:V.map(O=>n(Qs,{comment:O},O.id)),n(aa,{user:r,commentText:i,onTypeComment:s,children:n(l1,{variant:"outlined",onClick:T,disabled:!v||i.trim().length===0||i.trim().length>1e3,children:"Comment"})}),n(w,{condition:D,show:n(w1,{sx:O=>({marginTop:O.spacing(1.5)}),severity:"info",children:"You can not approve your own change request"})}),n(q4,{changeRequest:d}),l(tc,{children:[n(w,{condition:d.state==="In review"&&!P,show:n(ns,{disabled:!v})}),n(w,{condition:d.state==="Approved",show:n(_t,{variant:"contained",onClick:F,projectId:e,permission:ra,environmentId:d.environment,disabled:!v||f,children:"Apply changes"})}),n(w,{condition:d.state!=="Applied"&&d.state!=="Cancelled"&&(d.createdBy.id===(r==null?void 0:r.id)||o),show:n(l1,{sx:{marginLeft:O=>O.spacing(2)},variant:"outlined",onClick:M,children:"Cancel changes"})})]})]})}),l(G1,{open:t,onClick:j,onClose:_,title:"Cancel change request",children:[n($,{sx:{marginBottom:2},children:"You are about to cancel this change request"}),n($,{variant:"body2",sx:O=>({color:O.palette.neutral.dark}),children:"The change request will be moved to closed, and it can't be applied anymore. Once cancelled, the change request can't be reopened."})]})]})]})},oc=({value:e})=>{const t=()=>e?n(un,{state:e}):null;return e?n(o1,{children:t()}):n(o1,{})},ic=h("div")(({theme:e})=>({display:"flex",flexDirection:"row",alignItems:"center",margin:0})),sc=({value:e})=>n(o1,{children:n(ic,{children:l($,{component:"span",variant:"body2",children:[" ",e==null?void 0:e.username]})})}),cc=h("div")(({theme:e})=>({display:"flex",flexDirection:"row",margin:0})),lc=({value:e,row:{original:t}})=>{const a=Y("projectId"),{id:r,title:o,features:i}=t,s=`/projects/${a}/change-requests/${r}`;return e?l(o1,{sx:{minWidth:"200px"},children:[n(cc,{children:n($,{variant:"body2",children:n(p2,{component:R1,underline:"hover",to:s,sx:c=>({paddingTop:c.spacing(.2),marginRight:c.spacing(1),"&:hover":{textDecoration:"underline"}}),children:o})})}),l("span",{children:[`${i==null?void 0:i.length}`," ",i.length<=1?"update":"updates"]})]}):n(o1,{})},dc=U3()(e=>({header:{padding:e.spacing(0,4)},bodyClass:{padding:e.spacing(4),overflowX:"auto"}})),uc=h(E)(({theme:e})=>({display:"flex",flexDirection:"column",width:"300px",padding:e.spacing(1,0,1,2)})),pc=h(R1)(({theme:e})=>({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}})),hc=h(R1)(({theme:e})=>({textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}})),mc=h(E)(({theme:e})=>({display:"flex",flexDirection:"column",fontSize:e.fontSizes.smallBody,width:"100%",whiteSpace:"nowrap"})),gc=({value:e,project:t})=>{const a=e==null?void 0:e.map(r=>r.name);return n(uc,{children:n(w,{condition:(a==null?void 0:a.length)<3,show:a==null?void 0:a.map(r=>n(pc,{title:r,to:`/projects/${t}/features/${r}`,children:r})),elseShow:l(gn,{tooltipProps:{maxWidth:"800px"},tooltip:n(mc,{children:a==null?void 0:a.map(r=>n(hc,{title:r,to:`/projects/${t}/features/${r}`,children:r}))}),children:[a==null?void 0:a.length," toggles"]})})})},fc={id:"createdAt"},vc=h("div")({paddingLeft:0,paddingBottom:0}),yc=h(et)(({theme:e})=>({textTransform:"none",width:"auto",fontSize:e.fontSizes.bodySize,[e.breakpoints.up("md")]:{minWidth:160}})),bc=({changeRequests:e=[],loading:t,projectId:a})=>{var N,L;const{classes:r}=dc(),o=b1(oa.breakpoints.down("md")),[i,s]=h2(),[c,d]=u.useState(i.get("search")||""),{value:p,setValue:m}=pt(`${a}:ProjectChangeRequest`,fc),[g,f]=u.useMemo(()=>{const y=e.filter(I=>I.state!=="Cancelled"&&I.state!=="Applied"),k=e.filter(I=>I.state==="Cancelled"||I.state==="Applied");return[y,k]},[e]),C=[{title:"Change requests",data:g},{title:"Closed",data:f}],[S,b]=u.useState(0),R=u.useMemo(()=>[{id:"Title",Header:"Title",width:100,canSort:!0,accessor:"title",searchable:!0,Cell:lc},{id:"Updated feature toggles",Header:"Updated feature toggles",canSort:!1,accessor:"features",Cell:({value:y,row:{original:{title:k}}})=>n(gc,{project:a,value:y},k)},{Header:"By",accessor:"createdBy",maxWidth:180,canSort:!1,Cell:sc,align:"left"},{Header:"Submitted",accessor:"createdAt",searchable:!0,maxWidth:100,Cell:tt,sortType:"alphanumeric"},{Header:"Environment",accessor:"environment",searchable:!0,maxWidth:100,Cell:o1},{Header:"Status",accessor:"state",searchable:!0,maxWidth:"170px",Cell:oc}],[a]),{data:v,getSearchText:F,getSearchContext:T}=yt(R,c,(N=C[S])==null?void 0:N.data),j=u.useMemo(()=>t?ia:v,[v,t]),[M]=u.useState(()=>({sortBy:[{id:i.get("sort")||p.id,desc:i.has("order")?i.get("order")==="desc":p.desc}],hiddenColumns:[]})),{headerGroups:_,rows:D,state:{sortBy:P},prepareRow:B,setHiddenColumns:V,getTableProps:O,getTableBodyProps:J}=t1.useTable({columns:R,data:j,initialState:M,sortTypes:Oe,autoResetHiddenColumns:!1,disableSortRemove:!0,autoResetSortBy:!1,defaultColumn:{Cell:o1}},t1.useSortBy);return Ct([{condition:o,columns:["createdBy"]}],V,R),u.useEffect(()=>{if(t)return;const y={};y.sort=P[0].id,P[0].desc&&(y.order="desc"),c&&(y.search=c),s(y,{replace:!0}),m(k=>({...k,id:P[0].id,desc:P[0].desc||!1}))},[t,P,c,s]),l(d1,{isLoading:t,bodyClass:r.bodyClass,headerClass:r.header,header:n(i1,{titleElement:n(vc,{children:n(g2,{value:(L=C[S])==null?void 0:L.title,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:C.map((y,k)=>n(yc,{label:`${y.title} (${y.data.length})`,value:y.title,onClick:()=>b(k)},y.title))})}),actions:n(D1,{initialValue:c,onChange:d,hasFilters:!0,getSearchContext:T})}),children:[n(ue,{value:F(c),children:l(st,{...O(),children:[n(ct,{headerGroups:_}),n(lt,{...J(),children:D.map(y=>(B(y),n(dt,{hover:!0,...y.getRowProps(),children:y.cells.map(k=>n(ut,{...k.getCellProps(),padding:"none",children:k.render("Cell")}))})))})]})}),n(w,{condition:D.length===0,show:()=>n(w,{condition:(c==null?void 0:c.length)>0,show:l(S1,{children:["No changes found matching “",c,"”"]}),elseShow:n(S1,{children:"None of the changes were submitted yet."})})})]})},Cc=()=>{const e=Y("projectId"),t=F1(e),{isOss:a,isPro:r}=p1();x1(`Change requests – ${t}`);const{changeRequests:o,loading:i}=kn(e);return a()||r()?n(d1,{sx:{justifyContent:"center"},children:n(wt,{feature:"change-requests"})}):n(bc,{changeRequests:o,projectId:e,loading:i})};var K=(e=>(e.USER="USERS",e.GROUP="GROUPS",e.SERVICE_ACCOUNT="SERVICE ACCOUNTS",e))(K||{});const ye=(e,t={})=>{const a=K1(`api/admin/projects/${e}/access`),r=()=>fetch(a,{method:"GET"}).then(J1("project access")).then(g=>g.json()),o=`api/admin/projects/${e}/users`,{data:i,error:s}=de(o,r,t),[c,d]=u.useState(!s&&!i),p=()=>{on(o)};return u.useEffect(()=>{d(!s&&!i)},[i,s]),{access:u.useMemo(()=>{if(i)return Sc({roles:i.roles,users:i.users.filter(({accountType:g})=>!g||g==="User"),serviceAccounts:i.users.filter(({accountType:g})=>g==="Service Account"),groups:(i==null?void 0:i.groups.map(g=>({...g,users:hr(g.users??[])})))??[]})},[i]),error:s,loading:c,refetchProjectAccess:p}},Sc=e=>{const t=e.users||[],a=e.serviceAccounts||[],r=e.groups||[];return{...e,rows:[...t.map(o=>({entity:o,type:"USERS"})),...a.map(o=>({entity:o,type:"SERVICE ACCOUNTS"})),...r.map(o=>({entity:o,type:"GROUPS"}))]}},_c=h(d1)(({theme:e})=>({height:"100vh",overflow:"auto",padding:e.spacing(7.5,6),[e.breakpoints.down("md")]:{padding:e.spacing(4,2)},"& .header":{padding:e.spacing(0,0,2,0)},"& .body":{padding:e.spacing(3,0,0,0)},borderRadius:`${e.spacing(1.5,0,0,1.5)} !important`})),wc=h("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span":{color:e.palette.text.secondary,fontSize:e.fontSizes.bodySize}})),f3={id:"joinedAt"},Ht=[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:e}})=>n(o1,{children:n(v2,{user:e})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:e=>e.name||"",Cell:Ae,minWidth:100,searchable:!0},{id:"username",Header:"Username",accessor:e=>e.username||e.email,Cell:Ae,minWidth:100,searchable:!0},{id:"joined",Header:"Joined",accessor:"joinedAt",Cell:vt,sortType:"date",maxWidth:150},{id:"lastLogin",Header:"Last login",accessor:e=>e.seenAt||"",Cell:({row:{original:e}})=>n(tt,{value:e.seenAt,emptyText:"Never",title:t=>`Last login: ${t}`}),sortType:"date",maxWidth:150}],xc=["imageUrl","name","joined","lastLogin"],Tc=({open:e,setOpen:t,group:a,projectId:r,subtitle:o,onEdit:i,onRemove:s})=>{const c=m1(),d=b1(c.breakpoints.down("md")),[p]=u.useState(()=>({sortBy:[{id:f3.id,desc:f3.desc}]})),[m,g]=u.useState(""),{data:f,getSearchText:C,getSearchContext:S}=yt(Ht,m,(a==null?void 0:a.users)??[]),{headerGroups:b,rows:R,prepareRow:v,setHiddenColumns:F}=t1.useTable({columns:Ht,data:f,initialState:p,sortTypes:Oe,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},t1.useSortBy,t1.useFlexLayout);return Ct([{condition:d,columns:xc}],F,Ht),n(U1,{open:e,onClose:()=>{t(!1)},label:(a==null?void 0:a.name)||"Group",children:l(_c,{header:n(i1,{secondary:!0,titleElement:l(wc,{children:[a==null?void 0:a.name," (",R.length<f.length?`${R.length} of ${f.length}`:f.length,")",n("span",{children:o})]}),actions:l(G,{children:[n(w,{condition:!d,show:l(G,{children:[n(D1,{initialValue:m,onChange:g,hasFilters:!0,getSearchContext:S}),n(i1.Divider,{})]})}),n(z1,{permission:k1,projectId:r,tooltipProps:{title:"Edit group access"},onClick:i,children:n(xt,{})}),n(z1,{permission:k1,projectId:r,tooltipProps:{title:"Remove group access"},onClick:s,children:n(f2,{})})]}),children:n(w,{condition:d,show:n(D1,{initialValue:m,onChange:g,hasFilters:!0,getSearchContext:S})})}),children:[n(ue,{value:C(m),children:n(bt,{rows:R,headerGroups:b,prepareRow:v})}),n(w,{condition:R.length===0,show:n(w,{condition:(m==null?void 0:m.length)>0,show:l(S1,{children:["No users found matching “",m,"” in this group."]}),elseShow:n(S1,{children:"This group is empty. Get started by adding a user to the group."})})})]})})},Ec=({permissions:e})=>n(G,{children:e==null?void 0:e.filter(t=>!t.environment).map(t=>t.displayName).sort().map(t=>n("p",{children:t},t))}),Ac=({environment:e,permissions:t})=>n(G,{children:[...new Set(t.filter(a=>a.environment===e).map(a=>a.displayName))].sort().map(a=>n("p",{children:a},`${e}-${a}`))}),kc=h("div",{shouldForwardProp:e=>e!=="roleId"&&e!=="popover"&&e!=="sx"})(({theme:e,popover:t})=>({width:"100%",maxWidth:e.spacing(50),padding:e.spacing(3),backgroundColor:t?e.palette.background.paper:e.palette.neutral.light,color:e.palette.text.secondary,fontSize:e.fontSizes.smallBody,borderRadius:e.shape.borderRadiusMedium})),Wt=h("div")(({theme:e})=>({"& p:last-child":{marginBottom:e.spacing(2)}})),v3=h("p")(({theme:e})=>({color:e.palette.text.primary,fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.bold,marginBottom:e.spacing(2)})),y3=h("p")(({theme:e})=>({color:e.palette.text.primary,fontSize:e.fontSizes.smallBody,marginBottom:e.spacing(1)})),Nn=u.forwardRef(({roleId:e,projectId:t,className:a,sx:r,...o},i)=>{var g;const{role:s}=mr(e.toString()),{access:c}=ye(t),d=c==null?void 0:c.roles.find(f=>f.id===e),p=u.useMemo(()=>{var C;const f=new Set;return(C=s.permissions)==null||C.filter(S=>S.environment).forEach(S=>{f.add(S.environment)}),[...f].sort()},[s]),m=u.useMemo(()=>{var f;return(f=s.permissions)==null?void 0:f.filter(C=>!C.environment)},[s]);return n(kc,{className:a,sx:r,...o,ref:i,children:n(w,{condition:((g=s.permissions)==null?void 0:g.length)>0,show:l(G,{children:[n(w,{condition:!!(m!=null&&m.length),show:l(G,{children:[n(v3,{children:"Project permissions"}),n(Wt,{children:n(Ec,{permissions:s.permissions})})]})}),n(w,{condition:!!p.length,show:l(G,{children:[n(v3,{children:"Environment permissions"}),p.map(f=>l("div",{children:[n(y3,{children:f}),n(Wt,{children:n(Ac,{environment:f,permissions:s.permissions})})]},f))]})})]}),elseShow:l(G,{children:[n(y3,{children:d==null?void 0:d.name}),n(Wt,{children:d==null?void 0:d.description})]})})})}),Dc=h("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),b3=h("p")(({theme:e})=>({color:e.palette.text.secondary,marginBottom:e.spacing(1)})),C3=h("div")(({theme:e})=>({"& > div:first-of-type":{width:"100%",maxWidth:e.spacing(50),marginBottom:e.spacing(2)}})),Rc=h("div")(({theme:e})=>({marginTop:e.spacing(6),display:"flex",justifyContent:"flex-end"})),Fc=h(l1)(({theme:e})=>({marginLeft:e.spacing(3)})),Pc=h("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span:last-of-type":{color:e.palette.text.secondary}})),Zc=h("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span:first-of-type":{color:e.palette.text.secondary}})),Ic=h("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span:last-of-type":{fontSize:e.fontSizes.smallerBody,color:e.palette.text.secondary}})),Z2=({selected:e,accesses:t,users:a,serviceAccounts:r,groups:o,roles:i})=>{const{uiConfig:s}=p1(),{flags:c}=s,d=c.UG?"user / group":"user",p=Y("projectId"),{refetchProjectAccess:m}=ye(p),{addAccessToProject:g,changeUserRole:f,changeGroupRole:C,loading:S}=De(),b=!!e,{setToastData:R,setToastApiError:v}=u1(),F=T1(),T=[...o.filter(y=>b||!t.some(({entity:{id:k},type:I})=>y.id===k&&I===K.GROUP)).map(y=>({id:y.id,entity:y,type:K.GROUP})),...a.filter(y=>b||!t.some(({entity:{id:k},type:I})=>y.id===k&&I===K.USER)).sort((y,k)=>{const I=y.name||y.username||"",q=k.name||k.username||"";return I.localeCompare(q)}).map(y=>({id:y.id,entity:y,type:K.USER})),...r.filter(y=>b||!t.some(({entity:{id:k},type:I})=>y.id===k&&I===K.SERVICE_ACCOUNT)).sort((y,k)=>{const I=y.name||y.username||"",q=k.name||k.username||"";return I.localeCompare(q)}).map(y=>({id:y.id,entity:y,type:K.SERVICE_ACCOUNT}))],[j,M]=u.useState(()=>T.filter(({id:y,type:k})=>y===(e==null?void 0:e.entity.id)&&k===(e==null?void 0:e.type))),[_,D]=u.useState(i.find(({id:y})=>y===(e==null?void 0:e.entity.roleId))??null),P={users:j==null?void 0:j.filter(({type:y})=>y===K.USER||y===K.SERVICE_ACCOUNT).map(({id:y})=>({id:y})),groups:j==null?void 0:j.filter(({type:y})=>y===K.GROUP).map(({id:y})=>({id:y}))},B=async y=>{if(y.preventDefault(),!!L)try{b?(e==null?void 0:e.type)===K.USER||(e==null?void 0:e.type)===K.SERVICE_ACCOUNT?await f(p,_.id,e.entity.id):(e==null?void 0:e.type)===K.GROUP&&await C(p,_.id,e.entity.id):await g(p,_.id,P),m(),F(V1),R({title:`${j.length} ${j.length===1?"access":"accesses"} ${b?"edited":"assigned"} successfully`,type:"success"})}catch(k){v(h1(k))}},V=()=>b?`curl --location --request ${b?"PUT":"POST"} '${s.unleashUrl}/api/admin/projects/${p}/${(e==null?void 0:e.type)===K.USER||(e==null?void 0:e.type)===K.SERVICE_ACCOUNT?"users":"groups"}/${e==null?void 0:e.entity.id}/roles/${_==null?void 0:_.id}' \\
3
3
  --header 'Authorization: INSERT_API_KEY'`:`curl --location --request ${b?"PUT":"POST"} '${s.unleashUrl}/api/admin/projects/${p}/role/${_==null?void 0:_.id}/access' \\
4
4
  --header 'Authorization: INSERT_API_KEY' \\