unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
4 lines • 141 kB
JavaScript
import{aP as tn,aQ as sn,_ as Mt,aR as Ca,a as ee,aS as ut,j as t,s as d,aT as wa,aU as Pe,r as y,aV as nn,b as ze,aW as Ot,aX as Be,aY as an,aZ as T,a_ as q,a$ as Ta,W as se,A as Ra,m as on,l as Da,n as $a,o as Aa,b0 as rn,u as ka,h as V,aB as ne,b1 as le,b2 as ae,e as Y,b3 as Ke,b4 as Q,b5 as he,B as M,T as N,C as w,b6 as Fa,L as J,D as Ce,J as qt,y as Z,b7 as gt,b8 as ln,M as xe,b9 as Te,ba as Re,bb as Se,bc as ht,bd as Qe,be as pe,bf as Wt,bg as dt,bh as Xe,bi as cn,bj as Ze,bk as De,bl as dn,bm as Ia,bn as et,bo as Pa,bp as pn,bq as be,t as Vt,br as xt,bs as Nt,Q as fe,ab as un,v as Ea,bt as gn,bu as hn,i as ue,bv as Ba,bw as xn,bx as Oa,by as za,bz as Ht,bA as ce,bB as ft,av as _a,bC as fn,bD as yn,bE as Ut,bF as gs,bG as La,bH as Ma,bI as qa,bJ as Wa,bK as Ie,bL as Va,bM as Na,bN as Ha,bO as jn,bP as Ua,bQ as Ga,bR as Ya,bS as Ja,bT as me,bU as Ka,bV as Qa,bW as yt,bX as Xa,a1 as _e,bY as tt,bZ as Le,b_ as Me,a5 as mn,b$ as Sn,K as bn,c0 as qe,c1 as Za,c2 as vn,c3 as Gt,c4 as Fe,c5 as Cn,c6 as eo,c7 as wn,c8 as to,au as We,N as ve,c9 as so,ca as Tn,cb as no,cc as ao,cd as oo,ce as ro,cf as io,cg as st,ch as Rn,ci as Yt,cj as lo,ck as zt,cl as Dn,cm as $n,cn as co,co as po,cp as uo,cq as go,cr as ho,cs as An,ct as xo,cu as te,cv as fo,cw as yo,ah as jo,ai as St,aj as hs,cx as mo,cy as kn,cz as Fn,cA as In,cB as Pn,cC as So,cD as bo,cE as xs,Y as vo,cF as Co,cG as wo,cH as To,cI as Ro,cJ as we,cK as Do,cL as $o,a4 as Ao,aA as En,cM as ko,cN as Fo,cO as Io,cP as Po,cQ as Eo,cR as Bo,cS as Oo,E as jt,cT as zo,cU as _o,cV as Jt,cW as Bn,cX as Kt,cY as ye,cZ as Ye,c_ as On,c$ as Lo,d0 as Mo,d1 as qo,d2 as Wo,d3 as zn,d4 as Vo,d5 as No,f as Ho,d6 as Uo,d7 as bt,d8 as fs,aO as Go,d9 as Ee,da as ys,db as Yo,dc as Jo,dd as Ko,aL as Qt,aM as Qo,aG as js,de as Xo,df as Zo,dg as er,dh as ms,at as pt,G as nt,H as at,di as tr,al as vt,ax as sr,an as nr,ao as ar,ap as or,aq as rr,ar as ir,as as lr,dj as cr,dk as dr,dl as Ss,dm as pr,dn as ur,dp as Ct,dq as gr,dr as hr,ds as xr,x as _n,dt as fr,du as bs,dv as yr,dw as jr,dx as Ln,dy as mr,dz as Sr,dA as br,dB as vr,d as Mn,dC as Cr,dD as qn,dE as Wn,dF as wr,dG as Tr,dH as Rr,dI as Dr,dJ as $r,aD as Ar}from"./index-DEkgmbaI.js";import{u as kr,a as Fr,F as Xt,M as Vn}from"./MarkCompletedDialogue-3-FrccPG.js";import{F as Zt,a as _t,u as Nn,b as Ir,c as Pr}from"./aggregateFeatureMetrics-v3jEzw5e.js";import{u as Er,a as Br,T as Or,b as zr,c as _r,d as Lr,P as Oe,e as Hn,F as Un,C as Gn,f as Mr,E as qr,V as Wr,g as Vr,h as Nr,i as Hr,j as Ur}from"./FeatureStaleDialog-DmQwcw9H.js";import{S as Gr}from"./LegacyStrategyItemContainer-CqOcbhDa.js";function Yr(e){return sn("MuiPagination",e)}tn("MuiPagination",["root","ul","outlined","text"]);const Jr=["boundaryCount","componentName","count","defaultPage","disabled","hideNextButton","hidePrevButton","onChange","page","showFirstButton","showLastButton","siblingCount"];function Kr(e={}){const{boundaryCount:s=1,componentName:n="usePagination",count:a=1,defaultPage:o=1,disabled:r=!1,hideNextButton:l=!1,hidePrevButton:c=!1,onChange:i,page:p,showFirstButton:u=!1,showLastButton:g=!1,siblingCount:h=1}=e,x=Mt(e,Jr),[j,b]=Ca({controlled:p,default:o,name:n,state:"page"}),m=(A,L)=>{p||b(L),i&&i(A,L)},f=(A,L)=>{const U=L-A+1;return Array.from({length:U},(G,D)=>A+D)},R=f(1,Math.min(s,a)),k=f(Math.max(a-s+1,s+1),a),P=Math.max(Math.min(j-h,a-s-h*2-1),s+2),z=Math.min(Math.max(j+h,s+h*2+2),k.length>0?k[0]-2:a-1),_=[...u?["first"]:[],...c?[]:["previous"],...R,...P>s+2?["start-ellipsis"]:s+1<a-s?[s+1]:[],...f(P,z),...z<a-s-1?["end-ellipsis"]:a-s>s?[a-s]:[],...k,...l?[]:["next"],...g?["last"]:[]],$=A=>{switch(A){case"first":return 1;case"previous":return j-1;case"next":return j+1;case"last":return a;default:return null}},E=_.map(A=>typeof A=="number"?{onClick:L=>{m(L,A)},type:"page",page:A,selected:A===j,disabled:r,"aria-current":A===j?"true":void 0}:{onClick:L=>{m(L,$(A))},type:A,page:$(A),selected:!1,disabled:r||A.indexOf("ellipsis")===-1&&(A==="next"||A==="last"?j>=a:j<=1)});return ee({items:E},x)}function Qr(e){return sn("MuiPaginationItem",e)}const re=tn("MuiPaginationItem",["root","page","sizeSmall","sizeLarge","text","textPrimary","textSecondary","outlined","outlinedPrimary","outlinedSecondary","rounded","ellipsis","firstLast","previousNext","focusVisible","disabled","selected","icon"]),vs=ut(t.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"}),"FirstPage"),Cs=ut(t.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"}),"LastPage"),ws=ut(t.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"}),"NavigateBefore"),Ts=ut(t.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}),"NavigateNext"),Xr=["className","color","component","components","disabled","page","selected","shape","size","slots","type","variant"],Yn=(e,s)=>{const{ownerState:n}=e;return[s.root,s[n.variant],s[`size${Be(n.size)}`],n.variant==="text"&&s[`text${Be(n.color)}`],n.variant==="outlined"&&s[`outlined${Be(n.color)}`],n.shape==="rounded"&&s.rounded,n.type==="page"&&s.page,(n.type==="start-ellipsis"||n.type==="end-ellipsis")&&s.ellipsis,(n.type==="previous"||n.type==="next")&&s.previousNext,(n.type==="first"||n.type==="last")&&s.firstLast]},Zr=e=>{const{classes:s,color:n,disabled:a,selected:o,size:r,shape:l,type:c,variant:i}=e,p={root:["root",`size${Be(r)}`,i,l,n!=="standard"&&`${i}${Be(n)}`,a&&"disabled",o&&"selected",{page:"page",first:"firstLast",last:"firstLast","start-ellipsis":"ellipsis","end-ellipsis":"ellipsis",previous:"previousNext",next:"previousNext"}[c]],icon:["icon"]};return an(p,Qr,s)},ei=d("div",{name:"MuiPaginationItem",slot:"Root",overridesResolver:Yn})(({theme:e,ownerState:s})=>ee({},e.typography.body2,{borderRadius:32/2,textAlign:"center",boxSizing:"border-box",minWidth:32,padding:"0 6px",margin:"0 3px",color:(e.vars||e).palette.text.primary,height:"auto",[`&.${re.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity}},s.size==="small"&&{minWidth:26,borderRadius:26/2,margin:"0 1px",padding:"0 4px"},s.size==="large"&&{minWidth:40,borderRadius:40/2,padding:"0 10px",fontSize:e.typography.pxToRem(15)})),ti=d(wa,{name:"MuiPaginationItem",slot:"Root",overridesResolver:Yn})(({theme:e,ownerState:s})=>ee({},e.typography.body2,{borderRadius:32/2,textAlign:"center",boxSizing:"border-box",minWidth:32,height:32,padding:"0 6px",margin:"0 3px",color:(e.vars||e).palette.text.primary,[`&.${re.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${re.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},transition:e.transitions.create(["color","background-color"],{duration:e.transitions.duration.short}),"&:hover":{backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${re.selected}`]:{backgroundColor:(e.vars||e).palette.action.selected,"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette.action.selectedChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.hoverOpacity}))`:Pe(e.palette.action.selected,e.palette.action.selectedOpacity+e.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:(e.vars||e).palette.action.selected}},[`&.${re.focusVisible}`]:{backgroundColor:e.vars?`rgba(${e.vars.palette.action.selectedChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.focusOpacity}))`:Pe(e.palette.action.selected,e.palette.action.selectedOpacity+e.palette.action.focusOpacity)},[`&.${re.disabled}`]:{opacity:1,color:(e.vars||e).palette.action.disabled,backgroundColor:(e.vars||e).palette.action.selected}}},s.size==="small"&&{minWidth:26,height:26,borderRadius:26/2,margin:"0 1px",padding:"0 4px"},s.size==="large"&&{minWidth:40,height:40,borderRadius:40/2,padding:"0 10px",fontSize:e.typography.pxToRem(15)},s.shape==="rounded"&&{borderRadius:(e.vars||e).shape.borderRadius}),({theme:e,ownerState:s})=>ee({},s.variant==="text"&&{[`&.${re.selected}`]:ee({},s.color!=="standard"&&{color:(e.vars||e).palette[s.color].contrastText,backgroundColor:(e.vars||e).palette[s.color].main,"&:hover":{backgroundColor:(e.vars||e).palette[s.color].dark,"@media (hover: none)":{backgroundColor:(e.vars||e).palette[s.color].main}},[`&.${re.focusVisible}`]:{backgroundColor:(e.vars||e).palette[s.color].dark}},{[`&.${re.disabled}`]:{color:(e.vars||e).palette.action.disabled}})},s.variant==="outlined"&&{border:e.vars?`1px solid rgba(${e.vars.palette.common.onBackgroundChannel} / 0.23)`:`1px solid ${e.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)"}`,[`&.${re.selected}`]:ee({},s.color!=="standard"&&{color:(e.vars||e).palette[s.color].main,border:`1px solid ${e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / 0.5)`:Pe(e.palette[s.color].main,.5)}`,backgroundColor:e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / ${e.vars.palette.action.activatedOpacity})`:Pe(e.palette[s.color].main,e.palette.action.activatedOpacity),"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / calc(${e.vars.palette.action.activatedOpacity} + ${e.vars.palette.action.focusOpacity}))`:Pe(e.palette[s.color].main,e.palette.action.activatedOpacity+e.palette.action.focusOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${re.focusVisible}`]:{backgroundColor:e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / calc(${e.vars.palette.action.activatedOpacity} + ${e.vars.palette.action.focusOpacity}))`:Pe(e.palette[s.color].main,e.palette.action.activatedOpacity+e.palette.action.focusOpacity)}},{[`&.${re.disabled}`]:{borderColor:(e.vars||e).palette.action.disabledBackground,color:(e.vars||e).palette.action.disabled}})})),si=d("div",{name:"MuiPaginationItem",slot:"Icon",overridesResolver:(e,s)=>s.icon})(({theme:e,ownerState:s})=>ee({fontSize:e.typography.pxToRem(20),margin:"0 -8px"},s.size==="small"&&{fontSize:e.typography.pxToRem(18)},s.size==="large"&&{fontSize:e.typography.pxToRem(22)})),ni=y.forwardRef(function(s,n){const a=nn({props:s,name:"MuiPaginationItem"}),{className:o,color:r="standard",component:l,components:c={},disabled:i=!1,page:p,selected:u=!1,shape:g="circular",size:h="medium",slots:x={},type:j="page",variant:b="text"}=a,m=Mt(a,Xr),f=ee({},a,{color:r,disabled:i,selected:u,shape:g,size:h,type:j,variant:b}),R=ze(),k=Zr(f),z=(R.direction==="rtl"?{previous:x.next||c.next||Ts,next:x.previous||c.previous||ws,last:x.first||c.first||vs,first:x.last||c.last||Cs}:{previous:x.previous||c.previous||ws,next:x.next||c.next||Ts,first:x.first||c.first||vs,last:x.last||c.last||Cs})[j];return j==="start-ellipsis"||j==="end-ellipsis"?t.jsx(ei,{ref:n,ownerState:f,className:Ot(k.root,o),children:"…"}):t.jsxs(ti,ee({ref:n,ownerState:f,component:l,disabled:i,className:Ot(k.root,o)},m,{children:[j==="page"&&p,z?t.jsx(si,{as:z,ownerState:f,className:k.icon}):null]}))}),ai=["boundaryCount","className","color","count","defaultPage","disabled","getItemAriaLabel","hideNextButton","hidePrevButton","onChange","page","renderItem","shape","showFirstButton","showLastButton","siblingCount","size","variant"],oi=e=>{const{classes:s,variant:n}=e;return an({root:["root",n],ul:["ul"]},Yr,s)},ri=d("nav",{name:"MuiPagination",slot:"Root",overridesResolver:(e,s)=>{const{ownerState:n}=e;return[s.root,s[n.variant]]}})({}),ii=d("ul",{name:"MuiPagination",slot:"Ul",overridesResolver:(e,s)=>s.ul})({display:"flex",flexWrap:"wrap",alignItems:"center",padding:0,margin:0,listStyle:"none"});function li(e,s,n){return e==="page"?`${n?"":"Go to "}page ${s}`:`Go to ${e} page`}const Jn=y.forwardRef(function(s,n){const a=nn({props:s,name:"MuiPagination"}),{boundaryCount:o=1,className:r,color:l="standard",count:c=1,defaultPage:i=1,disabled:p=!1,getItemAriaLabel:u=li,hideNextButton:g=!1,hidePrevButton:h=!1,renderItem:x=E=>t.jsx(ni,ee({},E)),shape:j="circular",showFirstButton:b=!1,showLastButton:m=!1,siblingCount:f=1,size:R="medium",variant:k="text"}=a,P=Mt(a,ai),{items:z}=Kr(ee({},a,{componentName:"Pagination"})),_=ee({},a,{boundaryCount:o,color:l,count:c,defaultPage:i,disabled:p,getItemAriaLabel:u,hideNextButton:g,hidePrevButton:h,renderItem:x,shape:j,showFirstButton:b,showLastButton:m,siblingCount:f,size:R,variant:k}),$=oi(_);return t.jsx(ri,ee({"aria-label":"pagination navigation",className:Ot($.root,r),ownerState:_,ref:n},P,{children:t.jsx(ii,{className:$.ul,ownerState:_,children:z.map((E,A)=>t.jsx("li",{children:x(ee({},E,{color:l,"aria-label":u(E.type,E.page,E.selected),shape:j,size:R,variant:k}))},A))})}))}),ci=()=>{const e=T("projectId"),s=T("featureId"),{feature:n}=q(e,s);return n.name?t.jsx(Ta,{title:"Event log",feature:s}):null},di=()=>t.jsxs(se,{severity:"warning",children:["Remember to update your Unleash client! Feature dependencies require new SDK versions. Read more about ",t.jsx(pi,{}),"."]}),pi=()=>t.jsx("a",{href:"https://docs.getunleash.io/reference/feature-toggles#feature-flag-dependencies",target:"_blank",rel:"noreferrer",children:"Client SDK support for feature dependencies"}),ui=d(Ra)(({theme:e})=>({marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),gi=({project:e,parent:s,onSelect:n,selectedValues:a})=>{const{parentVariantOptions:o}=kr(e,s),r=t.jsx($a,{fontSize:"small"}),l=t.jsx(Aa,{fontSize:"small"});return t.jsx(ui,{multiple:!0,id:"parent-variant-options",options:o,disableCloseOnSelect:!0,renderOption:(c,i,{selected:p})=>t.jsxs("li",{...c,children:[t.jsx(on,{icon:r,checkedIcon:l,style:{marginRight:8},checked:p}),i]}),renderInput:c=>t.jsx(Da,{...c,placeholder:"Select values"}),fullWidth:!0,value:a,onChange:(c,i)=>{n(i)}})},je={key:"none (remove dependency)",label:"none (remove dependency)"},Kn=d(rn)(({theme:e})=>({marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),hi=({onSelect:e,parentValue:s})=>t.jsx(Kn,{fullWidth:!0,options:[{key:"enabled",label:"enabled"},{key:"enabled_with_variants",label:"enabled with variants"},{key:"disabled",label:"disabled"}],value:s.status,onChange:e}),es=e=>{const{makeRequest:s,createRequest:n,errors:a,loading:o}=ka({propagateErrors:!0}),r=async(p,u)=>{const g=n(`/api/admin/projects/${e}/features/${p}/dependencies`,{method:"POST",body:JSON.stringify(u)});await s(g.caller,g.id)},l=async(p,u)=>{const g=n(`/api/admin/projects/${e}/features/${p}/dependencies/${u}`,{method:"DELETE"});await s(g.caller,g.id)},c=async p=>{const u=n(`/api/admin/projects/${e}/features/${p}/dependencies`,{method:"DELETE"});await s(u.caller,u.id)},i=[n,s,V,e];return{addDependency:y.useCallback(r,i),removeDependency:y.useCallback(l,i),removeDependencies:y.useCallback(c,i),errors:a,loading:o}},xi=(e,s,n,a,o)=>{const{trackEvent:r}=ne(),{addChange:l}=le(),{refetch:c}=ae(e),{setToastData:i,setToastApiError:p}=Y(),{refetchFeature:u}=q(e,s),g=Ke(e)(),{isChangeRequestConfiguredInAnyEnv:h}=Q(e),{addDependency:x,removeDependencies:j}=es(e),b=async m=>{if(!g){console.error("No change request environment");return}m==="addDependency"&&(await l(e,g,[{action:m,feature:s,payload:{feature:n,enabled:a.status!=="disabled",variants:a.status==="enabled_with_variants"?a.variants:[]}}]),r("dependent_features",{props:{eventType:"dependency added"}})),m==="deleteDependency"&&await l(e,g,[{action:m,feature:s,payload:void 0}]),c(),i({type:"success",text:"Change added to draft"})};return async()=>{try{if(h()){const m=n===je.key?"deleteDependency":"addDependency";await b(m),r("dependent_features",{props:{eventType:m==="addDependency"?"add dependency added to change request":"delete dependency added to change request"}})}else n===je.key?(await j(s),r("dependent_features",{props:{eventType:"dependency removed"}}),i({text:"Dependency removed",type:"success"})):(await x(s,{feature:n,enabled:a.status!=="disabled",variants:a.status==="enabled_with_variants"?a.variants:[]}),r("dependent_features",{props:{eventType:"dependency added"}}),i({text:"Dependency added",type:"success"}))}catch(m){p(V(m))}u(),o()}},fi=({project:e,featureId:s,parent:n,onSelect:a})=>{const{parentOptions:o}=Fr(e,s),r=o?[je,...o.map(l=>({key:l,label:l}))]:[je];return t.jsx(Kn,{fullWidth:!0,options:r,value:n,onChange:a})},Qn=({project:e,featureId:s,parentDependency:n,showDependencyDialogue:a,onClose:o})=>{const[r,l]=y.useState((n==null?void 0:n.feature)||je.key),c=()=>{var f;return n?(f=n.variants)!=null&&f.length?{status:"enabled_with_variants",variants:n.variants}:n.enabled===!1?{status:"disabled"}:{status:"enabled"}:{status:"enabled"}},[i,p]=y.useState(c),u=()=>{l((n==null?void 0:n.feature)||je.key),p(c())};y.useEffect(()=>{u()},[JSON.stringify(n)]);const g=xi(e,s,r,i,o),{isChangeRequestConfiguredInAnyEnv:h}=Q(e),x=r!==je.key,j=r!==je.key&&i.status==="enabled_with_variants",b=f=>{(f==="enabled"||f==="disabled")&&p({status:f}),f==="enabled_with_variants"&&p({status:f,variants:[]})},m=f=>{p({status:"enabled_with_variants",variants:f})};return t.jsx(he,{open:a,title:"Add parent flag dependency",onClose:o,onClick:g,primaryButtonText:h()?"Add change to draft":r===je.key?"Remove":"Add",secondaryButtonText:"Cancel",children:t.jsxs(M,{children:[t.jsx(di,{}),t.jsxs(M,{sx:{mt:2,mb:4},children:["Your feature will be evaluated only when the selected parent feature is"," ",t.jsx("b",{children:i.status==="disabled"?"disabled":"enabled"})," ","in the same environment."]}),t.jsxs(N,{children:["What ",t.jsx("b",{children:"feature"})," do you want to depend on?"]}),t.jsx(w,{condition:a,show:t.jsx(fi,{project:e,featureId:s,parent:r,onSelect:f=>{p({status:"enabled"}),l(f)}})}),t.jsx(w,{condition:x,show:t.jsxs(M,{sx:{mt:2},children:[t.jsxs(N,{children:["What ",t.jsx("b",{children:"feature status"})," do you want to depend on?"]}),t.jsx(hi,{parentValue:i,onSelect:b})]})}),t.jsx(w,{condition:j,show:i.status==="enabled_with_variants"&&t.jsxs(M,{sx:{mt:2},children:[t.jsxs(N,{children:["What ",t.jsx("b",{children:"variant"})," do you want to depend on?"]}),t.jsx(gi,{parent:r,project:e,selectedValues:i.variants,onSelect:m})]})})]})})},Ve=d("div")({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"}),ke=d("div")(({theme:e})=>({justifyContent:"center",paddingTop:e.spacing(.75),...Fa})),Ne=d("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)})),mt=d(J)(({theme:e})=>({maxWidth:"100%",textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}})),yi=d(Ce)(({theme:e})=>({height:e.spacing(3.5),width:e.spacing(3.5)})),ji=d(qt)(({theme:e})=>({borderRadius:e.shape.borderRadiusLarge,padding:e.spacing(1,1.5)})),mi=({feature:e,onEdit:s,onDelete:n})=>{const a=`dependency-${e}-actions`,o=`${a}-menu`,[r,l]=y.useState(null),c=!!r,i=u=>{l(u.currentTarget)},p=()=>{l(null)};return t.jsxs(M,{children:[t.jsx(Z,{title:"Dependency actions",arrow:!0,describeChild:!0,children:t.jsx(yi,{id:a,"aria-controls":c?o:void 0,"aria-haspopup":"true","aria-expanded":c?"true":void 0,onClick:i,type:"button",children:t.jsx(gt,{})})}),t.jsx(ji,{id:o,anchorEl:r,open:c,onClose:p,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,children:t.jsxs(ln,{"aria-labelledby":a,children:[t.jsxs(xe,{onClick:()=>{s(),p()},children:[t.jsx(Te,{children:t.jsx(Re,{})}),t.jsx(Se,{children:t.jsx(N,{variant:"body2",children:"Edit"})})]}),t.jsxs(xe,{onClick:()=>{n(),p()},children:[t.jsx(Te,{children:t.jsx(ht,{})}),t.jsx(Se,{children:t.jsx(N,{variant:"body2",children:"Delete"})})]})]})})]})},ts=({childFeatures:e,project:s})=>t.jsx(Qe,{tooltip:t.jsx(t.Fragment,{children:e.map(n=>t.jsx(mt,{to:`/projects/${s}/features/${n}`,children:t.jsx("div",{children:n})},`${s}-${n}`))}),children:e.length===1?"1 feature":`${e.length} features`}),Xn=({variants:e})=>e.length===1&&e[0].length<20?t.jsx("span",{children:e[0]}):t.jsx(Qe,{tooltip:t.jsx(t.Fragment,{children:e.map((s,n)=>t.jsx("div",{children:s},n))}),children:e.length===1?"1 variant":`${e.length} variants`}),Si=d(pe)(({theme:e})=>({fontSize:e.fontSizes.smallBody,lineHeight:e.typography.body1.lineHeight})),bi=(e,s)=>{const{trackEvent:n}=ne(),{addChange:a}=le(),{refetch:o}=ae(e),{setToastData:r,setToastApiError:l}=Y(),{refetchFeature:c}=q(e,s),i=Ke(e)(),{isChangeRequestConfiguredInAnyEnv:p}=Q(e),{removeDependencies:u}=es(e),g=async()=>{if(!i){console.error("No change request environment");return}await a(e,i,[{action:"deleteDependency",feature:s,payload:void 0}])};return async()=>{try{p()?(await g(),n("dependent_features",{props:{eventType:"delete dependency added to change request"}}),r({type:"success",text:"Change added to draft"}),await o()):(await u(s),n("dependent_features",{props:{eventType:"dependency removed"}}),r({text:"Dependency removed",type:"success"}),await c())}catch(x){l(V(x))}}},vi=({feature:e})=>{var p,u,g,h,x,j;const[s,n]=y.useState(!1),a=!!e.project&&e.dependencies.length===0&&e.children.length===0,o=!!e.project&&e.dependencies.length>0,r=!!e.project&&e.children.length>0,l=Ke(e.project)(),c=Wt(e.project),i=bi(e.project,e.name);return t.jsxs(t.Fragment,{children:[a?t.jsxs(ie,{children:[t.jsx(ge,{children:"Dependency:"}),t.jsx("div",{children:t.jsx(Si,{size:"small",permission:dt,projectId:e.project,variant:"text",onClick:()=>{n(!0)},children:"Add parent flag"})})]}):null,o?t.jsxs(ie,{children:[t.jsx(ge,{children:"Dependency:"}),t.jsxs(Lt,{children:[t.jsx(mt,{to:`/projects/${e.project}/features/${(p=e.dependencies[0])==null?void 0:p.feature}`,children:(u=e.dependencies[0])==null?void 0:u.feature}),c(dt,l)?t.jsx(mi,{feature:e.name,onEdit:()=>n(!0),onDelete:i}):null]})]}):null,o&&!((g=e.dependencies[0])!=null&&g.enabled)?t.jsxs(ie,{children:[t.jsx(ge,{children:"Dependency value:"}),t.jsx("span",{children:"disabled"})]}):null,o&&((x=(h=e.dependencies[0])==null?void 0:h.variants)!=null&&x.length)?t.jsxs(ie,{children:[t.jsx(ge,{children:"Dependency value:"}),t.jsx(Xn,{variants:((j=e.dependencies[0])==null?void 0:j.variants)||[]})]}):null,r?t.jsxs(ie,{children:[t.jsx(ge,{children:"Children:"}),t.jsx(ts,{childFeatures:e.children,project:e.project})]}):null,e.project?t.jsx(Qn,{project:e.project,featureId:e.name,parentDependency:e.dependencies[0],onClose:()=>n(!1),showDependencyDialogue:s}):null]})},Ci=(e,s={})=>{const n=Xe(`/api/admin/projects/${e}/dependencies`),{data:a,error:o}=cn(e,!1,n,wi,s);return{dependenciesExist:a,error:o,loading:!o&&!a}},wi=async e=>await(await fetch(e).then(Ze("Dependencies exist check"))).json(),Zn=e=>{const{dependenciesExist:s}=Ci(e),{isOss:n}=De();return!!e&&!!(!n()||s)},ss=(e,s={})=>{const n=async()=>{const p=Xe(`api/admin/features/${e}/tags`);return(await fetch(p,{method:"GET"}).then(Ze("Tags"))).json()},a=`api/admin/features/${e}/tags`,{data:o,error:r}=cn(!!e,{tags:[]},a,n,s),[l,c]=y.useState(!r&&!o),i=()=>{dn(a)};return y.useEffect(()=>{c(!r&&!o)},[o,r]),{tags:(o==null?void 0:o.tags)||[],error:r,loading:l,refetch:i}},Ti=d("section")(({theme:e})=>({"& > *":{margin:e.spacing(1,0)}})),wt=e=>e.map(s=>({title:s.value})),Rs=(e,s)=>e.map(n=>({value:n.title,type:s})),ns=({open:e,setOpen:s})=>{const{tagTypes:n}=Ia(),a=T("featureId"),{createTag:o}=Er(),{updateFeatureTags:r,loading:l}=et(),{tags:c,refetch:i,loading:p}=ss(a),{setToastData:u}=Y(),g=n&&n.length>0?n[0]:{name:"simple",description:"Simple tag to get you started",icon:""},[h,x]=y.useState(g),j=l||p,[b,m]=y.useState(0),{trackEvent:f}=ne(),[R,k]=y.useState(wt(c.filter(S=>S.type===h.name))),{tags:P,refetch:z}=Br(h.name),_=y.useMemo(()=>wt(P),[P]);y.useEffect(()=>{c&&h&&k(wt(c.filter(S=>S.type===h.name)))},[JSON.stringify(c),h,e]);const $=()=>{s(!1),k([])};function E(S,C){const I=S.filter(B=>B.type===h.name).filter(B=>!C.find(O=>B.value===O.value&&B.type===O.type)),W=C.filter(B=>B.type===h.name).filter(B=>!S.find(O=>B.value===O.value&&B.type===O.type));return m(I.length+W.length),{added:I,removed:W}}const A=S=>S.filter(C=>!C.title.startsWith("Create")),L=async(S,C)=>{try{await r(a,{addedTags:S,removedTags:C}),await i()}catch{u({type:"error",text:"Failed to add tag"})}},U=async S=>{S.preventDefault();const C=Rs(A(R),h.name),{added:I,removed:W}=E(C,c);b>0&&(await L(I,W),b>1&&f("suggest_tags",{props:{eventType:"multiple_tags_added"}}),b>0&&u({type:"success",text:`Updated tag${I.length>1?"s":""} to flag`})),m(0),k([]),s(!1)},G=(S,C)=>{C!=null&&typeof C!="string"&&(S.preventDefault(),x(C),k([]),m(0))},D=(S,C,I)=>{const W=Pa(C);I==="selectOption"&&C.forEach((O,oe)=>{if(typeof O!="string"&&O.inputValue&&O.inputValue!==""){const H={value:O.inputValue,type:h.name};o(H).then(()=>{f("suggest_tags",{props:{eventType:"tag_created"}}),z()}),O.title=O.inputValue,O.inputValue="",W[oe]=O}});const B=Rs(A(W),h.name);E(B,c),k(W)},v="add-tag-form";return t.jsx(he,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update feature flag tags",onClick:U,disabledPrimaryButton:j||b===0,onClose:$,formId:v,children:t.jsxs(t.Fragment,{children:[t.jsx(N,{paragraph:!0,sx:{marginBottom:S=>S.spacing(2.5)},children:"Tags allow you to group features together"}),t.jsx("form",{id:v,onSubmit:U,children:t.jsxs(Ti,{children:[t.jsx(Or,{options:n,value:h,onChange:G}),t.jsx(zr,{options:_,existingTags:c,tagType:h,selectedOptions:R,onChange:D})]})})]})})},Ri=d(pe)(({theme:e})=>({lineHeight:e.typography.body1.lineHeight,borderRadius:e.shape.borderRadiusExtraLarge,background:e.palette.secondary.light,padding:e.spacing(.5,1),height:e.spacing(3.5)})),Di=d(pn)(({theme:e})=>({fontSize:e.typography.body2.fontSize})),Ds=({project:e,onClick:s})=>t.jsx(Ri,{size:"small",permission:be,projectId:e,variant:"text",onClick:s,startIcon:t.jsx(Di,{}),"data-loading":!0,children:"Add tag"}),$s=d("span")(({theme:e})=>({marginTop:e.spacing(1),color:e.palette.text.secondary,marginRight:e.spacing(1)})),$i=d("div")(({theme:e})=>({display:"flex",justifyContent:"space-between",flexWrap:"wrap",minHeight:e.spacing(4.5),fontSize:e.fontSizes.smallBody})),As=d("div")(({theme:e})=>({display:"flex",overflow:"hidden",gap:e.spacing(1),flexWrap:"wrap",marginTop:e.spacing(.75)})),Ai=d(Vt)(({theme:e})=>({overflowWrap:"anywhere",lineHeight:e.typography.body1.lineHeight,backgroundColor:e.palette.neutral.light,color:e.palette.text.primary,padding:e.spacing(.25),height:e.spacing(3.5)})),ki=d("span")(({theme:e})=>({color:e.palette.text.secondary})),Fi=({feature:e})=>{const{tags:s,refetch:n}=ss(e.name),{deleteTagFromFeature:a}=et(),[o,r]=y.useState(!1),[l,c]=y.useState(!1),[i,p]=y.useState(),{setToastData:u,setToastApiError:g}=Y(),{hasAccess:h}=y.useContext(xt),x=h(be,e.project),j=()=>{r(!0)},b=async()=>{if(i)try{await a(e.name,i.type,i.value),n(),u({type:"success",text:"Tag removed"})}catch(m){g(V(m))}};return t.jsxs(t.Fragment,{children:[s.length?t.jsxs($i,{children:[t.jsx($s,{children:"Tags:"}),t.jsxs(As,{children:[s.map(m=>t.jsx(Ii,{tag:m,canUpdateTags:x,onTagRemove:f=>{c(!0),p(f)}},Nt(m))),x?t.jsx(Ds,{project:e.project,onClick:j}):null]})]}):t.jsxs(ie,{children:[t.jsx($s,{children:"Tags:"}),t.jsx(As,{children:t.jsx(Ds,{project:e.project,onClick:j})})]}),t.jsx(ns,{open:o,setOpen:r}),t.jsxs(he,{open:l,primaryButtonText:"Remove tag",secondaryButtonText:"Cancel",onClose:()=>{c(!1),p(void 0),n()},onClick:()=>{c(!1),b(),p(void 0)},title:"Remove tag",children:["You are about to remove tag:"," ",t.jsxs("strong",{children:[i==null?void 0:i.type,":",i==null?void 0:i.value]})]})]})},Ii=({tag:e,canUpdateTags:s,onTagRemove:n})=>{const a=fe("tagTypeColor"),o=Nt(e),r=o.length>25,l=t.jsx(Z,{title:"Remove tag",arrow:!0,children:t.jsx(un,{})}),c=s?()=>n(e):void 0;if(a){const i=t.jsx(Z,{title:"Remove tag",arrow:!0,children:t.jsx(Ea,{sx:{height:"20px",width:"20px"}})});return t.jsx(Z,{title:r?o:"",arrow:!0,children:t.jsx("span",{children:t.jsx(_r,{tag:e,onDelete:c,deleteIcon:i})})},o)}return t.jsx(Ai,{label:t.jsx(Z,{title:r?o:"",arrow:!0,children:t.jsxs("span",{children:[o.substring(0,25),r?t.jsx(ki,{children:"…"}):""]})},o),size:"small",deleteIcon:l,onDelete:c},o)},Pi=d(gn)(({theme:e})=>({width:e.spacing(2.5),height:e.spacing(2.5)})),Ei=d(hn)({flexWrap:"nowrap"}),Bi=({collaborators:e})=>!e||e.length===0?null:t.jsx(Ei,{users:e,avatarLimit:9,AvatarComponent:Pi}),Oi="environment-visibility-button",ks="environment-visibility-menu",zi=d("div")(({theme:e})=>({display:"flex",justifyContent:"center",paddingTop:e.spacing(4)})),_i=({environments:e,hiddenEnvironments:s,onChange:n})=>{const[a,o]=y.useState(null),r=!!a,l=g=>{o(g.currentTarget)},c=()=>{o(null)},i=e.map(g=>g.name),p=new Set(i.filter(g=>!s.includes(g))),u=g=>{n(g)};return t.jsxs(zi,{children:[t.jsx(ue,{onClick:l,endIcon:r?t.jsx(Ba,{}):t.jsx(xn,{}),variant:"outlined",id:Oi,"aria-controls":ks,"aria-haspopup":"true","aria-expanded":r?"true":void 0,"data-loading":!0,children:"Hide/show environments"}),t.jsx(Oa,{id:ks,open:!!a,anchorEl:a,onClose:c,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:t.jsx(za,{multiselect:{selectedOptions:p},onChange:u,options:i.map(g=>({label:g,value:g})),search:{label:"Filter environments",placeholder:"Filter environments"}})})]})},Li=d("div")(({theme:e})=>({padding:e.spacing(3),borderRadius:e.shape.borderRadiusLarge,backgroundColor:e.palette.background.paper,display:"flex",flexDirection:"column",gap:e.spacing(2),width:"350px",border:`1px solid ${e.palette.divider}`,[e.breakpoints.down("md")]:{width:"100%"}})),Mi=d("h2")(({theme:e})=>({fontSize:e.typography.body1.fontSize,fontWeight:e.typography.fontWeightBold,marginBottom:e.spacing(.5)})),qi=d("div")({display:"flex",flexDirection:"column"}),ie=d("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",minHeight:e.spacing(4.5),fontSize:e.fontSizes.smallBody})),ge=d("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)})),ot=d("span")({overflowWrap:"anywhere"}),Lt=d("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1)})),Wi=({hiddenEnvironments:e,onEnvironmentVisibilityChange:s})=>{var m,f,R,k;const n=T("projectId"),a=T("featureId"),{feature:o,refetchFeature:r}=q(n,a),{locationSettings:l}=Ht(),c=ce(),[i,p]=y.useState(!1),[u,g]=y.useState(!1),{project:h,description:x,type:j}=o,b=Zn(h);return t.jsxs(t.Fragment,{children:[t.jsxs(Li,{children:[t.jsxs("div",{children:[t.jsx(Mi,{children:"Flag details"}),x?t.jsx(ie,{"data-loading":!0,children:t.jsx(ot,{children:t.jsx(ft,{arrow:!0,lines:5,title:x,children:x})})}):null]}),t.jsxs(qi,{children:[t.jsxs(ie,{children:[t.jsx(ge,{children:"Flag type:"}),t.jsxs(ot,{"data-loading":!0,children:[_a(j||" ")," flag"]})]}),o.lifecycle?t.jsxs(ie,{"data-loading":!0,children:[t.jsx(ge,{children:"Lifecycle:"}),t.jsx(fn,{feature:o,onArchive:()=>p(!0),onComplete:()=>g(!0),onUncomplete:r})]}):null,t.jsxs(ie,{children:[t.jsx(ge,{children:"Created:"}),t.jsx(ot,{"data-loading":!0,children:yn(Ut(o.createdAt),l.locale)})]}),o.createdBy?t.jsxs(ie,{children:[t.jsx(ge,{children:"Created by:"}),t.jsx(Lt,{children:t.jsx(ot,{"data-loading":!0,children:(m=o.createdBy)==null?void 0:m.name})})]}):null,(f=o.collaborators)!=null&&f.users&&((R=o.collaborators)==null?void 0:R.users.length)>0?t.jsxs(ie,{children:[t.jsx(ge,{children:"Collaborators:"}),t.jsx(Lt,{children:t.jsx(Bi,{collaborators:(k=o.collaborators)==null?void 0:k.users})})]}):null,b?t.jsx(vi,{feature:o}):null,t.jsx(Fi,{feature:o}),s?t.jsx(_i,{environments:o.environments||[],hiddenEnvironments:e||[],onChange:s}):null]})]}),o.children.length>0?t.jsx(Zt,{features:o.children,project:n,isOpen:i,onClose:()=>p(!1)}):t.jsx(Xt,{isOpen:i,onConfirm:()=>{c(`/projects/${n}`)},onClose:()=>p(!1),projectId:n,featureIds:[a]}),o.project?t.jsx(Vn,{isOpen:u,setIsOpen:g,projectId:o.project,featureId:o.name,onComplete:r}):null]})},Vi=e=>{var o;const{uiConfig:s}=De(),n=((o=s.resourceLimits)==null?void 0:o.featureEnvironmentStrategies)||100,a=e>=n;return{limit:n,limitReached:a}},ea=()=>{const[e,s]=y.useState(0),n=T("projectId"),a=T("featureId"),o=gs("environmentId"),r=gs("strategyName"),{strategy:l,defaultStrategyFallback:c}=Lr(n,o),i=JSON.parse(La().get("defaultStrategy")||"false"),{segments:p}=Ma(),u=(p||[]).filter(X=>{var Ae;return(Ae=l==null?void 0:l.segments)==null?void 0:Ae.includes(X.id)}),[g,h]=y.useState({}),[x,j]=y.useState(i?u:[]),{strategyDefinition:b}=qa(r),m=Wa(),{addStrategyToFeature:f,loading:R}=Ie(),{addChange:k}=le(),{setToastData:P,setToastApiError:z}=Y(),{uiConfig:_}=De(),{unleashUrl:$}=_,E=ce(),{feature:A,refetchFeature:L}=q(n,a),U=A==null?void 0:A.environments.find(X=>X.name===o),G=(U==null?void 0:U.strategies.length)||0,{limit:D,limitReached:v}=Vi(G),S=y.useRef(A),{isChangeRequestConfigured:C}=Q(n),{refetch:I}=ae(n),{trackEvent:W}=ne(),{data:B,staleDataNotification:O,forceRefreshCache:oe}=Va({unleashGetter:q,params:[n,a],dataKey:"feature",refetchFunctionKey:"refetchFeature",options:{}},A,{afterSubmitAction:L},Xa);y.useEffect(()=>{S.current.name===""&&A.name&&(oe(A),S.current=A)},[A.name]),y.useEffect(()=>{var X;if(i){const Ae=l||c;((X=Ae.parameters)==null?void 0:X.groupId)===""&&a?h({...Ae,parameters:{...Ae.parameters,groupId:a}}):h(Ae)}else b&&h(Na(a,b))},[a,JSON.stringify(b),JSON.stringify(l),i]);const H=async X=>{await f(n,a,o,X),P({text:"Strategy created",type:"success"})},de=async X=>{await k(n,o,{action:"addStrategy",feature:a,payload:X}),P({text:"Strategy added to draft",type:"success"}),I()},F=Ha(g,x),K=async()=>{W("strategyTitle",{props:{hasTitle:!!g.title,on:"create"}});try{C(o)?await de(F):await H(F),L(),E(yt(n,a))}catch(X){z(V(X))}};return!B||!B.project?null:t.jsxs(jn,{modal:!0,description:Ua,documentationLink:Ga,documentationLinkLabel:Ya,disablePadding:!0,formatApiCode:()=>Ni(n,a,o,F,$),children:[t.jsx(Ja,{projectId:n,feature:B,strategy:g,setStrategy:h,segments:x,setSegments:j,environmentId:o,onSubmit:K,loading:R,permission:me,errors:m,isChangeRequest:C(o),tab:e,setTab:s,StrategyVariants:t.jsx(Ka,{strategy:g,setStrategy:h,environment:o,projectId:n,editable:!0}),Limit:t.jsx(Qa,{name:"strategies in this environment",shortName:"strategies",currentValue:G,limit:D}),disabled:v}),O]})},as=(e,s,n,a,o=!1)=>{const r=new URLSearchParams({environmentId:n,strategyName:a,defaultStrategy:String(o)});return`/projects/${e}/features/${s}/strategies/create?${r}`},Ni=(e,s,n,a,o)=>{if(!o)return"";const r=`${o}/api/admin/projects/${e}/features/${s}/environments/${n}/strategies`,l=JSON.stringify(a,void 0,2);return`curl --location --request POST '${r}' \\
--header 'Authorization: INSERT_API_KEY' \\
--header 'Content-Type: application/json' \\
--data-raw '${l}'`},Hi=d("div")(({theme:e})=>({width:e.spacing(4),height:"auto","& > svg":{fill:e.palette.primary.main},"& > div":{height:e.spacing(2),marginLeft:"-.75rem",color:e.palette.primary.main}})),Ui=d("div")(()=>({overflow:"hidden",width:"100%"})),Gi=d(_e)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,display:"block",marginBottom:e.spacing(.5)})),Yi=d(J)(({theme:e})=>({display:"grid",gridTemplateColumns:"2.5rem 1fr",width:"100%",maxWidth:"30rem",padding:e.spacing(2),color:"inherit",textDecoration:"inherit",lineHeight:1.25,borderWidth:"1px",borderStyle:"solid",borderColor:e.palette.divider,borderRadius:e.spacing(1),overflow:"hidden","&:hover, &:focus":{borderColor:e.palette.primary.main}})),Tt=({projectId:e,featureId:s,environmentId:n,strategy:a,defaultStrategy:o})=>{const r=tt(a.name),l=Le(a.name),{trackEvent:c}=ne(),i=as(e,s,n,a.name,o),p=()=>{c("strategy-add",{props:{buttonTitle:a.displayName||l}})};return t.jsxs(Yi,{to:i,onClick:p,children:[t.jsx(Hi,{children:t.jsx(r,{})}),t.jsxs(Ui,{children:[t.jsx(Gi,{text:a.displayName||l,maxWidth:"200",maxLength:25}),t.jsx(ft,{lines:1,title:a.description,arrow:!0,sx:{fontSize:u=>u.typography.body2.fontSize,width:"100%"},children:a.description})]})]})},Ji=d("div")(({theme:e})=>({width:e.spacing(4),height:"auto","& > svg":{fill:e.palette.primary.main},"& > div":{height:e.spacing(2),marginLeft:"-.75rem",color:e.palette.primary.main}})),Ki=d("div")(()=>({overflow:"hidden",width:"100%"})),Qi=d(_e)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,display:"block",marginBottom:e.spacing(.5)})),Xi=d(ue)(({theme:e})=>({display:"grid",gridTemplateColumns:"2.5rem 1fr",width:"100%",maxWidth:"30rem",padding:e.spacing(2),color:"inherit",textDecoration:"inherit",lineHeight:1.25,borderWidth:"1px",borderStyle:"solid",borderColor:e.palette.divider,borderRadius:e.spacing(1),textAlign:"left",overflow:"hidden","&:hover, &:focus":{borderColor:e.palette.primary.main}})),Zi=({template:{name:e,description:s},onClick:n})=>{const a=tt("releasePlanTemplate");return t.jsxs(Xi,{onClick:n,children:[t.jsx(Ji,{children:t.jsx(a,{})}),t.jsxs(Ki,{children:[t.jsx(Qi,{text:e,maxWidth:"200",maxLength:25}),t.jsx(ft,{lines:1,title:s,arrow:!0,sx:{fontSize:o=>o.typography.body2.fontSize,fontWeight:o=>o.typography.fontWeightRegular,width:"100%"},children:s})]})]})},He=d(N)(({theme:e})=>({fontSize:e.fontSizes.smallBody,padding:e.spacing(1,2),width:"100%"})),el=d(Me)(({theme:e})=>({fontSize:e.fontSizes.smallBody,cursor:"pointer"})),tl=d(M)(()=>({width:"100%"})),rt=d(M)(({theme:e})=>({display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:e.spacing(1.5),padding:e.spacing(0,2),width:"100%"})),it=d(M)(()=>({width:"100%",minWidth:0})),sl=d(M)(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",padding:e.spacing(1,2)})),nl=d(N)(({theme:e})=>({fontSize:e.typography.body1.fontSize,fontWeight:e.typography.fontWeightBold,margin:0})),al=({projectId:e,featureId:s,environmentId:n,onlyReleasePlans:a,onAddReleasePlan:o,onClose:r})=>{const{strategies:l}=mn(),{templates:c}=Sn(),i=ce(),p=!a,u=l.filter(x=>!x.deprecated&&!x.editable),g=l.filter(x=>!x.deprecated&&x.editable),h={name:"flexibleRollout",displayName:"Default strategy",description:"This is the default strategy defined for this environment in the project"};return t.jsxs(tl,{children:[t.jsxs(sl,{children:[t.jsx(nl,{variant:"h2",children:a?"Select template":"Select strategy"}),r&&t.jsx(Ce,{size:"small",onClick:r,edge:"end","aria-label":"close",children:t.jsx(bn,{fontSize:"small"})})]}),p?t.jsxs(t.Fragment,{children:[t.jsxs(He,{color:"textSecondary",children:["Default strategy for ",n," environment"]}),t.jsx(rt,{children:t.jsx(it,{children:t.jsx(Tt,{projectId:e,featureId:s,environmentId:n,strategy:h,defaultStrategy:!0})},h.name)})]}):null,t.jsx(w,{condition:c.length>0,show:t.jsxs(t.Fragment,{children:[t.jsx(He,{color:"textSecondary",children:"Release templates"}),t.jsx(rt,{children:c.map(x=>t.jsx(it,{children:t.jsx(Zi,{template:x,onClick:()=>o(x)})},x.id))})]})}),t.jsx(w,{condition:c.length===0&&a,show:t.jsx(t.Fragment,{children:t.jsxs(He,{color:"textSecondary",sx:{padding:x=>x.spacing(1,2,0,2)},children:[t.jsx("p",{children:"No templates created."}),t.jsxs("p",{children:["Go to ",t.jsx(el,{onClick:()=>i("/release-templates"),children:"Release templates"})," to get started"]})]})})}),p?t.jsxs(t.Fragment,{children:[t.jsx(He,{color:"textSecondary",children:"Predefined strategy types"}),t.jsx(rt,{children:u.map(x=>t.jsx(it,{children:t.jsx(Tt,{projectId:e,featureId:s,environmentId:n,strategy:x})},x.name))}),t.jsx(w,{condition:g.length>0,show:t.jsxs(t.Fragment,{children:[t.jsx(He,{color:"textSecondary",children:"Custom strategies"}),t.jsx(rt,{children:g.map(x=>t.jsx(it,{children:t.jsx(Tt,{projectId:e,featureId:s,environmentId:n,strategy:x})},x.name))})]})})]}):null]})},ol=d("div")(({theme:e})=>({margin:e.spacing(2,0)})),rl=({open:e,setOpen:s,onConfirm:n,template:a,projectId:o,featureName:r,environment:l,crProtected:c})=>{const{feature:i}=q(o,r),{releasePlans:p}=qe(o,r,l),u=p[0],g=i==null?void 0:i.environments.find(({name:b})=>b===l),h=g==null?void 0:g.enabled,x=Za(a.id,r,l),j=x.milestones[0];return t.jsxs(he,{title:"Add release plan?",open:e,primaryButtonText:c?"Add suggestion to draft":"Add release plan",secondaryButtonText:"Cancel",onClick:n,onClose:()=>s(!1),children:[u&&t.jsxs(se,{severity:"error",sx:{mb:1},children:["This feature environment currently has"," ",t.jsx("strong",{children:u.name})," -"," ",t.jsx("strong",{children:u.milestones[0].name}),h?" running":" paused",". Adding a new release plan will replace the existing release plan."]}),h?t.jsxs(se,{severity:"info",children:["This environment is currently ",t.jsx("strong",{children:"enabled"}),".",j&&t.jsxs("p",{children:["The first milestone will be started as soon as the release plan is added:"," ",t.jsx("strong",{children:x.milestones[0].name})]})]}):t.jsxs(se,{severity:"warning",children:["This environment is currently ",t.jsx("strong",{children:"disabled"}),".",t.jsx("p",{children:"Milestones will not start automatically after adding the release plan. They will remain paused until the environment is enabled."})]}),t.jsx(ol,{children:t.jsx(vn,{plan:x,readonly:!0})}),c&&t.jsxs(N,{sx:{mt:4},children:[t.jsx("strong",{children:"Adding"})," release template"," ",t.jsx("strong",{children:a==null?void 0:a.name})," to"," ",t.jsx("strong",{children:r})," in"," ",t.jsx("strong",{children:l}),"."]})]})},il=d("div")(({theme:e})=>({width:e.spacing(4),height:"auto","& > svg":{fill:e.palette.primary.main},"& > div":{height:e.spacing(2),marginLeft:"-.75rem",color:e.palette.primary.main}})),ll=d("div")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),cl=d(_e)(({theme:e})=>({fontWeight:e.fontWeight.bold})),dl=d(J)(({theme:e})=>({display:"grid",gridTemplateColumns:"3rem 1fr",width:"20rem",padding:e.spacing(2),color:"inherit",textDecoration:"inherit",lineHeight:1.25,borderWidth:"1px",borderStyle:"solid",borderColor:e.palette.divider,borderRadius:e.spacing(1),"&:hover, &:focus":{borderColor:e.palette.primary.main}})),Rt=({projectId:e,featureId:s,environmentId:n,strategy:a,defaultStrategy:o})=>{const r=tt(a.name),l=Le(a.name),{trackEvent:c}=ne(),i=as(e,s,n,a.name,o),p=()=>{c("strategy-add",{props:{buttonTitle:a.displayName||l}})};return t.jsxs(dl,{to:i,onClick:p,children:[t.jsx(il,{children:t.jsx(r,{})}),t.jsxs("div",{children:[t.jsx(cl,{text:a.displayName||l,maxWidth:"200",maxLength:25}),t.jsx(ll,{children:a.description})]})]})},pl=d("div")(({theme:e})=>({width:e.spacing(4),height:"auto","& > svg":{fill:e.palette.primary.main},"& > div":{height:e.spacing(2),marginLeft:"-.75rem",color:e.palette.primary.main}})),ul=d("div")(({theme:e})=>({fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.medium})),gl=d(_e)(({theme:e})=>({fontWeight:e.fontWeight.bold})),hl=d(ue)(({theme:e})=>({display:"grid",gridTemplateColumns:"3rem 1fr",width:"20rem",padding:e.spacing(2),color:"inherit",textDecoration:"inherit",lineHeight:1.25,borderWidth:"1px",borderStyle:"solid",borderColor:e.palette.divider,borderRadius:e.spacing(1),textAlign:"left","&:hover, &:focus":{borderColor:e.palette.primary.main}})),xl=({template:{name:e,description:s},onClick:n})=>{const a=tt("releasePlanTemplate");return t.jsxs(hl,{onClick:n,children:[t.jsx(pl,{children:t.jsx(a,{})}),t.jsxs("div",{children:[t.jsx(gl,{text:e,maxWidth:"200",maxLength:25}),t.jsx(ul,{children:s})]})]})},Ue=d(N)(({theme:e})=>({fontSize:e.fontSizes.smallBody,padding:e.spacing(1,2)})),fl=d(Me)(({theme:e})=>({fontSize:e.fontSizes.smallBody,cursor:"pointer"})),yl=({projectId:e,featureId:s,environmentId:n,onlyReleasePlans:a,onAddReleasePlan:o})=>{const{strategies:r}=mn(),{templates:l}=Sn(),c=ce(),i=!a,p=r.filter(h=>!h.deprecated&&!h.editable),u=r.filter(h=>!h.deprecated&&h.editable),g={name:"flexibleRollout",displayName:"Default strategy",description:"This is the default strategy defined for this environment in the project"};return t.jsxs(Gt,{dense:!0,children:[i?t.jsxs(t.Fragment,{children:[t.jsxs(Ue,{color:"textSecondary",children:["Default strategy for ",n," environment"]}),t.jsx(Fe,{children:t.jsx(Rt,{projectId:e,featureId:s,environmentId:n,strategy:g,defaultStrategy:!0})},g.name)]}):null,t.jsx(w,{condition:l.length>0,show:t.jsxs(t.Fragment,{children:[t.jsx(Ue,{color:"textSecondary",children:"Release templates"}),l.map(h=>t.jsx(Fe,{children:t.jsx(xl,{template:h,onClick:()=>o(h)})},h.id))]})}),t.jsx(w,{condition:l.length===0&&a,show:t.jsx(t.Fragment,{children:t.jsxs(Ue,{color:"textSecondary",sx:{padding:h=>h.spacing(1,2,0,2)},children:[t.jsx("p",{children:"No templates created."}),t.jsxs("p",{children:["Go to ",t.jsx(fl,{onClick:()=>c("/release-templates"),children:"Release templates"})," to get started"]})]})})}),i?t.jsxs(t.Fragment,{children:[t.jsx(Ue,{color:"textSecondary",children:"Predefined strategy types"}),p.map(h=>t.jsx(Fe,{children:t.jsx(Rt,{projectId:e,featureId:s,environmentId:n,strategy:h})},h.name)),t.jsx(w,{condition:u.length>0,show:t.jsxs(t.Fragment,{children:[t.jsx(Ue,{color:"textSecondary",children:"Custom strategies"}),u.map(h=>t.jsx(Fe,{children:t.jsx(Rt,{projectId:e,featureId:s,environmentId:n,strategy:h})},h.name))]})})]}):null]})},jl=d("div")(({theme:e})=>({display:"flex",flexFlow:"row",justifyContent:"flex-end",gap:e.spacing(1)})),ml=d(pe)(({theme:e})=>({minWidth:0,width:e.spacing(4.5),alignSelf:"stretch",paddingBlock:0})),Je=({label:e,projectId:s,featureId:n,environmentId:a,variant:o,size:r,matchWidth:l,disableReason:c})=>{const[i,p]=y.useState(),[u,g]=y.useState(!1),h=ce(),{trackEvent:x}=ne(),[j,b]=y.useState(),[m,f]=y.useState(!1),R=!!i,k=R?"FeatureStrategyMenuPopover":void 0,{setToastApiError:P,setToastData:z}=Y(),{isChangeRequestConfigured:_}=Q(s),{addChange:$}=le(),{refetch:E}=ae(s),{refetch:A}=qe(s,n,a),{addReleasePlanToFeature:L}=Cn(),{isOss:U}=De(),G=fe("releasePlans"),D=fe("newStrategyDropdown"),v=!U()&&G,S=G&&_(a),C=()=>{p(void 0)},I=H=>{x("strategy-add",{props:{buttonTitle:e}}),h(oe)},W=H=>{g(!1),p(H.currentTarget)},B=H=>{g(!0),p(H.currentTarget)},O=async()=>{if(j)try{S?(await $(s,a,{feature:n,action:"addReleasePlan",payload:{templateId:j.id}}),z({type:"success",text:"Added to draft"}),E()):(await L(n,j.id,s,a),z({type:"success",text:"Release plan added"}),A()),x("release-management",{props:{eventType:"add-plan",plan:j.name}})}catch(H){P(V(H))}finally{f(!1),b(void 0)}},oe=as(s,n,a,"flexibleRollout",!0);return t.jsxs(jl,{onClick:H=>H.stopPropagation(),children:[v?t.jsx(pe,{"data-testid":"ADD_TEMPLATE_BUTTON",permission:me,projectId:s,environmentId:a,onClick:B,"aria-labelledby":k,variant:"outlined",sx:{minWidth:l?"282px":"auto"},disabled:!!c,tooltipProps:{title:c||void 0},children:"Use template"}):null,t.jsx(pe,{"data-testid":"ADD_STRATEGY_BUTTON",permission:me,projectId:s,environmentId:a,onClick:I,"aria-labelledby":k,variant:o,sx:{minWidth:l?"282px":"auto"},disabled:!!c,tooltipProps:{title:c||void 0},children:e}),t.jsx(ml,{permission:me,projectId:s,environmentId:a,onClick:W,variant:"outlined",hideLockIcon:!0,disabled:!!c,tooltipProps:{title:c||"More strategies"},children:t.jsx(gt,{})}),t.jsx(qt,{id:k,open:R,anchorEl:i,onClose:C,onClick:C,anchorOrigin:{vertical:"bottom",horizontal:"left"},PaperProps:{sx:H=>({paddingBottom:H.spacing(1),width:"auto",maxWidth:"95vw",overflow:"hidden"})},children:D?t.jsx(al,{projectId:s,featureId:n,environmentId:a,onlyReleasePlans:u,onAddReleasePlan:H=>{b(H),f(!0)},onClose:C}):t.jsx(yl,{projectId:s,featureId:n,environmentId:a,onlyReleasePlans:u,onAddReleasePlan:H=>{b(H),f(!0)}})}),j&&t.jsx(rl,{open:m,setOpen:f,onConfirm:O,template:j,projectId:s,featureName:n,environment:a,crProtected:S})]})},os=(e,s)=>e===0?0:Math.round(s/e*100),Sl=d("div")(()=>({display:"flex",alignItems:"center",justifyContent:"center",position:"relative",margin:0})),bl=d("div",{shouldForwardProp:e=>e!=="color"})(({theme:e,color:s})=>({position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:s,fontSize:e.fontSizes.smallerBody,margin:0})),vl=({percentage:e,size:s="4rem",disabled:n=!1,children:a})=>{const o=ze(),r={display:"block",borderRadius:"100%",transform:"rotate(-90deg)",height:s,width:s},l=100/(2*Math.PI),c=2*l,i=c*.2,p=n?o.palette.neutral.border:o.palette.primary.light;return t.jsxs(Sl,{children:[t.jsxs("svg",{viewBox:`0 0 ${c} ${c}`,style:r,"aria-hidden":!0,children:[t.jsx("circle",{r:l,cx:l,cy:l,fill:"none",stroke:o.palette.background.elevation2,strokeWidth:i}),t.jsx("circle",{r:l,cx:l,cy:l,fill:"none",stroke:p,strokeWidth:i,strokeDasharray:`${e} 100`})]}),t.jsx(bl,{color:p,children:a})]})},Cl=d("figure")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"flex-end",margin:0,padding:0})),wl=d("figcaption")(({theme:e})=>({fontSize:e.typography.body2.fontSize,textAlign:"right",[e.breakpoints.down("xl")]:{display:"none"},display:"flex",flexDirection:"column",flexGrow:1,margin:0,padding:0,span:{textWrap:"nowrap"}})),Tl=d("div")(({theme:e})=>({marginRight:e.spacing(1),marginLeft:e.spacing(1.5),[e.breakpoints.down(500)]:{display:"none"}})),Rl=d(({className:e,...s})=>t.jsx(Z,{...s,classes:{popper:e}}))({[`& .${eo.tooltip}`]:{maxWidth:200}}),Dl=({environmentMetric:e,collapsed:s})=>{if(!e)return null;const n=e.yes+e.no,a=os(n,e==null?void 0:e.yes),o=!e||e.yes===0&&e.no===0,r=o?t.jsxs(t.Fragment,{children:["No evaluation metrics",t.jsx("br",{}),"received in the last hour"]}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:["The flag has been evaluated"," ",t.jsxs("b",{children:[t.jsx(Oe,{value:n})," times"]})]})," ",t.jsxs("span",{children:["and enabled"," ",t.jsxs("b",{children:[t.jsx(Oe,{value:e.yes})," times"]})," ","in the last hour"]})]});return t.jsxs(Cl,{children:[s?null:t.jsx(wl,{children:r}),t.jsx(Rl,{title:s?r:"",arrow:!0,children:t.jsx(Tl,{"data-loading":!0,children:t.jsx(vl,{percentage:a,size:"3rem",children:o?null:`${a}%`})})})]})},$l=d("div")(({theme:e})=>({order:-1,flex:0})),Al=({environment:{name:e,type:s,strategies:n,enabled:a}})=>{const o=T("projectId"),r=T("featureId"),{refetchFeature:l}=q(o,r),{isChangeRequestConfigured:c}=Q(o),{onToggle:i,modals:p}=Hn(o),u=(g,h)=>i(g,{projectId:o,featureId:r,environmentName:e,environmentType:s,hasStrategies:n.length>0,hasEnabledStrategies:n.some(x=>!x.disabled),isChangeRequestEnabled:c(e),onRollback:h,onSuccess:l});return t.jsxs($l,{onClick:g=>g.stopPropagation(),children:[t.jsx(Un,{projectId:o,value:a,featureId:r,environmentName:e,onToggle:u}),p]})},kl=(e,s)=>{const n=[];let a=0;if(e.length<=a)return e;for(;a<e.length;)if(a===0){a+=s;const o=e.slice(0,a);n.push(o)}else{const o=e.slice(a,a+s);a+=s,n.push(o)}return n},ta=(e,s,n)=>{const[a,o]=y.useState([[]]),[r,l]=y.useState(0);y.useEffect(()=>{const h=kl(e,s);o(h)},[JSON.stringify(e),s]);const c=()=>{r<a.length-1&&l(g=>g+1)},i=()=>{r>0&&l(g=>g-1)},