unleash-server 5.8.0 → 5.8.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 (48) hide show
  1. package/dist/lib/features/scheduler/scheduler-service.d.ts.map +1 -1
  2. package/dist/lib/features/scheduler/scheduler-service.js +2 -2
  3. package/dist/lib/features/scheduler/scheduler-service.js.map +1 -1
  4. package/dist/lib/features/scheduler/scheduler-service.test.js +9 -24
  5. package/dist/lib/features/scheduler/scheduler-service.test.js.map +1 -1
  6. package/dist/lib/metrics.d.ts +2 -0
  7. package/dist/lib/metrics.d.ts.map +1 -1
  8. package/dist/lib/metrics.js +48 -18
  9. package/dist/lib/metrics.js.map +1 -1
  10. package/dist/lib/metrics.test.js +25 -1
  11. package/dist/lib/metrics.test.js.map +1 -1
  12. package/dist/lib/routes/admin-api/api-token.d.ts.map +1 -1
  13. package/dist/lib/routes/admin-api/api-token.js +1 -1
  14. package/dist/lib/routes/admin-api/api-token.js.map +1 -1
  15. package/dist/lib/routes/admin-api/project/api-token.d.ts.map +1 -1
  16. package/dist/lib/routes/admin-api/project/api-token.js +1 -1
  17. package/dist/lib/routes/admin-api/project/api-token.js.map +1 -1
  18. package/dist/lib/services/scheduler-service.test.js +6 -8
  19. package/dist/lib/services/scheduler-service.test.js.map +1 -1
  20. package/dist/lib/util/extract-user.d.ts +1 -0
  21. package/dist/lib/util/extract-user.d.ts.map +1 -1
  22. package/dist/lib/util/extract-user.js +6 -3
  23. package/dist/lib/util/extract-user.js.map +1 -1
  24. package/dist/lib/util/extract-user.test.js +7 -4
  25. package/dist/lib/util/extract-user.test.js.map +1 -1
  26. package/frontend/build/index.html +1 -1
  27. package/frontend/build/static/{AdvancedPlayground-iXZHz_Rq.js → AdvancedPlayground-FxfPUa2V.js} +1 -1
  28. package/frontend/build/static/{CreateProject-BbtWHPl8.js → CreateProject-aN-UGdcb.js} +1 -1
  29. package/frontend/build/static/{FeatureArchiveDialog-D_tZ06Sa.js → FeatureArchiveDialog-eHyhx7Yo.js} +1 -1
  30. package/frontend/build/static/{FeatureMetricsChart-SiwdLhRh.js → FeatureMetricsChart-ExGq1eXl.js} +1 -1
  31. package/frontend/build/static/{FeatureViewLazyExport-baWLSkEu.js → FeatureViewLazyExport-S8mj8m0z.js} +2 -2
  32. package/frontend/build/static/{LazyAdminExport-ckQgco28.js → LazyAdminExport-fpVZFnP9.js} +2 -2
  33. package/frontend/build/static/{LazyProjectExport-R4jiFkLZ.js → LazyProjectExport-_QSE5C5m.js} +1 -1
  34. package/frontend/build/static/{NetworkOverview-StnrlVkY.js → NetworkOverview-ylTzmeDg.js} +2 -2
  35. package/frontend/build/static/{NetworkTraffic-V87e4GGP.js → NetworkTraffic-qj5h7JRk.js} +1 -1
  36. package/frontend/build/static/{ReactJSONEditor-Ybg5ijJk.js → ReactJSONEditor-E59dRBYR.js} +1 -1
  37. package/frontend/build/static/{RoleCell-3lnoYolp.js → RoleCell-TGTVkKHO.js} +1 -1
  38. package/frontend/build/static/{StrategyItemContainer-wRkYMo4g.js → StrategyItemContainer-JoMPKX3L.js} +1 -1
  39. package/frontend/build/static/{chartjs-adapter-date-fns.esm-kkU_hxq-.js → chartjs-adapter-date-fns.esm-JSlDxtwH.js} +1 -1
  40. package/frontend/build/static/{flowchart-elk-definition-170a3958-vkzW0gdf.js → flowchart-elk-definition-170a3958-NkZoK_zv.js} +1 -1
  41. package/frontend/build/static/{index-ORDXjnpF.js → index-JVRlSBvr.js} +64 -64
  42. package/frontend/build/static/{is_dark-zSU9-MOM.js → is_dark-gjUQW15t.js} +1 -1
  43. package/frontend/build/static/{mindmap-definition-44684416-2v9fPc7w.js → mindmap-definition-44684416-obuYUG0L.js} +1 -1
  44. package/frontend/build/static/{timeline-definition-8e5a9bc6-RDFfY8I3.js → timeline-definition-8e5a9bc6-33WsNwwr.js} +1 -1
  45. package/frontend/build/static/{unknownify-vwm75Pg9.js → unknownify-YD2Teyht.js} +1 -1
  46. package/frontend/build/static/{useApiTokens-T6gzMZPt.js → useApiTokens-XTOY616x.js} +1 -1
  47. package/frontend/build/static/{useProjectForm-o3r31UMh.js → useProjectForm--jxh4Dtm.js} +1 -1
  48. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{c as C5,j as t,eL as n8,eM as x4,eN as s8,s as d,cN as r8,cK as p2,a5 as F5,r as c,eO as o8,ab as h1,a3 as t1,a6 as R5,a7 as P5,a8 as Z5,a9 as I5,v as j4,b7 as I1,J as x1,aN as r5,aO as G1,aP as K1,eP as y4,aE as q,eQ as o5,cf as M1,e as p1,cF as k1,az as d5,ax as i1,eR as a8,ae as b2,dc as V3,eS as v4,eT as b1,au as n1,ao as V1,at as a1,C as V,aK as _1,aq as u5,ap as f1,cI as i8,ai as S2,eU as l8,ba as p5,bb as h5,B as w,t as S1,x as H1,bg as c8,a1 as O5,bW as $5,M as N1,eV as t2,b3 as W1,d as w2,eW as C8,b5 as U1,T as L,eX as j5,cQ as V2,cR as b4,aJ as _2,cU as d8,ah as R1,D as _3,l as B5,b as r1,ac as u1,eY as S4,eZ as w4,aj as v1,h as m1,e_ as u8,e$ as p8,bI as h8,g as d1,c5 as g8,c4 as H2,bU as E2,c6 as V4,aV as M2,a_ as g5,aW as T2,f0 as A2,cB as q1,dG as H3,bR as m8,ay as D1,ak as E3,f1 as f8,cL as _4,f2 as m3,f3 as H4,f4 as E4,f5 as M4,f6 as M3,am as T4,f7 as A4,f8 as x8,f9 as j8,dq as z5,an as k2,dr as y8,cJ as k4,c9 as T3,ag as D2,fa as D4,X as v8,aM as b8,b6 as S8,al as L2,fb as w8,y as J1,fc as L4,P as F4,fd as R4,z as V8,fe as _8,cg as F2,ff as H8,fg as E8,fh as M8,fi as A5,fj as Y2,fk as T8,fl as d6,fm as A8,fn as k8,fo as D8,fp as L8,fq as P4,fr as F8,fs as R8,ft as P8,fu as Z8,fv as u6,fw as I8,fx as O8,fy as $8,aQ as A3,fz as k3,fA as Z4,a0 as B8,cO as I4,fB as z8,c0 as O4,fC as $4,fD as B4,fE as N8,fF as W8,fG as U8,a4 as N5,af as W5,aG as q8,fH as G8,fI as R2,fJ as K8,fK as z4,fL as J8,fM as Y8,fN as b5,fO as m5,aH as Y1,cV as S5,fP as w5,fQ as V5,fR as Q8,b_ as P2,fS as D3,E as L3,c8 as F3,fT as N4,aL as Z2,fU as X8,br as Q1,aw as W4,bH as a5,fV as e9,fW as t9,fX as n9,k as U5,fY as I2,fZ as s9,f_ as r9,f$ as o9,g0 as a9,dX as R3,dY as h2,bq as i9,cA as U4,dO as g2,g1 as l9,cT as P3,dj as q5,cj as c5,aI as y5,bX as q4,dA as Z3,A as G4,dI as c9,m as K4,n as J4,aD as s5,aA as G5,g2 as C9,g3 as d9,dE as n2,g4 as u9,g5 as p9,g6 as h9,g7 as g9,g8 as m9,ch as _5,ci as e1,g9 as f9,ga as p6,gb as Y4,u as I3,aB as x9,gc as j9,df as y9,gd as h6,ge as v9,gf as b9,gg as S9,gh as w9,gi as V9,bm as _9,bn as H9,bN as E9,bO as M9,bP as T9,bQ as A9,R as k9,gj as D9,cb as L9,gk as F9,w as g6,co as R9,gl as P9,gm as Q4,cM as X4,eF as e7,gn as Z9,dy as t7,go as v5,gp as X,gq as I9,gr as O9,gs as $9,gt as B9,cu as n7,gu as z9,G as c2,bt as N9,gv as W9,gw as U9,gx as q9}from"./index-ORDXjnpF.js";import{e as O3,W as m6,c as G9,b as s7,T as K9,d as J9,F as r7,V as o7,a as a7,f as i7,E as Y9}from"./FeatureArchiveDialog-D_tZ06Sa.js";import{h as Q9,m as X9,i as f6,b as ee,c as te,d as ne,e as se,E as re,f as oe,u as ae,a as ie,R as le,C as ce,A as Ce}from"./RoleCell-3lnoYolp.js";import{S as de}from"./StrategyItemContainer-wRkYMo4g.js";import{C as ue,u as pe,P as he,D as ge}from"./useProjectForm-o3r31UMh.js";const me=C5(t.jsx("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"}),"ArrowUpward"),fe=C5(t.jsx("path",{d:"M9 5v2h6.59L4 18.59 5.41 20 17 8.41V15h2V5z"}),"CallMade"),xe=C5(t.jsx("path",{d:"M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"}),"FileUpload"),je=C5(t.jsx("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"),ye=C5(t.jsx("path",{d:"M12 5.99 19.53 19H4.47L12 5.99M12 2 1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),ve=C5([t.jsx("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"},"0"),t.jsx("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")],"Schedule"),be=C5(t.jsx("path",{d:"M19 9h-2v6.59L5.41 4 4 5.41 15.59 17H9v2h10V9z"}),"SouthEast");function Se(e,n){n8(2,arguments);var s=s8(n);return x4(e,-s)}const x6=d("div")(()=>({display:"flex"})),we=d("div")(()=>({display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%"}));d("div")(()=>({display:"flex",flexDirection:"column"}));const Ve=d("span")(({theme:e})=>({fontSize:e.typography.h1.fontSize,textOverflow:"ellipsis",whiteSpace:"nowrap"})),_e=d("span")(({theme:e})=>({fontSize:e.fontSizes.smallBody,fontWeight:"normal"}));d(_e)(({theme:e})=>({color:e.palette.neutral.dark}));const He=d(r8)(({theme:e})=>({marginLeft:e.spacing(-1.5)})),Ee=d("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),Me=d("div")(({theme:e})=>({padding:e.spacing(2.5,5),display:"flex",flexDirection:"column",alignItems:"start"})),Te=d("span")(({theme:e})=>({margin:0,width:"100%",fontSize:e.fontSizes.mainHeader,fontWeight:"bold",display:"flex",justifyContent:"space-between",alignItems:"center",gap:e.spacing(2)})),Ae=d("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.divider,height:"1px"})),ke=d("div")(({theme:e})=>({padding:e.spacing(0,4)})),De=d(p2)(({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}})),Le=e=>e.reduce((n,s)=>s.enabled?n+1:n,0),Fe=d(F5)(({theme:e})=>({marginTop:e.spacing(3)})),Re=d("p",{shouldForwardProp:e=>e!=="warning"})(({theme:e,warning:n})=>({color:n?e.palette.error.dark:e.palette.text.primary,textAlign:"center"})),Pe=({environment:e,warnEnabledToggles:n})=>{const s=c.useMemo(()=>[{id:"Icon",width:"1%",Cell:({row:{original:u}})=>t.jsx(o8,{environment:u})},{Header:"Name",accessor:"name",Cell:h1},{Header:"Type",accessor:"type",Cell:h1},{Header:"Toggles enabled",accessor:"projectEnabledToggleCount",Cell:({value:u})=>t.jsx(h1,{children:t.jsx(Re,{warning:u>0,children:u===1?"1 toggle":`${u} toggles`})}),align:"center"}],[n]),{getTableProps:r,getTableBodyProps:o,headerGroups:a,rows:i,prepareRow:l}=t1.useTable({columns:s,data:[e],disableSortBy:!0});return t.jsxs(Fe,{...r(),rowHeight:"compact",children:[t.jsx(R5,{headerGroups:a}),t.jsx(P5,{...o(),children:i.map(u=>(l(u),t.jsx(Z5,{hover:!0,...u.getRowProps(),children:u.cells.map(C=>t.jsx(I5,{...C.getCellProps(),children:C.render("Cell")}))})))})]})},Ze=d("p")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1.5)})),Ie=d(j4)(()=>({width:"100%"})),Oe=({environment:e,open:n,setOpen:s,onConfirm:r})=>{const[o,a]=c.useState("");return c.useEffect(()=>{a("")},[n]),t.jsxs(I1,{title:"Hide environment and disable feature toggles?",open:n,primaryButtonText:"Hide environment and disable feature toggles",disabledPrimaryButton:(e==null?void 0:e.name)!==o,secondaryButtonText:"Close",onClick:r,onClose:()=>{s(!1)},children:[t.jsxs(x1,{severity:"error",children:[t.jsx("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."]}),t.jsx(Pe,{environment:e}),t.jsxs(Ze,{children:["In order to hide this environment, please enter the id of the environment in the textfield below:"," ",t.jsx("strong",{children:e==null?void 0:e.name})]}),t.jsx(Ie,{label:"Environment name",value:o,onChange:i=>a(i.target.value)})]})},$e=e=>{const{data:n,error:s,mutate:r}=r5(G1(`api/admin/environments/project/${e}`),Be),o=c.useMemo(()=>n||[],[n]),a=c.useCallback(async()=>{await r()},[r]);return{environments:o,refetchEnvironments:a,loading:!s&&!n,error:s}},Be=async e=>(await fetch(e).then(K1("Environments")).then(s=>s.json())).environments.sort((s,r)=>s.sortOrder-r.sortOrder),ze=d(x1)(({theme:e})=>({marginBottom:e.spacing(4)})),Ne=d("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",[e.breakpoints.down("sm")]:{justifyContent:"center"}})),We=d(y4)(({theme:e})=>({maxWidth:"400px",marginBottom:e.spacing(2)})),l7=()=>{const e=q("projectId"),n=o5(e);M1(`Project environments – ${n}`);const{setToastData:s,setToastApiError:r}=p1(),{environments:o,loading:a,error:i,refetchEnvironments:l}=$e(e),{project:u,refetch:C}=k1(e),{removeEnvironmentFromProject:h,addEnvironmentToProject:p}=d5(),[x,S]=c.useState(),[g,y]=c.useState(!1),{isOss:f}=i1(),m=c.useMemo(()=>o.map(M=>({...M,projectVisible:u==null?void 0:u.environments.map(W=>W.environment).includes(M.name)})),[o,u==null?void 0:u.environments]),H=()=>{l(),C()},_=()=>t.jsx(We,{onClick:H,text:"Error fetching environments"}),I=M=>`Got an API error when trying to set the environment as ${M?"visible":"hidden"}`,$=async M=>{if(M.projectVisible){if(Le(m)>1){S(M),y(!0);return}s({title:"One environment must be visible",text:"You must always have at least one visible environment per project",type:"error"})}else try{await p(e,M.name),H(),s({title:"Environment set as visible",text:"Environment successfully set as visible.",type:"success"})}catch{r(I(!0))}},E=async()=>{if(x)try{await h(e,x.name),H(),s({title:"Environment set as hidden",text:"Environment successfully set as hidden.",type:"success"})}catch{r(I(!1))}finally{y(!1)}},A=M=>f()&&M==="default",k=c.useMemo(()=>[{Header:"Name",accessor:"name",Cell:({row:{original:M}})=>t.jsx(a8,{environment:M})},{Header:"Type",accessor:"type",Cell:b2},{Header:"Project API tokens",accessor:M=>M.projectApiTokenCount===1?"1 token":`${M.projectApiTokenCount} tokens`,Cell:h1},{Header:"Visible in project",accessor:"enabled",align:"center",width:1,Cell:({row:{original:M}})=>t.jsx(V3,{children:t.jsx(v4,{tooltip:M.projectVisible?"Hide environment and disable feature toggles":"Make it visible",size:"medium",disabled:A(M.name),projectId:e,permission:b1,checked:M.projectVisible,onChange:()=>$(M)})}),disableGlobalFilter:!0}],[m]),{getTableProps:B,getTableBodyProps:z,headerGroups:N,rows:F,prepareRow:U,state:{globalFilter:j},setGlobalFilter:v}=t1.useTable({columns:k,data:m,disableSortBy:!0},t1.useGlobalFilter),O=t.jsx(n1,{title:`Environments (${F.length})`,actions:t.jsx(V1,{initialValue:j,onChange:v})});return t.jsx(a1,{header:O,isLoading:a,children:t.jsxs(Ne,{children:[t.jsx(V,{condition:!!i,show:_()}),t.jsxs(ze,{severity:"info",children:[t.jsx("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"," ",t.jsx(_1,{to:"/admin/api",children:"API tokens here"}),".",t.jsx("br",{}),t.jsx("br",{}),"Your administrator can configure an environment-specific API token to be used in the SDK. If you are an administrator you can ",t.jsx(_1,{to:"/admin/api",children:"create a new API token here"}),"."]}),t.jsx(u5,{value:j,children:t.jsxs(F5,{...B(),rowHeight:"compact",children:[t.jsx(R5,{headerGroups:N}),t.jsx(P5,{...z(),children:F.map(M=>(U(M),t.jsx(Z5,{hover:!0,...M.getRowProps(),children:M.cells.map(W=>t.jsx(I5,{...W.getCellProps(),children:W.render("Cell")}))})))})]})}),t.jsx(V,{condition:F.length===0,show:t.jsx(V,{condition:(j==null?void 0:j.length)>0,show:t.jsxs(f1,{children:["No environments found matching “",j,"”"]}),elseShow:t.jsx(f1,{children:"No environments available. Get started by adding one."})})}),t.jsx(Oe,{environment:x,open:g,setOpen:y,onConfirm:E})]})})},Ue={id:"archivedAt"},qe=({projectId:e})=>{const{archivedFeatures:n,loading:s,refetchArchived:r}=i8(e),{value:o,setValue:a}=S2(`${e}:ProjectFeaturesArchiveTable`,Ue);return t.jsx(l8,{title:"Project archive",archivedFeatures:n||[],loading:s,storedParams:o,setStoredParams:a,refetch:r,projectId:e})},Ge=()=>{const e=q("projectId"),n=o5(e);return M1(`Project archive – ${n}`),t.jsx(qe,{projectId:e})},Ke=(e=[])=>{var r;const n=e.map(o=>o.environment),s=c.useRef(n);return n.join("")!==((r=s.current)==null?void 0:r.join(""))&&(s.current=n),s.current};var $3={},Je=h5;Object.defineProperty($3,"__esModule",{value:!0});var c7=$3.default=void 0,Ye=Je(p5()),Qe=t,Xe=(0,Ye.default)((0,Qe.jsx)("path",{d:"M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-1 9h-4v4h-2v-4H9V9h4V5h2v4h4v2z"}),"LibraryAdd");c7=$3.default=Xe;var B3={},e0=h5;Object.defineProperty(B3,"__esModule",{value:!0});var C7=B3.default=void 0,t0=e0(p5()),n0=t,s0=(0,t0.default)((0,n0.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");C7=B3.default=s0;var z3={},r0=h5;Object.defineProperty(z3,"__esModule",{value:!0});var d7=z3.default=void 0,o0=r0(p5()),a0=t,i0=(0,o0.default)((0,a0.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");d7=z3.default=i0;const l0=d(w)(({theme:e})=>({display:"flex",justifyContent:"center",paddingRight:e.spacing(2)})),u7=({projectId:e,row:n,onOpenArchiveDialog:s,onOpenStaleDialog:r})=>{const[o,a]=c.useState(null),[i,l]=c.useState(!1),{setToastData:u}=p1(),{original:{name:C,stale:h}}=n,p=!!o,x=m=>{a(m.currentTarget)},S=()=>{a(null)},g=`feature-${C}-actions`,y=`${g}-menu`,f=()=>{try{d8(C),l(!0),setTimeout(()=>{S(),l(!1)},1e3)}catch{u({type:"error",title:"Could not copy feature name"})}};return t.jsxs(l0,{children:[t.jsx(S1,{title:"Feature toggle actions",arrow:!0,describeChild:!0,children:t.jsx(H1,{id:g,"data-loading":!0,"aria-controls":p?y:void 0,"aria-haspopup":"true","aria-expanded":p?"true":void 0,onClick:x,type:"button",children:t.jsx(c8,{})})}),t.jsx(O5,{id:y,anchorEl:o,open:p,onClose:S,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:m=>({borderRadius:`${m.shape.borderRadius}px`,padding:m.spacing(1,1.5)})},children:t.jsxs($5,{"aria-labelledby":g,children:[t.jsxs(N1,{sx:t2,onClick:f,children:[t.jsx(W1,{children:i?t.jsx(w2,{}):t.jsx(C8,{})}),t.jsx(U1,{children:t.jsx(L,{variant:"body2",children:i?"Copied!":"Copy Name"})})]}),t.jsx(j5,{projectId:e,permission:V2,children:({hasAccess:m})=>t.jsxs(N1,{sx:t2,onClick:S,disabled:!m,component:_1,to:`/projects/${e}/features/${C}/copy`,children:[t.jsx(W1,{children:t.jsx(c7,{})}),t.jsx(U1,{children:t.jsx(L,{variant:"body2",children:"Clone"})})]})}),t.jsx(j5,{projectId:e,permission:b4,children:({hasAccess:m})=>t.jsxs(N1,{sx:t2,onClick:()=>{s(C),S()},disabled:!m,children:[t.jsx(W1,{children:t.jsx(C7,{})}),t.jsx(U1,{children:t.jsx(L,{variant:"body2",children:"Archive"})})]})}),t.jsx(j5,{projectId:e,permission:_2,children:({hasAccess:m})=>t.jsxs(N1,{sx:t2,onClick:()=>{S(),r({featureId:C,stale:h===!0})},disabled:!m,children:[t.jsx(W1,{children:t.jsx(d7,{})}),t.jsx(U1,{children:t.jsxs(L,{variant:"body2",children:[h?"Un-mark":"Mark"," as stale"]})})]})})]})})]})};var N3={},c0=h5;Object.defineProperty(N3,"__esModule",{value:!0});var W3=N3.default=void 0,C0=c0(p5()),d0=t,u0=(0,C0.default)((0,d0.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");W3=N3.default=u0;const p0=d(w)(()=>({...R1,justifyContent:"center"})),h0=d(H1)(({theme:e})=>({margin:e.spacing(-1,0)})),g0=d(w)(({theme:e})=>({...R1,justifyContent:"space-between",padding:e.spacing(1,1,0,4)})),m0=d(N1)(({theme:e})=>({padding:e.spacing(0,2),margin:e.spacing(0,2),borderRadius:e.shape.borderRadius})),j6=d(_3)(({theme:e})=>({"&.MuiDivider-root.MuiDivider-fullWidth":{margin:e.spacing(.75,0)}})),f0=d(B5)(({theme:e})=>({padding:e.spacing(.75,1)})),x0={favorite:"Favorite"},j0=({allColumns:e,staticColumns:n=[],dividerBefore:s=[],dividerAfter:r=[],isCustomized:o=!1,onCustomize:a,setHiddenColumns:i})=>{const[l,u]=c.useState(null),C=r1(),h=u1(C.breakpoints.down("sm")),p=u1(C.breakpoints.down("md")),x=u1(C.breakpoints.down("lg"));c.useEffect(()=>{if(o)return;const H=(_,I=0)=>{const $=e.filter(({id:A})=>A.startsWith("environment:")!==!1).map(({id:A})=>A).slice(0,I),E=e.map(({id:A})=>A).filter(A=>!_.includes(A)).filter(A=>!n.includes(A)).filter(A=>!$.includes(A));i(E)};if(h)return H(["createdAt"]);if(p)return H(["createdAt"],1);if(x)return H(["type","createdAt"],1);H(["lastSeenAt","type","createdAt"],3)},[h,p,x]);const S=H=>{u(H.currentTarget)},g=()=>{u(null)},y=!!l,f="columns-menu",m=`columns-menu-list-${f}`;return t.jsxs(p0,{children:[t.jsx(S1,{title:"Select columns",arrow:!0,describeChild:!0,children:t.jsx(h0,{id:f,"aria-controls":y?m:void 0,"aria-haspopup":"true","aria-expanded":y?"true":void 0,onClick:S,type:"button",size:"large","data-loading":!0,children:t.jsx(W3,{})})}),t.jsxs(O5,{id:m,open:y,anchorEl:l,onClose:g,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},disableScrollLock:!0,PaperProps:{sx:H=>({borderRadius:H.shape.borderRadius,paddingBottom:H.spacing(2)})},children:[t.jsxs(g0,{children:[t.jsx(L,{variant:"body2",children:t.jsx("strong",{children:"Columns"})}),t.jsx(H1,{onClick:g,children:t.jsx(S4,{})})]}),t.jsx($5,{children:e.filter(({hideInMenu:H})=>!H).map(H=>[t.jsx(V,{condition:s.includes(H.id),show:t.jsx(j6,{})}),t.jsxs(m0,{onClick:()=>{H.toggleHidden(H.isVisible),a==null||a()},disabled:n.includes(H.id),children:[t.jsx(W1,{children:t.jsx(f0,{edge:"start",checked:H.isVisible,disableRipple:!0,inputProps:{"aria-labelledby":H.id},size:"medium"})}),t.jsx(U1,{id:H.id,primary:t.jsx(L,{variant:"body2",children:t.jsx(V,{condition:!!(typeof H.Header=="string"&&H.Header),show:()=>t.jsx(t.Fragment,{children:H.Header}),elseShow:()=>x0[H.id]||H.id})})})]}),t.jsx(V,{condition:r.includes(H.id),show:t.jsx(j6,{})})])})]})]})},y0=w4()(e=>({container:{boxShadow:"none",minHeight:"100%",position:"relative",[e.breakpoints.down("md")]:{paddingBottom:e.spacing(8),width:"inherit"}}})),v0=7,b0=e=>{const n=x4(new Date,-v0);return!!(e!=null&&e.lastSeenAt&&u8(new Date(e.lastSeenAt),n))},S0=({projectId:e,featureIds:n,features:s,onConfirm:r})=>{const{refetch:o}=k1(e),[a,i]=c.useState(!1),{trackEvent:l}=v1(),u=c.useMemo(()=>n.filter(h=>{const p=s.find(x=>x.name===h);return b0(p)}),[JSON.stringify(s),n]),C=async()=>{i(!1),r==null||r(),await o(),l("batch_operations",{props:{eventType:"features archived"}})};return t.jsxs(t.Fragment,{children:[t.jsx(j5,{projectId:e,permission:b4,children:({hasAccess:h})=>t.jsx(m1,{disabled:!h||a,variant:"outlined",size:"small",onClick:()=>i(!0),children:"Archive"})}),t.jsx(O3,{projectId:e,featureIds:n,featuresWithUsage:u,onConfirm:C,isOpen:a,onClose:()=>i(!1)})]})},s2="selection-actions-menu",w0=({projectId:e,data:n,onChange:s})=>{const[r,o]=c.useState(null),{staleFeatures:a}=d5(),{setToastData:i,setToastApiError:l}=p1(),{trackEvent:u}=v1(),C=!!r,h=n.map(({name:m})=>m),p=m=>{o(m.currentTarget)},x=()=>{o(null)},S=n.some(({stale:m})=>m===!0),g=n.some(({stale:m})=>m===!1),y=async()=>{try{x(),await a(e,h),s==null||s(),i({title:"State updated",text:"Feature toggles marked as stale",type:"success"}),u("batch_operations",{props:{eventType:"features staled"}})}catch(m){l(d1(m))}},f=async()=>{try{x(),await a(e,h,!1),s==null||s(),i({title:"State updated",text:"Feature toggles unmarked as stale",type:"success"}),u("batch_operations",{props:{eventType:"features unstaled"}})}catch(m){l(d1(m))}};return t.jsxs(t.Fragment,{children:[t.jsx(S1,{title:"More bulk actions",arrow:!0,describeChild:!0,children:t.jsx(H1,{id:s2,"aria-controls":C?s2:void 0,"aria-haspopup":"true","aria-expanded":C?"true":void 0,onClick:p,type:"button","data-testid":p8,children:t.jsx(h8,{})})}),t.jsx(O5,{id:`${s2}-menu`,anchorEl:r,open:C,onClose:x,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:m=>({borderRadius:`${m.shape.borderRadius}px`,padding:m.spacing(1,1.5)})},children:t.jsx($5,{"aria-labelledby":`${s2}-menu`,children:t.jsx(j5,{projectId:e,permission:_2,children:({hasAccess:m})=>t.jsxs(t.Fragment,{children:[t.jsx(V,{condition:g,show:()=>t.jsxs(N1,{onClick:y,disabled:!m,sx:{borderRadius:H=>`${H.shape.borderRadius}px`},children:[t.jsx(W1,{children:t.jsx(m6,{})}),t.jsx(U1,{children:t.jsx(L,{variant:"body2",children:"Mark as stale"})})]})}),t.jsx(V,{condition:S,show:()=>t.jsxs(N1,{onClick:f,disabled:!m,sx:{borderRadius:H=>`${H.shape.borderRadius}px`},children:[t.jsx(W1,{children:t.jsx(m6,{})}),t.jsx(U1,{children:t.jsx(L,{variant:"body2",children:"Un-mark as stale"})})]})})]})})})})]})},V0=d("section")(({theme:e})=>({"& > *":{margin:e.spacing(1,0)}})),y6="manage-tags-form",v6=(e,n)=>[...e,...e.some(s=>s.value===n.value&&s.type===n.type)?[]:[n]],b6=(e,n)=>e.filter(s=>!(s.value===n.value&&s.type===n.type)),_0=(e,n)=>{switch(n.type){case"add":return{...e,addedTags:v6(e.addedTags,n.payload),removedTags:b6(e.removedTags,n.payload)};case"remove":return{...e,addedTags:b6(e.addedTags,n.payload),removedTags:v6(e.removedTags,n.payload)};case"clear":return{addedTags:[],removedTags:n.payload};default:return e}},S6={name:"",description:"",icon:""},H0=({open:e,initialValues:n,initialIndeterminateValues:s,onCancel:r,onSubmit:o})=>{const{tagTypes:a,loading:i}=g8(),[l,u]=c.useState(S6),[C,h]=c.useState([]),[p,x]=c.useState([]),{tags:S,refetch:g}=G9(l.name),{createTag:y}=s7(),f=S.map(({value:k})=>({title:k})),[m,H]=c.useReducer(_0,{addedTags:[],removedTags:[]}),_=(k=a.length>0?a[0]:S6)=>{u(k);const B=s.filter(({type:z})=>z===k.name);h(n.filter(({type:z})=>z===k.name).filter(({type:z,value:N})=>!B.some(F=>F.value===N&&F.type===z)).map(({value:z})=>({title:z}))),x(B.map(({value:z})=>({title:z}))),H({type:"clear",payload:[]})};c.useEffect(()=>{a.length>0&&_()},[i]);const I=(k,B)=>{B!=null&&typeof B!="string"&&(k.preventDefault(),_(B))},$=(k,B)=>y({value:k,type:B}).then(async()=>{await g(),h(z=>[...z,{title:k}]),H({type:"add",payload:{value:k,type:B}})}),E=(k,B,z,N)=>{z==="selectOption"?B.forEach(F=>{if(typeof F!="string"&&typeof F.inputValue=="string"&&F.inputValue&&F.title.startsWith("Create new value"))return $(F.inputValue,l.name);h(B),x(U=>U.filter(({title:j})=>j!==F.title)),N!=null&&N.option&&H({type:"add",payload:{value:N.option.title,type:l.name}})}):z==="clear"?(h([]),H({type:"clear",payload:n})):z==="removeOption"&&(h(B),N!=null&&N.option&&H({type:"remove",payload:{value:N.option.title,type:l.name}}))},A=()=>{_(),r()};return t.jsxs(I1,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update feature toggle tags",onClick:()=>o(m),disabledPrimaryButton:m.addedTags.length===0&&m.removedTags.length===0,onClose:A,formId:y6,children:[t.jsx(L,{paragraph:!0,sx:{marginBottom:k=>k.spacing(2.5)},children:"Tags allow you to group features together"}),t.jsx("form",{id:y6,onSubmit:()=>o(m),children:t.jsxs(V0,{children:[t.jsx(K9,{options:a,disabled:i||a.length===0,value:l,onChange:I},i?"loading":a.length),t.jsx(V,{condition:!i&&a.length===0,show:t.jsxs(L,{variant:"body1",children:["No"," ",t.jsx(H2,{component:_1,to:"/tag-types",children:"tag types"})," ","available."]}),elseShow:t.jsx(J9,{disabled:i,options:f,existingTags:n,indeterminateOptions:p,tagType:l,selectedOptions:C,onChange:E})})]})})]})},E0=({projectId:e,data:n,onChange:s})=>{const{bulkUpdateTags:r}=s7(),{setToastData:o,setToastApiError:a}=p1(),{trackEvent:i}=v1(),[l,u]=c.useState(!1),[C,h]=c.useMemo(()=>{const x=n.flatMap(({tags:g})=>g||[]).reduce((g,y)=>[...g,...g.some(f=>f.type===y.type&&f.value===y.value)?[]:[y]],[]),S=x.filter(g=>!n.every(({tags:y})=>y==null?void 0:y.some(f=>f.type===g.type&&f.value===g.value)));return[x,S]},[n]),p=async({addedTags:x,removedTags:S})=>{const g=n.map(({name:f})=>f),y={features:g,tags:{addedTags:x,removedTags:S}};try{await r(y,e);const f=x.length?`Added tags: ${x.map(({type:H,value:_})=>`${H}:${_}`).join(", ")}.`:"",m=S.length?`Removed tags: ${S.map(({type:H,value:_})=>`${H}:${_}`).join(", ")}.`:"";o({title:"Tags updated",text:`${g.length} feature toggles updated. ${f} ${m}`,type:"success",autoHideDuration:12e3}),i("batch_operations",{props:{eventType:"tags updated"}})}catch(f){a(d1(f))}s==null||s(),u(!1)};return t.jsxs(t.Fragment,{children:[t.jsx(j5,{projectId:e,permission:_2,children:({hasAccess:x})=>t.jsx(m1,{disabled:!x||l,variant:"outlined",size:"small",onClick:()=>u(!0),children:"Tags"})}),t.jsx(H0,{open:l,onCancel:()=>u(!1),onSubmit:p,initialValues:C,initialIndeterminateValues:h},n.length)]})},M0=d(E2)(({theme:e})=>({minWidth:"450px",marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),w6=d(x1)(({theme:e})=>({marginBottom:e.spacing(1.5)})),T0=({showExportDialog:e,data:n,onClose:s,onConfirm:r,environments:o,projectId:a})=>{const[i,l]=c.useState(o[0]),{bulkToggleFeaturesEnvironmentOff:u}=V4(),{addChange:C}=M2(),{refetch:h}=k1(a),{setToastApiError:p,setToastData:x}=p1(),{isChangeRequestConfigured:S}=g5(a),{refetch:g}=T2(a),y=n.filter(_=>{var I,$;return(($=(I=_.environments)==null?void 0:I.find(E=>i===E.name))==null?void 0:$.enabled)===!1}).length,f=()=>o.map(_=>({key:_,label:_})),m=async()=>{try{S(i)?(await C(a,i,n.map(_=>({action:"updateEnabled",feature:_.name,payload:{enabled:!1}}))),g(),x({text:"Your disabled feature toggles changes have been added to change request",type:"success",title:"Changes added to a draft"})):(await u(a,n.map(_=>_.name),i),h(),x({text:"Your feature toggles have been disabled",type:"success",title:"Features disabled"})),s(),r==null||r()}catch(_){p(d1(_))}},H=S(i)?"Add to change request":"Disable toggles";return t.jsx(I1,{open:e,title:"Disable feature toggles",onClose:s,onClick:m,primaryButtonText:H,secondaryButtonText:"Cancel",children:t.jsxs(w,{children:["You have selected ",t.jsx("b",{children:n.length})," feature toggles to disable.",t.jsx("br",{}),t.jsx("br",{}),t.jsx(L,{children:"Select which environment to disable the features for:"}),t.jsx(M0,{options:f(),value:i,onChange:_=>l(_)}),t.jsx(V,{condition:S(i),show:t.jsx(w6,{severity:"warning",children:"Change requests are enabled for this environment."})}),t.jsx(V,{condition:y>0,show:t.jsxs(w6,{severity:"info",children:[y," feature"," ",y>1?"toggles are ":"toggle is ","already disabled."]})})]})})},A0=d(E2)(({theme:e})=>({minWidth:"450px",marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),V6=d(x1)(({theme:e})=>({marginBottom:e.spacing(1.5)})),k0=({showExportDialog:e,data:n,onClose:s,onConfirm:r,environments:o,projectId:a})=>{const[i,l]=c.useState(o[0]),{bulkToggleFeaturesEnvironmentOn:u}=V4(),{addChange:C}=M2(),{refetch:h}=k1(a),{setToastApiError:p,setToastData:x}=p1(),{isChangeRequestConfigured:S}=g5(a),{refetch:g}=T2(a),y=n.filter(_=>{var I,$;return(($=(I=_.environments)==null?void 0:I.find(E=>i===E.name))==null?void 0:$.enabled)===!0}).length,f=()=>o.map(_=>({key:_,label:_})),m=async()=>{try{S(i)?(await C(a,i,n.map(_=>({action:"updateEnabled",feature:_.name,payload:{enabled:!0}}))),g(),x({text:"Your enable feature toggles changes have been added to change request",type:"success",title:"Changes added to a draft"})):(await u(a,n.map(_=>_.name),i),h(),x({text:"Your feature toggles have been enabled",type:"success",title:"Features enabled"})),s(),r==null||r()}catch(_){p(d1(_))}},H=S(i)?"Add to change request":"Enable toggles";return t.jsx(I1,{open:e,title:"Enable feature toggles",onClose:s,onClick:m,primaryButtonText:H,secondaryButtonText:"Cancel",children:t.jsxs(w,{children:["You have selected ",t.jsx("b",{children:n.length})," feature toggles to enable.",t.jsx("br",{}),t.jsx("br",{}),t.jsx(L,{children:"Select which environment to enable the features for:"}),t.jsx(A0,{options:f(),value:i,onChange:_=>l(_)}),t.jsx(V,{condition:S(i),show:t.jsx(V6,{severity:"warning",children:"Change requests are enabled for this environment."})}),t.jsx(V,{condition:y>0,show:t.jsxs(V6,{severity:"info",children:[y," feature"," ",y>1?"toggles are ":"toggle is ","already enabled."]})})]})})},p7=({selectedIds:e,data:n,projectId:s,onResetSelection:r,onChange:o})=>{var _,I;const{uiConfig:a}=i1(),[i,l]=c.useState(!1),[u,C]=c.useState(!1),[h,p]=c.useState(!1),{trackEvent:x}=v1(),S=c.useMemo(()=>n.filter($=>e.includes($.name)),[n,e]),g=c.useMemo(()=>{const $=S.flatMap(E=>E.environments).map(E=>E==null?void 0:E.name).filter(E=>E!==void 0);return Array.from(new Set($))},[S]),y=()=>{o==null||o(),x("batch_operations",{props:{eventType:"features exported"}})},f=()=>{o==null||o(),x("batch_operations",{props:{eventType:"features enabled"}})},m=()=>{o==null||o(),x("batch_operations",{props:{eventType:"features disabled"}})},H=()=>{o==null||o(),r()};return t.jsxs(t.Fragment,{children:[t.jsx(V,{condition:!!((_=a==null?void 0:a.flags)!=null&&_.disableBulkToggle),show:null,elseShow:t.jsx(m1,{variant:"outlined",size:"small",onClick:()=>C(!0),children:"Enable"})}),t.jsx(V,{condition:!!((I=a==null?void 0:a.flags)!=null&&I.disableBulkToggle),show:null,elseShow:t.jsx(m1,{variant:"outlined",size:"small",onClick:()=>p(!0),children:"Disable"})}),t.jsx(S0,{projectId:s,featureIds:e,features:n,onConfirm:H}),t.jsx(m1,{variant:"outlined",size:"small",onClick:()=>l(!0),children:"Export"}),t.jsx(E0,{projectId:s,data:S,onChange:o}),t.jsx(w0,{projectId:s,data:S,onChange:o}),t.jsx(A2,{showExportDialog:i,data:S,onClose:()=>l(!1),environments:g,onConfirm:y}),t.jsx(k0,{showExportDialog:u,data:S,onClose:()=>C(!1),environments:g,projectId:s,onConfirm:f}),t.jsx(T0,{showExportDialog:h,data:S,onClose:()=>p(!1),environments:g,projectId:s,onConfirm:m})]})},D0=d("div",{shouldForwardProp:e=>e!=="hasWarning"})(({theme:e,hasWarning:n})=>({flexGrow:0,...R1,justifyContent:"center",...n&&{"::before":{content:'""',display:"block",width:e.spacing(2)}}})),L0=({value:e,feature:n,projectId:s,environmentName:r,isChangeRequestEnabled:o,refetch:a,onFeatureToggleSwitch:i})=>{const l=n.environments[r],u=c.useMemo(()=>n.someEnabledEnvironmentHasVariants&&l.variantCount===0&&l.enabled,[n,l]),C=(h,p)=>{i(h,{projectId:s,featureId:n.name,environmentName:r,environmentType:l==null?void 0:l.type,hasStrategies:l==null?void 0:l.hasStrategies,hasEnabledStrategies:l==null?void 0:l.hasEnabledStrategies,isChangeRequestEnabled:o,onRollback:p,onSuccess:a})};return t.jsxs(D0,{hasWarning:u,children:[t.jsx(r7,{projectId:s,value:e,featureId:n.name,environmentName:r,onToggle:C}),t.jsx(V,{condition:u,show:t.jsx(o7,{})})]})},F0=q1.memo(L0),R0=(e,n,s,r,o)=>({value:a,row:{original:i}})=>t.jsx(F0,{value:a,feature:i,projectId:e,environmentName:n,isChangeRequestEnabled:s,refetch:r,onFeatureToggleSwitch:o}),P0=d(H3)(()=>({whiteSpace:"nowrap"})),r2=["Select","Actions","name","favorite"],Z0={id:"createdAt",desc:!0},I0=({features:e,loading:n,environments:s=[],onChange:r,total:o,style:a={}})=>{var f5,X5;const{classes:i}=y0(),l=r1(),{setToastApiError:u}=p1(),C=u1(l.breakpoints.down("md")),[h,p]=c.useState({}),[x,S]=c.useState(),g=q("projectId"),{onToggle:y,modals:f}=a7(g),{value:m,setValue:H}=S2(`${g}:FeatureToggleListTable:v1`,Z0),{value:_,setValue:I}=m8(),$=D1(),[E,A]=E3(),k=Ke(n?[{environment:"a"},{environment:"b"},{environment:"c"}]:s),{isFavoritesPinned:B,sortTypes:z,onChangeIsFavoritePinned:N}=f8(E.has("favorites")?E.get("favorites")==="true":_.favorites),{favorite:F,unfavorite:U}=_4(),{isChangeRequestConfigured:j}=g5(g),[v,O]=c.useState(!1),{uiConfig:M}=i1(),W=c.useCallback(async R=>{try{R!=null&&R.favorite?await U(g,R.name):await F(g,R.name),r()}catch{u("Something went wrong, could not update favorite")}},[g,r]),D=c.useMemo(()=>e.some(R=>{var b;return(b=R==null?void 0:R.tags)==null?void 0:b.length}),[e]),G=c.useMemo(()=>[{id:"Select",Header:({getToggleAllRowsSelectedProps:R})=>t.jsx(B5,{...R()}),Cell:({row:R})=>{var b;return t.jsx(m3,{...(b=R==null?void 0:R.getToggleRowSelectedProps)==null?void 0:b.call(R)})},maxWidth:50,disableSortBy:!0,hideInMenu:!0,styles:{borderRadius:0}},{id:"favorite",Header:t.jsx(H4,{isActive:B,onClick:N}),accessor:"favorite",Cell:({row:{original:R}})=>t.jsx(E4,{value:R==null?void 0:R.favorite,onClick:()=>W(R)}),maxWidth:50,disableSortBy:!0,hideInMenu:!0},{Header:"Seen",accessor:"lastSeenAt",Cell:({value:R,row:{original:b}})=>t.jsx(M4,{feature:b}),align:"center",maxWidth:80},{Header:"Type",accessor:"type",Cell:M3,align:"center",filterName:"type",maxWidth:80},{Header:"Name",accessor:"name",Cell:({value:R})=>t.jsx(S1,{title:R,arrow:!0,describeChild:!0,children:t.jsx("span",{children:t.jsx(T4,{title:R,to:`/projects/${g}/features/${R}`})})}),minWidth:100,sortType:"alphanumeric",searchable:!0},...D?[{id:"tags",Header:"Tags",accessor:R=>{var b;return((b=R.tags)==null?void 0:b.map(({type:P,value:Z})=>`${P}:${Z}`).join(`
1
+ import{c as C5,j as t,eL as n8,eM as x4,eN as s8,s as d,cN as r8,cK as p2,a5 as F5,r as c,eO as o8,ab as h1,a3 as t1,a6 as R5,a7 as P5,a8 as Z5,a9 as I5,v as j4,b7 as I1,J as x1,aN as r5,aO as G1,aP as K1,eP as y4,aE as q,eQ as o5,cf as M1,e as p1,cF as k1,az as d5,ax as i1,eR as a8,ae as b2,dc as V3,eS as v4,eT as b1,au as n1,ao as V1,at as a1,C as V,aK as _1,aq as u5,ap as f1,cI as i8,ai as S2,eU as l8,ba as p5,bb as h5,B as w,t as S1,x as H1,bg as c8,a1 as O5,bW as $5,M as N1,eV as t2,b3 as W1,d as w2,eW as C8,b5 as U1,T as L,eX as j5,cQ as V2,cR as b4,aJ as _2,cU as d8,ah as R1,D as _3,l as B5,b as r1,ac as u1,eY as S4,eZ as w4,aj as v1,h as m1,e_ as u8,e$ as p8,bI as h8,g as d1,c5 as g8,c4 as H2,bU as E2,c6 as V4,aV as M2,a_ as g5,aW as T2,f0 as A2,cB as q1,dG as H3,bR as m8,ay as D1,ak as E3,f1 as f8,cL as _4,f2 as m3,f3 as H4,f4 as E4,f5 as M4,f6 as M3,am as T4,f7 as A4,f8 as x8,f9 as j8,dq as z5,an as k2,dr as y8,cJ as k4,c9 as T3,ag as D2,fa as D4,X as v8,aM as b8,b6 as S8,al as L2,fb as w8,y as J1,fc as L4,P as F4,fd as R4,z as V8,fe as _8,cg as F2,ff as H8,fg as E8,fh as M8,fi as A5,fj as Y2,fk as T8,fl as d6,fm as A8,fn as k8,fo as D8,fp as L8,fq as P4,fr as F8,fs as R8,ft as P8,fu as Z8,fv as u6,fw as I8,fx as O8,fy as $8,aQ as A3,fz as k3,fA as Z4,a0 as B8,cO as I4,fB as z8,c0 as O4,fC as $4,fD as B4,fE as N8,fF as W8,fG as U8,a4 as N5,af as W5,aG as q8,fH as G8,fI as R2,fJ as K8,fK as z4,fL as J8,fM as Y8,fN as b5,fO as m5,aH as Y1,cV as S5,fP as w5,fQ as V5,fR as Q8,b_ as P2,fS as D3,E as L3,c8 as F3,fT as N4,aL as Z2,fU as X8,br as Q1,aw as W4,bH as a5,fV as e9,fW as t9,fX as n9,k as U5,fY as I2,fZ as s9,f_ as r9,f$ as o9,g0 as a9,dX as R3,dY as h2,bq as i9,cA as U4,dO as g2,g1 as l9,cT as P3,dj as q5,cj as c5,aI as y5,bX as q4,dA as Z3,A as G4,dI as c9,m as K4,n as J4,aD as s5,aA as G5,g2 as C9,g3 as d9,dE as n2,g4 as u9,g5 as p9,g6 as h9,g7 as g9,g8 as m9,ch as _5,ci as e1,g9 as f9,ga as p6,gb as Y4,u as I3,aB as x9,gc as j9,df as y9,gd as h6,ge as v9,gf as b9,gg as S9,gh as w9,gi as V9,bm as _9,bn as H9,bN as E9,bO as M9,bP as T9,bQ as A9,R as k9,gj as D9,cb as L9,gk as F9,w as g6,co as R9,gl as P9,gm as Q4,cM as X4,eF as e7,gn as Z9,dy as t7,go as v5,gp as X,gq as I9,gr as O9,gs as $9,gt as B9,cu as n7,gu as z9,G as c2,bt as N9,gv as W9,gw as U9,gx as q9}from"./index-JVRlSBvr.js";import{e as O3,W as m6,c as G9,b as s7,T as K9,d as J9,F as r7,V as o7,a as a7,f as i7,E as Y9}from"./FeatureArchiveDialog-eHyhx7Yo.js";import{h as Q9,m as X9,i as f6,b as ee,c as te,d as ne,e as se,E as re,f as oe,u as ae,a as ie,R as le,C as ce,A as Ce}from"./RoleCell-TGTVkKHO.js";import{S as de}from"./StrategyItemContainer-JoMPKX3L.js";import{C as ue,u as pe,P as he,D as ge}from"./useProjectForm--jxh4Dtm.js";const me=C5(t.jsx("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"}),"ArrowUpward"),fe=C5(t.jsx("path",{d:"M9 5v2h6.59L4 18.59 5.41 20 17 8.41V15h2V5z"}),"CallMade"),xe=C5(t.jsx("path",{d:"M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"}),"FileUpload"),je=C5(t.jsx("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"),ye=C5(t.jsx("path",{d:"M12 5.99 19.53 19H4.47L12 5.99M12 2 1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),ve=C5([t.jsx("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"},"0"),t.jsx("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")],"Schedule"),be=C5(t.jsx("path",{d:"M19 9h-2v6.59L5.41 4 4 5.41 15.59 17H9v2h10V9z"}),"SouthEast");function Se(e,n){n8(2,arguments);var s=s8(n);return x4(e,-s)}const x6=d("div")(()=>({display:"flex"})),we=d("div")(()=>({display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%"}));d("div")(()=>({display:"flex",flexDirection:"column"}));const Ve=d("span")(({theme:e})=>({fontSize:e.typography.h1.fontSize,textOverflow:"ellipsis",whiteSpace:"nowrap"})),_e=d("span")(({theme:e})=>({fontSize:e.fontSizes.smallBody,fontWeight:"normal"}));d(_e)(({theme:e})=>({color:e.palette.neutral.dark}));const He=d(r8)(({theme:e})=>({marginLeft:e.spacing(-1.5)})),Ee=d("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),Me=d("div")(({theme:e})=>({padding:e.spacing(2.5,5),display:"flex",flexDirection:"column",alignItems:"start"})),Te=d("span")(({theme:e})=>({margin:0,width:"100%",fontSize:e.fontSizes.mainHeader,fontWeight:"bold",display:"flex",justifyContent:"space-between",alignItems:"center",gap:e.spacing(2)})),Ae=d("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.divider,height:"1px"})),ke=d("div")(({theme:e})=>({padding:e.spacing(0,4)})),De=d(p2)(({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}})),Le=e=>e.reduce((n,s)=>s.enabled?n+1:n,0),Fe=d(F5)(({theme:e})=>({marginTop:e.spacing(3)})),Re=d("p",{shouldForwardProp:e=>e!=="warning"})(({theme:e,warning:n})=>({color:n?e.palette.error.dark:e.palette.text.primary,textAlign:"center"})),Pe=({environment:e,warnEnabledToggles:n})=>{const s=c.useMemo(()=>[{id:"Icon",width:"1%",Cell:({row:{original:u}})=>t.jsx(o8,{environment:u})},{Header:"Name",accessor:"name",Cell:h1},{Header:"Type",accessor:"type",Cell:h1},{Header:"Toggles enabled",accessor:"projectEnabledToggleCount",Cell:({value:u})=>t.jsx(h1,{children:t.jsx(Re,{warning:u>0,children:u===1?"1 toggle":`${u} toggles`})}),align:"center"}],[n]),{getTableProps:r,getTableBodyProps:o,headerGroups:a,rows:i,prepareRow:l}=t1.useTable({columns:s,data:[e],disableSortBy:!0});return t.jsxs(Fe,{...r(),rowHeight:"compact",children:[t.jsx(R5,{headerGroups:a}),t.jsx(P5,{...o(),children:i.map(u=>(l(u),t.jsx(Z5,{hover:!0,...u.getRowProps(),children:u.cells.map(C=>t.jsx(I5,{...C.getCellProps(),children:C.render("Cell")}))})))})]})},Ze=d("p")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1.5)})),Ie=d(j4)(()=>({width:"100%"})),Oe=({environment:e,open:n,setOpen:s,onConfirm:r})=>{const[o,a]=c.useState("");return c.useEffect(()=>{a("")},[n]),t.jsxs(I1,{title:"Hide environment and disable feature toggles?",open:n,primaryButtonText:"Hide environment and disable feature toggles",disabledPrimaryButton:(e==null?void 0:e.name)!==o,secondaryButtonText:"Close",onClick:r,onClose:()=>{s(!1)},children:[t.jsxs(x1,{severity:"error",children:[t.jsx("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."]}),t.jsx(Pe,{environment:e}),t.jsxs(Ze,{children:["In order to hide this environment, please enter the id of the environment in the textfield below:"," ",t.jsx("strong",{children:e==null?void 0:e.name})]}),t.jsx(Ie,{label:"Environment name",value:o,onChange:i=>a(i.target.value)})]})},$e=e=>{const{data:n,error:s,mutate:r}=r5(G1(`api/admin/environments/project/${e}`),Be),o=c.useMemo(()=>n||[],[n]),a=c.useCallback(async()=>{await r()},[r]);return{environments:o,refetchEnvironments:a,loading:!s&&!n,error:s}},Be=async e=>(await fetch(e).then(K1("Environments")).then(s=>s.json())).environments.sort((s,r)=>s.sortOrder-r.sortOrder),ze=d(x1)(({theme:e})=>({marginBottom:e.spacing(4)})),Ne=d("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",[e.breakpoints.down("sm")]:{justifyContent:"center"}})),We=d(y4)(({theme:e})=>({maxWidth:"400px",marginBottom:e.spacing(2)})),l7=()=>{const e=q("projectId"),n=o5(e);M1(`Project environments – ${n}`);const{setToastData:s,setToastApiError:r}=p1(),{environments:o,loading:a,error:i,refetchEnvironments:l}=$e(e),{project:u,refetch:C}=k1(e),{removeEnvironmentFromProject:h,addEnvironmentToProject:p}=d5(),[x,S]=c.useState(),[g,y]=c.useState(!1),{isOss:f}=i1(),m=c.useMemo(()=>o.map(M=>({...M,projectVisible:u==null?void 0:u.environments.map(W=>W.environment).includes(M.name)})),[o,u==null?void 0:u.environments]),H=()=>{l(),C()},_=()=>t.jsx(We,{onClick:H,text:"Error fetching environments"}),I=M=>`Got an API error when trying to set the environment as ${M?"visible":"hidden"}`,$=async M=>{if(M.projectVisible){if(Le(m)>1){S(M),y(!0);return}s({title:"One environment must be visible",text:"You must always have at least one visible environment per project",type:"error"})}else try{await p(e,M.name),H(),s({title:"Environment set as visible",text:"Environment successfully set as visible.",type:"success"})}catch{r(I(!0))}},E=async()=>{if(x)try{await h(e,x.name),H(),s({title:"Environment set as hidden",text:"Environment successfully set as hidden.",type:"success"})}catch{r(I(!1))}finally{y(!1)}},A=M=>f()&&M==="default",k=c.useMemo(()=>[{Header:"Name",accessor:"name",Cell:({row:{original:M}})=>t.jsx(a8,{environment:M})},{Header:"Type",accessor:"type",Cell:b2},{Header:"Project API tokens",accessor:M=>M.projectApiTokenCount===1?"1 token":`${M.projectApiTokenCount} tokens`,Cell:h1},{Header:"Visible in project",accessor:"enabled",align:"center",width:1,Cell:({row:{original:M}})=>t.jsx(V3,{children:t.jsx(v4,{tooltip:M.projectVisible?"Hide environment and disable feature toggles":"Make it visible",size:"medium",disabled:A(M.name),projectId:e,permission:b1,checked:M.projectVisible,onChange:()=>$(M)})}),disableGlobalFilter:!0}],[m]),{getTableProps:B,getTableBodyProps:z,headerGroups:N,rows:F,prepareRow:U,state:{globalFilter:j},setGlobalFilter:v}=t1.useTable({columns:k,data:m,disableSortBy:!0},t1.useGlobalFilter),O=t.jsx(n1,{title:`Environments (${F.length})`,actions:t.jsx(V1,{initialValue:j,onChange:v})});return t.jsx(a1,{header:O,isLoading:a,children:t.jsxs(Ne,{children:[t.jsx(V,{condition:!!i,show:_()}),t.jsxs(ze,{severity:"info",children:[t.jsx("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"," ",t.jsx(_1,{to:"/admin/api",children:"API tokens here"}),".",t.jsx("br",{}),t.jsx("br",{}),"Your administrator can configure an environment-specific API token to be used in the SDK. If you are an administrator you can ",t.jsx(_1,{to:"/admin/api",children:"create a new API token here"}),"."]}),t.jsx(u5,{value:j,children:t.jsxs(F5,{...B(),rowHeight:"compact",children:[t.jsx(R5,{headerGroups:N}),t.jsx(P5,{...z(),children:F.map(M=>(U(M),t.jsx(Z5,{hover:!0,...M.getRowProps(),children:M.cells.map(W=>t.jsx(I5,{...W.getCellProps(),children:W.render("Cell")}))})))})]})}),t.jsx(V,{condition:F.length===0,show:t.jsx(V,{condition:(j==null?void 0:j.length)>0,show:t.jsxs(f1,{children:["No environments found matching “",j,"”"]}),elseShow:t.jsx(f1,{children:"No environments available. Get started by adding one."})})}),t.jsx(Oe,{environment:x,open:g,setOpen:y,onConfirm:E})]})})},Ue={id:"archivedAt"},qe=({projectId:e})=>{const{archivedFeatures:n,loading:s,refetchArchived:r}=i8(e),{value:o,setValue:a}=S2(`${e}:ProjectFeaturesArchiveTable`,Ue);return t.jsx(l8,{title:"Project archive",archivedFeatures:n||[],loading:s,storedParams:o,setStoredParams:a,refetch:r,projectId:e})},Ge=()=>{const e=q("projectId"),n=o5(e);return M1(`Project archive – ${n}`),t.jsx(qe,{projectId:e})},Ke=(e=[])=>{var r;const n=e.map(o=>o.environment),s=c.useRef(n);return n.join("")!==((r=s.current)==null?void 0:r.join(""))&&(s.current=n),s.current};var $3={},Je=h5;Object.defineProperty($3,"__esModule",{value:!0});var c7=$3.default=void 0,Ye=Je(p5()),Qe=t,Xe=(0,Ye.default)((0,Qe.jsx)("path",{d:"M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-1 9h-4v4h-2v-4H9V9h4V5h2v4h4v2z"}),"LibraryAdd");c7=$3.default=Xe;var B3={},e0=h5;Object.defineProperty(B3,"__esModule",{value:!0});var C7=B3.default=void 0,t0=e0(p5()),n0=t,s0=(0,t0.default)((0,n0.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");C7=B3.default=s0;var z3={},r0=h5;Object.defineProperty(z3,"__esModule",{value:!0});var d7=z3.default=void 0,o0=r0(p5()),a0=t,i0=(0,o0.default)((0,a0.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");d7=z3.default=i0;const l0=d(w)(({theme:e})=>({display:"flex",justifyContent:"center",paddingRight:e.spacing(2)})),u7=({projectId:e,row:n,onOpenArchiveDialog:s,onOpenStaleDialog:r})=>{const[o,a]=c.useState(null),[i,l]=c.useState(!1),{setToastData:u}=p1(),{original:{name:C,stale:h}}=n,p=!!o,x=m=>{a(m.currentTarget)},S=()=>{a(null)},g=`feature-${C}-actions`,y=`${g}-menu`,f=()=>{try{d8(C),l(!0),setTimeout(()=>{S(),l(!1)},1e3)}catch{u({type:"error",title:"Could not copy feature name"})}};return t.jsxs(l0,{children:[t.jsx(S1,{title:"Feature toggle actions",arrow:!0,describeChild:!0,children:t.jsx(H1,{id:g,"data-loading":!0,"aria-controls":p?y:void 0,"aria-haspopup":"true","aria-expanded":p?"true":void 0,onClick:x,type:"button",children:t.jsx(c8,{})})}),t.jsx(O5,{id:y,anchorEl:o,open:p,onClose:S,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:m=>({borderRadius:`${m.shape.borderRadius}px`,padding:m.spacing(1,1.5)})},children:t.jsxs($5,{"aria-labelledby":g,children:[t.jsxs(N1,{sx:t2,onClick:f,children:[t.jsx(W1,{children:i?t.jsx(w2,{}):t.jsx(C8,{})}),t.jsx(U1,{children:t.jsx(L,{variant:"body2",children:i?"Copied!":"Copy Name"})})]}),t.jsx(j5,{projectId:e,permission:V2,children:({hasAccess:m})=>t.jsxs(N1,{sx:t2,onClick:S,disabled:!m,component:_1,to:`/projects/${e}/features/${C}/copy`,children:[t.jsx(W1,{children:t.jsx(c7,{})}),t.jsx(U1,{children:t.jsx(L,{variant:"body2",children:"Clone"})})]})}),t.jsx(j5,{projectId:e,permission:b4,children:({hasAccess:m})=>t.jsxs(N1,{sx:t2,onClick:()=>{s(C),S()},disabled:!m,children:[t.jsx(W1,{children:t.jsx(C7,{})}),t.jsx(U1,{children:t.jsx(L,{variant:"body2",children:"Archive"})})]})}),t.jsx(j5,{projectId:e,permission:_2,children:({hasAccess:m})=>t.jsxs(N1,{sx:t2,onClick:()=>{S(),r({featureId:C,stale:h===!0})},disabled:!m,children:[t.jsx(W1,{children:t.jsx(d7,{})}),t.jsx(U1,{children:t.jsxs(L,{variant:"body2",children:[h?"Un-mark":"Mark"," as stale"]})})]})})]})})]})};var N3={},c0=h5;Object.defineProperty(N3,"__esModule",{value:!0});var W3=N3.default=void 0,C0=c0(p5()),d0=t,u0=(0,C0.default)((0,d0.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");W3=N3.default=u0;const p0=d(w)(()=>({...R1,justifyContent:"center"})),h0=d(H1)(({theme:e})=>({margin:e.spacing(-1,0)})),g0=d(w)(({theme:e})=>({...R1,justifyContent:"space-between",padding:e.spacing(1,1,0,4)})),m0=d(N1)(({theme:e})=>({padding:e.spacing(0,2),margin:e.spacing(0,2),borderRadius:e.shape.borderRadius})),j6=d(_3)(({theme:e})=>({"&.MuiDivider-root.MuiDivider-fullWidth":{margin:e.spacing(.75,0)}})),f0=d(B5)(({theme:e})=>({padding:e.spacing(.75,1)})),x0={favorite:"Favorite"},j0=({allColumns:e,staticColumns:n=[],dividerBefore:s=[],dividerAfter:r=[],isCustomized:o=!1,onCustomize:a,setHiddenColumns:i})=>{const[l,u]=c.useState(null),C=r1(),h=u1(C.breakpoints.down("sm")),p=u1(C.breakpoints.down("md")),x=u1(C.breakpoints.down("lg"));c.useEffect(()=>{if(o)return;const H=(_,I=0)=>{const $=e.filter(({id:A})=>A.startsWith("environment:")!==!1).map(({id:A})=>A).slice(0,I),E=e.map(({id:A})=>A).filter(A=>!_.includes(A)).filter(A=>!n.includes(A)).filter(A=>!$.includes(A));i(E)};if(h)return H(["createdAt"]);if(p)return H(["createdAt"],1);if(x)return H(["type","createdAt"],1);H(["lastSeenAt","type","createdAt"],3)},[h,p,x]);const S=H=>{u(H.currentTarget)},g=()=>{u(null)},y=!!l,f="columns-menu",m=`columns-menu-list-${f}`;return t.jsxs(p0,{children:[t.jsx(S1,{title:"Select columns",arrow:!0,describeChild:!0,children:t.jsx(h0,{id:f,"aria-controls":y?m:void 0,"aria-haspopup":"true","aria-expanded":y?"true":void 0,onClick:S,type:"button",size:"large","data-loading":!0,children:t.jsx(W3,{})})}),t.jsxs(O5,{id:m,open:y,anchorEl:l,onClose:g,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},disableScrollLock:!0,PaperProps:{sx:H=>({borderRadius:H.shape.borderRadius,paddingBottom:H.spacing(2)})},children:[t.jsxs(g0,{children:[t.jsx(L,{variant:"body2",children:t.jsx("strong",{children:"Columns"})}),t.jsx(H1,{onClick:g,children:t.jsx(S4,{})})]}),t.jsx($5,{children:e.filter(({hideInMenu:H})=>!H).map(H=>[t.jsx(V,{condition:s.includes(H.id),show:t.jsx(j6,{})}),t.jsxs(m0,{onClick:()=>{H.toggleHidden(H.isVisible),a==null||a()},disabled:n.includes(H.id),children:[t.jsx(W1,{children:t.jsx(f0,{edge:"start",checked:H.isVisible,disableRipple:!0,inputProps:{"aria-labelledby":H.id},size:"medium"})}),t.jsx(U1,{id:H.id,primary:t.jsx(L,{variant:"body2",children:t.jsx(V,{condition:!!(typeof H.Header=="string"&&H.Header),show:()=>t.jsx(t.Fragment,{children:H.Header}),elseShow:()=>x0[H.id]||H.id})})})]}),t.jsx(V,{condition:r.includes(H.id),show:t.jsx(j6,{})})])})]})]})},y0=w4()(e=>({container:{boxShadow:"none",minHeight:"100%",position:"relative",[e.breakpoints.down("md")]:{paddingBottom:e.spacing(8),width:"inherit"}}})),v0=7,b0=e=>{const n=x4(new Date,-v0);return!!(e!=null&&e.lastSeenAt&&u8(new Date(e.lastSeenAt),n))},S0=({projectId:e,featureIds:n,features:s,onConfirm:r})=>{const{refetch:o}=k1(e),[a,i]=c.useState(!1),{trackEvent:l}=v1(),u=c.useMemo(()=>n.filter(h=>{const p=s.find(x=>x.name===h);return b0(p)}),[JSON.stringify(s),n]),C=async()=>{i(!1),r==null||r(),await o(),l("batch_operations",{props:{eventType:"features archived"}})};return t.jsxs(t.Fragment,{children:[t.jsx(j5,{projectId:e,permission:b4,children:({hasAccess:h})=>t.jsx(m1,{disabled:!h||a,variant:"outlined",size:"small",onClick:()=>i(!0),children:"Archive"})}),t.jsx(O3,{projectId:e,featureIds:n,featuresWithUsage:u,onConfirm:C,isOpen:a,onClose:()=>i(!1)})]})},s2="selection-actions-menu",w0=({projectId:e,data:n,onChange:s})=>{const[r,o]=c.useState(null),{staleFeatures:a}=d5(),{setToastData:i,setToastApiError:l}=p1(),{trackEvent:u}=v1(),C=!!r,h=n.map(({name:m})=>m),p=m=>{o(m.currentTarget)},x=()=>{o(null)},S=n.some(({stale:m})=>m===!0),g=n.some(({stale:m})=>m===!1),y=async()=>{try{x(),await a(e,h),s==null||s(),i({title:"State updated",text:"Feature toggles marked as stale",type:"success"}),u("batch_operations",{props:{eventType:"features staled"}})}catch(m){l(d1(m))}},f=async()=>{try{x(),await a(e,h,!1),s==null||s(),i({title:"State updated",text:"Feature toggles unmarked as stale",type:"success"}),u("batch_operations",{props:{eventType:"features unstaled"}})}catch(m){l(d1(m))}};return t.jsxs(t.Fragment,{children:[t.jsx(S1,{title:"More bulk actions",arrow:!0,describeChild:!0,children:t.jsx(H1,{id:s2,"aria-controls":C?s2:void 0,"aria-haspopup":"true","aria-expanded":C?"true":void 0,onClick:p,type:"button","data-testid":p8,children:t.jsx(h8,{})})}),t.jsx(O5,{id:`${s2}-menu`,anchorEl:r,open:C,onClose:x,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:m=>({borderRadius:`${m.shape.borderRadius}px`,padding:m.spacing(1,1.5)})},children:t.jsx($5,{"aria-labelledby":`${s2}-menu`,children:t.jsx(j5,{projectId:e,permission:_2,children:({hasAccess:m})=>t.jsxs(t.Fragment,{children:[t.jsx(V,{condition:g,show:()=>t.jsxs(N1,{onClick:y,disabled:!m,sx:{borderRadius:H=>`${H.shape.borderRadius}px`},children:[t.jsx(W1,{children:t.jsx(m6,{})}),t.jsx(U1,{children:t.jsx(L,{variant:"body2",children:"Mark as stale"})})]})}),t.jsx(V,{condition:S,show:()=>t.jsxs(N1,{onClick:f,disabled:!m,sx:{borderRadius:H=>`${H.shape.borderRadius}px`},children:[t.jsx(W1,{children:t.jsx(m6,{})}),t.jsx(U1,{children:t.jsx(L,{variant:"body2",children:"Un-mark as stale"})})]})})]})})})})]})},V0=d("section")(({theme:e})=>({"& > *":{margin:e.spacing(1,0)}})),y6="manage-tags-form",v6=(e,n)=>[...e,...e.some(s=>s.value===n.value&&s.type===n.type)?[]:[n]],b6=(e,n)=>e.filter(s=>!(s.value===n.value&&s.type===n.type)),_0=(e,n)=>{switch(n.type){case"add":return{...e,addedTags:v6(e.addedTags,n.payload),removedTags:b6(e.removedTags,n.payload)};case"remove":return{...e,addedTags:b6(e.addedTags,n.payload),removedTags:v6(e.removedTags,n.payload)};case"clear":return{addedTags:[],removedTags:n.payload};default:return e}},S6={name:"",description:"",icon:""},H0=({open:e,initialValues:n,initialIndeterminateValues:s,onCancel:r,onSubmit:o})=>{const{tagTypes:a,loading:i}=g8(),[l,u]=c.useState(S6),[C,h]=c.useState([]),[p,x]=c.useState([]),{tags:S,refetch:g}=G9(l.name),{createTag:y}=s7(),f=S.map(({value:k})=>({title:k})),[m,H]=c.useReducer(_0,{addedTags:[],removedTags:[]}),_=(k=a.length>0?a[0]:S6)=>{u(k);const B=s.filter(({type:z})=>z===k.name);h(n.filter(({type:z})=>z===k.name).filter(({type:z,value:N})=>!B.some(F=>F.value===N&&F.type===z)).map(({value:z})=>({title:z}))),x(B.map(({value:z})=>({title:z}))),H({type:"clear",payload:[]})};c.useEffect(()=>{a.length>0&&_()},[i]);const I=(k,B)=>{B!=null&&typeof B!="string"&&(k.preventDefault(),_(B))},$=(k,B)=>y({value:k,type:B}).then(async()=>{await g(),h(z=>[...z,{title:k}]),H({type:"add",payload:{value:k,type:B}})}),E=(k,B,z,N)=>{z==="selectOption"?B.forEach(F=>{if(typeof F!="string"&&typeof F.inputValue=="string"&&F.inputValue&&F.title.startsWith("Create new value"))return $(F.inputValue,l.name);h(B),x(U=>U.filter(({title:j})=>j!==F.title)),N!=null&&N.option&&H({type:"add",payload:{value:N.option.title,type:l.name}})}):z==="clear"?(h([]),H({type:"clear",payload:n})):z==="removeOption"&&(h(B),N!=null&&N.option&&H({type:"remove",payload:{value:N.option.title,type:l.name}}))},A=()=>{_(),r()};return t.jsxs(I1,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update feature toggle tags",onClick:()=>o(m),disabledPrimaryButton:m.addedTags.length===0&&m.removedTags.length===0,onClose:A,formId:y6,children:[t.jsx(L,{paragraph:!0,sx:{marginBottom:k=>k.spacing(2.5)},children:"Tags allow you to group features together"}),t.jsx("form",{id:y6,onSubmit:()=>o(m),children:t.jsxs(V0,{children:[t.jsx(K9,{options:a,disabled:i||a.length===0,value:l,onChange:I},i?"loading":a.length),t.jsx(V,{condition:!i&&a.length===0,show:t.jsxs(L,{variant:"body1",children:["No"," ",t.jsx(H2,{component:_1,to:"/tag-types",children:"tag types"})," ","available."]}),elseShow:t.jsx(J9,{disabled:i,options:f,existingTags:n,indeterminateOptions:p,tagType:l,selectedOptions:C,onChange:E})})]})})]})},E0=({projectId:e,data:n,onChange:s})=>{const{bulkUpdateTags:r}=s7(),{setToastData:o,setToastApiError:a}=p1(),{trackEvent:i}=v1(),[l,u]=c.useState(!1),[C,h]=c.useMemo(()=>{const x=n.flatMap(({tags:g})=>g||[]).reduce((g,y)=>[...g,...g.some(f=>f.type===y.type&&f.value===y.value)?[]:[y]],[]),S=x.filter(g=>!n.every(({tags:y})=>y==null?void 0:y.some(f=>f.type===g.type&&f.value===g.value)));return[x,S]},[n]),p=async({addedTags:x,removedTags:S})=>{const g=n.map(({name:f})=>f),y={features:g,tags:{addedTags:x,removedTags:S}};try{await r(y,e);const f=x.length?`Added tags: ${x.map(({type:H,value:_})=>`${H}:${_}`).join(", ")}.`:"",m=S.length?`Removed tags: ${S.map(({type:H,value:_})=>`${H}:${_}`).join(", ")}.`:"";o({title:"Tags updated",text:`${g.length} feature toggles updated. ${f} ${m}`,type:"success",autoHideDuration:12e3}),i("batch_operations",{props:{eventType:"tags updated"}})}catch(f){a(d1(f))}s==null||s(),u(!1)};return t.jsxs(t.Fragment,{children:[t.jsx(j5,{projectId:e,permission:_2,children:({hasAccess:x})=>t.jsx(m1,{disabled:!x||l,variant:"outlined",size:"small",onClick:()=>u(!0),children:"Tags"})}),t.jsx(H0,{open:l,onCancel:()=>u(!1),onSubmit:p,initialValues:C,initialIndeterminateValues:h},n.length)]})},M0=d(E2)(({theme:e})=>({minWidth:"450px",marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),w6=d(x1)(({theme:e})=>({marginBottom:e.spacing(1.5)})),T0=({showExportDialog:e,data:n,onClose:s,onConfirm:r,environments:o,projectId:a})=>{const[i,l]=c.useState(o[0]),{bulkToggleFeaturesEnvironmentOff:u}=V4(),{addChange:C}=M2(),{refetch:h}=k1(a),{setToastApiError:p,setToastData:x}=p1(),{isChangeRequestConfigured:S}=g5(a),{refetch:g}=T2(a),y=n.filter(_=>{var I,$;return(($=(I=_.environments)==null?void 0:I.find(E=>i===E.name))==null?void 0:$.enabled)===!1}).length,f=()=>o.map(_=>({key:_,label:_})),m=async()=>{try{S(i)?(await C(a,i,n.map(_=>({action:"updateEnabled",feature:_.name,payload:{enabled:!1}}))),g(),x({text:"Your disabled feature toggles changes have been added to change request",type:"success",title:"Changes added to a draft"})):(await u(a,n.map(_=>_.name),i),h(),x({text:"Your feature toggles have been disabled",type:"success",title:"Features disabled"})),s(),r==null||r()}catch(_){p(d1(_))}},H=S(i)?"Add to change request":"Disable toggles";return t.jsx(I1,{open:e,title:"Disable feature toggles",onClose:s,onClick:m,primaryButtonText:H,secondaryButtonText:"Cancel",children:t.jsxs(w,{children:["You have selected ",t.jsx("b",{children:n.length})," feature toggles to disable.",t.jsx("br",{}),t.jsx("br",{}),t.jsx(L,{children:"Select which environment to disable the features for:"}),t.jsx(M0,{options:f(),value:i,onChange:_=>l(_)}),t.jsx(V,{condition:S(i),show:t.jsx(w6,{severity:"warning",children:"Change requests are enabled for this environment."})}),t.jsx(V,{condition:y>0,show:t.jsxs(w6,{severity:"info",children:[y," feature"," ",y>1?"toggles are ":"toggle is ","already disabled."]})})]})})},A0=d(E2)(({theme:e})=>({minWidth:"450px",marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),V6=d(x1)(({theme:e})=>({marginBottom:e.spacing(1.5)})),k0=({showExportDialog:e,data:n,onClose:s,onConfirm:r,environments:o,projectId:a})=>{const[i,l]=c.useState(o[0]),{bulkToggleFeaturesEnvironmentOn:u}=V4(),{addChange:C}=M2(),{refetch:h}=k1(a),{setToastApiError:p,setToastData:x}=p1(),{isChangeRequestConfigured:S}=g5(a),{refetch:g}=T2(a),y=n.filter(_=>{var I,$;return(($=(I=_.environments)==null?void 0:I.find(E=>i===E.name))==null?void 0:$.enabled)===!0}).length,f=()=>o.map(_=>({key:_,label:_})),m=async()=>{try{S(i)?(await C(a,i,n.map(_=>({action:"updateEnabled",feature:_.name,payload:{enabled:!0}}))),g(),x({text:"Your enable feature toggles changes have been added to change request",type:"success",title:"Changes added to a draft"})):(await u(a,n.map(_=>_.name),i),h(),x({text:"Your feature toggles have been enabled",type:"success",title:"Features enabled"})),s(),r==null||r()}catch(_){p(d1(_))}},H=S(i)?"Add to change request":"Enable toggles";return t.jsx(I1,{open:e,title:"Enable feature toggles",onClose:s,onClick:m,primaryButtonText:H,secondaryButtonText:"Cancel",children:t.jsxs(w,{children:["You have selected ",t.jsx("b",{children:n.length})," feature toggles to enable.",t.jsx("br",{}),t.jsx("br",{}),t.jsx(L,{children:"Select which environment to enable the features for:"}),t.jsx(A0,{options:f(),value:i,onChange:_=>l(_)}),t.jsx(V,{condition:S(i),show:t.jsx(V6,{severity:"warning",children:"Change requests are enabled for this environment."})}),t.jsx(V,{condition:y>0,show:t.jsxs(V6,{severity:"info",children:[y," feature"," ",y>1?"toggles are ":"toggle is ","already enabled."]})})]})})},p7=({selectedIds:e,data:n,projectId:s,onResetSelection:r,onChange:o})=>{var _,I;const{uiConfig:a}=i1(),[i,l]=c.useState(!1),[u,C]=c.useState(!1),[h,p]=c.useState(!1),{trackEvent:x}=v1(),S=c.useMemo(()=>n.filter($=>e.includes($.name)),[n,e]),g=c.useMemo(()=>{const $=S.flatMap(E=>E.environments).map(E=>E==null?void 0:E.name).filter(E=>E!==void 0);return Array.from(new Set($))},[S]),y=()=>{o==null||o(),x("batch_operations",{props:{eventType:"features exported"}})},f=()=>{o==null||o(),x("batch_operations",{props:{eventType:"features enabled"}})},m=()=>{o==null||o(),x("batch_operations",{props:{eventType:"features disabled"}})},H=()=>{o==null||o(),r()};return t.jsxs(t.Fragment,{children:[t.jsx(V,{condition:!!((_=a==null?void 0:a.flags)!=null&&_.disableBulkToggle),show:null,elseShow:t.jsx(m1,{variant:"outlined",size:"small",onClick:()=>C(!0),children:"Enable"})}),t.jsx(V,{condition:!!((I=a==null?void 0:a.flags)!=null&&I.disableBulkToggle),show:null,elseShow:t.jsx(m1,{variant:"outlined",size:"small",onClick:()=>p(!0),children:"Disable"})}),t.jsx(S0,{projectId:s,featureIds:e,features:n,onConfirm:H}),t.jsx(m1,{variant:"outlined",size:"small",onClick:()=>l(!0),children:"Export"}),t.jsx(E0,{projectId:s,data:S,onChange:o}),t.jsx(w0,{projectId:s,data:S,onChange:o}),t.jsx(A2,{showExportDialog:i,data:S,onClose:()=>l(!1),environments:g,onConfirm:y}),t.jsx(k0,{showExportDialog:u,data:S,onClose:()=>C(!1),environments:g,projectId:s,onConfirm:f}),t.jsx(T0,{showExportDialog:h,data:S,onClose:()=>p(!1),environments:g,projectId:s,onConfirm:m})]})},D0=d("div",{shouldForwardProp:e=>e!=="hasWarning"})(({theme:e,hasWarning:n})=>({flexGrow:0,...R1,justifyContent:"center",...n&&{"::before":{content:'""',display:"block",width:e.spacing(2)}}})),L0=({value:e,feature:n,projectId:s,environmentName:r,isChangeRequestEnabled:o,refetch:a,onFeatureToggleSwitch:i})=>{const l=n.environments[r],u=c.useMemo(()=>n.someEnabledEnvironmentHasVariants&&l.variantCount===0&&l.enabled,[n,l]),C=(h,p)=>{i(h,{projectId:s,featureId:n.name,environmentName:r,environmentType:l==null?void 0:l.type,hasStrategies:l==null?void 0:l.hasStrategies,hasEnabledStrategies:l==null?void 0:l.hasEnabledStrategies,isChangeRequestEnabled:o,onRollback:p,onSuccess:a})};return t.jsxs(D0,{hasWarning:u,children:[t.jsx(r7,{projectId:s,value:e,featureId:n.name,environmentName:r,onToggle:C}),t.jsx(V,{condition:u,show:t.jsx(o7,{})})]})},F0=q1.memo(L0),R0=(e,n,s,r,o)=>({value:a,row:{original:i}})=>t.jsx(F0,{value:a,feature:i,projectId:e,environmentName:n,isChangeRequestEnabled:s,refetch:r,onFeatureToggleSwitch:o}),P0=d(H3)(()=>({whiteSpace:"nowrap"})),r2=["Select","Actions","name","favorite"],Z0={id:"createdAt",desc:!0},I0=({features:e,loading:n,environments:s=[],onChange:r,total:o,style:a={}})=>{var f5,X5;const{classes:i}=y0(),l=r1(),{setToastApiError:u}=p1(),C=u1(l.breakpoints.down("md")),[h,p]=c.useState({}),[x,S]=c.useState(),g=q("projectId"),{onToggle:y,modals:f}=a7(g),{value:m,setValue:H}=S2(`${g}:FeatureToggleListTable:v1`,Z0),{value:_,setValue:I}=m8(),$=D1(),[E,A]=E3(),k=Ke(n?[{environment:"a"},{environment:"b"},{environment:"c"}]:s),{isFavoritesPinned:B,sortTypes:z,onChangeIsFavoritePinned:N}=f8(E.has("favorites")?E.get("favorites")==="true":_.favorites),{favorite:F,unfavorite:U}=_4(),{isChangeRequestConfigured:j}=g5(g),[v,O]=c.useState(!1),{uiConfig:M}=i1(),W=c.useCallback(async R=>{try{R!=null&&R.favorite?await U(g,R.name):await F(g,R.name),r()}catch{u("Something went wrong, could not update favorite")}},[g,r]),D=c.useMemo(()=>e.some(R=>{var b;return(b=R==null?void 0:R.tags)==null?void 0:b.length}),[e]),G=c.useMemo(()=>[{id:"Select",Header:({getToggleAllRowsSelectedProps:R})=>t.jsx(B5,{...R()}),Cell:({row:R})=>{var b;return t.jsx(m3,{...(b=R==null?void 0:R.getToggleRowSelectedProps)==null?void 0:b.call(R)})},maxWidth:50,disableSortBy:!0,hideInMenu:!0,styles:{borderRadius:0}},{id:"favorite",Header:t.jsx(H4,{isActive:B,onClick:N}),accessor:"favorite",Cell:({row:{original:R}})=>t.jsx(E4,{value:R==null?void 0:R.favorite,onClick:()=>W(R)}),maxWidth:50,disableSortBy:!0,hideInMenu:!0},{Header:"Seen",accessor:"lastSeenAt",Cell:({value:R,row:{original:b}})=>t.jsx(M4,{feature:b}),align:"center",maxWidth:80},{Header:"Type",accessor:"type",Cell:M3,align:"center",filterName:"type",maxWidth:80},{Header:"Name",accessor:"name",Cell:({value:R})=>t.jsx(S1,{title:R,arrow:!0,describeChild:!0,children:t.jsx("span",{children:t.jsx(T4,{title:R,to:`/projects/${g}/features/${R}`})})}),minWidth:100,sortType:"alphanumeric",searchable:!0},...D?[{id:"tags",Header:"Tags",accessor:R=>{var b;return((b=R.tags)==null?void 0:b.map(({type:P,value:Z})=>`${P}:${Z}`).join(`
2
2
  `))||""},Cell:A4,width:80,searchable:!0,filterName:"tags",filterBy(R,b){return x8(j8(this,R),b)}}]:[],{Header:"Created",accessor:"createdAt",Cell:z5,minWidth:120},...k.map(R=>{const b=typeof R=="string"?R:R.environment,P=j(b),Z=R0(g,b,P,r,y);return{Header:n?()=>"":b,maxWidth:90,id:`environments.${b}`,accessor:J=>{var C1;return(C1=J.environments[b])==null?void 0:C1.enabled},align:"center",Cell:Z,sortType:"boolean",filterName:b,filterParsing:J=>J?"enabled":"disabled"}}),{id:"Actions",maxWidth:56,width:56,Cell:R=>t.jsx(u7,{projectId:g,onOpenArchiveDialog:S,onOpenStaleDialog:p,...R}),disableSortBy:!0,hideInMenu:!0,styles:{borderRadius:0}}],[g,k,n]),[T,Y]=c.useState(E.get("search")||""),[j1,l1]=c.useState(!0),T1=c.useMemo(()=>e.map(R=>{var b;return{...R,environments:Object.fromEntries(k.map(P=>{const Z=R==null?void 0:R.environments.find(J=>(J==null?void 0:J.name)===P);return[P,{name:P,enabled:(Z==null?void 0:Z.enabled)||!1,variantCount:(Z==null?void 0:Z.variantCount)||0,lastSeenAt:Z==null?void 0:Z.lastSeenAt,type:Z==null?void 0:Z.type,hasStrategies:Z==null?void 0:Z.hasStrategies,hasEnabledStrategies:Z==null?void 0:Z.hasEnabledStrategies}]})),someEnabledEnvironmentHasVariants:((b=R.environments)==null?void 0:b.some(P=>P.variantCount>0&&P.enabled))||!1}}),[e,k]),{data:o1,getSearchText:g1,getSearchContext:X1}=k2(G,T,T1),e5=c.useMemo(()=>n?Array(6).fill({type:"-",name:"Feature name",createdAt:new Date,environments:{production:{name:"production",enabled:!1}}}):o1,[n,o1]),O1=c.useMemo(()=>{var P;const R=G.map(Z=>(Z==null?void 0:Z.id)||(typeof(Z==null?void 0:Z.accessor)=="string"?Z==null?void 0:Z.accessor:"")).filter(Boolean);let b=k.filter((Z,J)=>J>=3).map(Z=>`environment:${Z}`);if(E.has("columns")){const Z=((P=E.get("columns"))==null?void 0:P.split(","))||[],J=[...r2,...Z];b=R.filter(C1=>!J.includes(C1))}else if(m.columns){const Z=[...r2,...m.columns];b=R.filter(J=>!Z.includes(J))}return{sortBy:[{id:E.get("sort")||m.id||"createdAt",desc:E.has("order")?E.get("order")==="desc":m.desc}],hiddenColumns:b,selectedRowIds:{}}},[k]),$1=c.useCallback(R=>R.name,[]),{allColumns:w1,headerGroups:i5,rows:B1,state:{selectedRowIds:t5,sortBy:A1,hiddenColumns:y1},prepareRow:n5,setHiddenColumns:Q,toggleAllRowsSelected:L1}=t1.useTable({columns:G,data:e5,initialState:O1,sortTypes:z,autoResetHiddenColumns:!1,autoResetSelectedRows:!1,disableSortRemove:!0,autoResetSortBy:!1,getRowId:$1},t1.useFlexLayout,t1.useSortBy,t1.useRowSelect);return c.useEffect(()=>{if(n)return;const R={};R.sort=A1[0].id,A1[0].desc&&(R.order="desc"),T&&(R.search=T),B&&(R.favorites="true"),R.columns=w1.map(({id:b})=>b).filter(b=>!r2.includes(b)&&!(y1!=null&&y1.includes(b))).join(","),A(R,{replace:!0}),H(b=>({...b,id:A1[0].id,desc:A1[0].desc||!1,columns:R.columns.split(",")})),I(b=>({...b,favorites:!!B}))},[n,A1,y1,T,A,B]),t.jsxs(t.Fragment,{children:[t.jsxs(a1,{isLoading:n,disablePadding:!0,className:i.container,style:a,header:t.jsx(w,{sx:R=>({padding:`${R.spacing(2.5)} ${R.spacing(3.125)}`}),children:t.jsx(n1,{titleElement:j1?`Feature toggles (${o||B1.length})`:null,actions:t.jsxs(t.Fragment,{children:[t.jsx(V,{condition:!C,show:t.jsx(V1,{placeholder:"Search and Filter",expandable:!0,initialValue:T,onChange:Y,onFocus:()=>l1(!1),onBlur:()=>l1(!0),hasFilters:!0,getSearchContext:X1,id:"projectFeatureToggles"})}),t.jsx(j0,{allColumns:w1,staticColumns:r2,dividerAfter:["createdAt"],dividerBefore:["Actions"],isCustomized:!!m.columns,setHiddenColumns:Q}),t.jsx(n1.Divider,{sx:{marginLeft:0}}),t.jsx(V,{condition:!!((f5=M==null?void 0:M.flags)!=null&&f5.featuresExportImport),show:t.jsx(S1,{title:"Export toggles visible in the table below",arrow:!0,children:t.jsx(H1,{onClick:()=>O(!0),sx:R=>({marginRight:R.spacing(2)}),children:t.jsx(y8,{})})})}),t.jsx(P0,{onClick:()=>$(k4(g)),maxWidth:"960px",Icon:T3,projectId:g,permission:V2,"data-testid":"NAVIGATE_TO_CREATE_FEATURE",children:"New feature toggle"})]}),children:t.jsx(V,{condition:C,show:t.jsx(V1,{initialValue:T,onChange:Y,hasFilters:!0,getSearchContext:X1,id:"projectFeatureToggles"})})})}),children:[t.jsx(u5,{value:g1(T),children:t.jsx(D2,{rows:B1,headerGroups:i5,prepareRow:n5})}),t.jsx(V,{condition:B1.length===0,show:t.jsx(V,{condition:(T==null?void 0:T.length)>0,show:t.jsx(w,{sx:{padding:l.spacing(3)},children:t.jsxs(f1,{children:["No feature toggles found matching “",T,"”"]})}),elseShow:t.jsx(w,{sx:{padding:l.spacing(3)},children:t.jsx(f1,{children:"No feature toggles found matching your criteria. Get started by adding a new feature toggle."})})})}),t.jsx(i7,{isStale:h.stale===!0,isOpen:!!h.featureId,onClose:()=>{p({}),r()},featureId:h.featureId||"",projectId:g}),t.jsx(O3,{isOpen:!!x,onConfirm:r,onClose:()=>{S(void 0)},featureIds:[x||""],projectId:g}),t.jsx(V,{condition:!!((X5=M==null?void 0:M.flags)!=null&&X5.featuresExportImport)&&!n,show:t.jsx(A2,{showExportDialog:v,data:e5,onClose:()=>O(!1),environments:k})}),f]}),t.jsx(D4,{count:Object.keys(t5).length,children:t.jsx(p7,{selectedIds:Object.keys(t5),data:e,projectId:g,onResetSelection:()=>L1(!1),onChange:r})})]})},K5=d("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)}})),J5=d("p")(({theme:e})=>({marginBottom:e.spacing(2.5)})),U3=d("span")(({theme:e})=>({fontSize:e.typography.h2.fontSize,fontWeight:"bold",color:e.palette.text.primary})),O2=({children:e,to:n})=>t.jsx(L,{"data-loading":!0,variant:"body2",textAlign:"center",sx:{paddingTop:s=>s.spacing(2.5),marginTop:"auto",justifySelf:"flex-end"},children:t.jsx(H2,{component:_1,to:n,children:e})}),O0=d("p")(({theme:e})=>({fontSize:"1.5rem",[e.breakpoints.down("md")]:{fontSize:e.fontSizes.bodySize,marginBottom:e.spacing(4)}})),$0=d("p")(({theme:e})=>({fontSize:"1.5rem",[e.breakpoints.down("md")]:{fontSize:e.fontSizes.bodySize}})),B0=({projectId:e,health:n})=>t.jsxs(K5,{children:[t.jsx(J5,{"data-loading":!0,children:"Project health"}),t.jsxs(w,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:s=>s.spacing(2)},children:[t.jsx($0,{"data-loading":!0,children:t.jsx(v8,{percentage:n})}),t.jsxs(O0,{"data-loading":!0,children:[n,"%"]})]}),t.jsx(O2,{to:`/projects/${e}/health`,children:"View project health"})]}),z0=d(U3)(({theme:e})=>({marginLeft:"auto",fontWeight:e.typography.fontWeightRegular,color:e.palette.text.secondary})),N0=d("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}})),W0=({type:e,Icon:n,count:s})=>{const r=o=>o.charAt(0).toUpperCase()+o.slice(1).replace("-"," ");return t.jsxs(N0,{"data-loading":!0,children:[t.jsx(n,{fontSize:"small","data-loading":!0}),t.jsx("div",{children:r(e)}),t.jsx(z0,{children:s})]})},U0=({featureTypeCounts:e})=>{const n=c.useMemo(()=>{var l,u,C,h,p;const s=((l=e.find(x=>x.type==="release"))==null?void 0:l.count)||0,r=((u=e.find(x=>x.type==="experiment"))==null?void 0:u.count)||0,o=((C=e.find(x=>x.type==="operational"))==null?void 0:C.count)||0,a=((h=e.find(x=>x.type==="kill-switch"))==null?void 0:h.count)||0,i=((p=e.find(x=>x.type==="permission"))==null?void 0:p.count)||0;return{release:s,experiment:r,operational:o,"kill-switch":a,permission:i}},[e]);return t.jsxs(K5,{sx:{padding:s=>s.spacing(3)},children:[t.jsx(J5,{"data-loading":!0,children:"Toggle types used"}),Object.keys(n).map(s=>t.jsx(W0,{type:s,Icon:b8(s),count:n[s]},s))]})},q0=d("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})),G0=({id:e,description:n})=>t.jsxs(K5,{children:[t.jsx(J5,{"data-loading":!0,children:"Project Meta"}),t.jsxs(q0,{"data-loading":!0,children:[t.jsx(L,{component:"span",variant:"body2",color:"text.secondary",children:"ID:"})," ",t.jsx("code",{"data-loading":!0,children:e||"__________"})]}),t.jsx(V,{condition:!!n,show:t.jsx(L,{"data-loading":!0,variant:"body2",sx:{marginTop:s=>s.spacing(1.5),marginBottom:0,textAlign:"left"},children:n})}),t.jsx(V,{condition:!n,show:t.jsx(O2,{to:`/projects/${e}/settings`,children:"Add description"})})]}),K0=d(L)(({theme:e})=>({marginBottom:e.spacing(2.5)})),J0=d(w)(({theme:e})=>({fontSize:e.fontSizes.largeHeader})),Q2=d(w)(({theme:e})=>({...R1,flexDirection:"column",alignItems:"center",marginLeft:e.spacing(2.5)})),_6=d(L)(({theme:e})=>({color:e.palette.text.secondary,fontSize:e.typography.body2.fontSize})),Y0=d(L)(({theme:e})=>({marginLeft:e.spacing(1),fontSize:e.typography.body1.fontSize,fontWeight:e.typography.fontWeightBold})),Q0=e=>e>0?t.jsx(fe,{sx:{color:"success.dark",height:20,width:20}}):t.jsx(be,{sx:{color:"warning.dark",height:20,width:20}}),X0=e=>e>0?"success.dark":"warning.dark",D5=({title:e,boxText:n,change:s,percentage:r,children:o,customChangeElement:a})=>t.jsxs(t.Fragment,{children:[t.jsx(V,{condition:!!e,show:t.jsx(K0,{"data-loading":!0,children:e})}),o,t.jsxs(w,{sx:{...R1,justifyContent:"center",width:"auto"},children:[t.jsx(J0,{"data-loading":!0,children:n}),t.jsx(V,{condition:!!a,show:t.jsx(Q2,{"data-loading":!0,children:a}),elseShow:t.jsx(V,{condition:s!==void 0&&s!==0,show:t.jsxs(Q2,{"data-loading":!0,children:[t.jsxs(w,{sx:{...R1},children:[Q0(s),t.jsxs(Y0,{color:X0(s),children:[s>0?"+":"",s,r?"%":""]})]}),t.jsx(_6,{children:"this month"})]}),elseShow:t.jsx(Q2,{children:t.jsx(_6,{"data-loading":!0,children:"No change"})})})})]})]}),et=({projectId:e,memberCount:n,change:s=0})=>{var a,i;const{uiConfig:r}=i1();let o="/admin/users";return(i=(a=r==null?void 0:r.versionInfo)==null?void 0:a.current)!=null&&i.enterprise&&(o=`/projects/${e}/settings/access`),t.jsxs(K5,{children:[t.jsx(J5,{"data-loading":!0,children:"Project members"}),t.jsx(w,{"data-loading":!0,sx:{display:"flex",justifyContent:"center"},children:t.jsx(D5,{boxText:`${n}`,change:s})}),t.jsx(O2,{"data-loading":!0,to:o,children:"View all members"})]})},tt=e=>fetch(e).then(K1("ChangeRequest")).then(n=>n.json()),h7=e=>{const{data:n,error:s,mutate:r}=S8([],G1(`api/admin/projects/${e}/change-requests`),tt);return c.useMemo(()=>({changeRequests:n,loading:!s&&!n,refetch:r,error:s}),[n,s,r])},C2="change-requests-widget",nt=d(w)(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing(1.5)})),H6=d(w)(({theme:e})=>({flex:1,textAlign:"left",padding:e.spacing(1.5),borderRadius:e.shape.borderRadiusMedium,alignItems:"center",minWidth:175})),E6=d(w)(({theme:e})=>({display:"flex",alignItems:"center"})),st=d(U3)(({theme:e})=>({background:e.palette.seen.recent,padding:e.spacing(0,1),marginRight:e.spacing(.5),borderRadius:e.shape.borderRadius})),rt=d(U3)(({theme:e})=>({background:e.palette.seen.primary,padding:e.spacing(0,1),marginRight:e.spacing(.5),borderRadius:e.shape.borderRadius})),M6=d(L)(({theme:e})=>({fontSize:e.typography.body2.fontSize,marginBottom:e.spacing(.5)})),T6=()=>t.jsx(L,{component:"span",variant:"body2",color:"text.secondary",lineHeight:1,"data-loading":C2,children:"change requests"}),ot=({projectId:e})=>{const{changeRequests:n,loading:s}=h7(e),r=L2(s,`[data-loading="${C2}"]`),o=n==null?void 0:n.filter(i=>(i==null?void 0:i.state)==="Approved").length,a=n==null?void 0:n.filter(i=>(i==null?void 0:i.state)==="In review").length;return t.jsxs(K5,{ref:r,children:[t.jsx(J5,{children:"Open change requests"}),t.jsxs(nt,{children:[t.jsxs(H6,{sx:{background:i=>i.palette.success.light},children:[t.jsx(M6,{children:"To be applied"}),t.jsxs(E6,{children:[t.jsx(st,{"data-loading":C2,children:o||0})," ",t.jsx(T6,{})]})]}),t.jsxs(H6,{sx:{background:i=>i.palette.secondary.light},children:[t.jsx(M6,{children:"To be reviewed"}),t.jsxs(E6,{children:[t.jsx(rt,{"data-loading":C2,children:a||0})," ",t.jsx(T6,{})]})]})]}),t.jsx(O2,{to:`/projects/${e}/change-requests`,children:"View change requests"})]})},at=d(w)(({theme:e})=>({...R1,width:"225px",flexDirection:"column",gap:e.spacing(2),boxShadow:"none",[e.breakpoints.down("md")]:{display:"grid",width:"100%",alignItems:"stretch"},[e.breakpoints.down("sm")]:{display:"flex"}})),g7=({id:e,description:n,memberCount:s,health:r,featureTypeCounts:o,stats:a})=>{const{isEnterprise:i}=i1(),l=r1(),u=u1(l.breakpoints.down("md")),{isChangeRequestConfiguredInAnyEnv:C}=g5(e),h=i()&&C(),p=e!==w8,x=!h&&!p||u&&h&&p;return t.jsx("aside",{children:t.jsxs(at,{sx:x?{gridTemplateColumns:"repeat(auto-fill, minmax(225px, 1fr))"}:{gridTemplateColumns:"repeat(2, 1fr)"},children:[t.jsx(V,{condition:h,show:t.jsx(w,{sx:{gridColumnStart:p?"span 2":"span 1",flex:1,display:"flex"},children:t.jsx(ot,{projectId:e})})}),t.jsx(G0,{id:e,description:n}),t.jsx(B0,{projectId:e,health:r}),t.jsx(V,{condition:p,show:t.jsx(et,{projectId:e,memberCount:s,change:a==null?void 0:a.projectMembersAddedCurrentWindow})}),t.jsx(U0,{featureTypeCounts:o})]})})},it=d(J1)(({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})),A6=({children:e,id:n})=>{const[s,r]=c.useState(null),o=l=>r(l.currentTarget),a=()=>r(null),i=!!s;return t.jsxs(w,{sx:{position:"absolute",top:l=>l.spacing(.5),right:l=>l.spacing(.5)},children:[t.jsx(H1,{onClick:o,"aria-describedby":n,size:"small",children:t.jsx(L4,{sx:{fontSize:l=>l.typography.body1.fontSize}})}),t.jsx(F4,{id:n,open:i,anchorEl:s,sx:l=>({zIndex:l.zIndex.tooltip}),children:t.jsx(R4,{onClickAway:a,children:t.jsxs(it,{elevation:3,children:[t.jsx(H1,{onClick:a,sx:{position:"absolute",right:4,top:4},children:t.jsx(V8,{sx:{fontSize:l=>l.typography.body1.fontSize}})}),e,t.jsx(_8,{id:n,eventName:"project_overview",localStorageKey:"ProjectOverviewFeedback"})]})})})]})},lt=d(w)(({theme:e})=>({display:"grid",gap:e.spacing(2),gridTemplateColumns:"repeat(4, 1fr)",flexWrap:"wrap",[e.breakpoints.down("lg")]:{gridTemplateColumns:"repeat(2, 1fr)"},[e.breakpoints.down("sm")]:{flexDirection:"column"}})),o2=d(w)(({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)}})),ct=d(L)(({theme:e})=>({color:e.palette.text.secondary,fontSize:e.typography.body2.fontSize,lineHeight:e.typography.body2.lineHeight})),m7=({stats:e})=>{if(Object.keys(e).length===0)return null;const{avgTimeToProdCurrentWindow:n,projectActivityCurrentWindow:s,projectActivityPastWindow:r,createdCurrentWindow:o,createdPastWindow:a,archivedCurrentWindow:i,archivedPastWindow:l}=e;return t.jsxs(lt,{children:[t.jsx(o2,{children:t.jsx(D5,{title:"Total changes",boxText:String(s),change:s-r,children:t.jsx(A6,{id:"total-changes",children:"Sum of all configuration and state modifications in the project."})})}),t.jsx(o2,{children:t.jsx(D5,{title:"Avg. time to production",boxText:t.jsxs(w,{sx:{display:"flex",alignItems:"center",gap:u=>u.spacing(1)},children:[n," ",t.jsx(L,{component:"span",children:"days"})]}),customChangeElement:t.jsx(ct,{children:"In project life"}),percentage:!0,children:t.jsx(A6,{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".'})})}),t.jsx(o2,{children:t.jsx(D5,{title:"Features created",boxText:String(o),change:o-a})}),t.jsx(o2,{children:t.jsx(D5,{title:"Features archived",boxText:String(i),change:i-l})})]})},Ct=d(w)(()=>({...R1,justifyContent:"center"})),dt=d(H1)(({theme:e})=>({margin:e.spacing(-1,0)})),ut=d(w)(({theme:e})=>({...R1,justifyContent:"space-between",padding:e.spacing(1,1,0,4)})),pt=d(N1)(({theme:e})=>({padding:e.spacing(0,2),margin:e.spacing(0,2),borderRadius:e.shape.borderRadius})),ht=d(_3)(({theme:e})=>({"&.MuiDivider-root.MuiDivider-fullWidth":{margin:e.spacing(.75,0)}})),gt=d(B5)(({theme:e})=>({padding:e.spacing(.75,1)})),mt=({columns:e,onToggle:n})=>{const[s,r]=c.useState(null),o=C=>{r(C.currentTarget)},a=()=>{r(null)},i=!!s,l="columns-menu",u=`columns-menu-list-${l}`;return t.jsxs(Ct,{children:[t.jsx(S1,{title:"Select columns",arrow:!0,describeChild:!0,children:t.jsx(dt,{id:l,"aria-controls":i?u:void 0,"aria-haspopup":"true","aria-expanded":i?"true":void 0,onClick:o,type:"button",size:"large","data-loading":!0,children:t.jsx(W3,{})})}),t.jsxs(O5,{id:u,open:i,anchorEl:s,onClose:a,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},disableScrollLock:!0,PaperProps:{sx:C=>({borderRadius:C.shape.borderRadius,paddingBottom:C.spacing(2)})},children:[t.jsxs(ut,{children:[t.jsx(L,{variant:"body2",children:t.jsx("strong",{children:"Columns"})}),t.jsx(H1,{onClick:a,children:t.jsx(S4,{})})]}),t.jsx($5,{children:e.map(C=>C.id==="divider"?t.jsx(ht,{},"divider"):t.jsxs(pt,{onClick:()=>{n==null||n(C.id)},disabled:C.isStatic===!0&&C.isVisible===!0,children:[t.jsx(W1,{children:t.jsx(gt,{edge:"start",checked:C.isVisible,disableRipple:!0,inputProps:{"aria-labelledby":C.id},size:"medium"})}),t.jsx(U1,{id:C.id,primary:t.jsx(L,{variant:"body2",children:C.header})})]},C.id))})]})]})},ft=d(H3)(()=>({whiteSpace:"nowrap"})),xt=({isLoading:e,totalItems:n,searchQuery:s,onChangeSearchQuery:r,environmentsToExport:o,actions:a})=>{const i=q("projectId"),l=L2(e||!1),[u,C]=c.useState(!0),h=r1(),p=u1(h.breakpoints.down("md")),x=F2("featuresExportImport"),[S,g]=c.useState(!1),y=D1(),f=m=>{r==null||r(m)};return t.jsx(w,{ref:l,"aria-busy":e,"aria-live":"polite",sx:m=>({padding:`${m.spacing(2.5)} ${m.spacing(3.125)}`}),children:t.jsx(n1,{titleElement:u?`Feature toggles ${n!==void 0?`(${n})`:""}`:null,actions:t.jsxs(t.Fragment,{children:[t.jsx(V,{condition:!p,show:t.jsx(V1,{"data-loading":!0,placeholder:"Search and Filter",expandable:!0,initialValue:s||"",onChange:f,onFocus:()=>C(!1),onBlur:()=>C(!0),hasFilters:!0,id:"projectFeatureToggles"})}),a,t.jsx(n1.Divider,{sx:{marginLeft:0}}),t.jsx(V,{condition:x,show:t.jsxs(t.Fragment,{children:[t.jsx(S1,{title:"Export all project toggles",arrow:!0,children:t.jsx(H1,{"data-loading":!0,onClick:()=>g(!0),sx:m=>({marginRight:m.spacing(2)}),children:t.jsx(H8,{})})}),t.jsx(V,{condition:!e,show:t.jsx(A2,{showExportDialog:S,project:i,data:[],onClose:()=>g(!1),environments:o||[]})})]})}),t.jsx(ft,{onClick:()=>y(k4(i)),maxWidth:"960px",Icon:T3,projectId:i,permission:V2,"data-testid":"NAVIGATE_TO_CREATE_FEATURE",children:"New feature toggle"})]}),children:t.jsx(V,{condition:p,show:t.jsx(V1,{initialValue:s||"",onChange:f,hasFilters:!0,id:"projectFeatureToggles"})})})})},jt=d("div",{shouldForwardProp:e=>e!=="hasWarning"})(({theme:e,hasWarning:n})=>({flexGrow:0,...R1,justifyContent:"center",...n&&{"::before":{content:'""',display:"block",width:e.spacing(2)}}})),yt=({value:e,featureId:n,projectId:s,environment:r,isChangeRequestEnabled:o,someEnabledEnvironmentHasVariants:a,refetch:i,onFeatureToggleSwitch:l})=>{const u=c.useMemo(()=>a&&(r==null?void 0:r.variantCount)===0&&(r==null?void 0:r.enabled),[a,r]),C=(h,p)=>{l(h,{projectId:s,featureId:n,environmentName:(r==null?void 0:r.name)||"",environmentType:r==null?void 0:r.type,hasStrategies:r==null?void 0:r.hasStrategies,hasEnabledStrategies:r==null?void 0:r.hasEnabledStrategies,isChangeRequestEnabled:o,onRollback:p,onSuccess:i})};return t.jsxs(jt,{hasWarning:u,children:[t.jsx(r7,{projectId:s,value:e,featureId:n,environmentName:(r==null?void 0:r.name)||"",onToggle:C}),t.jsx(V,{condition:u||!1,show:t.jsx(o7,{})})]})},vt=q1.memo(yt),bt=({state:e,onChange:n})=>{const{tags:s}=E8(),[r,o]=c.useState([]);return c.useEffect(()=>{const i=[{label:"Tags",icon:"label",options:(s||[]).map(l=>({label:`${l.type}:${l.value}`,value:`${l.type}:${l.value}`})),filterKey:"tag",singularOperators:["INCLUDE","DO_NOT_INCLUDE"],pluralOperators:["INCLUDE_ALL_OF","INCLUDE_ANY_OF","EXCLUDE_IF_ANY_OF","EXCLUDE_ALL"]},{label:"Created date",icon:"today",options:[],filterKey:"createdAt",dateOperators:["IS_ON_OR_AFTER","IS_BEFORE"]}];o(i)},[JSON.stringify(s)]),t.jsx(M8,{availableFilters:r,state:e,onChange:n})},a2=["select","actions","name","favorite"],i2=(e,n)=>e.reduce((s,r)=>({...s,[r]:n.includes(r)}),{}),St=e=>{const n=r1(),s=u1(n.breakpoints.down("sm")),r=u1(n.breakpoints.down("md")),o=u1(n.breakpoints.down("lg")),a=c.useCallback((i=0)=>e.filter(l=>l.startsWith("environment:")!==!1).slice(0,i),[e]);return s?i2(e,[...a2,"createdAt"]):r?i2(e,[...a2,"createdAt",...a(1)]):o?i2(e,[...a2,"createdAt","type",...a(1)]):i2(e,[...a2,"lastSeenAt","createdAt","type","tags",...a(2)])},wt=({query:e})=>{var n;return((n=e||"")==null?void 0:n.length)>0?t.jsx(w,{sx:s=>({padding:s.spacing(3)}),children:t.jsxs(f1,{children:["No feature toggles found matching “",e,"”"]})}):t.jsx(w,{sx:s=>({padding:s.spacing(3)}),children:t.jsx(f1,{children:"No feature toggles available."})})},Vt=(e,n)=>{const[s,r]=c.useState(),[o,a]=c.useState({});return{rowActionsDialogs:t.jsxs(t.Fragment,{children:[t.jsx(i7,{isStale:!!o.stale,isOpen:!!o.featureId,onClose:()=>{a({}),e()},featureId:o.featureId||"",projectId:n}),t.jsx(O3,{isOpen:!!s,onConfirm:e,onClose:()=>{r(void 0)},featureIds:[s||""],projectId:n})]}),setFeatureArchiveState:r,setFeatureStaleDialogState:a}},_t=(e,n)=>{const[s,r]=c.useState([]);return c.useEffect(()=>{r(o=>{const a=[...e];return o.forEach(i=>{a.find(l=>l.name===i.name)||a.push(i)}),a.filter(i=>n[i.name])})},[e,n]),s},X2=e=>`environment:${e}`,z1=Z8(),Ht=e=>e.name,Et=({environments:e,refreshInterval:n=15*1e3,storageKey:s="project-feature-toggles-v2"})=>{const r=q("projectId"),o=F2("featuresExportImport"),a={offset:A5(u6,0),limit:A5(u6,I8),query:Y2,favoritesFirst:A5(O8,!0),sortBy:A5(Y2,"createdAt"),sortOrder:A5(Y2,"desc"),columns:T8,tag:d6,createdAt:d6},[i,l]=A8(`${s}-${r}`,a),u={tag:i.tag,createdAt:i.createdAt},{features:C,total:h,refetch:p,loading:x,initialLoad:S}=k8(D8({...L8(a,i),project:`IS:${r}`},T=>T?`${T}`:void 0),{refreshInterval:n}),{favorite:g,unfavorite:y}=_4(),f=c.useCallback(async T=>{T!=null&&T.favorite?await y(r,T.name):await g(r,T.name),p()},[r,p]),{isChangeRequestConfigured:m}=g5(r),{onToggle:H,modals:_}=a7(r),{rowActionsDialogs:I,setFeatureArchiveState:$,setFeatureStaleDialogState:E}=Vt(p,r),[A,k]=c.useState(!1),B=c.useMemo(()=>[z1.display({id:"select",header:({table:T})=>t.jsx(m3,{noPadding:!0,title:"Select all rows",checked:T==null?void 0:T.getIsAllRowsSelected(),onChange:T==null?void 0:T.getToggleAllRowsSelectedHandler()}),cell:({row:T})=>t.jsx(m3,{noPadding:!0,title:"Select row",checked:T==null?void 0:T.getIsSelected(),onChange:T==null?void 0:T.getToggleSelectedHandler()}),meta:{width:"1%"},enableHiding:!1}),z1.accessor("favorite",{id:"favorite",header:()=>t.jsx(H4,{isActive:i.favoritesFirst,onClick:()=>l({favoritesFirst:!i.favoritesFirst})}),cell:({row:{original:T}})=>t.jsx(E4,{value:T==null?void 0:T.favorite,onClick:()=>f(T)}),enableSorting:!1,enableHiding:!1,meta:{align:"center",width:"1%"}}),z1.accessor("lastSeenAt",{id:"lastSeenAt",header:"Last seen",cell:({row:{original:T}})=>t.jsx(M4,{feature:T,"data-loading":!0}),size:50,meta:{align:"center",width:"1%"}}),z1.accessor("type",{id:"type",header:"Type",cell:M3,meta:{align:"center",width:"1%"}}),z1.accessor("name",{id:"name",header:"Name",cell:P4,enableHiding:!1,meta:{width:"50%"}}),z1.accessor("tags",{id:"tags",header:"Tags",enableSorting:!1,cell:A4,meta:{width:"1%"}}),z1.accessor("createdAt",{id:"createdAt",header:"Created",cell:z5}),...e.map(T=>{const Y=T.environment,j1=m(Y);return z1.accessor(l1=>{var T1,o1;return{featureId:l1.name,environment:(T1=l1.environments)==null?void 0:T1.find(g1=>g1.name===Y),someEnabledEnvironmentHasVariants:((o1=l1.environments)==null?void 0:o1.some(g1=>g1.variantCount&&g1.variantCount>0&&g1.enabled))||!1}},{id:X2(Y),header:Y,meta:{align:"center",width:90},cell:({getValue:l1})=>{const{featureId:T1,environment:o1,someEnabledEnvironmentHasVariants:g1}=l1();return t.jsx(vt,{value:(o1==null?void 0:o1.enabled)||!1,featureId:T1,someEnabledEnvironmentHasVariants:g1,environment:o1,projectId:r,environmentName:Y,isChangeRequestEnabled:j1,refetch:p,onFeatureToggleSwitch:H})}})}),z1.display({id:"actions",header:"",cell:({row:T})=>t.jsx(u7,{row:T,projectId:r,onOpenArchiveDialog:$,onOpenStaleDialog:E}),enableSorting:!1,enableHiding:!1,meta:{align:"right",width:"1%"}})],[r,e,i.favoritesFirst,p]),z=c.useMemo(()=>Array(i.limit).fill(null).map((T,Y)=>({id:Y,type:"-",name:`Feature name ${Y}`,createdAt:new Date().toISOString(),environments:[{name:"production",enabled:!1},{name:"production",enabled:!1}]})),[i.limit]),N=!!(S||x&&h),F=L2(N),U=c.useMemo(()=>N?z:C,[N,C]),j=c.useMemo(()=>B.map(T=>T.id).filter(Boolean),[B]),v=St(j),O=F8(R8(i,l,{columns:B,data:U,enableRowSelection:!0,state:{columnVisibility:v},getRowId:Ht})),{columnVisibility:M,rowSelection:W}=O.getState(),D=c.useCallback(T=>{const Y=M[T],j1={...M,[T]:!Y};l({columns:Object.keys(j1).filter(l1=>j1[l1])})},[M,l]),G=_t(C,W);return t.jsxs(t.Fragment,{children:[t.jsx(a1,{disableLoading:!0,disablePadding:!0,header:t.jsx(xt,{isLoading:S,totalItems:h,searchQuery:i.query||"",onChangeSearchQuery:T=>{l({query:T})},dataToExport:U,environmentsToExport:e.map(({environment:T})=>T),actions:t.jsx(mt,{columns:[{header:"Last seen",id:"lastSeenAt",isVisible:M.lastSeenAt},{header:"Type",id:"type",isVisible:M.type},{header:"Name",id:"name",isVisible:M.name,isStatic:!0},{header:"Tags",id:"tags",isVisible:M.tags},{header:"Created",id:"createdAt",isVisible:M.createdAt},{id:"divider"},...e.map(({environment:T})=>({header:T,id:X2(T),isVisible:M[X2(T)]}))],onToggle:D})}),bodyClass:"noop",style:{cursor:"inherit"},children:t.jsxs("div",{ref:F,"aria-busy":N,"aria-live":"polite",children:[t.jsx(bt,{onChange:l,state:u}),t.jsx(u5,{value:i.query||"",children:t.jsx(P8,{tableInstance:O,totalItems:h})}),t.jsx(V,{condition:!U.length&&!N,show:t.jsx(wt,{query:i.query||""})}),I,t.jsx(V,{condition:o&&!x,show:t.jsx(A2,{showExportDialog:A,data:U,onClose:()=>k(!1),environments:e.map(({environment:T})=>T)})}),_]})}),t.jsx(D4,{count:G.length,children:t.jsx(p7,{selectedIds:Object.keys(W),data:G,projectId:r,onResetSelection:O.resetRowSelection,onChange:p})})]})},Mt=e=>{const n=()=>{const r=G1(`api/admin/projects/${e}/overview`);return fetch(r,{method:"GET"}).then(K1("Project overview")).then(o=>o.json())},s=`api/admin/projects/${e}/overview`;return{fetcher:n,KEY:s}},Tt={featureTypeCounts:[],environments:[],name:"",health:0,members:0,version:"1",description:"Default",favorite:!1,mode:"open",defaultStickiness:"default",stats:{archivedCurrentWindow:0,archivedPastWindow:0,avgTimeToProdCurrentWindow:0,createdCurrentWindow:0,createdPastWindow:0,projectActivityCurrentWindow:0,projectActivityPastWindow:0,projectMembersAddedCurrentWindow:0}},q3=(e,n={})=>{const{KEY:s,fetcher:r}=Mt(e),{data:o,error:a,mutate:i}=r5(s,r,n),l=c.useCallback(()=>{i()},[i]);return{project:o||Tt,loading:!a&&!o,error:a,refetch:l}},G3=e=>q3(e).project.name||e,f3=15*1e3,f7=d("div")(({theme:e})=>({display:"flex",gap:e.spacing(2),[e.breakpoints.down("md")]:{flexDirection:"column"}})),x7=d("div")(()=>({width:"100%",minWidth:0})),j7=d(w)(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(2),width:"100%",minWidth:0})),At=({storageKey:e="project-overview-v2"})=>{const n=q("projectId"),{project:s}=q3(n,{refreshInterval:f3}),{members:r,featureTypeCounts:o,health:a,description:i,environments:l,stats:u}=s;return t.jsxs(f7,{children:[t.jsx(g7,{id:n,description:i,memberCount:r,health:a,featureTypeCounts:o,stats:u}),t.jsxs(j7,{children:[t.jsx(m7,{stats:s.stats}),t.jsx(x7,{children:t.jsx(Et,{environments:l,refreshInterval:f3,storageKey:e})})]})]},n)},kt=()=>{const e=q("projectId"),n=o5(e),{project:s,loading:r,refetch:o}=k1(e,{refreshInterval:f3}),{members:a,features:i,health:l,description:u,environments:C,stats:h}=s;M1(`Project overview – ${n}`);const{setLastViewed:p}=$8(),x=F2("featureSearchFrontend");if(c.useEffect(()=>{p(e)},[e,p]),x)return t.jsx(At,{});const S=i.reduce((g,y)=>{const f=g.find(m=>m.type===y.type);return f?f.count+=1:g.push({type:y.type,count:1}),g},[]);return t.jsxs(f7,{children:[t.jsx(g7,{id:e,description:u,memberCount:a,health:l,featureTypeCounts:S,stats:h}),t.jsxs(j7,{children:[t.jsx(m7,{stats:s.stats}),t.jsx(x7,{children:t.jsx(I0,{features:i,environments:C,loading:r,onChange:o},r?"loading":"ready")})]})]})},Dt=(e,n)=>{const s=G1(`api/admin/projects/${e}/health-report`),{data:r,error:o}=r5(s,Lt,n),a=c.useCallback(()=>{A3(s).catch(console.warn)},[s]);return{healthReport:r,refetchHealthReport:a,loading:!o&&!r,error:o}},Lt=e=>fetch(e).then(K1("Health report")).then(n=>n.json());var K3={},Ft=h5;Object.defineProperty(K3,"__esModule",{value:!0});var x3=K3.default=void 0,Rt=Ft(p5()),Pt=t,Zt=(0,Rt.default)((0,Pt.jsx)("path",{d:"M12 5.99 19.53 19H4.47L12 5.99M12 2 1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined");x3=K3.default=Zt;const It=d(w)(({theme:e})=>({display:"flex",alignItems:"center",color:e.palette.success.dark,"& svg":{color:e.palette.success.main}})),k6=d(w)(({theme:e})=>({display:"flex",alignItems:"center",color:e.palette.warning.dark,"& svg":{color:e.palette.warning.main}})),Ot=d(J1)(({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)}})),e3=d("h2")(({theme:e})=>({fontSize:e.fontSizes.mainHeader,marginBottom:e.spacing(1),justifyItems:"center",display:"flex"})),$t=d("p")(({theme:e})=>({fontSize:"2rem",fontWeight:e.fontWeight.bold})),Bt=d("p")(({theme:e})=>({color:e.palette.text.secondary})),D6=d("ul")(({theme:e})=>({listStyleType:"none",margin:0,padding:0,"& svg":{marginRight:e.spacing(1)}})),L6=d("p")(({theme:e})=>({marginLeft:e.spacing(4)})),zt=({healthReport:e})=>{const n=e.health<50?"error.main":e.health<75?"warning.main":"success.main",s=()=>t.jsxs(It,{children:[t.jsx(w2,{}),t.jsxs("span",{children:[e.activeCount," active toggles"]})]}),r=()=>t.jsxs(k6,{children:[t.jsx(x3,{}),t.jsxs("span",{children:[e.staleCount," stale toggles"]})]}),o=()=>t.jsxs(k6,{children:[t.jsx(x3,{}),t.jsxs("span",{children:[e.potentiallyStaleCount," potentially stale toggles"]})]}),a=()=>t.jsx(Z4,{title:t.jsxs(t.Fragment,{children:["If your toggle exceeds the expected lifetime of it's toggle type it will be marked as potentially stale.",t.jsx(w,{sx:{mt:2},children:t.jsx("a",{href:"https://docs.getunleash.io/reference/technical-debt#stale-and-potentially-stale-toggles",target:"_blank",rel:"noreferrer",children:"Read more in the documentation"})})]}),children:t.jsx(B8,{sx:{color:i=>i.palette.text.secondary,ml:1}})});return t.jsxs(Ot,{children:[t.jsxs(w,{children:[t.jsx(e3,{children:"Health rating"}),t.jsx(V,{condition:e.health>-1,show:t.jsxs(t.Fragment,{children:[t.jsxs($t,{sx:{color:n},children:[e.health,"%"]}),t.jsxs(Bt,{children:["Last updated:"," ",t.jsx(k3,{date:e.updatedAt,live:!1})]})]})})]}),t.jsxs(w,{children:[t.jsx(e3,{children:"Toggle report"}),t.jsxs(D6,{children:[t.jsx("li",{children:t.jsx(V,{condition:!!e.activeCount,show:s})}),t.jsx(V,{condition:!!e.activeCount,show:t.jsx(L6,{children:"Also includes potentially stale toggles."})}),t.jsx("li",{children:t.jsx(V,{condition:!!e.staleCount,show:r})})]})]}),t.jsxs(w,{sx:{flexBasis:"40%"},children:[t.jsxs(e3,{children:["Potential actions"," ",t.jsx("span",{children:t.jsx(a,{})})]}),t.jsx(D6,{children:t.jsx("li",{children:t.jsx(V,{condition:!!e.potentiallyStaleCount,show:o})})}),t.jsx(V,{condition:!!e.potentiallyStaleCount,show:t.jsxs(t.Fragment,{children:[t.jsx(L6,{children:"Review your feature toggles and delete unused toggles."}),t.jsx(w,{sx:{mt:2},children:t.jsx(H2,{component:_1,to:"/feature-toggle-type",children:"Configure feature types lifetime"})})]}),elseShow:t.jsx("span",{children:"No action is required"})})]})]})},Nt=({row:e})=>{const n=r1();return e.original.expiredAt?t.jsx(z5,{value:e.original.expiredAt}):t.jsx(h1,{children:t.jsx(L,{variant:"body2",color:n.palette.text.secondary,children:"N/A"})})},Wt=d("span")(({theme:e})=>({display:"flex",gap:"1ch",alignItems:"center",color:e.palette.warning.dark,"& svg":{color:e.palette.warning.main}})),Ut=d("span")(({theme:e})=>({display:"flex",gap:"1ch",alignItems:"center",color:e.palette.success.dark,"& svg":{color:e.palette.success.main}})),qt=({row:e})=>e.original.status==="potentially-stale"?t.jsx(h1,{children:t.jsxs(Wt,{children:[t.jsx(ye,{}),t.jsx("span",{children:"Potentially stale"})]})}):t.jsx(h1,{children:t.jsxs(Ut,{children:[t.jsx(I4,{}),t.jsx("span",{children:"Healthy"})]})}),y7=(e,n)=>Math.abs(z8(e,n)),v7=(e,n)=>{var s;return n.lifetimeDays?e>=((s=n==null?void 0:n.lifetimeDays)==null?void 0:s.valueOf()):!1},Gt=(e,n)=>{const{type:s,createdAt:r}=e,o=n.find(u=>u.id===s),a=O4(r),l=y7(a,new Date);return o&&v7(l,o)&&s!==$4&&s!==B4?"potentially-stale":"healthy"},Kt=(e,n)=>{var u;const{type:s,createdAt:r}=e,o=n.find(C=>C.id===s);if(o&&(o.name===$4||o.name===B4))return;const a=O4(r),i=new Date,l=y7(a,i);if(o&&v7(l,o)){const C=l-(((u=o==null?void 0:o.lifetimeDays)==null?void 0:u.valueOf())||0);return Se(i,C).toISOString()}},Jt=({projectId:e,features:n})=>{const s=r1(),r=u1(s.breakpoints.down("sm")),o=u1(s.breakpoints.down("md")),a=u1(s.breakpoints.down("lg"));i1();const{featureTypes:i}=N8(),l=c.useMemo(()=>n.map(m=>({project:e,name:m.name,type:m.type,stale:m.stale,environments:m.environments,status:Gt(m,i),lastSeenAt:m.lastSeenAt,createdAt:m.createdAt,expiredAt:Kt(m,i)})),[e,n,i]),u=c.useMemo(()=>({hiddenColumns:[],sortBy:[{id:"createdAt",desc:!0}]}),[]),C=c.useMemo(()=>[{Header:"Seen",accessor:"lastSeenAt",Cell:({value:m,row:{original:H}})=>t.jsx(W8,{feature:H}),align:"center",maxWidth:80},{Header:"Type",accessor:"type",align:"center",Cell:M3,disableGlobalFilter:!0,maxWidth:85},{Header:"Name",accessor:"name",sortType:"alphanumeric",Cell:P4,minWidth:120},{Header:"Created",accessor:"createdAt",Cell:z5,disableGlobalFilter:!0,maxWidth:150},{Header:"Expired",accessor:"expiredAt",Cell:Nt,disableGlobalFilter:!0,maxWidth:150},{Header:"Status",id:"status",accessor:"status",Cell:qt,disableGlobalFilter:!0,width:180},{Header:"State",accessor:"stale",sortType:"boolean",Cell:U8,disableGlobalFilter:!0,maxWidth:120}],[]),{headerGroups:h,rows:p,prepareRow:x,state:{globalFilter:S},setGlobalFilter:g,setHiddenColumns:y}=t1.useTable({columns:C,data:l,initialState:u,sortTypes:N5,autoResetGlobalFilter:!1,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0},t1.useGlobalFilter,t1.useFlexLayout,t1.useSortBy);W5([{condition:r,columns:["stale"]},{condition:o,columns:["expiredAt","lastSeenAt"]},{condition:a,columns:["createdAt"]}],y,C);const f=p.length<l.length?`Feature toggles (${p.length} of ${l.length})`:`Feature toggles (${l.length})`;return t.jsxs(a1,{header:t.jsx(n1,{title:f,actions:t.jsx(V1,{initialValue:S,onChange:g})}),children:[t.jsx(u5,{value:S,children:t.jsx(D2,{headerGroups:h,prepareRow:x,rows:p})}),t.jsx(V,{condition:p.length===0,show:t.jsx(V,{condition:(S==null?void 0:S.length)>0,show:t.jsxs(f1,{children:["No feature toggles found matching “",S,"”"]}),elseShow:t.jsx(f1,{children:"No feature toggles available. Get started by adding a new feature toggle."})})})]})},Yt=()=>{const e=q("projectId"),n=o5(e);M1(`Project health – ${n}`);const{healthReport:s,refetchHealthReport:r,error:o}=Dt(e,{refreshInterval:15*1e3});return s?t.jsxs("div",{children:[t.jsx(V,{condition:!!o,show:t.jsx(y4,{"data-loading":!0,style:{maxWidth:"500px",marginTop:"1rem"},onClick:r,text:`Could not fetch health rating for ${e}`})}),t.jsx(zt,{healthReport:s}),t.jsx(Jt,{projectId:e,features:s.features})]}):null},Qt=d("div")(({theme:e})=>({borderRadius:"12.5px",backgroundColor:e.palette.background.paper,padding:"2rem"})),Xt=()=>{const e=q("projectId");return t.jsx(Qt,{children:t.jsx(q8,{title:"Event Log",project:e,displayInline:!0})})},b7=(e,n)=>{const{data:s,error:r,mutate:o}=r5(G1(`api/admin/projects/${e}/change-requests/${n}`),en,{refreshInterval:15e3});return{data:s,loading:!r&&!s,refetchChangeRequest:()=>o(),error:r}},en=e=>fetch(e).then(K1("Request changes")).then(n=>n.json()),tn=d(J1)(({theme:e})=>({padding:e.spacing(3,4),borderRadius:`${e.shape.borderRadiusLarge}px`}));d(w)(({theme:e})=>({display:"flex",alignItems:"center",marginBottom:e.spacing(2)}));const nn=d(w)(({theme:e})=>({display:"flex",alignItems:"center"})),sn=d(L)(({theme:e})=>({display:"flex",alignItems:"center",marginRight:e.spacing(1),fontSize:e.fontSizes.mainHeader})),rn=d(G8)(({theme:e})=>({padding:e.spacing(.75,1.5),backgroundColor:e.palette.background.elevation2})),J3=d(R2)(({theme:e})=>({height:"24px",width:"24px"})),on=({changeRequest:e})=>{var r,o,a;const[n,s]=c.useState(e.title);return t.jsxs(tn,{elevation:0,children:[t.jsx(K8,{environmentChangeRequest:e,title:n,setTitle:s,children:t.jsx(sn,{variant:"h1",sx:{mr:1.5},children:n})}),t.jsxs(nn,{children:[t.jsx(z4,{changeRequest:e}),t.jsxs(L,{variant:"body2",sx:i=>({margin:i.spacing("auto",0,"auto",2)}),children:["Created"," ",t.jsx(k3,{minPeriod:60,date:new Date(e.createdAt)})," ","by"]}),t.jsx(w,{sx:i=>({marginLeft:i.spacing(1)}),children:t.jsx(S1,{title:(r=e==null?void 0:e.createdBy)==null?void 0:r.username,children:t.jsx(J3,{src:(o=e==null?void 0:e.createdBy)==null?void 0:o.imageUrl})})}),t.jsx(L,{variant:"body2",sx:i=>({marginLeft:i.spacing(.5)}),children:(a=e==null?void 0:e.createdBy)==null?void 0:a.username}),t.jsx(w,{sx:i=>({marginLeft:i.spacing(1.5)}),children:t.jsx(rn,{variant:"outlined",children:t.jsxs(L,{variant:"body2",sx:{lineHeight:1},children:["Environment:"," ",t.jsx(L,{display:"inline",fontWeight:"bold",variant:"body2",component:"span",children:e==null?void 0:e.environment})," ",t.jsx(J8,{}),"Updates:",t.jsx(Y8,{featuresCount:e.features.length,segmentsCount:e.segments.length})]})})})]})]})};function c1(){return c1=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=s[r])}return e},c1.apply(this,arguments)}function H5(e,n){if(e==null)return{};var s={},r=Object.keys(e),o,a;for(a=0;a<r.length;a++)o=r[a],!(n.indexOf(o)>=0)&&(s[o]=e[o]);return s}const an=c.createContext({}),m2=an;function ln(e){return b5("MuiTimeline",e)}m5("MuiTimeline",["root","positionLeft","positionRight","positionAlternate"]);const cn=["position","className"],Cn=e=>{const{position:n,classes:s}=e,r={root:["root",n&&`position${Y1(n)}`]};return V5(r,ln,s)},dn=d("ul",{name:"MuiTimeline",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:s}=e;return[n.root,s.position&&n[`position${Y1(s.position)}`]]}})({display:"flex",flexDirection:"column",padding:"6px 16px",flexGrow:1}),un=c.forwardRef(function(n,s){const r=S5({props:n,name:"MuiTimeline"}),{position:o="right",className:a}=r,i=H5(r,cn),l=c1({},r,{position:o}),u=Cn(l),C=c.useMemo(()=>({position:o}),[o]);return t.jsx(m2.Provider,{value:C,children:t.jsx(dn,c1({className:w5(u.root,a),ownerState:l,ref:s},i))})}),S7=un;function pn(e){return b5("MuiTimelineContent",e)}const hn=m5("MuiTimelineContent",["root","positionLeft","positionRight","positionAlternate"]),gn=["className"],mn=e=>{const{position:n,classes:s}=e,r={root:["root",`position${Y1(n)}`]};return V5(r,pn,s)},fn=d(L,{name:"MuiTimelineContent",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:s}=e;return[n.root,n[`position${Y1(s.position)}`]]}})(({ownerState:e})=>c1({flex:1,padding:"6px 16px",textAlign:"left"},e.position==="left"&&{textAlign:"right"})),xn=c.forwardRef(function(n,s){const r=S5({props:n,name:"MuiTimelineContent"}),{className:o}=r,a=H5(r,gn),{position:i}=c.useContext(m2),l=c1({},r,{position:i||"right"}),u=mn(l);return t.jsx(fn,c1({component:"div",className:w5(u.root,o),ownerState:l,ref:s},a))}),w7=xn,jn=m5("MuiTimelineOppositeContent",["root","positionLeft","positionRight","positionAlternate"]),yn=jn;function vn(e){return b5("MuiTimelineItem",e)}const bn=m5("MuiTimelineItem",["root","positionLeft","positionRight","positionAlternate","missingOppositeContent"]),V7=bn,Sn=["position","className"],wn=e=>{const{position:n,classes:s,hasOppositeContent:r}=e,o={root:["root",`position${Y1(n)}`,!r&&"missingOppositeContent"]};return V5(o,vn,s)},Vn=d("li",{name:"MuiTimelineItem",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:s}=e;return[n.root,n[`position${Y1(s.position)}`]]}})(({ownerState:e})=>c1({listStyle:"none",display:"flex",position:"relative",minHeight:70},e.position==="left"&&{flexDirection:"row-reverse"},e.position==="alternate"&&{"&:nth-of-type(even)":{flexDirection:"row-reverse",[`& .${hn.root}`]:{textAlign:"right"},[`& .${yn.root}`]:{textAlign:"left"}}},!e.hasOppositeContent&&{"&:before":{content:'""',flex:1,padding:"6px 16px"}})),_n=c.forwardRef(function(n,s){const r=S5({props:n,name:"MuiTimelineItem"}),{position:o,className:a}=r,i=H5(r,Sn),{position:l}=c.useContext(m2);let u=!1;c.Children.forEach(r.children,x=>{Q8(x,["TimelineOppositeContent"])&&(u=!0)});const C=c1({},r,{position:o||l||"right",hasOppositeContent:u}),h=wn(C),p=c.useMemo(()=>({position:C.position}),[C.position]);return t.jsx(m2.Provider,{value:p,children:t.jsx(Vn,c1({className:w5(h.root,a),ownerState:C,ref:s},i))})}),d2=_n;function Hn(e){return b5("MuiTimelineSeparator",e)}m5("MuiTimelineSeparator",["root"]);const En=["className"],Mn=e=>{const{classes:n}=e;return V5({root:["root"]},Hn,n)},Tn=d("div",{name:"MuiTimelineSeparator",slot:"Root",overridesResolver:(e,n)=>n.root})({display:"flex",flexDirection:"column",flex:0,alignItems:"center"}),An=c.forwardRef(function(n,s){const r=S5({props:n,name:"MuiTimelineSeparator"}),{className:o}=r,a=H5(r,En),i=r,l=Mn(i);return t.jsx(Tn,c1({className:w5(l.root,o),ownerState:i,ref:s},a))}),u2=An;function kn(e){return b5("MuiTimelineDot",e)}m5("MuiTimelineDot",["root","filled","outlined","filledGrey","outlinedGrey","filledPrimary","outlinedPrimary","filledSecondary","outlinedSecondary"]);const Dn=["className","color","variant"],Ln=e=>{const{color:n,variant:s,classes:r}=e,o={root:["root",s,n!=="inherit"&&`${s}${Y1(n)}`]};return V5(o,kn,r)},Fn=d("span",{name:"MuiTimelineDot",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:s}=e;return[n.root,n[s.color!=="inherit"&&`${s.variant}${Y1(s.color)}`],n[s.variant]]}})(({ownerState:e,theme:n})=>c1({display:"flex",alignSelf:"baseline",borderStyle:"solid",borderWidth:2,padding:4,borderRadius:"50%",boxShadow:(n.vars||n).shadows[1],margin:"11.5px 0"},e.variant==="filled"&&c1({borderColor:"transparent"},e.color!=="inherit"&&c1({},e.color==="grey"?{color:(n.vars||n).palette.grey[50],backgroundColor:(n.vars||n).palette.grey[400]}:{color:(n.vars||n).palette[e.color].contrastText,backgroundColor:(n.vars||n).palette[e.color].main})),e.variant==="outlined"&&c1({boxShadow:"none",backgroundColor:"transparent"},e.color!=="inherit"&&c1({},e.color==="grey"?{borderColor:(n.vars||n).palette.grey[400]}:{borderColor:(n.vars||n).palette[e.color].main})))),Rn=c.forwardRef(function(n,s){const r=S5({props:n,name:"MuiTimelineDot"}),{className:o,color:a="grey",variant:i="filled"}=r,l=H5(r,Dn),u=c1({},r,{color:a,variant:i}),C=Ln(u);return t.jsx(Fn,c1({className:w5(C.root,o),ownerState:u,ref:s},l))}),_7=Rn;function Pn(e){return b5("MuiTimelineConnector",e)}m5("MuiTimelineConnector",["root"]);const Zn=["className"],In=e=>{const{classes:n}=e;return V5({root:["root"]},Pn,n)},On=d("span",{name:"MuiTimelineConnector",slot:"Root",overridesResolver:(e,n)=>n.root})(({theme:e})=>({width:2,backgroundColor:(e.vars||e).palette.grey[400],flexGrow:1})),$n=c.forwardRef(function(n,s){const r=S5({props:n,name:"MuiTimelineConnector"}),{className:o}=r,a=H5(r,Zn),i=r,l=In(i);return t.jsx(On,c1({className:w5(l.root,o),ownerState:i,ref:s},a))}),H7=$n,Bn=d(J1)(({theme:e})=>({marginTop:e.spacing(2),borderRadius:`${e.shape.borderRadiusLarge}px`})),zn=d(w)(({theme:e})=>({padding:e.spacing(2),marginBottom:`-${e.spacing(4)}`})),Nn=d(w)(({theme:e})=>({display:"flex",flexDirection:"row",alignItems:"flex-end"})),Wn=d(S7)(()=>({[`& .${V7.root}:before`]:{flex:0,padding:0}})),Un=["Draft","In review","Approved","Applied"],qn=["Draft","In review","Rejected"],Gn=["Draft","In review","Approved","Scheduled","Applied"],Kn=(e,n,s,r,o)=>e==="Cancelled"?"grey":e==="Rejected"?s==="Rejected"?"error":"success":n!==-1&&n>r?"success":n!==-1&&n===r?e==="Scheduled"?o?"error":"warning":"success":n+1===r?"primary":"grey",Jn=({state:e,scheduledAt:n,failureReason:s})=>{let r;switch(e){case"Rejected":r=qn;break;case"Scheduled":r=Gn;break;default:r=Un}const o=r.findIndex(i=>i===e),{locationSettings:a}=P2();return t.jsx(Bn,{elevation:0,children:t.jsx(zn,{children:t.jsx(Wn,{children:r.map((i,l)=>{const u=n&&e==="Scheduled"&&e===i?D3(new Date(n),a==null?void 0:a.locale):void 0,C=Kn(e,o,i,l,s);let h={};return o+1===l&&!(e==="Cancelled"&&i==="Draft")&&(h={variant:"outlined"}),Yn(C,i,u,s,l<r.length-1,h)})})})})},Yn=(e,n,s,r,o,a={})=>t.jsxs(d2,{children:[t.jsxs(u2,{children:[t.jsx(_7,{color:e,...a}),o&&t.jsx(H7,{})]}),t.jsxs(w7,{children:[n,t.jsx(V,{condition:!!s,show:t.jsxs(Nn,{children:[t.jsx(L,{color:"text.secondary",sx:{mr:1},children:`(for ${s})`}),t.jsx(V,{condition:!!r,show:t.jsx(Z4,{title:`Schedule failed because of ${r}`,arrow:!0,children:t.jsx(L3,{color:"error",fontSize:"small"})})})]})})]})]},n),Y3=()=>e=>e!=="color"&&e!=="sx"&&e!=="approved"&&e!=="border"&&e!=="bgColor"&&e!=="svgColor",P1=d(w)(({theme:e})=>({display:"flex",alignItems:"center"})),E7=d(F3)(({theme:e})=>({color:e.palette.error.main,height:"35px",width:"35px",marginRight:e.spacing(1)})),F6=d(F3)(({theme:e})=>({color:e.palette.warning.main,height:"35px",width:"35px",marginRight:e.spacing(1)})),f2=d(N4)(({theme:e})=>({color:e.palette.success.main,height:"35px",width:"35px",marginRight:e.spacing(1)})),Qn=d(ve)(({theme:e})=>({color:e.palette.warning.main,height:"35px",width:"35px",marginRight:e.spacing(1)})),Xn=d(L3)(({theme:e})=>({color:e.palette.error.main,height:"35px",width:"35px",marginRight:e.spacing(1)})),es=d(Z2)(({theme:e})=>({color:e.palette.text.secondary,height:"24px",width:"24px"})),ts=d(w)(({theme:e})=>({display:"flex",marginTop:e.spacing(2)})),ns=d(w,{shouldForwardProp:Y3()})(({theme:e,bgColor:n,svgColor:s})=>({borderRadius:`${e.shape.borderRadiusMedium}px`,backgroundColor:n,padding:e.spacing(1,2),marginRight:e.spacing(2),height:"45px",width:"45px",display:"flex",alignItems:"center",justifyContent:"center",svg:{color:s}})),Q3=d(_3)(({theme:e})=>({margin:e.spacing(2.5,0)})),ss=d(w,{shouldForwardProp:Y3()})(({theme:e,border:n})=>({borderRadius:`${e.shape.borderRadiusLarge}px`,border:n,padding:e.spacing(3),width:"100%"})),Z1=d(L,{shouldForwardProp:Y3()})(({theme:e,color:n})=>({fontWeight:"bold",color:n})),rs=d(w)({display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%"}),$2=()=>Intl.DateTimeFormat().resolvedOptions().timeZone,os=(e,n)=>e==="Approved"||e==="Scheduled"?`2px solid ${n.palette.success.main}`:e==="Applied"?`2px solid ${n.palette.primary.main}`:`1px solid ${n.palette.divider}`,as=(e,n)=>e==="Approved"?{bgColor:n.palette.success.main,svgColor:n.palette.background.paper}:e==="Applied"?{bgColor:n.palette.primary.main,svgColor:n.palette.background.paper}:{bgColor:n.palette.background.elevation2,svgColor:n.palette.neutral.main},is=({changeRequest:e,onEditClick:n})=>{const s=r1();return t.jsxs(ts,{children:[t.jsx(ns,{...as(e.state,s),children:t.jsx(X8,{style:{transform:"scale(1.5)"}})}),t.jsx(ss,{sx:{backgroundColor:e.state==="In review"?s.palette.warning.light:"initial"},border:os(e.state,s),children:t.jsx(ls,{changeRequest:e,onEditClick:n})})]})},ls=({changeRequest:e,onEditClick:n})=>{const{state:s,schedule:r}=e;return s?s==="Approved"?t.jsx(cs,{}):s==="Applied"?t.jsx(ds,{}):s==="Cancelled"?t.jsx(ms,{}):s==="Rejected"?t.jsx(fs,{}):s==="Scheduled"?t.jsx(ps,{schedule:r,onEditClick:n}):t.jsx(Cs,{minApprovals:e.minApprovals}):null},cs=()=>{const e=r1();return t.jsxs(t.Fragment,{children:[t.jsxs(P1,{children:[t.jsx(f2,{}),t.jsxs(w,{children:[t.jsx(Z1,{color:e.palette.success.dark,children:"Changes approved"}),t.jsx(L,{children:"One approving review from requested approvers"})]})]}),t.jsx(Q3,{}),t.jsxs(P1,{children:[t.jsx(f2,{}),t.jsx(w,{children:t.jsx(Z1,{color:e.palette.success.dark,children:"Changes are ready to be applied"})})]})]})},Cs=({minApprovals:e})=>{const n=r1();return t.jsxs(t.Fragment,{children:[t.jsxs(P1,{children:[t.jsx(F6,{}),t.jsxs(w,{children:[t.jsx(Z1,{color:n.palette.warning.dark,children:"Review required"}),t.jsxs(L,{children:["At least ",e," approval(s) must be submitted before changes can be applied"]})]})]}),t.jsx(Q3,{}),t.jsxs(P1,{children:[t.jsx(F6,{}),t.jsx(Z1,{color:n.palette.warning.dark,children:"Apply changes is blocked"})]})]})},ds=()=>{const e=r1();return t.jsx(t.Fragment,{children:t.jsxs(P1,{children:[t.jsx(f2,{sx:{color:e.palette.primary.main}}),t.jsx(w,{children:t.jsx(Z1,{color:e.palette.primary.main,children:"Changes applied"})})]})})},us=d(H1)({maxWidth:"32px",maxHeight:"32px"}),ps=({schedule:e,onEditClick:n})=>{const s=r1();return $2(),P2(),e!=null&&e.scheduledAt?t.jsxs(t.Fragment,{children:[t.jsxs(P1,{children:[t.jsx(f2,{}),t.jsxs(w,{children:[t.jsx(Z1,{color:s.palette.success.dark,children:"Changes approved"}),t.jsx(L,{children:"One approving review from requested approvers"})]})]}),t.jsx(Q3,{}),t.jsxs(rs,{children:[t.jsx(V,{condition:(e==null?void 0:e.status)==="pending",show:t.jsx(gs,{schedule:e}),elseShow:t.jsx(hs,{schedule:e})}),t.jsx(us,{onClick:n,children:t.jsx(es,{})})]})]}):null},hs=({schedule:e})=>{const n=r1(),s=$2(),{locationSettings:r}=P2();if(!(e!=null&&e.scheduledAt))return null;const o=D3(new Date(e==null?void 0:e.scheduledAt),r==null?void 0:r.locale);return t.jsxs(P1,{children:[t.jsx(Xn,{}),t.jsxs(w,{children:[t.jsxs(Z1,{color:n.palette.error.main,children:["Changes failed to be applied on ",o," because of"," ",e==null?void 0:e.failureReason]}),t.jsxs(L,{children:["Your timezone is ",s]})]})]})},gs=({schedule:e})=>{const n=r1(),s=$2(),{locationSettings:r}=P2();if(!(e!=null&&e.scheduledAt))return null;const o=D3(new Date(e==null?void 0:e.scheduledAt),r==null?void 0:r.locale);return t.jsxs(P1,{children:[t.jsx(Qn,{}),t.jsxs(w,{children:[t.jsxs(Z1,{color:n.palette.warning.dark,children:["Changes are scheduled to be applied on: ",o]}),t.jsxs(L,{children:["Your timezone is ",s]})]})]})},ms=()=>{const e=r1();return t.jsx(t.Fragment,{children:t.jsxs(P1,{children:[t.jsx(E7,{}),t.jsx(w,{children:t.jsx(Z1,{color:e.palette.error.main,children:"Changes cancelled"})})]})})},fs=()=>{const e=r1();return t.jsx(t.Fragment,{children:t.jsxs(P1,{children:[t.jsx(E7,{}),t.jsx(w,{children:t.jsx(Z1,{color:e.palette.error.main,children:"Changes rejected"})})]})})};var X3={},xs=h5;Object.defineProperty(X3,"__esModule",{value:!0});var M7=X3.default=void 0,js=xs(p5()),ys=t,vs=(0,js.default)((0,ys.jsx)("path",{d:"m7 10 5 5 5-5z"}),"ArrowDropDown");M7=X3.default=vs;const T7=({disabled:e,children:n,actions:s,permission:r})=>{const{isAdmin:o}=c.useContext(Q1),a=q("projectId"),i=q("id"),{user:l}=W4(),{data:u}=b7(a,i),[C,h]=q1.useState(!1),p=q1.useRef(null),x=()=>{h(y=>!y)},S=y=>{var f;(f=p.current)!=null&&f.contains(y.target)||h(!1)},g=p.current?p.current.offsetWidth:null;return t.jsxs(q1.Fragment,{children:[t.jsx(a5,{variant:"contained",disabled:e||(u==null?void 0:u.createdBy.id)===(l==null?void 0:l.id)&&!o,"aria-controls":C?"review-options-menu":void 0,"aria-expanded":C?"true":void 0,"aria-label":"review changes","aria-haspopup":"menu",onClick:x,ref:p,endIcon:t.jsx(M7,{}),permission:r,projectId:a,environmentId:u==null?void 0:u.environment,children:n}),t.jsx(F4,{sx:{zIndex:1,width:g},open:C,anchorEl:p.current,role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:y,placement:f})=>t.jsx(e9,{...y,style:{transformOrigin:f==="bottom"?"center top":"center bottom"},children:t.jsx(J1,{className:"dropdown-outline",children:t.jsx(R4,{onClickAway:S,children:t.jsx($5,{id:"review-options-menu",autoFocusItem:!0,children:s.map(({label:m,onSelect:H,icon:_})=>t.jsxs(N1,{onClick:H,children:[t.jsx(W1,{children:_}),t.jsx(U1,{children:m})]},`MenuItem-${m}`))})})})})})]})},bs=({disabled:e,onReject:n,onApprove:s,children:r})=>t.jsx(T7,{permission:t9,disabled:e,actions:[{label:"Approve",onSelect:s,icon:t.jsx(w2,{fontSize:"small"})},{label:"Reject",onSelect:n,icon:t.jsx(Q9,{fontSize:"small"})}],children:r});var A7={},e6={},t6={};Object.defineProperty(t6,"__esModule",{value:!0});var Ss=c,ws=Vs(Ss);function Vs(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s]);return n.default=e,n}t6.default=function(e,n,s){return ws.createElement("a",{href:e,key:s},n)};var n6={};Object.defineProperty(n6,"__esModule",{value:!0});n6.default=function(e){return e};var s6={},t3,R6;function _s(){return R6||(R6=1,t3=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/),t3}var n3,P6;function Hs(){return P6||(P6=1,n3=/[\0-\x1F\x7F-\x9F]/),n3}var s3,Z6;function Es(){return Z6||(Z6=1,s3=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/),s3}var r3,I6;function Ms(){return I6||(I6=1,r3=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\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]/),r3}var o3,O6;function Ts(){return O6||(O6=1,o3=function(e){var n={};n.src_Any=_s().source,n.src_Cc=Hs().source,n.src_Z=Es().source,n.src_P=Ms().source,n.src_ZPCc=[n.src_Z,n.src_P,n.src_Cc].join("|"),n.src_ZCc=[n.src_Z,n.src_Cc].join("|");var s="[><|]";return n.src_pseudo_letter="(?:(?!"+s+"|"+n.src_ZPCc+")"+n.src_Any+")",n.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]?)",n.src_auth="(?:(?:(?!"+n.src_ZCc+"|[@/\\[\\]()]).)+@)?",n.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",n.src_host_terminator="(?=$|"+s+"|"+n.src_ZPCc+")(?!-|_|:\\d|\\.-|\\.(?!$|"+n.src_ZPCc+"))",n.src_path="(?:[/?#](?:(?!"+n.src_ZCc+"|"+s+`|[()[\\]{}.,"'?!\\-]).|\\[(?:(?!`+n.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+n.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+n.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+n.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+n.src_ZCc+"|[']).)+\\'|\\'(?="+n.src_pseudo_letter+"|[-]).|\\.{2,4}[a-zA-Z0-9%/]|\\.(?!"+n.src_ZCc+"|[.]).|"+(e&&e["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+"\\,(?!"+n.src_ZCc+").|\\!(?!"+n.src_ZCc+"|[!]).|\\?(?!"+n.src_ZCc+"|[?]).)+|\\/)?",n.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',n.src_xn="xn--[a-z0-9\\-]{1,59}",n.src_domain_root="(?:"+n.src_xn+"|"+n.src_pseudo_letter+"{1,63})",n.src_domain="(?:"+n.src_xn+"|(?:"+n.src_pseudo_letter+")|(?:"+n.src_pseudo_letter+"(?:-|"+n.src_pseudo_letter+"){0,61}"+n.src_pseudo_letter+"))",n.src_host="(?:(?:(?:(?:"+n.src_domain+")\\.)*"+n.src_domain+"))",n.tpl_host_fuzzy="(?:"+n.src_ip4+"|(?:(?:(?:"+n.src_domain+")\\.)+(?:%TLDS%)))",n.tpl_host_no_ip_fuzzy="(?:(?:(?:"+n.src_domain+")\\.)+(?:%TLDS%))",n.src_host_strict=n.src_host+n.src_host_terminator,n.tpl_host_fuzzy_strict=n.tpl_host_fuzzy+n.src_host_terminator,n.src_host_port_strict=n.src_host+n.src_port+n.src_host_terminator,n.tpl_host_port_fuzzy_strict=n.tpl_host_fuzzy+n.src_port+n.src_host_terminator,n.tpl_host_port_no_ip_fuzzy_strict=n.tpl_host_no_ip_fuzzy+n.src_port+n.src_host_terminator,n.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+n.src_ZPCc+"|>|$))",n.tpl_email_fuzzy="(^|"+s+'|"|\\(|'+n.src_ZCc+")("+n.src_email_name+"@"+n.tpl_host_fuzzy_strict+")",n.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+n.src_ZPCc+"))((?![$+<=>^`||])"+n.tpl_host_port_fuzzy_strict+n.src_path+")",n.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+n.src_ZPCc+"))((?![$+<=>^`||])"+n.tpl_host_port_no_ip_fuzzy_strict+n.src_path+")",n}),o3}function j3(e){var n=Array.prototype.slice.call(arguments,1);return n.forEach(function(s){s&&Object.keys(s).forEach(function(r){e[r]=s[r]})}),e}function B2(e){return Object.prototype.toString.call(e)}function As(e){return B2(e)==="[object String]"}function ks(e){return B2(e)==="[object Object]"}function Ds(e){return B2(e)==="[object RegExp]"}function $6(e){return B2(e)==="[object Function]"}function Ls(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var k7={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function Fs(e){return Object.keys(e||{}).reduce(function(n,s){return n||k7.hasOwnProperty(s)},!1)}var Rs={"http:":{validate:function(e,n,s){var r=e.slice(n);return s.re.http||(s.re.http=new RegExp("^\\/\\/"+s.re.src_auth+s.re.src_host_port_strict+s.re.src_path,"i")),s.re.http.test(r)?r.match(s.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(e,n,s){var r=e.slice(n);return s.re.no_http||(s.re.no_http=new RegExp("^"+s.re.src_auth+"(?:localhost|(?:(?:"+s.re.src_domain+")\\.)+"+s.re.src_domain_root+")"+s.re.src_port+s.re.src_host_terminator+s.re.src_path,"i")),s.re.no_http.test(r)?n>=3&&e[n-3]===":"||n>=3&&e[n-3]==="/"?0:r.match(s.re.no_http)[0].length:0}},"mailto:":{validate:function(e,n,s){var r=e.slice(n);return s.re.mailto||(s.re.mailto=new RegExp("^"+s.re.src_email_name+"@"+s.re.src_host_strict,"i")),s.re.mailto.test(r)?r.match(s.re.mailto)[0].length:0}}},Ps="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]",Zs="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function Is(e){e.__index__=-1,e.__text_cache__=""}function Os(e){return function(n,s){var r=n.slice(s);return e.test(r)?r.match(e)[0].length:0}}function B6(){return function(e,n){n.normalize(e)}}function x2(e){var n=e.re=Ts()(e.__opts__),s=e.__tlds__.slice();e.onCompile(),e.__tlds_replaced__||s.push(Ps),s.push(n.src_xn),n.src_tlds=s.join("|");function r(l){return l.replace("%TLDS%",n.src_tlds)}n.email_fuzzy=RegExp(r(n.tpl_email_fuzzy),"i"),n.link_fuzzy=RegExp(r(n.tpl_link_fuzzy),"i"),n.link_no_ip_fuzzy=RegExp(r(n.tpl_link_no_ip_fuzzy),"i"),n.host_fuzzy_test=RegExp(r(n.tpl_host_fuzzy_test),"i");var o=[];e.__compiled__={};function a(l,u){throw new Error('(LinkifyIt) Invalid schema "'+l+'": '+u)}Object.keys(e.__schemas__).forEach(function(l){var u=e.__schemas__[l];if(u!==null){var C={validate:null,link:null};if(e.__compiled__[l]=C,ks(u)){Ds(u.validate)?C.validate=Os(u.validate):$6(u.validate)?C.validate=u.validate:a(l,u),$6(u.normalize)?C.normalize=u.normalize:u.normalize?a(l,u):C.normalize=B6();return}if(As(u)){o.push(l);return}a(l,u)}}),o.forEach(function(l){e.__compiled__[e.__schemas__[l]]&&(e.__compiled__[l].validate=e.__compiled__[e.__schemas__[l]].validate,e.__compiled__[l].normalize=e.__compiled__[e.__schemas__[l]].normalize)}),e.__compiled__[""]={validate:null,normalize:B6()};var i=Object.keys(e.__compiled__).filter(function(l){return l.length>0&&e.__compiled__[l]}).map(Ls).join("|");e.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+n.src_ZPCc+"))("+i+")","i"),e.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+n.src_ZPCc+"))("+i+")","ig"),e.re.pretest=RegExp("("+e.re.schema_test.source+")|("+e.re.host_fuzzy_test.source+")|@","i"),Is(e)}function $s(e,n){var s=e.__index__,r=e.__last_index__,o=e.__text_cache__.slice(s,r);this.schema=e.__schema__.toLowerCase(),this.index=s+n,this.lastIndex=r+n,this.raw=o,this.text=o,this.url=o}function z6(e,n){var s=new $s(e,n);return e.__compiled__[s.schema].normalize(s,e),s}function E1(e,n){if(!(this instanceof E1))return new E1(e,n);n||Fs(e)&&(n=e,e={}),this.__opts__=j3({},k7,n),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=j3({},Rs,e),this.__compiled__={},this.__tlds__=Zs,this.__tlds_replaced__=!1,this.re={},x2(this)}E1.prototype.add=function(n,s){return this.__schemas__[n]=s,x2(this),this};E1.prototype.set=function(n){return this.__opts__=j3(this.__opts__,n),this};E1.prototype.test=function(n){if(this.__text_cache__=n,this.__index__=-1,!n.length)return!1;var s,r,o,a,i,l,u,C,h;if(this.re.schema_test.test(n)){for(u=this.re.schema_search,u.lastIndex=0;(s=u.exec(n))!==null;)if(a=this.testSchemaAt(n,s[2],u.lastIndex),a){this.__schema__=s[2],this.__index__=s.index+s[1].length,this.__last_index__=s.index+s[0].length+a;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(C=n.search(this.re.host_fuzzy_test),C>=0&&(this.__index__<0||C<this.__index__)&&(r=n.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(i=r.index+r[1].length,(this.__index__<0||i<this.__index__)&&(this.__schema__="",this.__index__=i,this.__last_index__=r.index+r[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(h=n.indexOf("@"),h>=0&&(o=n.match(this.re.email_fuzzy))!==null&&(i=o.index+o[1].length,l=o.index+o[0].length,(this.__index__<0||i<this.__index__||i===this.__index__&&l>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=i,this.__last_index__=l))),this.__index__>=0};E1.prototype.pretest=function(n){return this.re.pretest.test(n)};E1.prototype.testSchemaAt=function(n,s,r){return this.__compiled__[s.toLowerCase()]?this.__compiled__[s.toLowerCase()].validate(n,r,this):0};E1.prototype.match=function(n){var s=0,r=[];this.__index__>=0&&this.__text_cache__===n&&(r.push(z6(this,s)),s=this.__last_index__);for(var o=s?n.slice(s):n;this.test(o);)r.push(z6(this,s)),o=o.slice(this.__last_index__),s+=this.__last_index__;return r.length?r:null};E1.prototype.tlds=function(n,s){return n=Array.isArray(n)?n:[n],s?(this.__tlds__=this.__tlds__.concat(n).sort().filter(function(r,o,a){return r!==a[o-1]}).reverse(),x2(this),this):(this.__tlds__=n.slice(),this.__tlds_replaced__=!0,x2(this),this)};E1.prototype.normalize=function(n){n.schema||(n.url="http://"+n.url),n.schema==="mailto:"&&!/^mailto:/i.test(n.url)&&(n.url="mailto:"+n.url)};E1.prototype.onCompile=function(){};var Bs=E1;const zs=["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(s6,"__esModule",{value:!0});var Ns=Bs,Ws=D7(Ns),Us=zs,qs=D7(Us);function D7(e){return e&&e.__esModule?e:{default:e}}var L7=new Ws.default;L7.tlds(qs.default);s6.default=function(e){return L7.match(e)};var r6={};Object.defineProperty(r6,"__esModule",{value:!0});r6.default=function(e){return e};Object.defineProperty(e6,"__esModule",{value:!0});var Gs=function(){function e(n,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(n,o.key,o)}}return function(n,s,r){return s&&e(n.prototype,s),r&&e(n,r),n}}(),Ks=c,k5=rr(Ks),Js=t6,Ys=z2(Js),Qs=n6,Xs=z2(Qs),er=s6,tr=z2(er),nr=r6,sr=z2(nr);function z2(e){return e&&e.__esModule?e:{default:e}}function rr(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s]);return n.default=e,n}function or(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function ar(e,n){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n&&(typeof n=="object"||typeof n=="function")?n:e}function ir(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof n);e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),n&&(Object.setPrototypeOf?Object.setPrototypeOf(e,n):e.__proto__=n)}var F7=function(e){ir(n,e);function n(){return or(this,n),ar(this,(n.__proto__||Object.getPrototypeOf(n)).apply(this,arguments))}return Gs(n,[{key:"parseString",value:function(r){var o=this;if(r==="")return r;var a=this.props.matchDecorator(r);if(!a)return r;var i=[],l=0;return a.forEach(function(u,C){u.index>l&&i.push(r.substring(l,u.index));var h=o.props.hrefDecorator(u.url),p=o.props.textDecorator(u.text),x=o.props.componentDecorator(h,p,C);i.push(x),l=u.lastIndex}),r.length>l&&i.push(r.substring(l)),i.length===1?i[0]:i}},{key:"parse",value:function(r){var o=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return typeof r=="string"?this.parseString(r):k5.isValidElement(r)&&r.type!=="a"&&r.type!=="button"?k5.cloneElement(r,{key:a},this.parse(r.props.children)):Array.isArray(r)?r.map(function(i,l){return o.parse(i,l)}):r}},{key:"render",value:function(){return k5.createElement(k5.Fragment,null,this.parse(this.props.children))}}]),n}(k5.Component);F7.defaultProps={componentDecorator:Ys.default,hrefDecorator:Xs.default,matchDecorator:tr.default,textDecorator:sr.default};e6.default=F7;Object.defineProperty(A7,"__esModule",{value:!0});var lr=e6,cr=Cr(lr);function Cr(e){return e&&e.__esModule?e:{default:e}}var dr=A7.default=cr.default;const ur=d(w)(({theme:e})=>({display:"flex",marginTop:e.spacing(2)})),pr=d(J1)(({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})),hr=d(w)(({theme:e})=>({display:"flex",borderBottom:"1px solid",borderColor:e.palette.divider,paddingBottom:e.spacing(1.5)})),gr=({comment:e})=>t.jsxs(ur,{children:[t.jsx(S1,{title:e.createdBy.username,children:t.jsx(n9,{src:e.createdBy.imageUrl})}),t.jsxs(pr,{variant:"outlined",children:[t.jsx(hr,{children:t.jsxs(w,{children:[t.jsx("strong",{children:e.createdBy.username})," ",t.jsxs(L,{color:"text.secondary",component:"span",children:["commented"," ",t.jsx(k3,{minPeriod:60,date:new Date(e.createdAt)})]})]})}),t.jsx(w,{sx:{paddingTop:2.5},children:t.jsx(dr,{children:e.text})})]})]}),R7=d(w)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"wrap",marginTop:e.spacing(1.5),gap:e.spacing(1)})),mr=d(N4)(({theme:e})=>({color:e.palette.success.main,marginLeft:"auto"})),fr=d(F3)(({theme:e})=>({color:e.palette.error.main,marginLeft:"auto"})),P7=d(L)({maxWidth:"170px",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",color:"text.primary"}),xr=({name:e,imageUrl:n})=>t.jsxs(R7,{children:[t.jsx(J3,{src:n}),t.jsx(P7,{variant:"body1",children:e}),t.jsx(mr,{})]}),jr=({name:e,imageUrl:n})=>t.jsxs(R7,{children:[t.jsx(J3,{src:n}),t.jsx(P7,{variant:"body1",children:e}),t.jsx(fr,{})]}),yr=({rejections:e=[]})=>t.jsxs(t.Fragment,{children:[t.jsx(L,{variant:"body1",color:"text.secondary",children:"Rejected by"}),e.map(n=>t.jsx(jr,{name:n.createdBy.username||"Unknown user",imageUrl:n.createdBy.imageUrl},n.createdBy.username))]}),vr=({approvals:e=[]})=>t.jsxs(t.Fragment,{children:[t.jsx(L,{variant:"body1",color:"text.secondary",children:t.jsx(V,{condition:(e==null?void 0:e.length)>0,show:"Approved by",elseShow:"No approvals yet"})}),e.map(n=>t.jsx(xr,{name:n.createdBy.username||"Unknown user",imageUrl:n.createdBy.imageUrl},n.createdBy.username))]}),br=d(w)(({theme:e})=>({marginBottom:e.spacing(2)})),Sr=({actualApprovals:e,minApprovals:n})=>t.jsxs(t.Fragment,{children:["Reviewers"," ",t.jsxs(L,{component:"span",color:"text.secondary",children:["(",e,"/",n," required)"]})]}),wr=({header:e,children:n})=>t.jsxs(J1,{elevation:0,sx:s=>({marginTop:s.spacing(2),padding:s.spacing(4),borderRadius:r=>`${r.shape.borderRadiusLarge}px`}),children:[t.jsx(br,{children:e}),n]}),Vr=({changeRequest:e})=>t.jsx(wr,{header:t.jsx(Sr,{actualApprovals:e.approvals.length,minApprovals:e.minApprovals}),children:t.jsx(V,{condition:e.state==="Rejected",show:t.jsx(yr,{rejections:e.rejections}),elseShow:t.jsx(vr,{approvals:e.approvals})})}),_r=({open:e,onConfirm:n,onClose:s})=>{const[r,o]=c.useState("");return t.jsxs(I1,{open:e,primaryButtonText:"Reject changes",secondaryButtonText:"Cancel",onClick:()=>n(r),onClose:s,title:"Reject changes",fullWidth:!0,children:[t.jsx(w,{children:"Add an optional comment why you reject those changes"}),t.jsx(U5,{sx:{mt:1},variant:"outlined",placeholder:"Add your comment here",fullWidth:!0,multiline:!0,minRows:2,onChange:a=>o(a.target.value),value:r})]})};var o6={},Hr=h5;Object.defineProperty(o6,"__esModule",{value:!0});var Z7=o6.default=void 0,Er=Hr(p5()),Mr=t,Tr=(0,Er.default)((0,Mr.jsx)("path",{d:"M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z"}),"Today");Z7=o6.default=Tr;const N6=({disabled:e,onSchedule:n,onApply:s,variant:r="create",children:o})=>t.jsx(T7,{permission:I2,disabled:e,actions:[{label:"Apply changes",onSelect:s,icon:t.jsx(w2,{fontSize:"small"})},{label:r==="create"?"Schedule changes":"Update schedule",onSelect:n,icon:t.jsx(Z7,{fontSize:"small"})}],children:o}),Ar=d(x1)(({theme:e})=>({marginBottom:e.spacing(2),backgroundColor:`${e.palette.neutral.light}!important`,color:`${e.palette.text.primary}!important`,borderColor:`${e.palette.neutral.light}!important`})),I7=({open:e,onConfirm:n,onClose:s,title:r,primaryButtonText:o,message:a,scheduledTime:i,permissionButton:l})=>i?t.jsxs(I1,{title:r,primaryButtonText:o,secondaryButtonText:"Cancel",open:e,onClose:s,onClick:()=>n(),permissionButton:l,fullWidth:!0,children:[t.jsxs(Ar,{icon:!1,children:["There is a scheduled time to apply these changes set for"," ",t.jsxs("strong",{children:[t.jsx("br",{}),`${new Date(i).toLocaleString()}`]})]}),t.jsx(L,{variant:"body1",children:a})]}):null,kr=({projectId:e,environment:n,disabled:s,onConfirm:r,...o})=>{const a="Applying the changes now means the scheduled time will be ignored",i="Apply changes",l="Apply changes now";return t.jsx(I7,{message:a,title:i,primaryButtonText:l,onConfirm:r,permissionButton:t.jsx(a5,{variant:"contained",onClick:()=>r(),projectId:e,permission:I2,environmentId:n,disabled:s,children:"Apply changes now"}),...o})},Dr=({...e})=>{const n="Rejecting this change request will delete its schedule and it can no longer be rescheduled or applied.",s="Reject changes",r="Reject changes";return t.jsx(I7,{message:n,title:s,primaryButtonText:r,...e})},Lr=d(w)(({theme:e})=>({display:"flex",flexDirection:"row",alignItems:"center",gap:e.spacing(2)})),Fr=({open:e,onConfirm:n,onClose:s,title:r,primaryButtonText:o,projectId:a,environment:i,disabled:l,scheduledAt:u})=>{const[C,h]=c.useState(u?new Date(u):new Date),[p,x]=c.useState(void 0),S=$2();return t.jsxs(I1,{title:r,primaryButtonText:o,secondaryButtonText:"Cancel",open:e,onClose:()=>s(),onClick:()=>n(C),permissionButton:t.jsx(a5,{variant:"contained",onClick:()=>n(C),projectId:a,permission:I2,environmentId:i,disabled:l,children:o}),fullWidth:!0,children:[t.jsx(x1,{severity:"info",sx:{mb:g=>g.spacing(2)},children:"The time shown below is based on your browser's time zone."}),t.jsx(L,{variant:"body1",sx:{mb:g=>g.spacing(4)},children:"Select the date and time when these changes should be applied. If you change your mind later, you can reschedule the changes or apply them immediately."}),t.jsxs(Lr,{children:[t.jsx(s9,{label:"Date",value:C,onChange:g=>{x(void 0),g<new Date&&x(`The time you provided (${g.toLocaleString()}) is not valid because it's in the past. Please select a time in the future.`),h(g)},min:new Date,error:!!p,errorText:p,required:!0}),t.jsxs(L,{variant:"body2",children:["Your browser's time zone is ",S]})]})]})},Rr=d(w)(({theme:e})=>({width:"30%",display:"flex",flexDirection:"column",[e.breakpoints.down("sm")]:{width:"100%"}})),Pr=d(J1)(({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%"}})),Zr=d(w)(({theme:e})=>({marginTop:e.spacing(3),display:"flex",justifyContent:"flex-end"})),Ir=d(w)(({theme:e})=>({padding:e.spacing(2)})),W6=d(m1)(({theme:e})=>({marginLeft:e.spacing(2)})),Or=d(w)(({theme:e})=>({display:"flex",[e.breakpoints.down("sm")]:{flexDirection:"column"}})),$r=()=>{var X1,e5,O1,$1,w1,i5,B1,t5,A1,y1,n5;const e=q("projectId"),[n,s]=c.useState(!1),[r,o]=c.useState(!1),[a,i]=c.useState(!1),[l,u]=c.useState(!1),[C,h]=c.useState(!1),{user:p}=W4(),{isAdmin:x}=c.useContext(Q1),[S,g]=c.useState(""),y=q("id"),{data:f,refetchChangeRequest:m}=b7(e,y),{changeState:H,addComment:_,loading:I}=M2(),{refetch:$}=T2(e),{setToastData:E,setToastApiError:A}=p1(),{isChangeRequestConfiguredForReview:k}=g5(e),B=F2("scheduledConfigurationChanges"),{trackEvent:z}=v1();if(!f)return null;const N=k(f.environment),F=!!((X1=f.schedule)!=null&&X1.scheduledAt),U=async()=>{try{await H(e,Number(y),{state:"Applied"}),u(!1),m(),$(),E({type:"success",title:"Success",text:"Changes applied"}),F&&z("scheduled-configuration-changes",{props:{action:"scheduled-applied"}})}catch(Q){A(d1(Q))}},j=async Q=>{const L1=F?"scheduled-updated":"scheduled-created";try{await H(e,Number(y),{state:"Scheduled",scheduledAt:Q.toISOString()}),i(!1),m(),$(),E({type:"success",title:"Success",text:"Changes scheduled"}),z("scheduled-configuration-changes",{props:{action:L1}})}catch(f5){A(d1(f5))}},v=async()=>{try{await _(e,y,S),g(""),m(),E({type:"success",title:"Success",text:"Comment added"})}catch(Q){A(d1(Q))}},O=async()=>{try{await H(e,Number(y),{state:"Cancelled"}),s(!1),m(),$(),E({type:"success",title:"Success",text:"Changes cancelled"})}catch(Q){A(d1(Q))}},M=async Q=>{try{await H(e,Number(y),{state:"Rejected",comment:Q}),o(!1),E({type:"success",title:"Success",text:"Changes rejected"}),m(),$(),F&&z("scheduled-configuration-changes",{props:{action:"scheduled-rejected"}})}catch(L1){A(d1(L1))}},W=async()=>{try{await H(e,Number(y),{state:"Approved"}),m(),$(),E({type:"success",title:"Success",text:"Changes approved"})}catch(Q){A(d1(Q))}},D=()=>s(!0),G=()=>s(!1),T=()=>o(!1),Y=()=>u(!1),j1=()=>i(!1),l1=()=>h(!1),T1=(f==null?void 0:f.createdBy.id)===(p==null?void 0:p.id)&&f.state==="In review"&&!x,o1=(e5=f.approvals)==null?void 0:e5.some(Q=>Q.createdBy.id===(p==null?void 0:p.id)),g1=r9(f);return t.jsxs(t.Fragment,{children:[t.jsx(on,{changeRequest:f}),t.jsxs(Or,{children:[t.jsxs(Rr,{children:[t.jsx(Jn,{state:f.state,scheduledAt:(O1=f.schedule)==null?void 0:O1.scheduledAt,failureReason:($1=f.schedule)==null?void 0:$1.failureReason}),t.jsx(Vr,{changeRequest:f})]}),t.jsx(Pr,{elevation:0,children:t.jsxs(Ir,{children:["Requested Changes (",g1,")",t.jsx(o9,{changeRequest:f,onRefetch:m}),(w1=f.comments)==null?void 0:w1.map(Q=>t.jsx(gr,{comment:Q},Q.id)),t.jsx(a9,{user:p,commentText:S,onTypeComment:g,children:t.jsx(m1,{variant:"outlined",onClick:v,disabled:!N||S.trim().length===0||S.trim().length>1e3,children:"Comment"})}),t.jsx(V,{condition:T1,show:t.jsx(x1,{sx:Q=>({marginTop:Q.spacing(1.5)}),severity:"info",children:"You can not approve your own change request"})}),t.jsx(is,{changeRequest:f,onEditClick:()=>i(!0)}),t.jsxs(Zr,{children:[t.jsx(V,{condition:f.state==="In review"&&!o1,show:t.jsxs(bs,{onReject:()=>o(!0),onApprove:W,disabled:!N,children:["Review changes (",g1,")"]})}),t.jsx(V,{condition:f.state==="Approved",show:t.jsx(V,{condition:B,show:t.jsx(N6,{onApply:U,disabled:!N||I,onSchedule:()=>i(!0),children:"Apply or schedule changes"}),elseShow:t.jsx(a5,{variant:"contained",onClick:U,projectId:e,permission:I2,environmentId:f.environment,disabled:!N||I,children:"Apply changes"})})}),t.jsx(V,{condition:B&&f.state==="Scheduled",show:t.jsx(N6,{onApply:()=>u(!0),disabled:!N||I,onSchedule:()=>i(!0),variant:"update",children:"Apply or schedule changes"})}),t.jsx(V,{condition:f.state!=="Applied"&&f.state!=="Rejected"&&f.state!=="Cancelled"&&(f.createdBy.id===(p==null?void 0:p.id)||x),show:t.jsx(V,{condition:B&&!!((i5=f.schedule)!=null&&i5.scheduledAt),show:t.jsx(W6,{variant:"outlined",onClick:()=>h(!0),children:"Reject changes"}),elseShow:t.jsx(W6,{variant:"outlined",onClick:D,children:"Cancel changes"})})})]})]})}),t.jsxs(I1,{open:n,onClick:O,onClose:G,title:"Cancel change request",children:[t.jsx(L,{sx:{marginBottom:2},children:"You are about to cancel this change request"}),t.jsx(L,{variant:"body2",sx:Q=>({color:Q.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."})]}),t.jsx(_r,{open:r,onConfirm:M,onClose:T}),t.jsx(V,{condition:B,show:t.jsxs(t.Fragment,{children:[t.jsx(Fr,{open:a,onConfirm:j,onClose:j1,disabled:!N||I,projectId:e,environment:f.environment,primaryButtonText:(B1=f==null?void 0:f.schedule)!=null&&B1.scheduledAt?"Update scheduled time":"Schedule changes",title:(t5=f==null?void 0:f.schedule)!=null&&t5.scheduledAt?"Update schedule":"Schedule changes",scheduledAt:((A1=f==null?void 0:f.schedule)==null?void 0:A1.scheduledAt)||void 0}),t.jsx(kr,{open:l,onConfirm:U,onClose:Y,scheduledTime:(y1=f==null?void 0:f.schedule)==null?void 0:y1.scheduledAt,disabled:!N||I,projectId:e,environment:f.environment}),t.jsx(Dr,{open:C,onConfirm:M,onClose:l1,scheduledTime:(n5=f==null?void 0:f.schedule)==null?void 0:n5.scheduledAt})]})})]})]})},Br=({value:e,row:{original:n}})=>{const s=()=>e?t.jsx(z4,{changeRequest:n}):null;return e?t.jsx(h1,{children:s()}):t.jsx(h1,{})},zr=d("div")(({theme:e})=>({display:"flex",flexDirection:"row",alignItems:"center",margin:0})),Nr=({value:e})=>{const{searchQuery:n}=R3();return t.jsx(h1,{children:t.jsx(zr,{children:t.jsxs(L,{component:"span",variant:"body2",children:[" ",t.jsx(h2,{search:n,children:e==null?void 0:e.username})]})})})},Wr=d("div")(({theme:e})=>({display:"flex",flexDirection:"row",margin:0})),Ur=({value:e,row:{original:n}})=>{const{searchQuery:s}=R3(),r=q("projectId"),{id:o,title:a,features:i,segments:l}=n,u=(i||[]).length+(l||[]).length,C=`/projects/${r}/change-requests/${o}`;return e?t.jsxs(h1,{sx:{minWidth:"200px"},children:[t.jsx(Wr,{children:t.jsx(L,{variant:"body2",children:t.jsx(H2,{component:_1,underline:"hover",to:C,sx:h=>({paddingTop:h.spacing(.2),marginRight:h.spacing(1),"&:hover":{textDecoration:"underline"}}),children:t.jsx(h2,{search:s,children:a})})})}),t.jsxs("span",{children:[`${u}`," ",u<=1?"update":"updates"]})]}):t.jsx(h1,{})},qr=w4()(e=>({header:{padding:e.spacing(0,4)},bodyClass:{padding:e.spacing(2,4,4,4),overflowX:"auto"}})),Gr=d(w)(({theme:e})=>({display:"flex",flexDirection:"column",width:"300px",padding:e.spacing(1,0,1,2)})),Kr=d(_1)(({theme:e})=>({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}})),Jr=d(_1)(({theme:e})=>({textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}})),Yr=d(w)(({theme:e})=>({display:"flex",flexDirection:"column",fontSize:e.fontSizes.smallBody,width:"100%",whiteSpace:"nowrap"})),Qr=({value:e,project:n})=>{const{searchQuery:s}=R3(),r=e==null?void 0:e.map(o=>o.name);return t.jsx(Gr,{children:t.jsx(V,{condition:(r==null?void 0:r.length)<3,show:r==null?void 0:r.map(o=>t.jsx(Kr,{title:o,to:`/projects/${n}/features/${o}`,children:t.jsx(h2,{search:s,children:o})})),elseShow:t.jsxs(i9,{tooltipProps:{maxWidth:"800px"},tooltip:t.jsx(Yr,{children:r==null?void 0:r.map(o=>t.jsx(Jr,{title:o,to:`/projects/${n}/features/${o}`,children:t.jsx(h2,{search:s,children:o})}))}),children:[r==null?void 0:r.length," toggles"]})})})},Xr={id:"createdAt",desc:!0},eo=d("div")({paddingLeft:0,paddingBottom:0}),to=d(p2)(({theme:e})=>({textTransform:"none",width:"auto",fontSize:e.fontSizes.bodySize,[e.breakpoints.up("md")]:{minWidth:160}})),no=d(w)(({theme:e})=>({textAlign:"right",paddingBottom:e.spacing(2),fontSize:e.fontSizes.smallBody})),so=({changeRequests:e=[],loading:n,projectId:s})=>{var U,j;const{classes:r}=qr(),o=u1(U4.breakpoints.down("md")),[a,i]=E3(),[l,u]=c.useState(a.get("search")||""),{value:C,setValue:h}=S2(`${s}:ProjectChangeRequest`,Xr),[p,x]=c.useMemo(()=>{const v=e.filter(M=>M.state!=="Cancelled"&&M.state!=="Rejected"&&M.state!=="Applied"),O=e.filter(M=>M.state==="Cancelled"||M.state==="Rejected"||M.state==="Applied");return[v,O]},[e]),S=[{title:"Change requests",data:p},{title:"Closed",data:x}],[g,y]=c.useState(0),f=c.useMemo(()=>[{id:"Title",Header:"Title",width:100,canSort:!0,accessor:"title",searchable:!0,Cell:Ur},{id:"Updated feature toggles",Header:"Updated feature toggles",canSort:!1,accessor:"features",searchable:!0,filterName:"feature",filterParsing:v=>(v==null?void 0:v.map(({name:O})=>O).join(`
3
3
  `))||"",filterBy:(v,O)=>v.features.find(M=>O.map(W=>W.toLowerCase()).includes(M.name.toLowerCase())),Cell:({value:v,row:{original:{title:O}}})=>t.jsx(Qr,{project:s,value:v},O)},{Header:"By",accessor:"createdBy",maxWidth:180,canSort:!1,Cell:Nr,align:"left",searchable:!0,filterName:"by",filterParsing:v=>(v==null?void 0:v.username)||""},{Header:"Submitted",accessor:"createdAt",maxWidth:100,Cell:g2},{Header:"Environment",accessor:"environment",searchable:!0,maxWidth:100,Cell:b2,filterName:"environment"},{Header:"Status",accessor:"state",searchable:!0,maxWidth:"170px",Cell:Br,filterName:"status"}],[s]),{data:m,getSearchText:H,getSearchContext:_}=k2(f,l,(U=S[g])==null?void 0:U.data),I=c.useMemo(()=>n?l9:m,[m,n]),[$]=c.useState(()=>({sortBy:[{id:a.get("sort")||C.id,desc:a.has("order")?a.get("order")==="desc":C.desc}],hiddenColumns:[]})),{headerGroups:E,rows:A,state:{sortBy:k},prepareRow:B,setHiddenColumns:z,getTableProps:N,getTableBodyProps:F}=t1.useTable({columns:f,data:I,initialState:$,sortTypes:N5,autoResetHiddenColumns:!1,disableSortRemove:!0,autoResetSortBy:!1,defaultColumn:{Cell:h1}},t1.useSortBy);return W5([{condition:o,columns:["createdBy"]}],z,f),c.useEffect(()=>{if(n)return;const v={};v.sort=k[0].id,k[0].desc&&(v.order="desc"),l&&(v.search=l),i(v,{replace:!0}),h(O=>({...O,id:k[0].id,desc:k[0].desc||!1}))},[n,k,l,i]),t.jsxs(a1,{isLoading:n,bodyClass:r.bodyClass,headerClass:r.header,header:t.jsx(n1,{titleElement:t.jsx(eo,{children:t.jsx(P3,{value:(j=S[g])==null?void 0:j.title,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:S.map((v,O)=>t.jsx(to,{label:`${v.title} (${v.data.length})`,value:v.title,onClick:()=>y(O)},v.title))})}),actions:t.jsx(V1,{placeholder:"Search and Filter",expandable:!0,initialValue:l,onChange:u,hasFilters:!0,getSearchContext:_,id:"changeRequestList"})}),children:[t.jsx(no,{children:t.jsx(_1,{to:`/projects/${s}/settings/change-requests`,children:"Change request configuration"})}),t.jsx(u5,{value:H(l),children:t.jsxs(F5,{...N(),children:[t.jsx(R5,{headerGroups:E}),t.jsx(P5,{...F(),children:A.map(v=>(B(v),t.jsx(Z5,{hover:!0,...v.getRowProps(),children:v.cells.map(O=>t.jsx(I5,{...O.getCellProps(),padding:"none",children:O.render("Cell")}))})))})]})}),t.jsx(V,{condition:A.length===0,show:()=>t.jsx(V,{condition:(l==null?void 0:l.length)>0,show:t.jsxs(f1,{children:["No changes found matching “",l,"”"]}),elseShow:t.jsx(f1,{children:"None of the changes were submitted yet."})})})]})},ro=()=>{const e=q("projectId"),n=o5(e),{isOss:s,isPro:r}=i1();M1(`Change requests – ${n}`);const{changeRequests:o,loading:a}=h7(e);return s()||r()?t.jsx(a1,{sx:{justifyContent:"center"},children:t.jsx(q5,{feature:"change-requests"})}):t.jsx(so,{changeRequests:o,projectId:e,loading:a})};var K=(e=>(e.USER="USERS",e.GROUP="GROUPS",e.SERVICE_ACCOUNT="SERVICE ACCOUNTS",e))(K||{});const Y5=(e,n={})=>{const s=G1(`api/admin/projects/${e}/access`),r=()=>fetch(s,{method:"GET"}).then(K1("project access")).then(p=>p.json()),o=`api/admin/projects/${e}/users`,{data:a,error:i}=r5(o,r,n),[l,u]=c.useState(!i&&!a),C=()=>{A3(o)};return c.useEffect(()=>{u(!i&&!a)},[a,i]),{access:c.useMemo(()=>{if(a)return oo({roles:a.roles,users:a.users.filter(({accountType:p})=>!p||p==="User"),serviceAccounts:a.users.filter(({accountType:p})=>p==="Service Account"),groups:(a==null?void 0:a.groups.map(p=>({...p,users:X9(p.users??[])})))??[]})},[a]),error:i,loading:l,refetchProjectAccess:C}},oo=e=>{const n=e.users||[],s=e.serviceAccounts||[],r=e.groups||[];return{...e,rows:[...n.map(o=>({entity:o,type:"USERS"})),...s.map(o=>({entity:o,type:"SERVICE ACCOUNTS"})),...r.map(o=>({entity:o,type:"GROUPS"}))]}},ao=d(a1)(({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`})),io=d("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span":{display:"flex",alignItems:"center",color:e.palette.text.secondary,fontSize:e.fontSizes.bodySize}})),U6={id:"joinedAt",desc:!0},a3=[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:e}})=>t.jsx(h1,{children:t.jsx(Z3,{user:e})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:e=>e.name||"",Cell:({value:e,row:{original:n}})=>t.jsx(b2,{value:e,subtitle:n.email||n.username}),minWidth:100,searchable:!0},{id:"joined",Header:"Joined",accessor:"joinedAt",Cell:z5,maxWidth:150},{id:"lastLogin",Header:"Last login",accessor:e=>e.seenAt||"",Cell:({row:{original:e}})=>t.jsx(g2,{value:e.seenAt,emptyText:"Never",title:n=>`Last login: ${n}`}),maxWidth:150},{accessor:e=>e.username||"",Header:"Username",searchable:!0},{accessor:e=>e.email||"",Header:"Email",searchable:!0}],lo=["imageUrl","name","joined","lastLogin"],co=({open:e,setOpen:n,group:s,projectId:r,subtitle:o,onEdit:a,onRemove:i})=>{const l=r1(),u=u1(l.breakpoints.down("md")),[C]=c.useState(()=>({sortBy:[{id:U6.id,desc:U6.desc}],hiddenColumns:["Username","Email"]})),[h,p]=c.useState(""),{data:x,getSearchText:S,getSearchContext:g}=k2(a3,h,(s==null?void 0:s.users)??[]),{headerGroups:y,rows:f,prepareRow:m,setHiddenColumns:H}=t1.useTable({columns:a3,data:x,initialState:C,sortTypes:N5,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},t1.useSortBy,t1.useFlexLayout);return W5([{condition:u,columns:lo}],H,a3),t.jsx(c5,{open:e,onClose:()=>{n(!1)},label:(s==null?void 0:s.name)||"Group",children:t.jsxs(ao,{header:t.jsx(n1,{secondary:!0,titleElement:t.jsxs(io,{children:[s==null?void 0:s.name," (",f.length<x.length?`${f.length} of ${x.length}`:x.length,")",t.jsx("span",{children:o})]}),actions:t.jsxs(t.Fragment,{children:[t.jsx(V,{condition:!u,show:t.jsxs(t.Fragment,{children:[t.jsx(V1,{initialValue:h,onChange:p,hasFilters:!0,getSearchContext:g}),t.jsx(n1.Divider,{})]})}),t.jsx(y5,{permission:b1,projectId:r,tooltipProps:{title:"Edit group access"},onClick:a,children:t.jsx(Z2,{})}),t.jsx(y5,{permission:b1,projectId:r,tooltipProps:{title:"Remove group access"},onClick:i,children:t.jsx(q4,{})})]}),children:t.jsx(V,{condition:u,show:t.jsx(V1,{initialValue:h,onChange:p,hasFilters:!0,getSearchContext:g})})}),children:[t.jsx(u5,{value:S(h),children:t.jsx(D2,{rows:f,headerGroups:y,prepareRow:m})}),t.jsx(V,{condition:f.length===0,show:t.jsx(V,{condition:(h==null?void 0:h.length)>0,show:t.jsxs(f1,{children:["No users found matching “",h,"” in this group."]}),elseShow:t.jsx(f1,{children:"This group is empty. Get started by adding a user to the group."})})})]})})},Co=d("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span:last-of-type":{fontSize:e.fontSizes.smallerBody,color:e.palette.text.secondary}})),uo=({roles:e,value:n,setValue:s,required:r,...o})=>{const a=(i,l,u)=>t.jsxs("li",{...i,children:[t.jsx(B5,{icon:t.jsx(K4,{fontSize:"small"}),checkedIcon:t.jsx(J4,{fontSize:"small"}),style:{marginRight:8},checked:u.selected}),t.jsxs(Co,{children:[t.jsx("span",{children:l.name}),t.jsx("span",{children:l.description})]})]});return t.jsxs(t.Fragment,{children:[t.jsx(G4,{multiple:!0,disableCloseOnSelect:!0,openOnFocus:!0,size:"small",value:n,onChange:(i,l)=>s(l),options:e,renderOption:a,getOptionLabel:i=>i.name,renderInput:i=>t.jsx(U5,{...i,label:"Role",required:r}),...o}),t.jsx(V,{condition:n.length>0,show:()=>n.map(({id:i})=>t.jsx(c9,{sx:{marginTop:1},roleId:i},i))})]})},po=d("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),q6=d("p")(({theme:e})=>({color:e.palette.text.secondary,marginBottom:e.spacing(1)})),G6=d("div")(({theme:e})=>({"& > div:first-of-type":{width:"100%",maxWidth:e.spacing(50),marginBottom:e.spacing(2)}})),ho=d("div")(({theme:e})=>({marginTop:e.spacing(6),display:"flex",justifyContent:"flex-end"})),go=d(m1)(({theme:e})=>({marginLeft:e.spacing(3)})),mo=d("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span:last-of-type":{color:e.palette.text.secondary}})),fo=d("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span:first-of-type":{color:e.palette.text.secondary}})),a6=({selected:e,accesses:n,users:s,serviceAccounts:r,groups:o,roles:a})=>{const{uiConfig:i}=i1(),{flags:l}=i,u=l.UG?"user / group":"user",C=q("projectId"),{refetchProjectAccess:h}=Y5(C),{addAccessToProject:p,setUserRoles:x,setGroupRoles:S,loading:g}=d5(),y=!!e,{setToastData:f,setToastApiError:m}=p1(),H=D1(),_=[...o.filter(j=>y||!n.some(({entity:{id:v},type:O})=>j.id===v&&O===K.GROUP)).map(j=>({id:j.id,entity:j,type:K.GROUP})),...s.filter(j=>y||!n.some(({entity:{id:v},type:O})=>j.id===v&&O===K.USER)).sort((j,v)=>{const O=j.name||j.username||"",M=v.name||v.username||"";return O.localeCompare(M)}).map(j=>({id:j.id,entity:j,type:K.USER})),...r.filter(j=>y||!n.some(({entity:{id:v},type:O})=>j.id===v&&O===K.SERVICE_ACCOUNT)).sort((j,v)=>{const O=j.name||j.username||"",M=v.name||v.username||"";return O.localeCompare(M)}).map(j=>({id:j.id,entity:j,type:K.SERVICE_ACCOUNT}))],[I,$]=c.useState(()=>_.filter(({id:j,type:v})=>j===(e==null?void 0:e.entity.id)&&v===(e==null?void 0:e.type))),[E,A]=c.useState(a.filter(({id:j})=>{var v,O;return(O=(v=e==null?void 0:e.entity)==null?void 0:v.roles)==null?void 0:O.includes(j)})),k={roles:E.map(({id:j})=>j),groups:I==null?void 0:I.filter(({type:j})=>j===K.GROUP).map(({id:j})=>j),users:I==null?void 0:I.filter(({type:j})=>j===K.USER||j===K.SERVICE_ACCOUNT).map(({id:j})=>j)},B=async j=>{if(j.preventDefault(),!!U)try{y?(e==null?void 0:e.type)===K.USER||(e==null?void 0:e.type)===K.SERVICE_ACCOUNT?await x(C,E.map(({id:v})=>v),e.entity.id):(e==null?void 0:e.type)===K.GROUP&&await S(C,E.map(({id:v})=>v),e.entity.id):await p(C,k),h(),H(s5),f({title:`${I.length} ${I.length===1?"access":"accesses"} ${y?"edited":"assigned"} successfully`,type:"success"})}catch(v){m(d1(v))}},z=()=>y?`curl --location --request PUT '${i.unleashUrl}/api/admin/projects/${C}/${(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' \\
4
4
  --header 'Authorization: INSERT_API_KEY' \\