UNPKG

unleash-server

Version:

Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.

4 lines 912 kB
var xd=Object.defineProperty;var jd=(e,t,n)=>t in e?xd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var q=(e,t,n)=>jd(e,typeof t!="symbol"?t+"":t,n);import{r as h,s as u,dB as bd,dy as w2,an as E0,j as a,fD as yd,at as g1,al as O1,ao as Z0,ap as I0,aq as M0,ar as A0,w as F0,b5 as se,W as T1,ca as v3,bh as I1,bj as J1,B as w,b_ as te,D as R1,c$ as S2,fq as P0,y as Y1,K as R0,fE as xc,aZ as Q,fF as oe,cV as ne,e as C1,dt as X1,fG as Qe,bk as u1,fH as _d,aw as N2,dT as Ur,fI as jc,fJ as Q1,aM as j1,aG as ie,L as s1,aL as M1,C as D,aI as g3,aH as k1,dv as wd,aA as V2,fK as Sd,b7 as kr,J as W0,b8 as L0,M as de,fL as m3,b9 as ue,d as Je,dC as bc,bb as he,T,fM as $e,dD as z2,dE as yc,bq as qr,dG as _c,G as G1,H as K1,az as x3,E as L3,m as Gr,aB as A1,i as d1,fN as Od,fO as Cd,fP as $d,h as w1,bm as Dd,b0 as N3,bn as Kr,b1 as B2,b4 as N0,b2 as Y2,fQ as wc,dJ as Pd,fR as Td,fS as Ed,U as Zd,fT as Sc,bA as le,fU as Id,fV as Md,fW as Oc,fX as Cc,x as $c,fY as Qr,bO as Xe,fZ as Ad,f_ as Mr,bV as Fd,f$ as Ar,g0 as Rd,bs as V0,dF as Dc,g1 as Pc,cQ as Jr,eu as H2,aD as j3,b as x1,au as N1,Q as Pe,g2 as Tc,g3 as Wd,g4 as Ld,aC as Xr,bp as V3,g5 as Nd,dj as ke,fn as U2,fo as k2,g6 as Vd,g7 as zd,g8 as Bd,t as Yd,N as fe,el as z3,bz as b3,g9 as Hd,ga as ee,em as re,gb as P8,gc as Ud,a_ as kd,dp as Se,ds as O2,gd as qd,dq as M3,ge as Gd,dr as Kd,gf as D3,gg as Ec,gh as Qd,gi as Zc,gj as Ic,cO as z0,gk as Jd,u as q2,d3 as Mc,gl as o3,gm as Xd,gn as eu,go as tu,gp as nu,gq as au,gr as ru,gs as iu,gt as cu,gu as su,gv as ou,gw as lu,gx as du,gy as uu,gz as hu,gA as fu,gB as y3,gC as mu,aU as Ke,gD as C2,aO as pu,gE as e5,gF as Ac,gG as vu,aP as _3,aQ as B3,aV as Y3,_ as H3,a as z1,aW as U3,aY as k3,aX as G2,gH as gu,gI as v1,l as Te,dx as t5,gJ as xu,gK as ju,gL as bu,be as w3,gM as yu,dc as Fc,c as $2,gN as _u,gO as Rc,cZ as De,dz as wu,gP as T8,gQ as Su,gR as Ou,ea as K2,gS as Cu,gT as $u,gU as Du,gV as Wc,gW as Lc,cu as p3,gX as Pu,gY as Tu,gZ as Nc,g_ as Eu,g$ as Zu,h0 as Vc,fv as Iu,h1 as Mu,bl as zc,aN as Ee,h2 as n5,O as Au,aE as q3,h3 as Fu,bE as Bc,h4 as Yc,h5 as Hc,h6 as Ru,h7 as Wu,h8 as Lu,h9 as Nu,am as G3,ax as K3,ay as Q2,a$ as Vu,ha as zu,hb as Bu,hc as Uc,hd as Yu,he as Hu,hf as Q3,ab as a5,aa as kc,hg as Uu,ba as J3,hh as ku,hi as qu,hj as qc,hk as Gu,hl as Gc,br as Ze,c8 as Kc,hm as Ku,v as Qu,hn as Ju,ho as r5,hp as Xu,c7 as Qc,hq as eh,hr as th,hs as nh,ht as ah,bd as X3,di as A3,eC as D2,aF as i5,hu as rh,hv as Jc,e5 as e0,bc as B0,A as J2,dZ as ih,n as Xc,o as es,hw as ch,ec as x2,dY as qe,hx as sh,hy as oh,es as r2,hz as lh,hA as dh,hB as uh,hC as L4,hD as hh,hE as fh,cX as t0,cY as p1,hF as mh,hG as ts,hH as P2,hI as E8,hJ as ph,dW as vh,dX as gh,hK as Z8,hL as xh,hM as jh,hN as bh,hO as yh,hP as _h,hQ as ns,cD as wh,cE as Sh,cy as X2,cM as c5,cz as et,cN as Oh,a1 as Ch,hR as as,hS as $h,hT as Dh,hU as Ph,cU as Y0,z as I8,fi as Th,d4 as Eh,d6 as Zh,hV as Ih,hW as rs,hX as Mh,hY as Ah,hZ as Fh,bi as tt,h_ as Rh,h$ as Wh,i0 as Lh,X as nt,i1 as s5,i2 as o5,dk as is,i3 as l5,bw as Nh,cS as Vh,i4 as zh,i5 as N4,i6 as Bh,i7 as Yh,i8 as M8,i9 as Hh,ia as Uh,ib as kh,ic as qh,id as Gh,d7 as T2,ie as Kh,fw as Qh,ig as Jh,fz as Xh,dO as A8,dL as ef,dA as cs,ih as Fr,ii as tf,eh as ss,cR as nf,ij as af,ik as rf,il as cf,im as sf,io as d0,ip as of,iq as lf,ir as df,fp as uf,is as hf,bG as ff,it as mf,iu as pf,iv as vf}from"./index-DEkgmbaI.js";import{g as gf,h as xf,i as Rr,a as jf,u as os,T as bf,b as yf,F as _f,V as wf,j as Sf,c as ls,e as Of,E as Cf,k as $f,P as ds}from"./FeatureStaleDialog-DmQwcw9H.js";import{F as us,M as Df}from"./MarkCompletedDialogue-3-FrccPG.js";import{m as Pf,h as Tf,j as F8,b as Ef,c as Zf,d as If,e as Mf,E as Af,f as Ff,u as Rf,a as Wf,R as Lf,C as Nf,A as Vf,g as hs,k as zf}from"./RoleCell-zuwhSmmG.js";import{S as Bf}from"./LegacyStrategyItemContainer-CqOcbhDa.js";import"./useApiTokens-DuYwQsyc.js";const fs=e=>h.createElement("svg",{width:20,height:18,viewBox:"0 0 20 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},h.createElement("path",{d:"M14.125 0C15.7917 0 17.1875 0.616667 18.3125 1.85C19.4375 3.08333 20 4.55 20 6.25C20 6.55 19.9833 6.84583 19.95 7.1375C19.9167 7.42917 19.8583 7.71667 19.775 8H13.525L11.825 5.45C11.7417 5.31667 11.625 5.20833 11.475 5.125C11.325 5.04167 11.1667 5 11 5C10.7833 5 10.5875 5.06667 10.4125 5.2C10.2375 5.33333 10.1167 5.5 10.05 5.7L8.7 9.75L7.825 8.45C7.74167 8.31667 7.625 8.20833 7.475 8.125C7.325 8.04167 7.16667 8 7 8H0.225C0.141667 7.71667 0.0833333 7.42917 0.05 7.1375C0.0166667 6.84583 0 6.55833 0 6.275C0 4.55833 0.558333 3.08333 1.675 1.85C2.79167 0.616667 4.18333 0 5.85 0C6.65 0 7.40417 0.158333 8.1125 0.475C8.82083 0.791667 9.45 1.23333 10 1.8C10.5333 1.23333 11.1542 0.791667 11.8625 0.475C12.5708 0.158333 13.325 0 14.125 0ZM10 18C9.7 18 9.4125 17.9458 9.1375 17.8375C8.8625 17.7292 8.61667 17.5667 8.4 17.35L1.7 10.625C1.6 10.525 1.50833 10.425 1.425 10.325C1.34167 10.225 1.25833 10.1167 1.175 10H6.45L8.15 12.55C8.23333 12.6833 8.35 12.7917 8.5 12.875C8.65 12.9583 8.80833 13 8.975 13C9.19167 13 9.39167 12.9333 9.575 12.8C9.75833 12.6667 9.88333 12.5 9.95 12.3L11.3 8.25L12.15 9.55C12.25 9.68333 12.375 9.79167 12.525 9.875C12.675 9.95833 12.8333 10 13 10H18.8L18.55 10.3L18.3 10.6L11.575 17.35C11.3583 17.5667 11.1167 17.7292 10.85 17.8375C10.5833 17.9458 10.3 18 10 18Z"})),R8=u("div")(()=>({display:"flex"})),Yf=u("div")(()=>({display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",width:"100%"}));u("div")(()=>({display:"flex",flexDirection:"column"}));const Hf=u("span")(({theme:e})=>({textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"})),Uf=u("span")(({theme:e})=>({fontSize:e.fontSizes.smallBody,fontWeight:"normal"}));u(Uf)(({theme:e})=>({color:e.palette.neutral.dark}));const kf=u(bd)(({theme:e})=>({marginLeft:e.spacing(-1.5)})),qf=u("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),Gf=u("div")(({theme:e})=>({padding:e.spacing(2.5,5),display:"flex",flexDirection:"column",alignItems:"start"})),Kf=u("span")(({theme:e})=>({margin:0,width:"100%",fontSize:e.typography.h1.fontSize,fontWeight:"bold",display:"flex",alignItems:"center",gap:e.spacing(2),overflow:"hidden"})),Qf=u("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.divider,height:"1px"})),Jf=u("div")(({theme:e})=>({padding:e.spacing(0,4)})),Xf=u(w2)(({theme:e})=>({textTransform:"none",fontSize:e.fontSizes.bodySize,flexBasis:0,[e.breakpoints.down("md")]:{paddingLeft:e.spacing(1),paddingRight:e.spacing(1),minWidth:170},[e.breakpoints.up("md")]:{minWidth:170}})),em=e=>e.reduce((t,n)=>n.enabled?t+1:t,0),tm=u(E0)(({theme:e})=>({marginTop:e.spacing(3)})),nm=u("p",{shouldForwardProp:e=>e!=="warning"})(({theme:e,warning:t})=>({color:t?e.palette.error.dark:e.palette.text.primary,textAlign:"center"})),am=({environment:e,warnEnabledToggles:t})=>{const n=h.useMemo(()=>[{id:"Icon",width:"1%",Cell:({row:{original:d}})=>a.jsx(yd,{environment:d})},{Header:"Name",accessor:"name",Cell:g1},{Header:"Type",accessor:"type",Cell:g1},{Header:"Toggles enabled",accessor:"projectEnabledToggleCount",Cell:({value:d})=>a.jsx(g1,{children:a.jsx(nm,{warning:d>0,children:d===1?"1 toggle":`${d} toggles`})}),align:"center"}],[t]),{getTableProps:i,getTableBodyProps:c,headerGroups:s,rows:o,prepareRow:l}=O1.useTable({columns:n,data:[e],disableSortBy:!0});return a.jsxs(tm,{...i(),rowHeight:"compact",children:[a.jsx(Z0,{headerGroups:s}),a.jsx(I0,{...c(),children:o.map(d=>{l(d);const{key:f,...m}=d.getRowProps();return a.jsx(M0,{hover:!0,...m,children:d.cells.map(p=>{const{key:g,...v}=p.getCellProps();return a.jsx(A0,{...v,children:p.render("Cell")},g)})},f)})})]})},rm=u("p")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1.5)})),im=u(F0)(()=>({width:"100%"})),cm=({environment:e,open:t,setOpen:n,onConfirm:i})=>{const[c,s]=h.useState("");return h.useEffect(()=>{s("")},[t]),a.jsxs(se,{title:"Hide environment and disable feature flags?",open:t,primaryButtonText:"Hide environment and disable feature flags",disabledPrimaryButton:(e==null?void 0:e.name)!==c,secondaryButtonText:"Close",onClick:i,onClose:()=>{n(!1)},children:[a.jsxs(T1,{severity:"error",children:[a.jsx("strong",{children:"Danger!"})," Hiding an environment will disable all the feature flags that are enabled in this environment and it can impact client applications connected to the environment."]}),a.jsx(am,{environment:e}),a.jsxs(rm,{children:["In order to hide this environment, please enter the id of the environment in the textfield below:"," ",a.jsx("strong",{children:e==null?void 0:e.name})]}),a.jsx(im,{label:"Environment name",value:c,onChange:o=>s(o.target.value)})]})},sm=e=>{const{data:t,error:n,mutate:i}=v3(I1(`api/admin/environments/project/${e}`),om),c=h.useMemo(()=>t||[],[t]),s=h.useCallback(async()=>{await i()},[i]);return{environments:c,refetchEnvironments:s,loading:!n&&!t,error:n}},om=async e=>(await fetch(e).then(J1("Environments")).then(n=>n.json())).environments.sort((n,i)=>n.sortOrder-i.sortOrder),lm="/static/upgradeEnvironments-DCYoh4BH.png",dm=u(w)(({theme:e})=>({marginTop:e.spacing(3),width:"100%",backgroundColor:e.palette.background.elevation1,borderRadius:e.shape.borderRadiusMedium,padding:e.spacing(2),display:"flex",justifyContent:"center",position:"relative"})),um=u(te)(({theme:e})=>({textDecoration:"none",fontWeight:e.typography.fontWeightBold})),hm=u("img")(({theme:e})=>({width:e.spacing(20)})),fm=u(R1)(({theme:e})=>({position:"absolute",top:e.spacing(1.25),right:e.spacing(1.5)})),mm=u(w)(({theme:e})=>({display:"flex",gap:e.spacing(3),marginTop:e.spacing(2),marginBottom:e.spacing(2)})),pm=u(w)(({theme:e})=>({display:"flex",flexDirection:"column",justifyContent:"center",gap:e.spacing(1),maxWidth:e.spacing(60)})),vm=()=>{const[e,t]=S2("upgrade-environments:v1","open");return e==="closed"?null:a.jsxs(dm,{children:[a.jsxs(mm,{children:[a.jsx(hm,{src:P0(lm),alt:"Multiple environments"}),a.jsxs(pm,{children:[a.jsx("b",{children:"Need more environments?"}),a.jsx("p",{children:"You are currently using our open-source version, which allows for only two environments. With our Enterprise offering, you can have unlimited environments to better suit your organization's needs."}),a.jsx(um,{href:"https://www.getunleash.io/upgrade-unleash?utm_source=oss&utm_medium=feature&utm_content=environments",target:"_blank",children:"View our Enterprise offering"})]})]}),a.jsx(Y1,{title:"Dismiss",arrow:!0,children:a.jsx(fm,{"aria-label":"dismiss",onClick:()=>{t("closed")},size:"small",children:a.jsx(R0,{fontSize:"inherit"})})})]})},gm=u(T1)(({theme:e})=>({marginBottom:e.spacing(4)})),xm=u("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",[e.breakpoints.down("sm")]:{justifyContent:"center"}})),jm=u(xc)(({theme:e})=>({maxWidth:"400px",marginBottom:e.spacing(2)})),ms=()=>{const e=Q("projectId"),t=oe(e);ne(`Project environments – ${t}`);const{setToastData:n,setToastApiError:i}=C1(),{environments:c,loading:s,error:o,refetchEnvironments:l}=sm(e),{project:d,refetch:f}=X1(e),{removeEnvironmentFromProject:m,addEnvironmentToProject:p}=Qe(),[g,v]=h.useState(),[j,y]=h.useState(!1),{isOss:b}=u1(),x=h.useMemo(()=>c.map(_=>({..._,projectVisible:d==null?void 0:d.environments.map(V=>V.environment).includes(_.name)})),[c,d==null?void 0:d.environments]),O=()=>{l(),f()},C=()=>a.jsx(jm,{onClick:O,text:"Error fetching environments"}),$=_=>`Got an API error when trying to set the environment as ${_?"visible":"hidden"}`,Z=async _=>{if(_.projectVisible){if(em(x)>1){v(_),y(!0);return}n({text:"At least one environment must be visible in the project",type:"error"})}else try{await p(e,_.name),O(),n({text:"Environment set as visible",type:"success"})}catch{i($(!0))}},I=async()=>{if(g)try{await m(e,g.name),O(),n({text:"Environment hidden",type:"success"})}catch{i($(!1))}finally{y(!1)}},E=_=>b()&&_.name==="default"||_.projectVisible&&R(),R=()=>x.filter(_=>_.projectVisible).length===1,z=_=>_.projectVisible&&R()?"Cannot disable, at least one environment must be visible in the project":_.projectVisible?"Hide environment and disable feature flags":"Make it visible",W=h.useMemo(()=>[{Header:"Name",accessor:"name",Cell:({row:{original:_}})=>a.jsx(_d,{environment:_})},{Header:"Type",accessor:"type",Cell:N2},{Header:"Project API tokens",accessor:_=>_.projectApiTokenCount===1?"1 token":`${_.projectApiTokenCount} tokens`,Cell:g1},{Header:"Visible in project",accessor:"enabled",align:"center",width:1,Cell:({row:{original:_}})=>a.jsx(Ur,{children:a.jsx(jc,{tooltip:z(_),size:"medium",disabled:E(_),projectId:e,permission:Q1,checked:_.projectVisible,onChange:()=>Z(_)})}),disableGlobalFilter:!0}],[x]),{getTableProps:A,getTableBodyProps:U,headerGroups:k,rows:M,prepareRow:B,state:{globalFilter:H},setGlobalFilter:F}=O1.useTable({columns:W,data:x,disableSortBy:!0},O1.useGlobalFilter),S=a.jsx(j1,{title:`Environments (${M.length})`,actions:a.jsxs(a.Fragment,{children:[a.jsx(ie,{initialValue:H,onChange:F}),b()?null:a.jsxs(a.Fragment,{children:[a.jsx(j1.Divider,{}),a.jsx(te,{component:s1,to:"/environments",children:"Configure environments"})]})]})});return a.jsx(M1,{header:S,isLoading:s,children:a.jsxs(xm,{children:[a.jsx(D,{condition:!!o,show:C()}),a.jsxs(gm,{severity:"info",children:[a.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"," ",a.jsx(s1,{to:"/admin/api",children:"API tokens here"}),".",a.jsx("br",{}),a.jsx("br",{}),"Your administrator can configure an environment-specific API token to be used in the SDK. If you are an administrator you can"," ",a.jsx(s1,{to:"/admin/api",children:"create a new API token here"}),"."]}),a.jsx(g3,{value:H,children:a.jsxs(E0,{...A(),rowHeight:"compact",children:[a.jsx(Z0,{headerGroups:k}),a.jsx(I0,{...U(),children:M.map(_=>{B(_);const{key:V,...K}=_.getRowProps();return a.jsx(M0,{hover:!0,...K,children:_.cells.map(G=>{const{key:h1,...f1}=G.getCellProps();return a.jsx(A0,{...f1,children:G.render("Cell")},h1)})},V)})})]})}),a.jsx(D,{condition:M.length===0,show:a.jsx(D,{condition:(H==null?void 0:H.length)>0,show:a.jsxs(k1,{children:["No environments found matching “",H,"”"]}),elseShow:a.jsx(k1,{children:"No environments available. Get started by adding one."})})}),b()?a.jsx(vm,{}):null,a.jsx(cm,{environment:g,open:j,setOpen:y,onConfirm:I})]})})},bm={id:"archivedAt"},ym=({projectId:e})=>{const{archivedFeatures:t,loading:n,refetchArchived:i}=wd(e),{value:c,setValue:s}=V2(`${e}:ProjectFeaturesArchiveTable`,bm);return a.jsx(Sd,{title:"Archived flags",archivedFeatures:t||[],loading:n,storedParams:c,setStoredParams:s,refetch:i,projectId:e})},_m=()=>{const e=Q("projectId"),t=oe(e);return ne(`Project archived flags – ${t}`),a.jsx(ym,{projectId:e})},wm=e=>h.createElement("svg",{width:24,height:24,viewBox:"0 0 16 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},h.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.58 10.08L12 11.5L8 15.5L4 11.5L5.42 10.08L7.01 11.67V0.5H8.99V11.67L10.58 10.08ZM16 19V8C16 6.89 15.1 6 14 6H11V8H14V19H2V8H5V6H2C0.889999 6 0 6.89 0 8V19C0 20.1 0.889999 21 2 21H14C15.1 21 16 20.1 16 19Z",fill:"currentColor"})),Sm=u(w)(({theme:e})=>({display:"flex",justifyContent:"center",paddingRight:e.spacing(2)})),Om=({projectId:e,row:t,onOpenArchiveDialog:n,onOpenStaleDialog:i})=>{const[c,s]=h.useState(null),[o,l]=h.useState(!1),{setToastData:d}=C1(),{original:{name:f,stale:m}}=t,p=!!c,g=x=>{s(x.currentTarget)},v=()=>{s(null)},j=`feature-${f}-actions`,y=`${j}-menu`,b=()=>{try{_c(f),l(!0),setTimeout(()=>{v(),l(!1)},1e3)}catch{d({type:"error",text:"Could not copy feature name"})}};return a.jsxs(Sm,{children:[a.jsx(Y1,{title:"Feature flag actions",arrow:!0,describeChild:!0,children:a.jsx(R1,{id:j,"data-loading":!0,"aria-controls":p?y:void 0,"aria-haspopup":"true","aria-expanded":p?"true":void 0,onClick:g,type:"button",children:a.jsx(kr,{})})}),a.jsx(W0,{id:y,anchorEl:c,open:p,onClose:v,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:x=>({borderRadius:`${x.shape.borderRadius}px`,padding:x.spacing(1,1.5)})},children:a.jsxs(L0,{"aria-labelledby":j,children:[a.jsxs(de,{sx:m3,onClick:b,children:[a.jsx(ue,{children:o?a.jsx(Je,{}):a.jsx(bc,{})}),a.jsx(he,{children:a.jsx(T,{variant:"body2",children:o?"Copied!":"Copy Name"})})]}),a.jsx($e,{projectId:e,permission:z2,children:({hasAccess:x})=>a.jsxs(de,{sx:m3,onClick:v,disabled:!x,component:s1,to:`/projects/${e}/features/${f}/copy`,children:[a.jsx(ue,{children:a.jsx(gf,{})}),a.jsx(he,{children:a.jsx(T,{variant:"body2",children:"Clone"})})]})}),a.jsx($e,{projectId:e,permission:yc,children:({hasAccess:x})=>a.jsxs(de,{sx:m3,onClick:()=>{n(f),v()},disabled:!x,children:[a.jsx(ue,{children:a.jsx(xf,{})}),a.jsx(he,{children:a.jsx(T,{variant:"body2",children:"Archive"})})]})}),a.jsx($e,{projectId:e,permission:qr,children:({hasAccess:x})=>a.jsxs(de,{sx:m3,onClick:()=>{v(),i({featureId:f,stale:m===!0})},disabled:!x,children:[a.jsx(ue,{children:a.jsx(Rr,{})}),a.jsx(he,{children:a.jsxs(T,{variant:"body2",children:[m?"Un-mark":"Mark"," as stale"]})})]})})]})})]})};var d5={},Cm=K1;Object.defineProperty(d5,"__esModule",{value:!0});var ps=d5.default=void 0,$m=Cm(G1()),Dm=a,Pm=(0,$m.default)((0,Dm.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");ps=d5.default=Pm;const Tm=u(w)(()=>({...x3,justifyContent:"center"})),Em=u(R1)(({theme:e})=>({margin:e.spacing(-1,0)})),Zm=u(w)(({theme:e})=>({...x3,justifyContent:"space-between",padding:e.spacing(1,1,0,4)})),Im=u(de)(({theme:e})=>({padding:e.spacing(0,2),margin:e.spacing(0,2),borderRadius:e.shape.borderRadius})),Mm=u(L3)(({theme:e})=>({"&.MuiDivider-root.MuiDivider-fullWidth":{margin:e.spacing(.75,0)}})),Am=u(Gr)(({theme:e})=>({padding:e.spacing(.75,1)})),Fm=({columns:e,onToggle:t})=>{const[n,i]=h.useState(null),c=f=>{i(f.currentTarget)},s=()=>{i(null)},o=!!n,l="columns-menu",d=`columns-menu-list-${l}`;return a.jsxs(Tm,{children:[a.jsx(Y1,{title:"Select columns",arrow:!0,describeChild:!0,children:a.jsx(Em,{id:l,"aria-controls":o?d:void 0,"aria-haspopup":"true","aria-expanded":o?"true":void 0,onClick:c,type:"button",size:"large","data-loading":!0,children:a.jsx(ps,{})})}),a.jsxs(W0,{id:d,open:o,anchorEl:n,onClose:s,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},disableScrollLock:!0,PaperProps:{sx:f=>({borderRadius:f.shape.borderRadius,paddingBottom:f.spacing(2)})},children:[a.jsxs(Zm,{children:[a.jsx(T,{variant:"body2",children:a.jsx("strong",{children:"Columns"})}),a.jsx(R1,{onClick:s,children:a.jsx(R0,{})})]}),a.jsx(L0,{children:e.map(f=>f.id==="divider"?a.jsx(Mm,{},"divider"):a.jsxs(Im,{onClick:()=>{t==null||t(f.id)},disabled:f.isStatic===!0&&f.isVisible===!0,children:[a.jsx(ue,{children:a.jsx(Am,{edge:"start",checked:f.isVisible,disableRipple:!0,inputProps:{"aria-labelledby":f.id},size:"medium"})}),a.jsx(he,{id:f.id,primary:a.jsx(T,{variant:"body2",children:f.header})})]},f.id))})]})]})},Rm=7,Wm=e=>{const t=Od(new Date,-Rm);return!!(e!=null&&e.lastSeenAt&&Cd(new Date(e.lastSeenAt),t))},Lm=({projectId:e,featureIds:t,features:n,onConfirm:i})=>{const[c,s]=h.useState(!1),{trackEvent:o}=A1(),l=h.useMemo(()=>t.filter(f=>{const m=n.find(p=>p.name===f);return Wm(m)}),[JSON.stringify(n),t]),d=async()=>{s(!1),i==null||i(),o("batch_operations",{props:{eventType:"features archived"}})};return a.jsxs(a.Fragment,{children:[a.jsx($e,{projectId:e,permission:yc,children:({hasAccess:f})=>a.jsx("span",{children:a.jsx(d1,{disabled:!f||c,variant:"outlined",size:"small",onClick:()=>s(!0),children:"Archive"})})}),a.jsx(us,{projectId:e,featureIds:t,featuresWithUsage:l,onConfirm:d,isOpen:c,onClose:()=>s(!1)})]})},i2="selection-actions-menu",Nm=({projectId:e,data:t,onChange:n})=>{const[i,c]=h.useState(null),{staleFeatures:s}=Qe(),{setToastData:o,setToastApiError:l}=C1(),{trackEvent:d}=A1(),f=!!i,m=t.map(({name:x})=>x),p=x=>{c(x.currentTarget)},g=()=>{c(null)},v=t.some(({stale:x})=>x===!0),j=t.some(({stale:x})=>x===!1),y=async()=>{try{g(),await s(e,m),n==null||n(),o({text:"Feature flags marked as stale",type:"success"}),d("batch_operations",{props:{eventType:"features staled"}})}catch(x){l(w1(x))}},b=async()=>{try{g(),await s(e,m,!1),n==null||n(),o({text:"Feature flags unmarked as stale",type:"success"}),d("batch_operations",{props:{eventType:"features unstaled"}})}catch(x){l(w1(x))}};return a.jsxs(a.Fragment,{children:[a.jsx(Y1,{title:"More bulk actions",arrow:!0,describeChild:!0,children:a.jsx(R1,{id:i2,"aria-controls":f?i2:void 0,"aria-haspopup":"true","aria-expanded":f?"true":void 0,onClick:p,type:"button","data-testid":$d,children:a.jsx(kr,{})})}),a.jsx(W0,{id:`${i2}-menu`,anchorEl:i,open:f,onClose:g,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:x=>({borderRadius:`${x.shape.borderRadius}px`,padding:x.spacing(1,1.5)})},children:a.jsx(L0,{"aria-labelledby":`${i2}-menu`,children:a.jsx($e,{projectId:e,permission:qr,children:({hasAccess:x})=>a.jsxs(a.Fragment,{children:[a.jsx(D,{condition:j,show:()=>a.jsxs(de,{onClick:y,disabled:!x,sx:{borderRadius:O=>`${O.shape.borderRadius}px`},children:[a.jsx(ue,{children:a.jsx(Rr,{})}),a.jsx(he,{children:a.jsx(T,{variant:"body2",children:"Mark as stale"})})]})}),a.jsx(D,{condition:v,show:()=>a.jsxs(de,{onClick:b,disabled:!x,sx:{borderRadius:O=>`${O.shape.borderRadius}px`},children:[a.jsx(ue,{children:a.jsx(Rr,{})}),a.jsx(he,{children:a.jsx(T,{variant:"body2",children:"Un-mark as stale"})})]})})]})})})})]})},Vm=u("section")(({theme:e})=>({"& > *":{margin:e.spacing(1,0)}})),W8="manage-tags-form",L8=(e,t)=>[...e,...e.some(n=>n.value===t.value&&n.type===t.type)?[]:[t]],N8=(e,t)=>e.filter(n=>!(n.value===t.value&&n.type===t.type)),zm=(e,t)=>{switch(t.type){case"add":return{...e,addedTags:L8(e.addedTags,t.payload),removedTags:N8(e.removedTags,t.payload)};case"remove":return{...e,addedTags:N8(e.addedTags,t.payload),removedTags:L8(e.removedTags,t.payload)};case"clear":return{addedTags:[],removedTags:t.payload};case"reset":return{addedTags:[],removedTags:[]};default:return e}},V8={name:"",description:"",icon:""},Bm=({open:e,initialValues:t,initialIndeterminateValues:n,onCancel:i,onSubmit:c})=>{const{tagTypes:s,loading:o}=Dd(),[l,d]=h.useState(V8),[f,m]=h.useState([]),[p,g]=h.useState([]),{tags:v,refetch:j}=jf(l.name),{createTag:y}=os(),b=v.map(({value:z})=>({title:z})),[x,O]=h.useReducer(zm,{addedTags:[],removedTags:[]}),C=()=>{c(x),O({type:"reset"})},$=(z=s.length>0?s[0]:V8)=>{d(z);const W=n.filter(({type:A})=>A===z.name);m(t.filter(({type:A})=>A===z.name).filter(({type:A,value:U})=>!W.some(k=>k.value===U&&k.type===A)).map(({value:A})=>({title:A}))),g(W.map(({value:A})=>({title:A}))),O({type:"clear",payload:[]})};h.useEffect(()=>{s.length>0&&$()},[o]);const Z=(z,W)=>{W!=null&&typeof W!="string"&&(z.preventDefault(),$(W))},I=(z,W)=>y({value:z,type:W}).then(async()=>{j(),m(A=>[...A,{title:z}]),O({type:"add",payload:{value:z,type:W}})}),E=(z,W,A,U)=>{A==="selectOption"?W.forEach(k=>{if(typeof k!="string"&&typeof k.inputValue=="string"&&k.inputValue&&k.title.startsWith("Create new value"))return I(k.inputValue,l.name);m(W),g(M=>M.filter(({title:B})=>B!==k.title)),U!=null&&U.option&&O({type:"add",payload:{value:U.option.title,type:l.name}})}):A==="clear"?(m([]),O({type:"clear",payload:t})):A==="removeOption"&&(m(W),U!=null&&U.option&&O({type:"remove",payload:{value:U.option.title,type:l.name}}))},R=()=>{$(),i()};return a.jsxs(se,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update feature flag tags",onClick:C,disabledPrimaryButton:x.addedTags.length===0&&x.removedTags.length===0,onClose:R,formId:W8,children:[a.jsx(T,{paragraph:!0,sx:{marginBottom:z=>z.spacing(2.5)},children:"Tags allow you to group features together"}),a.jsx("form",{id:W8,onSubmit:C,children:a.jsxs(Vm,{children:[a.jsx(bf,{options:s,disabled:o||s.length===0,value:l,onChange:Z},o?"loading":s.length),a.jsx(D,{condition:!o&&s.length===0,show:a.jsxs(T,{variant:"body1",children:["No"," ",a.jsx(te,{component:s1,to:"/tag-types",children:"tag types"})," ","available."]}),elseShow:a.jsx(yf,{disabled:o,options:b,existingTags:t,indeterminateOptions:p,tagType:l,selectedOptions:f,onChange:E})})]})})]})},Ym=({projectId:e,data:t,onChange:n})=>{const{bulkUpdateTags:i}=os(),{setToastData:c,setToastApiError:s}=C1(),{trackEvent:o}=A1(),[l,d]=h.useState(!1),[f,m]=h.useMemo(()=>{const g=t.flatMap(({tags:j})=>j||[]).reduce((j,y)=>[...j,...j.some(b=>b.type===y.type&&b.value===y.value)?[]:[y]],[]),v=g.filter(j=>!t.every(({tags:y})=>y==null?void 0:y.some(b=>b.type===j.type&&b.value===j.value)));return[g,v]},[t]),p=async({addedTags:g,removedTags:v})=>{const y={features:t.map(({name:b})=>b),tags:{addedTags:g,removedTags:v}};try{const b=[g.length>0&&`added ${g.length} tag${g.length>1?"s":""}`,v.length>0&&`removed ${v.length} tag${v.length>1?"s":""}`].filter(Boolean).join(" and ");await i(y,e),c({text:b,type:"success",autoHideDuration:12e3}),o("batch_operations",{props:{eventType:"tags updated"}})}catch(b){s(w1(b))}n==null||n(),d(!1)};return a.jsxs(a.Fragment,{children:[a.jsx($e,{projectId:e,permission:qr,children:({hasAccess:g})=>a.jsx("span",{children:a.jsx(d1,{disabled:!g||l,variant:"outlined",size:"small",onClick:()=>d(!0),children:"Tags"})})}),a.jsx(Bm,{open:l,onCancel:()=>d(!1),onSubmit:p,initialValues:f,initialIndeterminateValues:m},t.length)]})},Hm=u(N3)(({theme:e})=>({minWidth:"450px",marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),z8=u(T1)(({theme:e})=>({marginBottom:e.spacing(1.5)})),Um=({showExportDialog:e,data:t,onClose:n,onConfirm:i,environments:c,projectId:s})=>{const[o,l]=h.useState(c[0]),{bulkToggleFeaturesEnvironmentOff:d}=Kr(),{addChange:f}=B2(),{setToastApiError:m,setToastData:p}=C1(),{isChangeRequestConfigured:g}=N0(s),{refetch:v}=Y2(s),j=t.filter(O=>{var C,$;return(($=(C=O.environments)==null?void 0:C.find(Z=>o===Z.name))==null?void 0:$.enabled)===!1}).length,y=()=>c.map(O=>({key:O,label:O})),b=async()=>{try{g(o)?(await f(s,o,t.map(O=>({action:"updateEnabled",feature:O.name,payload:{enabled:!1}}))),v(),p({type:"success",text:"Changes added to draft"})):(await d(s,t.map(O=>O.name),o),p({type:"success",text:"Feature flags disabled"})),n(),i==null||i()}catch(O){m(w1(O))}},x=g(o)?"Add to change request":"Disable flags";return a.jsx(se,{open:e,title:"Disable feature flags",onClose:n,onClick:b,primaryButtonText:x,secondaryButtonText:"Cancel",children:a.jsxs(w,{children:["You have selected ",a.jsx("b",{children:t.length})," feature flags to disable.",a.jsx("br",{}),a.jsx("br",{}),a.jsx(T,{children:"Select which environment to disable the features for:"}),a.jsx(Hm,{options:y(),value:o,onChange:O=>l(O)}),a.jsx(D,{condition:g(o),show:a.jsx(z8,{severity:"warning",children:"Change requests are enabled for this environment."})}),a.jsx(D,{condition:j>0,show:a.jsxs(z8,{severity:"info",children:[j," feature"," ",j>1?"flags are ":"flag is ","already disabled."]})})]})})},km=u(N3)(({theme:e})=>({minWidth:"450px",marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),B8=u(T1)(({theme:e})=>({marginBottom:e.spacing(1.5)})),qm=({showExportDialog:e,data:t,onClose:n,onConfirm:i,environments:c,projectId:s})=>{const[o,l]=h.useState(c[0]),{bulkToggleFeaturesEnvironmentOn:d}=Kr(),{addChange:f}=B2(),{setToastApiError:m,setToastData:p}=C1(),{isChangeRequestConfigured:g}=N0(s),{refetch:v}=Y2(s),j=t.filter(O=>{var C,$;return(($=(C=O.environments)==null?void 0:C.find(Z=>o===Z.name))==null?void 0:$.enabled)===!0}).length,y=()=>c.map(O=>({key:O,label:O})),b=async()=>{try{g(o)?(await f(s,o,t.map(O=>({action:"updateEnabled",feature:O.name,payload:{enabled:!0}}))),v(),p({type:"success",text:"Changes added to draft"})):(await d(s,t.map(O=>O.name),o),p({type:"success",text:"Feature flags enabled"})),n(),i==null||i()}catch(O){m(w1(O))}},x=g(o)?"Add to change request":"Enable flags";return a.jsx(se,{open:e,title:"Enable feature flags",onClose:n,onClick:b,primaryButtonText:x,secondaryButtonText:"Cancel",children:a.jsxs(w,{children:["You have selected ",a.jsx("b",{children:t.length})," feature flags to enable.",a.jsx("br",{}),a.jsx("br",{}),a.jsx(T,{children:"Select which environment to enable the features for:"}),a.jsx(km,{options:y(),value:o,onChange:O=>l(O)}),a.jsx(D,{condition:g(o),show:a.jsx(B8,{severity:"warning",children:"Change requests are enabled for this environment."})}),a.jsx(D,{condition:j>0,show:a.jsxs(B8,{severity:"info",children:[j," feature"," ",j>1?"flags are ":"flag is ","already enabled."]})})]})})},Gm=({selectedIds:e,data:t,projectId:n,onResetSelection:i,onChange:c})=>{var C,$;const{uiConfig:s}=u1(),[o,l]=h.useState(!1),[d,f]=h.useState(!1),[m,p]=h.useState(!1),{trackEvent:g}=A1(),v=h.useMemo(()=>t.filter(Z=>e.includes(Z.name)),[t,e]),j=h.useMemo(()=>{const Z=v.flatMap(I=>I.environments).map(I=>I==null?void 0:I.name).filter(I=>I!==void 0);return Array.from(new Set(Z))},[v]),y=()=>{c==null||c(),g("batch_operations",{props:{eventType:"features exported"}})},b=()=>{c==null||c(),g("batch_operations",{props:{eventType:"features enabled"}})},x=()=>{c==null||c(),g("batch_operations",{props:{eventType:"features disabled"}})},O=()=>{c==null||c(),i()};return a.jsxs(a.Fragment,{children:[a.jsx(D,{condition:!!((C=s==null?void 0:s.flags)!=null&&C.disableBulkToggle),show:null,elseShow:a.jsx(d1,{variant:"outlined",size:"small",onClick:()=>f(!0),children:"Enable"})}),a.jsx(D,{condition:!!(($=s==null?void 0:s.flags)!=null&&$.disableBulkToggle),show:null,elseShow:a.jsx(d1,{variant:"outlined",size:"small",onClick:()=>p(!0),children:"Disable"})}),a.jsx(Lm,{projectId:n,featureIds:e,features:t,onConfirm:O}),a.jsx(d1,{variant:"outlined",size:"small",onClick:()=>l(!0),children:"Export"}),a.jsx(Ym,{projectId:n,data:v,onChange:c}),a.jsx(Nm,{projectId:n,data:v,onChange:c}),a.jsx(wc,{showExportDialog:o,data:v,onClose:()=>l(!1),environments:j,onConfirm:y}),a.jsx(qm,{showExportDialog:d,data:v,onClose:()=>f(!1),environments:j,projectId:n,onConfirm:b}),a.jsx(Um,{showExportDialog:m,data:v,onClose:()=>p(!1),environments:j,projectId:n,onConfirm:x})]})};var u5={},Km=K1;Object.defineProperty(u5,"__esModule",{value:!0});var h5=u5.default=void 0,Qm=Km(G1()),Jm=a,Xm=(0,Qm.default)((0,Jm.jsx)("path",{d:"m9.78 11.16-1.42 1.42c-.68-.69-1.34-1.58-1.79-2.94l1.94-.49c.32.89.77 1.5 1.27 2.01zM11 6 7 2 3 6h3.02c.02.81.08 1.54.19 2.17l1.94-.49C8.08 7.2 8.03 6.63 8.02 6H11zm10 0-4-4-4 4h2.99c-.1 3.68-1.28 4.75-2.54 5.88-.5.44-1.01.92-1.45 1.55-.34-.49-.73-.88-1.13-1.24L9.46 13.6c.93.85 1.54 1.54 1.54 3.4v5h2v-5c0-2.02.71-2.66 1.79-3.63 1.38-1.24 3.08-2.78 3.2-7.37H21z"}),"AltRoute");h5=u5.default=Xm;function ep({onClick:e,currentValue:t,label:n,icon:i,labelWidth:c,tooltip:s}){return a.jsx(Pd,{titleComponent:a.jsxs(Td,{children:[a.jsx("h3",{children:s.header}),a.jsx("p",{children:s.description}),s.additionalContent]}),variant:"custom",children:a.jsx(d1,{"aria-role":"switch","aria-checked":t,variant:t?"contained":"outlined",color:"primary",startIcon:i,onClick:e,disableElevation:!0,children:a.jsx(Ed,{labelWidth:c,children:n})})})}const tp=({global:e,project:t})=>{const{limitReached:n,limitMessage:i}=np(e.limit,e.count),c=ap(t.limit,t.count);return{limitMessage:n?i:c?`You have reached the project limit of ${t.limit} feature flags.`:void 0,globalFlagLimitReached:n,projectFlagLimitReached:c}},np=(e,t)=>{const n=t>=e;return{limitReached:n,limitMessage:n?`You have reached the instance-wide limit of ${e} feature flags.`:void 0}},ap=(e,t)=>e!=null&&e<=t,rp=()=>{const{setShowFeedback:e}=h.useContext(Zd);return h.useCallback(()=>{const{value:t,setValue:n}=V2("flagsCreated","0"),i=Number.parseInt(t)+1;n(`${i}`),i>1&&e(!0)},[e])},ip=u(Sc)(({theme:e})=>({"& .MuiDialog-paper":{borderRadius:e.shape.borderRadiusLarge,maxWidth:e.spacing(170),width:"100%",backgroundColor:"transparent"},padding:0,"& .MuiPaper-root > section":{overflowX:"hidden"}})),Ve={project:{icon:a.jsx(Pc,{}),text:"Projects allow you to group feature flags together in the Unleash admin UI and in SDK payloads."},tags:{icon:a.jsx(Dc,{}),text:"Tags are used to label flags in Unleash. They can be used when filtering flags in the UI. Additionally, they are used by some integrations."},type:{icon:a.jsx(Mr,{}),text:"A flag's type conveys its purpose. All types have the same capabilities, but choosing the right type signals what kind of flag it is. You can change this at any time."},impressionData:{icon:a.jsx(h5,{}),text:"Impression data is used to track how your flag is performing. When enabled, you can subscribe to 'impression events' in the SDK and process them according to your needs."}},cp=({open:e,onClose:t,onSuccess:n,skipNavigationOnComplete:i})=>{if(e)return a.jsx(sp,{open:e,onClose:t,skipNavigationOnComplete:i,onSuccess:n})},sp=({open:e,onClose:t,skipNavigationOnComplete:n,onSuccess:i})=>{var y1,$1,L;const{setToastData:c,setToastApiError:s}=C1(),{uiConfig:o,isOss:l}=u1(),d=le(),f=rp(),{type:m,setType:p,tags:g,setTags:v,name:j,setName:y,project:b,setProject:x,description:O,setDescription:C,validateToggleName:$,impressionData:Z,setImpressionData:I,getTogglePayload:E,clearErrors:R,errors:z}=Id(),{createFeatureToggle:W,loading:A}=Kr(),U={icon:a.jsx(Mr,{}),text:"Feature flags are at the core of Unleash. Use them to control your feature rollouts.",link:{url:"https://docs.getunleash.io/reference/feature-toggles",label:"Feature flags documentation"}},[k,M]=h.useState(U),B=()=>M(U),H=E(),F=()=>`curl --location --request POST '${o.unleashUrl}/api/admin/projects/${b}/features' \\ --header 'Authorization: INSERT_API_KEY' \\ --header 'Content-Type: application/json' \\ --data-raw '${JSON.stringify(H,void 0,2)}'`,S=async i1=>{if(i1.preventDefault(),R(),await $()){const U1=E();try{await W(b,U1),n||d(`/projects/${b}/features/${j}`),c({text:"Flag created successfully",type:"success"}),t(),i==null||i(),f()}catch(Z1){s(w1(Z1))}}},{total:_,loading:V}=Md(1),{project:K}=X1(b),{tags:G}=Oc(),{globalFlagLimitReached:h1,projectFlagLimitReached:f1,limitMessage:J}=tp({global:{limit:o.resourceLimits.featureFlags,count:_??0},project:{limit:K.featureLimit,count:Cc(K)}}),{projects:t1}=$c(),{featureTypes:a1}=Qr(),r1=Jr(m),n1=a1.reduce((i1,D1)=>i1>=D1.name.length?i1:D1.name.length,0),b1=h.useMemo(()=>{const i1=t1.find(D1=>D1.id===b);return i1==null?void 0:i1.name},[b,t1]);return a.jsx(ip,{open:e,onClose:t,children:a.jsx(Xe,{compact:!0,disablePadding:!0,description:k.text,documentationIcon:k.icon,documentationLink:(y1=k.link)==null?void 0:y1.url,documentationLinkLabel:($1=k.link)==null?void 0:$1.label,formatApiCode:F,useFixedSidebar:!0,children:a.jsx(Ad,{createButtonProps:{projectId:b,disabled:A||V||h1||f1,permission:z2,tooltipProps:{title:J,arrow:!0}},description:O,namingPattern:K.featureNaming,errors:z,handleSubmit:S,Icon:a.jsx(Mr,{}),validateName:$,Limit:a.jsx(Fd,{name:"feature flags",limit:o.resourceLimits.featureFlags,currentValue:_??0}),name:j,onClose:t,resource:"feature flag",setDescription:C,setName:y,configButtons:a.jsxs(a.Fragment,{children:[a.jsx(D,{condition:!l(),show:a.jsx(Ar,{tooltip:{header:"Select a project for the flag"},description:Ve.project.text,options:t1.map(i1=>({label:i1.name,value:i1.id})),onChange:i1=>{x(i1)},button:{label:b1??b,icon:Ve.project.icon,labelWidth:"20ch"},search:{label:"Filter projects",placeholder:"Select project"},onOpen:()=>M(Ve.project),onClose:B})}),a.jsx(Rd,{tooltip:{header:"Select tags"},description:Ve.tags.text,selectedOptions:g,options:G.map(i1=>({label:V0(i1),value:i1})),onChange:v,button:{label:g.size>0?`${g.size} selected`:"Tags",labelWidth:"11ch",icon:a.jsx(Dc,{})},search:{label:"Filter tags",placeholder:"Select tags"},onOpen:()=>M(Ve.tags),onClose:B}),a.jsx(Ar,{tooltip:{header:"Select a flag type"},description:Ve.type.text,options:a1.map(i1=>({label:i1.name,value:i1.id})),onChange:i1=>{p(i1)},button:{label:((L=a1.find(i1=>i1.id===m))==null?void 0:L.name)||"Select flag type",icon:a.jsx(r1,{}),labelWidth:`${n1}ch`},search:{label:"Filter flag types",placeholder:"Select flag type"},onOpen:()=>M({text:Ve.type.text,icon:a.jsx(r1,{})}),onClose:B}),a.jsx(ep,{tooltip:{header:"Enable or disable impression data",description:Ve.impressionData.text},currentValue:Z,onClick:()=>I(!Z),label:`Impression data ${Z?"on":"off"}`,icon:a.jsx(h5,{}),labelWidth:"19ch"})]})})})})},op=u(H2)(()=>({whiteSpace:"nowrap"})),vs=({variant:e,text:t="New feature flag",skipNavigationOnComplete:n,isLoading:i,onSuccess:c})=>{const{loading:s}=u1(),[o]=Xr(),l=Q("projectId"),d=!!o.get("create"),[f,m]=h.useState(d);return a.jsxs(a.Fragment,{children:[a.jsx(op,{onClick:()=>m(!0),maxWidth:"960px",Icon:V3,projectId:l,disabled:s||i,variant:e,permission:z2,"data-testid":s||i?"":Nd,children:t}),a.jsx(cp,{open:f,onClose:()=>m(!1),skipNavigationOnComplete:n,onSuccess:c})]})},lp=({isLoading:e,totalItems:t,searchQuery:n,onChangeSearchQuery:i,environmentsToExport:c,actions:s})=>{const o=Q("projectId"),l=j3(e||!1),[d,f]=h.useState(!0),m=x1(),p=N1(m.breakpoints.down("md")),[g,v]=h.useState(!1),{trackEvent:j}=A1(),y=Pe("projectOverviewRefactorFeedback"),{openFeedback:b}=Tc("newProjectOverview","automatic"),x=C=>{i==null||i(C),j("search-bar",{props:{screen:"project",length:C.length}})},O=()=>{b({title:"How easy was it to work with the project overview in Unleash?",positiveLabel:"What do you like most about the updated project overview?",areasForImprovementsLabel:"What improvements are needed in the project overview?"})};return a.jsx(w,{ref:l,"aria-busy":e,"aria-live":"polite",sx:C=>({padding:`${C.spacing(2.5)} ${C.spacing(3.125)}`}),children:a.jsx(j1,{titleElement:d?`Feature flags ${t!==void 0?`(${t})`:""}`:null,actions:a.jsxs(a.Fragment,{children:[a.jsx(D,{condition:!p,show:a.jsx(ie,{"data-loading":!0,placeholder:"Search and Filter",expandable:!0,initialValue:n||"",onChange:x,onFocus:()=>f(!1),onBlur:()=>f(!0),hasFilters:!0,id:"projectFeatureFlags"})}),s,a.jsx(j1.Divider,{sx:{marginLeft:0}}),a.jsx(Y1,{title:"Export all project flags",arrow:!0,children:a.jsx(R1,{"data-loading":!0,onClick:()=>v(!0),sx:C=>({marginRight:C.spacing(2)}),children:a.jsx(Wd,{})})}),a.jsx(D,{condition:!e,show:a.jsx(wc,{showExportDialog:g,project:o,data:[],onClose:()=>v(!1),environments:c||[]})}),a.jsx(D,{condition:y&&!p,show:a.jsx(d1,{startIcon:a.jsx(Ld,{}),onClick:O,variant:"outlined","data-loading":!0,children:"Provide feedback"})}),a.jsx(vs,{isLoading:e})]}),children:a.jsx(D,{condition:p,show:a.jsx(ie,{initialValue:n||"",onChange:x,hasFilters:!0,id:"projectFeatureFlags"})})})})},gs=u("div",{shouldForwardProp:e=>e!=="hasWarning"})(({theme:e,hasWarning:t})=>({flexGrow:0,...x3,justifyContent:"center",...t&&{"::before":{content:'""',display:"block",width:e.spacing(2)}}})),dp=u("div")(({theme:e})=>({flexGrow:0,...x3,justifyContent:"center"})),up=({value:e,featureId:t,projectId:n,environment:i,isChangeRequestEnabled:c,someEnabledEnvironmentHasVariants:s,refetch:o,onFeatureToggleSwitch:l})=>{const d=h.useMemo(()=>s&&(i==null?void 0:i.variantCount)===0&&(i==null?void 0:i.enabled),[s,i]),f=(m,p)=>{l(m,{projectId:n,featureId:t,environmentName:(i==null?void 0:i.name)||"",environmentType:i==null?void 0:i.type,hasStrategies:i==null?void 0:i.hasStrategies,hasEnabledStrategies:i==null?void 0:i.hasEnabledStrategies,isChangeRequestEnabled:c,onRollback:p,onSuccess:o})};return a.jsxs(gs,{hasWarning:d,children:[a.jsx(_f,{projectId:n,value:e,featureId:t,environmentName:(i==null?void 0:i.name)||"",onToggle:f}),a.jsx(D,{condition:d||!1,show:a.jsx(wf,{})})]})},hp=ke.memo(up),fp=()=>a.jsx(gs,{children:a.jsx("div",{"data-loading":!0,children:"toggle"})}),mp=()=>a.jsx(dp,{"aria-hidden":"true",children:"-"}),pp=e=>{const t=`api/admin/projects/${e}/flag-creators`,{data:n,refetch:i,loading:c,error:s}=U2(I1(t),()=>k2(I1(t),"Flag creators"));return{flagCreators:n||[],refetch:i,error:s}},vp=({state:e,onChange:t,project:n})=>{const{tags:i}=Oc(),{flagCreators:c}=pp(n),[s,o]=h.useState([]);return h.useEffect(()=>{const l=(i||[]).map(p=>{const g=V0(p);return{label:g,value:g}}),d=c.map(p=>({label:p.name,value:String(p.id)}));o([{label:"State",icon:"hexagon",options:[{label:"Active",value:"active"},{label:"Stale",value:"stale"},{label:"Potentially stale",value:"potentially-stale"}],filterKey:"state",singularOperators:["IS","IS_NOT"],pluralOperators:["IS_ANY_OF","IS_NONE_OF"]},{label:"Tags",icon:"label",options:l,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"]},{label:"Flag type",icon:"flag",options:[{label:"Release",value:"release"},{label:"Experiment",value:"experiment"},{label:"Operational",value:"operational"},{label:"Kill switch",value:"kill-switch"},{label:"Permission",value:"permission"}],filterKey:"type",singularOperators:["IS","IS_NOT"],pluralOperators:["IS_ANY_OF","IS_NONE_OF"]},{label:"Created by",icon:"person",options:d,filterKey:"createdBy",singularOperators:["IS","IS_NOT"],pluralOperators:["IS_ANY_OF","IS_NONE_OF"]},{label:"Show only archived",icon:"inventory",options:[{label:"True",value:"true"}],filterKey:"archived",singularOperators:["IS"],pluralOperators:["IS_ANY_OF"]}])},[JSON.stringify(i),JSON.stringify(c)]),a.jsx(Vd,{availableFilters:s,state:e,onChange:t})},c2=["select","actions","name","favorite"],s2=(e,t)=>e.reduce((n,i)=>({...n,[i]:t.includes(i)}),{}),gp=e=>{const t=x1(),n=N1(t.breakpoints.down("sm")),i=N1(t.breakpoints.down("md")),c=N1(t.breakpoints.down("lg")),s=h.useCallback((o=0)=>e.filter(l=>l.startsWith("environment:")),[e]);return n?s2(e,[...c2,"createdAt"]):i?s2(e,[...c2,"createdAt",...s(1)]):c?s2(e,[...c2,"createdAt","type",...s(1)]):s2(e,[...c2,"lastSeenAt","lifecycle","createdAt","createdBy","type","tags",...s(3)])},xp=({query:e})=>{var t;return((t=e||"")==null?void 0:t.length)>0?a.jsx(w,{sx:n=>({padding:n.spacing(3)}),children:a.jsxs(k1,{children:["No feature flags found matching “",e,"”"]})}):a.jsx(w,{sx:n=>({padding:n.spacing(3)}),children:a.jsx(k1,{children:"No feature flags available."})})},jp=(e,t)=>{const[n,i]=h.useState(),[c,s]=h.useState({}),[o,l]=h.useState({featureId:"default",open:!1}),[d,f]=h.useState({featureId:"default",open:!1}),[m,p]=h.useState({featureId:"default",open:!1});return{rowActionsDialogs:a.jsxs(a.Fragment,{children:[a.jsx(Sf,{isStale:!!c.stale,isOpen:!!c.featureId,onClose:()=>{s({}),e()},featureId:c.featureId||"",projectId:t}),a.jsx(us,{isOpen:!!n,onConfirm:e,onClose:()=>{i(void 0)},featureIds:[n||""],projectId:t}),a.jsx(Df,{isOpen:o.open,setIsOpen:v=>{l({...o,open:v})},projectId:t,featureId:o.featureId,onComplete:e}),a.jsx(zd,{deletedFeatures:[m.featureId],projectId:t,open:m.open,setOpen:v=>{p(j=>({...j,open:v}))},refetch:e}),a.jsx(Bd,{revivedFeatures:[d.featureId],projectId:t,open:d.open,setOpen:v=>{f(j=>({...j,open:v}))},refetch:()=>{f(v=>({...v,open:!1})),e()}})]}),setFeatureArchiveState:i,setFeatureStaleDialogState:s,setShowMarkCompletedDialogue:l,setShowFeatureReviveDialogue:f,setShowFeatureDeleteDialogue:p}},bp=(e,t)=>{const[n,i]=h.useState([]);return h.useEffect(()=>{i(c=>{const s=[...e];return c.forEach(o=>{s.find(l=>l.name===o.name)||s.push(o)}),s.filter(o=>t[o.name])})},[e,t]),n},yp=u(s1)({textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}}),_p=u("button")(({theme:e})=>({marginRight:e.spacing(.5),border:`1px solid ${e.palette.divider}`,borderRadius:e.shape.borderRadius,fontSize:e.fontSizes.smallerBody,textOverflow:"ellipsis",overflow:"hidden",textWrap:"nowrap",maxWidth:"250px",padding:e.spacing(.25,.5),cursor:"pointer",background:"inherit",color:"inherit"})),wp=u(Yd)(({theme:e})=>({overflowWrap:"anywhere",lineHeight:e.typography.body1.lineHeight,backgroundColor:e.palette.background.paper,color:e.palette.text.primary,padding:e.spacing(.25,.5),height:"auto",fontSize:e.fontSizes.smallerBody,border:`1px solid ${e.palette.divider}`,borderRadius:e.shape.borderRadius,"&:hover":{backgroundColor:e.palette.background.paper},"& .MuiChip-label":{padding:0}})),Sp=({text:e,searchQuery:t})=>a.jsx(D,{condition:!!(e&&e.length>40),show:a.jsx(ee,{title:a.jsx(re,{search:t,children:e}),placement:"bottom-start",arrow:!0,children:a.jsx(P8,{children:a.jsx(re,{search:t,children:e})})}),elseShow:a.jsx(P8,{children:a.jsx(re,{search:t,children:e})})}),Op=u(w)(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(.5),margin:e.spacing(1.25,0,1,0),paddingLeft:e.spacing(2)})),Cp=u(w)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),color:e.palette.primary.dark})),$p=u(w)(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing(.25)})),Dp=u(fe)(({theme:e})=>({padding:e.spacing(.5),border:0,textTransform:"capitalize"})),Pp=({project:e,feature:t,searchQuery:n})=>a.jsx(w,{sx:i=>({fontWeight:i.typography.fontWeightBold}),children:a.jsx(yp,{to:`/projects/${e}/features/${t}`,children:a.jsx(Ud,{style:{WebkitLineClamp:1,lineClamp:1,overflowWrap:"anywhere"},children:a.jsx(re,{search:n,children:t})})})}),Tp=({feature:e,searchQuery:t})=>a.jsx(w,{sx:n=>({fontWeight:n.typography.fontWeightBold,color:n.palette.neutral.main}),children:a.jsx(re,{search:t,children:e})}),V4=({tag:e,onClick:t})=>{const n=Pe("tagTypeColor"),i=V0(e);if(n){const o=a.jsx(w,{onClick:()=>t(e),sx:{cursor:"pointer"},children:a.jsx(ls,{tag:e,maxLength:30})});return a.jsx(ee,{title:i,arrow:!0,children:a.jsx("span",{children:o})},i)}const c=i.length>30,s=c?`${i.substring(0,30)}...`:i;return a.jsx(wp,{label:s,size:"small",onClick:()=>t(e),sx:{cursor:"pointer"},title:c?i:void 0},i)},Ep=({tags:e,onClick:t})=>{const n=Pe("tagTypeColor");return a.jsx(ee,{title:e.map(i=>{const c=V0(i);return a.jsx(w,{sx:{cursor:"pointer"},onClick:()=>t(c),children:n?a.jsx(ls,{tag:i,maxLength:30}):c},c)}),children:a.jsxs(_p,{sx:{cursor:"initial",...n&&{borderRadius:i=>i.spacing(2)}},children:[e.length," more..."]})})},Zp=({tags:e,onClick:t})=>{if(!e||e.length===0)return null;const[n,i,c,...s]=e,o=l=>{t(V0(l))};return a.jsxs($p,{children:[n&&a.jsx(V4,{tag:n,onClick:o}),i&&a.jsx(V4,{tag:i,onClick:o}),c&&a.jsx(V4,{tag:c,onClick:o}),a.jsx(D,{condition:s.length>0,show:a.jsx(Ep,{tags:s,onClick:t})})]})},Ip=u(s1)({display:"block"}),Mp=({feature:e,project:t})=>{const{feature:n}=kd(t,e),i=n.children,c=n.dependencies;if(i.length>0)return a.jsxs(a.Fragment,{children:[a.jsx(w,{children:"Children"}),i.map(s=>a.jsx(Ip,{to:`/projects/${t}/features/${s}`,children:s},s))]});if(c[0]){const s=c[0].feature;return a.jsxs(a.Fragment,{children:[a.jsx(w,{children:"Parent"}),a.jsx(s1,{to:`/projects/${t}/features/${s}`,children:s})]})}return a.jsx(a.Fragment,{children:"Loading..."})},Ap=({project:e,feature:t,archivedAt:n,type:i,searchQuery:c,dependencyType:s,onTypeClick:o,delay:l=500})=>{var y;const{featureTypes:d}=Qr(),f=Jr(i),p=`${((y=d.find(b=>b.id===i))==null?void 0:y.name)||i} flag`,{locationSettings:g}=b3(),v=Hd(n,g.locale),j=()=>a.jsx(ee,{arrow:!0,title:p,describeChild:!0,children:a.jsx(R1,{sx:{p:0},"aria-label":`add ${i} flag to filter`,onClick:()=>o(i),children:a.jsx(f,{sx:b=>({fontSize:b.spacing(2)}),"data-testid":"feature-type-icon"})})});return a.jsxs(Cp,{"data-loading":!0,children:[a.jsx(j,{}),n?a.jsx(Tp,{feature:t,searchQuery:c}):a.jsx(Pp,{project:e,feature:t,searchQuery:c}),a.jsx(D,{condition:!!s,show:a.jsx(ee,{title:a.jsx(Mp,{feature:t,project:e}),enterDelay:l,enterNextDelay:l,children:a.jsx(Dp,{color:s==="parent"?"warning":"secondary",children:s})})}),n&&a.jsx(ee,{arrow:!0,title:v,describeChild:!0,children:a.jsx(fe,{tabIndex:0,color:"neutral",children:"Archived"})})]})},Fp=({description:e,searchQuery:t})=>a.jsx(D,{condition:!!e,show:a.jsx(w,{sx:n=>({display:"flex",gap:n.spacing(1)}),children:a.jsx(Sp,{text:e,searchQuery:t})})}),Rp=(e,t)=>({row:n})=>{const{searchQuery:i}=z3();return a.jsxs(Op,{children:[a.jsx(Ap,{project:n.original.project||"",feature:n.original.name,archivedAt:n.original.archivedAt,searchQuery:i,type:n.original.type||"",dependencyType:n.original.dependencyType||"",onTypeClick:t}),a.jsx(Fp,{description:n.original.description||"",searchQuery:i}),a.jsx(Zp,{tags:n.original.tags,onClick:e})]})},xs=(e,t="project-overview-v2",n=15*1e3)=>{const i={offset:Se(O2,0),limit:Se(O2,qd),query:M3,favoritesFirst:Se(Gd,!0),sortBy:Se(M3,"createdAt"),sortOrder:Se(M3,"desc"),columns:Kd,tag:D3,state:D3,createdAt:D3,type:D3,createdBy:D3,archived:D3},[c,s]=Ec(`${t}-${e}`,i),{columns:o,...l}=c,{features:d,total:f,refetch:m,loading:p,initialLoad:g}=Qd(Zc({...Ic(i,l),project:`IS:${e}`},v=>v?`${v}`:void 0),{refreshInterval:n});return{features:d,total:f,refetch:m,loading:p,initialLoad:g,tableState:c,setTableState:s}},Wp=(e,t)=>{const n=(o,l)=>{const d=e[o.key];d&&d.values.length>0&&!d.values.includes(l)?t({[o.key]:{operator:d.operator,values:[...d.values,l]}}):d||t({[o.key]:{operator:o.operator,values:[l]}})};return{onFlagTypeClick:o=>n({key:"type",operator:"IS"},o),onTagClick:o=>n({key:"tag",operator:"INCLUDE"},o),onAvatarClick:o=>n({key:"createdBy",operator:"IS"},o.toString())}},Lp=u("div")({width:"100%",display:"flex",justifyContent:"center",alignItems:"center"}),Np=u("button")({border:"none",background:"none",cursor:"pointer",borderRadius:"100%",padding:0}),Vp=u("p")(({theme:e})=>({color:e.palette.text.secondary})),zp=u(z0)(({theme:e})=>({width:e.spacing(3),height:e.spacing(3)})),Bp=e=>({row:{original:t}})=>{const n=t.createdBy.id===0,i=n?()=>{}:()=>e(t.createdBy.id),c=n?a.jsxs(a.Fragment,{children:[a.jsx("p",{children:t.createdBy.name}),a.jsx(Vp,{children:"You can't filter by unknown users."})]}):a.jsx("p",{children:t.createdBy.name});return a.jsx(Lp,{children:a.jsx(ee,{arrow:!0,describeChild:!0,title:c,children:a.jsxs(Np,{"ar