UNPKG

unleash-server

Version:

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

276 lines (234 loc) 907 kB
var sd=Object.defineProperty;var od=(e,t,n)=>t in e?sd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var q=(e,t,n)=>od(e,typeof t!="symbol"?t+"":t,n);import{fI as ld,fJ as dd,fK as ze,r as h,s as u,fL as ud,dm as v2,G as X1,H as ee,j as a,B as O,e as O1,y as Y1,D as $1,a_ as Pr,J as C0,a$ as D0,M as ce,fM as p3,b0 as pe,d as V3,fN as cc,b2 as se,T as M,fO as ve,ds as P2,L as x1,cW as E2,bi as Z2,dk as sc,dx as Ze,fP as hd,m as $0,aE as Ie,fQ as md,fR as fd,as as C1,i as c1,fS as pd,fT as vd,fU as Je,fV as gd,C as N,h as _1,be as xd,aY as he,cK as le,aT as N3,V as T1,bf as Er,aU as T0,aX as P0,aV as I2,bc as p1,fW as oc,fr as jd,cc as M3,aq as M2,dF as Zr,dG as Ir,b9 as B1,fX as bd,fY as lc,bk as dc,b as j1,fZ as yd,al as Q1,ay as re,f_ as uc,f$ as hc,dB as Pe,g0 as j8,g1 as _d,dC as I3,g2 as wd,dD as Sd,g3 as Be,g4 as mc,dh as fc,g5 as pc,g6 as vc,cm as W3,bb as me,u as A2,N as z3,g7 as pr,d3 as gc,g8 as l3,g9 as Od,ga as Cd,gb as Dd,gc as $d,gd as Td,ge as Pd,gf as Ed,gg as Zd,gh as Id,gi as Md,gj as Ad,gk as Fd,gl as Rd,gm as Ld,gn as Vd,go as g3,fv as y0,gp as xc,gq as Nd,aL as Qe,c3 as te,gr as g2,aF as Wd,cb as Mr,dt as zd,gs as Bd,gt as Yd,U as Hd,ar as Ar,bt as ne,cQ as _0,gu as Ud,gv as kd,gw as jc,x as Fr,gx as qd,bK as Xe,gy as Kd,gz as vr,bR as bc,gA as Gd,gB as yc,gC as Qd,eE as F2,at as R2,aQ as n1,bh as e3,gD as Jd,gE as Rr,K as L2,c4 as J1,gF as _c,gG as Xd,gH as eu,b3 as x3,aG as j3,aH as B3,aM as Y3,_ as H3,a as W1,aN as U3,aP as k3,aO as V2,gI as tu,gJ as v1,c2 as nu,l as de,dl as Lr,gK as au,gL as ru,gM as iu,b5 as b3,gN as cu,db as wc,c as x2,gO as su,gP as Sc,d1 as ge,gQ as ou,gR as lu,E as q3,cG as A3,ce as du,gS as uu,au as y3,aD as S1,gT as hu,ax as Se,dn as mu,gU as fu,gV as pu,gW as vu,ei as Oc,gX as gu,gY as xu,gZ as ju,g_ as bu,g$ as Cc,h0 as Dc,aC as A1,az as K3,h1 as $c,h2 as Tc,fy as yu,h3 as je,cJ as F3,cY as fe,h4 as _u,aS as wu,h5 as Su,eC as N2,h6 as Ou,b8 as w0,h7 as Cu,h8 as Pc,h9 as Du,ha as $u,bs as G3,du as Tu,Z as Vr,Y as Ec,hb as Pu,b1 as Q3,hc as Zc,hd as E0,he as Eu,hf as Zu,hg as Iu,hh as Mu,bj as Me,ck as Ic,hi as Au,v as Fu,hj as Ru,hk as Nr,hl as Lu,cj as Mc,hm as Vu,hn as Nu,ez as Ac,n as Wr,o as zr,eB as v3,ho as Wu,hp as zu,hq as Bu,eu as Br,ak as Z1,ev as j2,hr as Yr,ae as W2,dv as S0,hs as Yu,ht as Hu,eL as b2,an as z2,hu as Uu,aw as Hr,hv as ku,ac as k1,ad as Z0,ao as B2,af as Y2,ag as H2,ah as U2,ai as k2,hw as Fc,e4 as I0,bd as qu,ap as Ur,A as q2,dY as Ku,hx as Gu,em as u2,dX as oe,hy as Qu,hz as Ju,t as Rc,hA as Xu,hB as eh,av as M0,dS as kr,hC as th,hD as I4,hE as nh,hF as ah,c$ as _3,d0 as f1,hG as rh,hH as ih,w as w3,hI as ch,hJ as sh,hK as Lc,hL as Vc,hM as gr,hN as b8,hO as oh,dV as lh,dW as dh,hP as y8,hQ as uh,hR as hh,hS as mh,hT as fh,hU as ph,hV as vh,hW as gh,cf as qr,cg as xh,bp as Nc,cM as Kr,cN as Gr,hX as jh,c5 as bh,c6 as yh,c7 as A0,hY as _h,hZ as wh,bx as Sh,by as Oh,z as _8,fp as Ch,d4 as Dh,d6 as $h,h_ as Th,h$ as Wc,i0 as Ph,i1 as Eh,i2 as Zh,ba as Qr,i3 as Ih,i4 as Mh,b4 as F0,i5 as xr,i6 as Ah,i7 as K2,i8 as Jr,i9 as Xr,dy as zc,ia as e5,fA as Fh,ib as Bc,eX as Rh,ic as Lh,id as Vh,ie as jr,ig as Nh,ih as Wh,F as zh,I as Bh,S as Yh,ii as Yc,ij as Hc,ik as Uc,il as Hh,im as kc,io as Uh,ip as kh,iq as qh,fz as Kh,ir as Gh,fD as Qh,dN as w8,dK as Jh,is as Xh,it as em,iu as tm,dp as qc,iv as br,iw as nm,e6 as Kc,ix as am,dE as S8,iy as rm,iz as im,iA as cm,iB as a0,ci as Gc,iC as sm,iD as om,iE as lm,iF as dm,iG as um,fu as hm,iH as mm,bC as fm,iI as pm,iJ as vm,iK as gm}from"./index-BAMIkcom.js";import{F as Qc,M as xm}from"./MarkCompletedDialogue-BwS_OP77.js";import{a as jm,u as Jc,T as bm,b as ym,F as _m,h as wm,f as Sm,g as Om,e as Cm,d as Dm,E as $m}from"./FeatureStaleDialog-DZEtcHDT.js";import{m as Tm,i as O8,b as Pm,c as Em,d as Zm,e as Im,E as Mm,f as Am,u as Fm,a as Rm,R as Lm,C as Vm,A as Nm,g as Xc,j as Wm}from"./RoleCell-Da0TjMne.js";import"./useApiTokens-Btk4Hd2u.js";function zm(e,t){var n,i;ld(1,arguments);var c=dd(e);if(isNaN(c.getTime()))throw new RangeError("Invalid time value");var s=String((n=t==null?void 0:t.format)!==null&&n!==void 0?n:"extended"),o=String((i=t==null?void 0:t.representation)!==null&&i!==void 0?i:"complete");if(s!=="extended"&&s!=="basic")throw new RangeError("format must be 'extended' or 'basic'");if(o!=="date"&&o!=="time"&&o!=="complete")throw new RangeError("representation must be 'date', 'time', or 'complete'");var l="",d="",m=s==="extended"?"-":"",f=s==="extended"?":":"";if(o!=="time"){var v=ze(c.getDate(),2),p=ze(c.getMonth()+1,2),g=ze(c.getFullYear(),4);l="".concat(g).concat(m).concat(p).concat(m).concat(v)}if(o!=="date"){var x=c.getTimezoneOffset();if(x!==0){var b=Math.abs(x),_=ze(Math.floor(b/60),2),j=ze(b%60,2),w=x<0?"+":"-";d="".concat(w).concat(_,":").concat(j)}else d="Z";var T=ze(c.getHours(),2),D=ze(c.getMinutes(),2),C=ze(c.getSeconds(),2),Z=l===""?"":"T",S=[T,D,C].join(f);l="".concat(l).concat(Z).concat(S).concat(d)}return l}const es=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"})),C8=u("div")(()=>({display:"flex"})),Bm=u("div")(()=>({display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",width:"100%"}));u("div")(()=>({display:"flex",flexDirection:"column"}));const Ym=u("span")(({theme:e})=>({textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"})),Hm=u("span")(({theme:e})=>({fontSize:e.fontSizes.smallBody,fontWeight:"normal"}));u(Hm)(({theme:e})=>({color:e.palette.neutral.dark}));const Um=u(ud)(({theme:e})=>({marginLeft:e.spacing(-1.5)})),km=u("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),qm=u("div")(({theme:e})=>({padding:e.spacing(2.5,5),display:"flex",flexDirection:"column",alignItems:"start"})),Km=u("h1")(({theme:e})=>({margin:0,width:"100%",fontSize:e.typography.h1.fontSize,fontWeight:"bold",display:"flex",alignItems:"center",gap:e.spacing(2),overflow:"hidden",lineHeight:1.5})),Gm=u("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.divider,height:"1px"})),Qm=u("div")(({theme:e})=>({padding:e.spacing(0,4)})),Jm=u(v2)(({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}}));var t5={},Xm=ee;Object.defineProperty(t5,"__esModule",{value:!0});var ts=t5.default=void 0,ef=Xm(X1()),tf=a,nf=(0,ef.default)((0,tf.jsx)("path",{d:"M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-1 9h-4v4h-2v-4H9V9h4V5h2v4h4v2z"}),"LibraryAdd");ts=t5.default=nf;var n5={},af=ee;Object.defineProperty(n5,"__esModule",{value:!0});var ns=n5.default=void 0,rf=af(X1()),cf=a,sf=(0,rf.default)((0,cf.jsx)("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM12 17.5 6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z"}),"Archive");ns=n5.default=sf;var a5={},of=ee;Object.defineProperty(a5,"__esModule",{value:!0});var y2=a5.default=void 0,lf=of(X1()),df=a,uf=(0,lf.default)((0,df.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm4.2 14.2L11 13V7h1.5v5.2l4.5 2.7-.8 1.3z"}),"WatchLater");y2=a5.default=uf;const hf=u(O)(({theme:e})=>({display:"flex",justifyContent:"center",paddingRight:e.spacing(2)})),mf=({projectId:e,row:t,onOpenArchiveDialog:n,onOpenStaleDialog:i})=>{const[c,s]=h.useState(null),[o,l]=h.useState(!1),{setToastData:d}=O1(),{original:{name:m,stale:f}}=t,v=!!c,p=j=>{s(j.currentTarget)},g=()=>{s(null)},x=`feature-${m}-actions`,b=`${x}-menu`,_=()=>{try{sc(m),l(!0),setTimeout(()=>{g(),l(!1)},1e3)}catch{d({type:"error",text:"Could not copy feature name"})}};return a.jsxs(hf,{children:[a.jsx(Y1,{title:"Feature flag actions",arrow:!0,describeChild:!0,children:a.jsx($1,{id:x,"data-loading":!0,"aria-controls":v?b:void 0,"aria-haspopup":"true","aria-expanded":v?"true":void 0,onClick:p,type:"button",children:a.jsx(Pr,{})})}),a.jsx(C0,{id:b,anchorEl:c,open:v,onClose:g,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:j=>({borderRadius:`${j.shape.borderRadius}px`,padding:j.spacing(1,1.5)})},children:a.jsxs(D0,{"aria-labelledby":x,children:[a.jsxs(ce,{sx:p3,onClick:_,children:[a.jsx(pe,{children:o?a.jsx(V3,{}):a.jsx(cc,{})}),a.jsx(se,{children:a.jsx(M,{variant:"body2",children:o?"Copied!":"Copy Name"})})]}),a.jsx(ve,{projectId:e,permission:P2,children:({hasAccess:j})=>a.jsxs(ce,{sx:p3,onClick:g,disabled:!j,component:x1,to:`/projects/${e}/features/${m}/copy`,children:[a.jsx(pe,{children:a.jsx(ts,{})}),a.jsx(se,{children:a.jsx(M,{variant:"body2",children:"Clone"})})]})}),a.jsx(ve,{projectId:e,permission:E2,children:({hasAccess:j})=>a.jsxs(ce,{sx:p3,onClick:()=>{n(m),g()},disabled:!j,children:[a.jsx(pe,{children:a.jsx(ns,{})}),a.jsx(se,{children:a.jsx(M,{variant:"body2",children:"Archive"})})]})}),a.jsx(ve,{projectId:e,permission:Z2,children:({hasAccess:j})=>a.jsxs(ce,{sx:p3,onClick:()=>{g(),i({featureId:m,stale:f===!0})},disabled:!j,children:[a.jsx(pe,{children:a.jsx(y2,{})}),a.jsx(se,{children:a.jsxs(M,{variant:"body2",children:[f?"Un-mark":"Mark"," as stale"]})})]})})]})})]})},ff=u(O)(({theme:e})=>({display:"flex",justifyContent:"center",marginRight:e.spacing(-2)})),pf=({onChange:e,checked:t,title:n})=>a.jsx(ff,{"data-testid":hd,children:a.jsx($0,{onChange:e,title:n,checked:t,"data-loading":!0})}),D8=Ze.memo(pf),vf=u("div")(({theme:e})=>({position:"sticky",bottom:50,zIndex:e.zIndex.fab,pointerEvents:"none"})),gf=u(O)(({theme:e})=>({display:"flex",justifyContent:"center",width:"100%",flexWrap:"wrap",paddingBottom:e.spacing(2)})),xf=u(Ie)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"flex-end",marginTop:e.spacing(2),marginLeft:"auto",marginRight:"auto",padding:e.spacing(2,3),backgroundColor:e.palette.background.paper,border:`1px solid ${e.palette.background.alternative}`,borderRadius:e.shape.borderRadiusLarge,gap:e.spacing(1),flexWrap:"wrap",pointerEvents:"auto"})),jf=u("span")(({theme:e})=>({background:e.palette.background.alternative,color:e.palette.common.white,padding:e.spacing(.5,1),borderRadius:e.shape.borderRadius})),bf=u(M)(({theme:e})=>({paddingRight:e.spacing(2),marginRight:"auto"})),yf=({count:e,children:t})=>e===0?null:a.jsx(vf,{"data-testid":md,children:a.jsx(gf,{children:a.jsxs(xf,{elevation:4,children:[a.jsxs(bf,{children:[a.jsx(jf,{"data-testid":fd,children:e})," selected"]}),t]})})}),_f=7,wf=e=>{const t=pd(new Date,-_f);return!!(e!=null&&e.lastSeenAt&&vd(new Date(e.lastSeenAt),t))},Sf=({projectId:e,featureIds:t,features:n,onConfirm:i})=>{const[c,s]=h.useState(!1),{trackEvent:o}=C1(),l=h.useMemo(()=>t.filter(m=>{const f=n.find(v=>v.name===m);return wf(f)}),[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(ve,{projectId:e,permission:E2,children:({hasAccess:m})=>a.jsx("span",{children:a.jsx(c1,{disabled:!m||c,variant:"outlined",size:"small",onClick:()=>s(!0),children:"Archive"})})}),a.jsx(Qc,{projectId:e,featureIds:t,featuresWithUsage:l,onConfirm:d,isOpen:c,onClose:()=>s(!1)})]})},Q0="selection-actions-menu",Of=({projectId:e,data:t,onChange:n})=>{const[i,c]=h.useState(null),{staleFeatures:s}=Je(),{setToastData:o,setToastApiError:l}=O1(),{trackEvent:d}=C1(),m=!!i,f=t.map(({name:j})=>j),v=j=>{c(j.currentTarget)},p=()=>{c(null)},g=t.some(({stale:j})=>j===!0),x=t.some(({stale:j})=>j===!1),b=async()=>{try{p(),await s(e,f),n==null||n(),o({text:"Feature flags marked as stale",type:"success"}),d("batch_operations",{props:{eventType:"features staled"}})}catch(j){l(_1(j))}},_=async()=>{try{p(),await s(e,f,!1),n==null||n(),o({text:"Feature flags unmarked as stale",type:"success"}),d("batch_operations",{props:{eventType:"features unstaled"}})}catch(j){l(_1(j))}};return a.jsxs(a.Fragment,{children:[a.jsx(Y1,{title:"More bulk actions",arrow:!0,describeChild:!0,children:a.jsx($1,{id:Q0,"aria-controls":m?Q0:void 0,"aria-haspopup":"true","aria-expanded":m?"true":void 0,onClick:v,type:"button","data-testid":gd,children:a.jsx(Pr,{})})}),a.jsx(C0,{id:`${Q0}-menu`,anchorEl:i,open:m,onClose:p,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:j=>({borderRadius:`${j.shape.borderRadius}px`,padding:j.spacing(1,1.5)})},children:a.jsx(D0,{"aria-labelledby":`${Q0}-menu`,children:a.jsx(ve,{projectId:e,permission:Z2,children:({hasAccess:j})=>a.jsxs(a.Fragment,{children:[a.jsx(N,{condition:x,show:()=>a.jsxs(ce,{onClick:b,disabled:!j,sx:{borderRadius:w=>`${w.shape.borderRadius}px`},children:[a.jsx(pe,{children:a.jsx(y2,{})}),a.jsx(se,{children:a.jsx(M,{variant:"body2",children:"Mark as stale"})})]})}),a.jsx(N,{condition:g,show:()=>a.jsxs(ce,{onClick:_,disabled:!j,sx:{borderRadius:w=>`${w.shape.borderRadius}px`},children:[a.jsx(pe,{children:a.jsx(y2,{})}),a.jsx(se,{children:a.jsx(M,{variant:"body2",children:"Un-mark as stale"})})]})})]})})})})]})},Cf=u("section")(({theme:e})=>({"& > *":{margin:e.spacing(1,0)}})),$8="manage-tags-form",T8=(e,t)=>[...e,...e.some(n=>n.value===t.value&&n.type===t.type)?[]:[t]],P8=(e,t)=>e.filter(n=>!(n.value===t.value&&n.type===t.type)),Df=(e,t)=>{switch(t.type){case"add":return{...e,addedTags:T8(e.addedTags,t.payload),removedTags:P8(e.removedTags,t.payload)};case"remove":return{...e,addedTags:P8(e.addedTags,t.payload),removedTags:T8(e.removedTags,t.payload)};case"clear":return{addedTags:[],removedTags:t.payload};case"reset":return{addedTags:[],removedTags:[]};default:return e}},E8={name:"",description:"",icon:""},$f=({open:e,initialValues:t,initialIndeterminateValues:n,onCancel:i,onSubmit:c})=>{const{tagTypes:s,loading:o}=xd(),[l,d]=h.useState(E8),[m,f]=h.useState([]),[v,p]=h.useState([]),{tags:g,refetch:x}=jm(l.name),{createTag:b}=Jc(),_=g.map(({value:z})=>({title:z})),[j,w]=h.useReducer(Df,{addedTags:[],removedTags:[]}),T=()=>{c(j),w({type:"reset"})},D=(z=s.length>0?s[0]:E8)=>{d(z);const F=n.filter(({type:A})=>A===z.name);f(t.filter(({type:A})=>A===z.name).filter(({type:A,value:k})=>!F.some(K=>K.value===k&&K.type===A)).map(({value:A})=>({title:A}))),p(F.map(({value:A})=>({title:A}))),w({type:"clear",payload:[]})};h.useEffect(()=>{s.length>0&&D()},[o]);const C=(z,F)=>{F!=null&&typeof F!="string"&&(z.preventDefault(),D(F))},Z=(z,F)=>b({value:z,type:F}).then(async()=>{x(),f(A=>[...A,{title:z}]),w({type:"add",payload:{value:z,type:F}})}),S=(z,F,A,k)=>{A==="selectOption"?F.forEach(K=>{typeof K!="string"&&typeof K.inputValue=="string"&&K.inputValue&&K.title.startsWith("Create new value")&&Z(K.inputValue,l.name),f(F),p(I=>I.filter(({title:H})=>H!==K.title)),k!=null&&k.option&&w({type:"add",payload:{value:k.option.title,type:l.name}})}):A==="clear"?(f([]),w({type:"clear",payload:t})):A==="removeOption"&&(f(F),k!=null&&k.option&&w({type:"remove",payload:{value:k.option.title,type:l.name}}))},L=()=>{D(),i()};return a.jsxs(he,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update feature flag tags",onClick:T,disabledPrimaryButton:j.addedTags.length===0&&j.removedTags.length===0,onClose:L,formId:$8,children:[a.jsx(M,{paragraph:!0,sx:{marginBottom:z=>z.spacing(2.5)},children:"Tags allow you to group features together"}),a.jsx("form",{id:$8,onSubmit:T,children:a.jsxs(Cf,{children:[a.jsx(bm,{options:s,disabled:o||s.length===0,value:l,onChange:C},o?"loading":s.length),a.jsx(N,{condition:!o&&s.length===0,show:a.jsxs(M,{variant:"body1",children:["No"," ",a.jsx(le,{component:x1,to:"/tag-types",children:"tag types"})," ","available."]}),elseShow:a.jsx(ym,{disabled:o,options:_,existingTags:t,indeterminateOptions:v,tagType:l,selectedOptions:m,onChange:S})})]})})]})},Tf=({projectId:e,data:t,onChange:n})=>{const{bulkUpdateTags:i}=Jc(),{setToastData:c,setToastApiError:s}=O1(),{trackEvent:o}=C1(),[l,d]=h.useState(!1),[m,f]=h.useMemo(()=>{const p=t.flatMap(({tags:x})=>x||[]).reduce((x,b)=>[...x,...x.some(_=>_.type===b.type&&_.value===b.value)?[]:[b]],[]),g=p.filter(x=>!t.every(({tags:b})=>b==null?void 0:b.some(_=>_.type===x.type&&_.value===x.value)));return[p,g]},[t]),v=async({addedTags:p,removedTags:g})=>{const b={features:t.map(({name:_})=>_),tags:{addedTags:p,removedTags:g}};try{const _=[p.length>0&&`added ${p.length} tag${p.length>1?"s":""}`,g.length>0&&`removed ${g.length} tag${g.length>1?"s":""}`].filter(Boolean).join(" and ");await i(b,e),c({text:_,type:"success",autoHideDuration:12e3}),o("batch_operations",{props:{eventType:"tags updated"}})}catch(_){s(_1(_))}n==null||n(),d(!1)};return a.jsxs(a.Fragment,{children:[a.jsx(ve,{projectId:e,permission:Z2,children:({hasAccess:p})=>a.jsx("span",{children:a.jsx(c1,{disabled:!p||l,variant:"outlined",size:"small",onClick:()=>d(!0),children:"Tags"})})}),a.jsx($f,{open:l,onCancel:()=>d(!1),onSubmit:v,initialValues:m,initialIndeterminateValues:f},t.length)]})},Pf=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)})),Ef=({showExportDialog:e,data:t,onClose:n,onConfirm:i,environments:c,projectId:s})=>{const[o,l]=h.useState(c[0]),{bulkToggleFeaturesEnvironmentOff:d}=Er(),{addChange:m}=T0(),{setToastApiError:f,setToastData:v}=O1(),{isChangeRequestConfigured:p}=P0(s),{refetch:g}=I2(s),x=t.filter(w=>{var T,D;return((D=(T=w.environments)==null?void 0:T.find(C=>o===C.name))==null?void 0:D.enabled)===!1}).length,b=()=>c.map(w=>({key:w,label:w})),_=async()=>{try{p(o)?(await m(s,o,t.map(w=>({action:"updateEnabled",feature:w.name,payload:{enabled:!1}}))),g(),v({type:"success",text:"Changes added to draft"})):(await d(s,t.map(w=>w.name),o),v({type:"success",text:"Feature flags disabled"})),n(),i==null||i()}catch(w){f(_1(w))}},j=p(o)?"Add to change request":"Disable flags";return a.jsx(he,{open:e,title:"Disable feature flags",onClose:n,onClick:_,primaryButtonText:j,secondaryButtonText:"Cancel",children:a.jsxs(O,{children:["You have selected ",a.jsx("b",{children:t.length})," feature flags to disable.",a.jsx("br",{}),a.jsx("br",{}),a.jsx(M,{children:"Select which environment to disable the features for:"}),a.jsx(Pf,{options:b(),value:o,onChange:w=>l(w)}),a.jsx(N,{condition:p(o),show:a.jsx(Z8,{severity:"warning",children:"Change requests are enabled for this environment."})}),a.jsx(N,{condition:x>0,show:a.jsxs(Z8,{severity:"info",children:[x," feature"," ",x>1?"flags are ":"flag is ","already disabled."]})})]})})},Zf=u(N3)(({theme:e})=>({minWidth:"450px",marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),I8=u(T1)(({theme:e})=>({marginBottom:e.spacing(1.5)})),If=({showExportDialog:e,data:t,onClose:n,onConfirm:i,environments:c,projectId:s})=>{const[o,l]=h.useState(c[0]),{bulkToggleFeaturesEnvironmentOn:d}=Er(),{addChange:m}=T0(),{setToastApiError:f,setToastData:v}=O1(),{isChangeRequestConfigured:p}=P0(s),{refetch:g}=I2(s),x=t.filter(w=>{var T,D;return((D=(T=w.environments)==null?void 0:T.find(C=>o===C.name))==null?void 0:D.enabled)===!0}).length,b=()=>c.map(w=>({key:w,label:w})),_=async()=>{try{p(o)?(await m(s,o,t.map(w=>({action:"updateEnabled",feature:w.name,payload:{enabled:!0}}))),g(),v({type:"success",text:"Changes added to draft"})):(await d(s,t.map(w=>w.name),o),v({type:"success",text:"Feature flags enabled"})),n(),i==null||i()}catch(w){f(_1(w))}},j=p(o)?"Add to change request":"Enable flags";return a.jsx(he,{open:e,title:"Enable feature flags",onClose:n,onClick:_,primaryButtonText:j,secondaryButtonText:"Cancel",children:a.jsxs(O,{children:["You have selected ",a.jsx("b",{children:t.length})," feature flags to enable.",a.jsx("br",{}),a.jsx("br",{}),a.jsx(M,{children:"Select which environment to enable the features for:"}),a.jsx(Zf,{options:b(),value:o,onChange:w=>l(w)}),a.jsx(N,{condition:p(o),show:a.jsx(I8,{severity:"warning",children:"Change requests are enabled for this environment."})}),a.jsx(N,{condition:x>0,show:a.jsxs(I8,{severity:"info",children:[x," feature"," ",x>1?"flags are ":"flag is ","already enabled."]})})]})})},Mf=({selectedIds:e,data:t,projectId:n,onResetSelection:i,onChange:c})=>{p1();const[s,o]=h.useState(!1),[l,d]=h.useState(!1),[m,f]=h.useState(!1),{trackEvent:v}=C1(),p=h.useMemo(()=>t.filter(w=>e.includes(w.name)),[t,e]),g=h.useMemo(()=>{const w=p.flatMap(T=>T.environments).map(T=>T==null?void 0:T.name).filter(T=>T!==void 0);return Array.from(new Set(w))},[p]),x=()=>{c==null||c(),v("batch_operations",{props:{eventType:"features exported"}})},b=()=>{c==null||c(),v("batch_operations",{props:{eventType:"features enabled"}})},_=()=>{c==null||c(),v("batch_operations",{props:{eventType:"features disabled"}})},j=()=>{c==null||c(),i()};return a.jsxs(a.Fragment,{children:[a.jsx(c1,{variant:"outlined",size:"small",onClick:()=>d(!0),children:"Enable"}),a.jsx(c1,{variant:"outlined",size:"small",onClick:()=>f(!0),children:"Disable"}),a.jsx(Sf,{projectId:n,featureIds:e,features:t,onConfirm:j}),a.jsx(c1,{variant:"outlined",size:"small",onClick:()=>o(!0),children:"Export"}),a.jsx(Tf,{projectId:n,data:p,onChange:c}),a.jsx(Of,{projectId:n,data:p,onChange:c}),a.jsx(oc,{showExportDialog:s,data:p,onClose:()=>o(!1),environments:g,onConfirm:x}),a.jsx(If,{showExportDialog:l,data:p,onClose:()=>d(!1),environments:g,projectId:n,onConfirm:b}),a.jsx(Ef,{showExportDialog:m,data:p,onClose:()=>f(!1),environments:g,projectId:n,onConfirm:_})]})},Af=u(jd)(({theme:e})=>({color:e.palette.warning.main,fontSize:e.fontSizes.bodySize})),Ff=()=>a.jsx(M3,{arrow:!0,title:a.jsxs(a.Fragment,{children:["This environment has no variants enabled. If you check this feature's variants in this environment, you will get the"," ",a.jsx("a",{href:"https://docs.getunleash.io/concepts/feature-flag-variants#the-disabled-variant",target:"_blank",rel:"noreferrer",children:"disabled variant"}),"."]}),children:a.jsx(Af,{})}),as=u("div",{shouldForwardProp:e=>e!=="hasWarning"})(({theme:e,hasWarning:t})=>({flexGrow:0,...M2,justifyContent:"center",...t&&{"::before":{content:'""',display:"block",width:e.spacing(2)}}})),Rf=u("div")(({theme:e})=>({flexGrow:0,...M2,justifyContent:"center"})),Lf=({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]),m=(f,v)=>{var p;l(f,{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,hasReleasePlans:!!((p=i==null?void 0:i.releasePlans)!=null&&p.length),hasEnabledStrategies:i==null?void 0:i.hasEnabledStrategies,isChangeRequestEnabled:c,onRollback:v,onSuccess:o})};return a.jsxs(as,{hasWarning:d,children:[a.jsx(_m,{projectId:n,value:e,featureId:t,environmentName:(i==null?void 0:i.name)||"",onToggle:m}),a.jsx(N,{condition:d||!1,show:a.jsx(Ff,{})})]})},Vf=Ze.memo(Lf),Nf=()=>a.jsx(as,{children:a.jsx("div",{"data-loading":!0,children:"toggle"})}),Wf=()=>a.jsx(Rf,{"aria-hidden":"true",children:"-"}),zf=e=>{const t=`api/admin/projects/${e}/flag-creators`,{data:n,refetch:i,loading:c,error:s}=Zr(B1(t),()=>Ir(B1(t),"Flag creators"));return{flagCreators:n||[],refetch:i,error:s}},Bf=u(bd)({padding:0}),M8=({state:e,onChange:t,project:n})=>{const{tags:i}=lc(),{flagCreators:c}=zf(n),[s,o]=h.useState([]);return h.useEffect(()=>{const l=(i||[]).map(v=>{const p=dc(v);return{label:p,value:p}}),d=c.map(v=>({label:v.name,value:String(v.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:"Last seen",icon:"monitor_heart",options:[],filterKey:"lastSeenAt",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"]}])},[JSON.stringify(i),JSON.stringify(c)]),a.jsx(Bf,{availableFilters:s,state:e,onChange:t})},Yf=e=>`api/admin/projects/${e}/status`,Hf={activityCountByDate:[],resources:{members:0,apiTokens:0,segments:0},health:{current:0},technicalDebt:{current:0},lifecycleSummary:{initial:{currentFlags:0,averageDays:null},preLive:{currentFlags:0,averageDays:null},live:{currentFlags:0,averageDays:null},completed:{currentFlags:0,averageDays:null},archived:{currentFlags:0,last30Days:0}},staleFlags:{total:0}},R0=e=>{const t=B1(Yf(e)),{data:n,refetch:i,loading:c,error:s}=Zr(t,()=>Ir(t,"Project Status"));return{data:n||Hf,refetch:i,loading:c,error:s}},Uf=({projectId:e,state:t,onChange:n,total:i,children:c})=>{var d,m;const{data:s}=R0(e);j1();const o=Object.entries((s==null?void 0:s.lifecycleSummary)||{}).reduce((f,[v,p])=>(f[v==="preLive"?"pre-live":v]=p.currentFlags||0,f),{}),l=(m=(d=t.archived)==null?void 0:d.values)==null?void 0:m.includes("true");return h.useEffect(()=>{l&&t.lifecycle&&n({...t,lifecycle:null})},[l,t,n]),l?null:a.jsx(O,{sx:{marginRight:"auto"},children:a.jsx(yd,{state:t,onChange:n,total:i,countData:o,children:c})})},J0=["select","actions","name","favorite"],X0=(e,t)=>e.reduce((n,i)=>({...n,[i]:t.includes(i)}),{}),kf=e=>{const t=j1(),n=Q1(t.breakpoints.down("sm")),i=Q1(t.breakpoints.down("md")),c=Q1(t.breakpoints.down("lg")),s=h.useCallback((o=0)=>e.filter(l=>l.startsWith("environment:")),[e]);return n?X0(e,[...J0,"createdAt"]):i?X0(e,[...J0,"createdAt",...s(1)]):c?X0(e,[...J0,"createdAt","type",...s(1)]):X0(e,[...J0,"lastSeenAt","lifecycle","createdAt","createdBy","type","tags",...s(3)])},qf=({query:e})=>{var t;return((t=e||"")==null?void 0:t.length)>0?a.jsx(O,{sx:n=>({padding:n.spacing(3)}),children:a.jsxs(re,{children:["No feature flags found matching “",e,"”"]})}):a.jsx(O,{sx:n=>({padding:n.spacing(3)}),children:a.jsx(re,{children:"No feature flags available."})})},Kf=(e,t,n)=>{const[i,c]=h.useState(),[s,o]=h.useState({}),[l,d]=h.useState({featureId:"default",open:!1}),[m,f]=h.useState({featureId:"default",open:!1}),[v,p]=h.useState({featureId:"default",open:!1});return{rowActionsDialogs:a.jsxs(a.Fragment,{children:[a.jsx(wm,{isStale:!!s.stale,isOpen:!!s.featureId,onClose:()=>{o({}),e()},featureId:s.featureId||"",projectId:t}),a.jsx(Qc,{isOpen:!!i,onConfirm:()=>{e(),n==null||n()},onClose:()=>{c(void 0)},featureIds:[i||""],projectId:t}),a.jsx(xm,{isOpen:l.open,setIsOpen:x=>{d({...l,open:x})},projectId:t,featureId:l.featureId,onComplete:e}),a.jsx(uc,{deletedFeatures:[v.featureId],projectId:t,open:v.open,setOpen:x=>{p(b=>({...b,open:x}))},refetch:e}),a.jsx(hc,{revivedFeatures:[m.featureId],projectId:t,open:m.open,setOpen:x=>{f(b=>({...b,open:x}))},refetch:()=>{f(x=>({...x,open:!1})),e()}})]}),setFeatureArchiveState:c,setFeatureStaleDialogState:o,setShowMarkCompletedDialogue:d,setShowFeatureReviveDialogue:f,setShowFeatureDeleteDialogue:p}},Gf=(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},rs=(e,t="project-overview-v2",n=15*1e3)=>{const i={offset:Pe(j8,0),limit:Pe(j8,_d),query:I3,favoritesFirst:Pe(wd,!0),sortBy:Pe(I3,"createdAt"),sortOrder:Pe(I3,"desc"),columns:Sd,tag:Be,state:Be,createdAt:Be,lastSeenAt:Be,type:Be,createdBy:Be,archived:Be,lifecycle:Be},[c,s]=mc(`${t}-${e}`,i),{columns:o,...l}=c,{features:d,total:m,refetch:f,loading:v,initialLoad:p}=fc(pc({...vc(i,l),project:`IS:${e}`},g=>g?`${g}`:void 0),{refreshInterval:n});return{features:d,total:m,refetch:f,loading:v,initialLoad:p,tableState:c,setTableState:s}},Qf=(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())}},r5=(e,t={})=>{const n=B1(`api/admin/projects/${e}/api-tokens`),{data:i,error:c,mutate:s}=W3(n,Jf,t),o=h.useMemo(()=>i??[],[i]),l=h.useCallback(()=>{s().catch(console.warn)},[s]);return{tokens:o,error:c,loading:!c&&!i,refetch:l}},Jf=async e=>(await(await fetch(e).then(me("Project Api tokens"))).json()).tokens,i5=()=>{const{makeRequest:e,createRequest:t,errors:n,loading:i}=A2({propagateErrors:!0});return{deleteToken:async(o,l)=>{const d=`api/admin/projects/${l}/api-tokens/${o}`,m=t(d,{method:"DELETE"});return e(m.caller,m.id)},createToken:async(o,l)=>{const d=`api/admin/projects/${l}/api-tokens`,m=t(d,{method:"POST",body:JSON.stringify(o)});return e(m.caller,m.id)},errors:n,loading:i}},Xf=e=>{if(!e)return null;const[t,n]=e.split(":",2);if(!n)return null;const[i,c,...s]=n.split(".");return t&&i&&c&&s.length===0?{project:t,environment:i,secret:c}:null},R3=u("div")(({theme:e})=>({fontWeight:e.typography.fontWeightBold,marginBottom:e.spacing(1),fontSize:e.typography.body1.fontSize})),G2=u("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:e.spacing(2)})),ep=u("div")(({theme:e})=>({display:"flex",gap:e.spacing(1)})),tp=u("div")(({theme:e})=>({background:e.palette.background.application,borderRadius:e.shape.borderRadius,width:e.spacing(7),height:e.spacing(1)})),np=u("div")(({theme:e})=>({background:e.palette.background.sidebar,borderRadius:e.shape.borderRadius,width:e.spacing(7),height:e.spacing(1)})),Q2=({active:e,steps:t})=>a.jsx(ep,{children:Array.from({length:t},(n,i)=>i===e?a.jsx(np,{},i):a.jsx(tp,{},i))}),ap=({environments:e,onSelect:t,currentEnvironment:n})=>{const i=Math.max(...e.map(c=>c.length));return a.jsx(pr,{tooltip:{header:""},description:"Select the environment where the API key will be created",options:e.map(c=>({label:c,value:c})),onChange:c=>{t(c)},button:{label:n,icon:a.jsx(gc,{}),labelWidth:`${i+5}ch`},search:{label:"Filter project mode options",placeholder:"Select project mode"}})},rp=u("div")(({theme:e})=>({backgroundColor:e.palette.background.elevation1,borderRadius:e.shape.borderRadius,padding:e.spacing(3),display:"flex",flexDirection:"column",alignItems:"center"})),M4=u("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadius,padding:e.spacing(2),flex:1,color:e.palette.text.secondary,fontSize:e.typography.body2.fontSize})),ip=u(O)(({theme:e})=>({display:"flex",gap:e.spacing(2),alignItems:"flex-start",marginTop:e.spacing(8),flexWrap:"wrap"})),A4=u("p")(({theme:e})=>({color:e.palette.text.secondary,fontSize:e.typography.body2.fontSize,marginBottom:e.spacing(2)})),cp=u("div")(({theme:e})=>({padding:e.spacing(5,8,3,8),display:"flex",flexDirection:"column",gap:e.spacing(3)})),sp=({project:e,environment:t,secret:n})=>{const i=j1(),c=Q1(i.breakpoints.up("lg"));return a.jsx(l3.ArcherContainer,{strokeColor:i.palette.secondary.border,endMarker:!1,lineStyle:"curve",children:a.jsxs(rp,{children:[a.jsxs(O,{sx:{wordBreak:"break-all"},children:[a.jsx(l3.ArcherElement,{id:"project",children:a.jsx("span",{children:e})}),":",a.jsx(l3.ArcherElement,{id:"environment",children:a.jsx("span",{children:t})}),".",a.jsx(l3.ArcherElement,{id:"secret",children:a.jsx("span",{children:n})})]}),c?a.jsxs(ip,{children:[a.jsx(l3.ArcherElement,{id:"project-description",relations:[{targetId:"project",targetAnchor:"bottom",sourceAnchor:"top"}],children:a.jsx(M4,{children:"The project this API key can retrieve feature flags from"})}),a.jsx(l3.ArcherElement,{id:"environment-description",relations:[{targetId:"environment",targetAnchor:"bottom",sourceAnchor:"top"}],children:a.jsx(M4,{children:"The environment this API key can retrieve feature flag configuration from"})}),a.jsx(l3.ArcherElement,{id:"secret-description",relations:[{targetId:"secret",targetAnchor:"right",sourceAnchor:"top"}],children:a.jsx(M4,{children:"The API key secret"})})]}):null]})})},op=({environments:e,environment:t,project:n,sdkType:i,onEnvSelect:c,onApiKey:s})=>{const{trackEvent:o}=C1(),{tokens:l,refetch:d}=r5(n),{createToken:m,loading:f}=i5(),v=l.find(_=>_.environment===t&&_.type===i);h.useEffect(()=>{s((v==null?void 0:v.secret)||null)},[v]);const p=Xf(v==null?void 0:v.secret),{setToastApiError:g}=O1(),x=async()=>{try{await m({environment:t,type:i,projects:[n],tokenName:`api-key-${n}-${t}`},n),d(),b()}catch(_){g(_1(_))}},b=()=>{o("onboarding",{props:{eventType:"api-key-generated"}})};return a.jsxs(cp,{children:[a.jsx(M,{variant:"h2",children:"Connect an SDK to Unleash"}),a.jsxs(G2,{children:[a.jsx(Q2,{active:1,steps:3}),a.jsx(z3,{color:"secondary",children:"2/3 - Generate API Key"})]}),a.jsxs(O,{sx:{mt:2},children:[a.jsx(R3,{children:"Environment"}),a.jsx(A4,{children:"The environment the SDK connects to to retrieve configuration."}),e.length>0?a.jsx(ap,{environments:e,currentEnvironment:t,onSelect:c}):null]}),a.jsxs(O,{sx:{mt:3},children:[a.jsx(R3,{children:"API Key"}),p?a.jsxs(A4,{children:["Here is your generated API key. We will use it to connect to the ",a.jsx("b",{children:p.project})," project in the ",a.jsx("b",{children:p.environment})," environment."]}):a.jsx(A4,{children:"You currently have no active API keys for this project/environment combination. Generate an API key to proceed with connecting your SDK."}),p?a.jsx(sp,{project:p.project,environment:p.environment,secret:p.secret}):a.jsx(c1,{variant:"contained",disabled:f,onClick:x,children:"Generate API Key"})]})]})},is=[{name:"Node.js",icon:Od},{name:"Go",icon:Cd},{name:"Ruby",icon:Dd},{name:"PHP",icon:$d},{name:"Rust",icon:Td},{name:".NET",icon:Pd},{name:"Java",icon:Ed},{name:"Python",icon:Zd}],cs=[{name:"JavaScript",icon:Id},{name:"React",icon:Md},{name:"Vue",icon:Ad},{name:"Svelte",icon:Fd},{name:"Swift",icon:Rd},{name:"Android",icon:Ld},{name:"Flutter",icon:Vd}],ss=[...is,...cs],lp=u("div")(({theme:e})=>({padding:e.spacing(5,8,8,8),display:"flex",flexDirection:"column",gap:e.spacing(3)})),A8=u("div")(({theme:e})=>({marginTop:e.spacing(4),marginBottom:e.spacing(2),fontSize:e.typography.body1.fontSize})),F8=u("div")(({theme:e})=>({backgroundColor:e.palette.background.elevation1,borderRadius:e.shape.borderRadius,padding:e.spacing(6),display:"flex",columnGap:e.spacing(2),rowGap:e.spacing(5),alignItems:"center",justifyContent:"flex-start",flexWrap:"wrap"})),R8=u("div")(({theme:e})=>({fontSize:e.typography.body2.fontSize,backgroundColor:e.palette.background.default,borderRadius:e.shape.borderRadius,padding:e.spacing(2,3),width:"170px",position:"relative"})),L8=u("div")(()=>({display:"flex",justifyContent:"space-between"})),V8=u(g3)(({theme:e})=>({position:"absolute",width:e.spacing(4),height:e.spacing(4),top:e.spacing(-2.75),left:e.spacing(2),boxShadow:e.shadows[2]})),dp=({onSelect:e})=>a.jsxs(lp,{children:[a.jsx(M,{variant:"h2",children:"Connect an SDK to Unleash"}),a.jsxs(G2,{children:[a.jsx(Q2,{active:0,steps:3}),a.jsx(z3,{color:"secondary",children:"1/3 - Choose SDK"})]}),a.jsxs(O,{sx:{mt:2},children:[a.jsx(R3,{children:"Select SDK"}),a.jsx(A8,{children:"Server side SDKs"}),a.jsx(F8,{children:is.map(t=>a.jsxs(R8,{children:[a.jsx(V8,{src:y0(t.icon)}),a.jsxs(L8,{children:[a.jsx("b",{children:t.name})," ",a.jsx(le,{onClick:()=>e({name:t.name,type:"client"}),component:"button",children:"Select"})]})]},t.name))}),a.jsx(A8,{children:"Client side SDKs"}),a.jsx(F8,{children:cs.map(t=>a.jsxs(R8,{children:[a.jsx(V8,{src:y0(t.icon)}),a.jsxs(L8,{children:[a.jsx("b",{children:t.name})," ",a.jsx(le,{onClick:()=>e({name:t.name,type:"frontend"}),component:"button",children:"Select"})]})]},t.name))})]})]}),os=u("div")(({theme:e})=>({backgroundColor:e.palette.background.sidebar,padding:e.spacing(12,6,6,6),flex:0,minWidth:"400px"})),h2=u("p")(({theme:e})=>({color:e.palette.primary.contrastText,fontSize:e.typography.caption.fontSize,marginBottom:e.spacing(2)})),c5=({theme:e})=>({color:e.palette.primary.contrastText,fontSize:e.typography.body2.fontSize,marginTop:e.spacing(.5)}),up=u(xc)(c5),hp=u(gc)(c5),ls=u(Nd)(c5),m2=u("div")(({theme:e})=>({display:"flex",gap:e.spacing(1.5),alignItems:"flex-start",marginTop:e.spacing(3)})),f2=u("div")(({theme:e})=>({color:e.palette.primary.contrastText,fontSize:e.typography.body2.fontSize,fontWeight:e.typography.fontWeightBold,marginBottom:e.spacing(2)})),mp=()=>a.jsxs(os,{children:[a.jsxs(m2,{children:[a.jsx(up,{}),a.jsxs(O,{children:[a.jsx(f2,{children:"Flags live in projects"}),a.jsx(h2,{children:"Projects are containers for feature flags. Each flag belongs to the project where you create it."})]})]}),a.jsxs(m2,{children:[a.jsx(hp,{}),a.jsxs(O,{children:[a.jsx(f2,{children:"Flags have configuration in environments"}),a.jsx(h2,{children:"You can have multiple environments, and each feature flag has a different configuration per environment."})]})]}),a.jsxs(m2,{children:[a.jsx(ls,{}),a.jsxs(O,{children:[a.jsx(f2,{children:"SDKs connect to Unleash to retrieve configuration"}),a.jsx(h2,{children:"When you connect an SDK to Unleash, it uses the API key to identify which feature flags and configuration to retrieve from each environment."})]})]})]}),fp=()=>a.jsx(os,{children:a.jsxs(m2,{children:[a.jsx(ls,{}),a.jsxs(O,{children:[a.jsx(f2,{children:"SDKs and Unleash"}),a.jsx(h2,{children:"SDKs serve to bind your application to Unleash. The SDK can connect to Unleash via HTTP and retrieve feature flag configuration that is then cached in your application. Making sure none of your application data ever leaves your servers."})]})]})}),ds=u(g3,{shouldForwardProp:e=>e!=="active"})(({theme:e,active:t})=>({transition:"background-color 0.5s ease",color:e.palette.common.white,backgroundColor:t?e.palette.primary.main:e.palette.divider,"@keyframes pulse":{"0%":{boxShadow:`0 0 0 0px ${Qe(e.palette.primary.main,.7)}`},"100%":{boxShadow:`0 0 0 20px ${Qe(e.palette.primary.main,0)}`}},animation:t?"pulse 2s infinite":""})),pp=u(g3,{shouldForwardProp:e=>e!=="active"})(({theme:e,active:t})=>({transition:"background-color 0.5s ease",color:e.palette.primary.main,backgroundColor:t?e.palette.background.default:e.palette.divider,"@keyframes pulse":{"0%":{boxShadow:`0 0 0 0px ${Qe(e.palette.background.default,.7)}`},"100%":{boxShadow:`0 0 0 20px ${Qe(e.palette.background.default,0)}`}},animation:t?"pulse 2s infinite":""}));var s5={},vp=ee;Object.defineProperty(s5,"__esModule",{value:!0});var J2=s5.default=void 0,gp=vp(X1()),xp=a,jp=(0,gp.default)((0,xp.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM7 13.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"}),"Pending");J2=s5.default=jp;const bp=u("div")(({theme:e})=>({backgroundColor:e.palette.background.sidebar,padding:e.spacing(6,9,6,9),minWidth:"400px",display:"flex",flexDirection:"column",color:e.palette.primary.contrastText})),yp=u(M)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",fontWeight:e.typography.fontWeightBold})),_p=u("div")(({theme:e})=>({display:"flex",flexDirection:"row",padding:e.spacing(4,0,12,0),justifyContent:"space-between",fontSize:e.spacing(1)})),N8=u("div")(({theme:e})=>({display:"flex",gap:e.spacing(1),flexDirection:"column"})),W8=u("div")(({theme:e})=>({alignItems:"center",justifyContent:"center",display:"flex",gap:e.spacing(2),flexDirection:"column",fontSize:e.fontSizes.smallBody})),wp=u(V3)(({theme:e})=>({color:e.palette.primary.main,backgroundColor:e.palette.background.paper,borderRadius:"50%",padding:e.spacing(1),width:"80px",height:"80px"})),Sp=({projectId:e,sdk:t,environment:n})=>{const i=j1(),{project:c}=te(e,{refreshInterval:1e3}),s=c.onboardingStatus.status==="onboarded";return a.jsxs(bp,{children:[a.jsx(yp,{children:"Connection information"}),a.jsxs(_p,{children:[a.jsxs(N8,{children:[a.jsx(M,{fontWeight:"bold",variant:"body2",children:"Environment"}),a.jsx(M,{variant:"body2",children:n})]}),a.jsxs(N8,{children:[a.jsx(M,{fontWeight:"bold",variant:"body2",children:"SDK"}),a.jsx(M,{variant:"body2",children:t})]})]}),s?a.jsxs(W8,{children:[a.jsx(M,{fontWeight:"bold",variant:"body2",children:"Connection status"}),a.jsx(M,{sx:{mb:i.spacing(4)},variant:"body2",children:"Connected"}),a.jsx(wp,{}),a.jsx(M,{sx:{mb:i.spacing(4)},variant:"body2",children:"We received metrics from your application!"})]}):a.jsxs(W8,{children:[a.jsx(M,{fontWeight:"bold",variant:"body2",children:"Connection status"}),a.jsx(M,{sx:{mb:i.spacing(4)},variant:"body2",children:"Waiting for SDK data..."}),a.jsx(pp,{sx:{width:80,height:80},active:!0,children:a.jsx(J2,{fontSize:"large"})})]})]})},Op=`1\\. Install the SDK \`\`\`gradle implementation("io.getunleash:unleash-android:1") \`\`\` 2\\. Enable required [permissions](https://developer.android.com/guide/topics/manifest/uses-permission-element) \`\`\`xml <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> \`\`\` 2\\. Initialize Unleash in your application \`\`\`kotlin class MyApplication: Application() { val unleash: Unleash by lazy { val instance = DefaultUnleash( androidContext = this, unleashConfig = UnleashConfig.newBuilder(appName = "unleash-onboarding-android") .proxyUrl("<YOUR_API_URL>") .clientKey("<YOUR_API_TOKEN>") .build() ) instance.start() instance } override fun onTerminate() { super.onTerminate() unleash.close() } } \`\`\` 3\\. Check flag status \`\`\`kotlin class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val unleashInstance = (application as MyApplication).unleash setContent { var flagStatus by remember { mutableStateOf("loading") } LaunchedEffect(Unit) { while (isActive) { val isFlagEnabled = unleashInstance.isEnabled("<YOUR_FLAG>") flagStatus = if (isFlagEnabled) "enabled" else "disabled" delay(3000L) } } Text(text = "Flag is $flagStatus!") } } } \`\`\` ℹ️ **Info:** The Android SDK takes at least 60 seconds to post metrics to Unleash. --- --- - [SDK repository with documentation and example](https://github.com/Unleash/unleash-android) - [Android SDK basic example](hhttps://github.com/Unleash/unleash-sdk-examples/tree/main/Android) `,Cp=`1\\. Install the SDK \`\`\`sh go get github.com/Unleash/unleash-client-go/v4 \`\`\` 2\\. Run Unleash \`\`\`go package main import ( "github.com/Unleash/unleash-client-go/v4" "net/http" "time" ) func init() { unleash.Initialize( unleash.WithListener(&unleash.DebugListener{}), unleash.WithAppName("unleash-onboarding-golang"), unleash.WithUrl("<YOUR_API_URL>"), unleash.WithCustomHeaders(http.Header{"Authorization": {"<YOUR_API_TOKEN>"}}), // in production use environment variable ) } func main() { for { unleash.IsEnabled("<YOUR_FLAG>") time.Sleep(time.Second) } } \`\`\` --- \`\`\`go func init() { unleash.Initialize( unleash.WithListener(&unleash.DebugListener{}), unleash.WithAppName("unleash-onboarding-golang"), unleash.WithUrl("<YOUR_API_URL>"), unleash.WithCustomHeaders(http.Header{ "Authorization": {os.Getenv("UNLEASH_API_KEY")}, }) ) } \`\`\` --- - [SDK repository with documentation](https://github.com/Unleash/unleash-client-go) - [Go SDK example with CodeSandbox](https://github.com/Unleash/unleash-sdk-examples/tree/main/Go) `,Dp=`1\\. Install the SDK \`\`\`sh npm install unleash-proxy-client \`\`\` 2\\. Run Unleash \`\`\`js const { UnleashClient } = require('unleash-proxy-client'); const unleash = new UnleashClient({ url: '<YOUR_API_URL>', clientKey: '<YOUR_API_TOKEN>', // in production use environment variable appName: 'unleash-onboarding-javascript', }); unleash.start(); setInterval(() => { console.log('Is enabled', unleash.isEnabled('<YOUR_FLAG>')); }, 1000); \`\`\` --- \`\`\`js const unleash = new UnleashClient({ url: '<YOUR_API_URL>', clientKey: process.env.UNLEASH_API_TOKEN, appName: 'unleash-onboarding-javascript', }); unleash.start(); \`\`\` --- - [SDK repository with documentation](https://github.com/Unleash/unleash-proxy-client-js) - [JavaScript SDK example with CodeSandbox](https://github.com/Unleash/unleash-sdk-examples/tree/main/JavaScript) `,$p=`1\\. Install the SDK \`\`\`sh npm install unleash-client \`\`\` 2\\. Run Unleash \`\`\`js const { initialize } = require('unleash-client'); const unleash = initialize({ url: '<YOUR_API_URL>', appName: 'unleash-onboarding-node', customHeaders: { Authorization: '<YOUR_API_TOKEN>' // in production use environment variable }, }); setInterval(() => { console.log('Is enabled', unleash.isEnabled('<YOUR_FLAG>')); }, 1000); \`\`\` --- \`\`\`js const { initialize } = require('unleash-client'); const unleash = initialize({ url: '<YOUR_API_URL>', appName: 'unleash-onboarding-node', customHeaders: { Authorization: process.env.UNLEASH_API_KEY }, }); \`\`\` --- - [SDK repository with documentation](https://github.com/Unleash/unleash-client-node) - [Node.js SDK example with CodeSandbox](https://github.com/Unleash/unleash-sdk-examples/tree/main/Node.js) - [Node.js SDK tutorial](https://dev.to/reeshee/how-to-implement-feature-flags-in-nodejs-using-unleash-3907) `,Tp=`1\\. Install the SDK \`\`\`sh pip install UnleashClient \`\`\` 2\\. Run Unleash \`\`\`python from UnleashClient import UnleashClient import asyncio client = UnleashClient( url="<YOUR_API_URL>", app_name="unleash-onboarding-python", custom_headers={'Authorization': '<YOUR_API_TOKEN>'}) # in production use environment variable client.initialize_client() while True: print(client.is_enabled("<YOUR_FLAG>")) asyncio.run(asyncio.sleep(1)) \`\`\` --- \`\`\`python from UnleashClient import UnleashClient import asyncio import os client = UnleashClient( url="<YOUR_API_URL>", app_name="unleash-onboarding-python", custom_headers={'Authorization': os.getenv('UNLEASH_API_TOKEN')} \`\`\` --- - [SDK repository with documentation](https://github.com/Unleash/unleash-client-python) - [Python SDK example with CodeSandbox](https://github.com/Unleash/unleash-sdk-examples/tree/main/Python) - [How to Implement Feature Flags in Python](https://docs.getunleash.io/feature-flag-tutorials/python) `,Pp=`1\\. Install the SDK \`\`\`sh gem install unleash \`\`\` 2\\. Run Unleash \`\`\`rb require 'unleash' @unleash = Unleash::Client.new( url: "<YOUR_API_URL>", custom_http_headers: { 'Authorization': "<YOUR_API_TOKEN>" }, # in production use environment variable app_name: 'unleash-onboarding-ruby', instance_id: 'unleash-onboarding-ruby', ) while true if @unleash.is_enabled?("<YOUR_FLAG>") puts "Flag is enabled" else puts "Flag is not enabled" end sleep 3 end \`\`\` --- \`\`\`rb @unleash = Unleash::Client.new( url: "<YOUR_API_URL>", custom_http_headers: { 'Authorization': ENV['UNLEASH_API_TOKEN'] }, app_name: 'unleash-onboarding-ruby', instance_id: 'unleash-onboarding-ruby', ) \`\`\` --- - [SDK repository with documentation](https://github.com/Unleash/unleash-client-ruby) - [Ruby example with CodeSandbox](https://github.com/Unleash/unleash-sdk-examples/tree/main/Ruby) - [How to Implement Feature Flags in Ruby](https://docs.getunleash.io/feature-flag-tutorials/ruby) `,Ep=`1\\. Install the SDK \`\`\`sh npm install @unleash/proxy-client-svelte \`\`\` 2\\. Initialize Unleash \`\`\`svelte <script> import { FlagProvider } from '@unleash/proxy-client-svelte'; const config = { url: '<YOUR_API_URL>', clientKey: '<YOUR_API_