unleash-server 5.1.0 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/dist/lib/db/event-store.js +2 -1
  2. package/dist/lib/db/event-store.js.map +1 -1
  3. package/frontend/build/index.html +1 -1
  4. package/frontend/build/static/{CreateProject-3c093214.js → CreateProject-217f67b6.js} +1 -1
  5. package/frontend/build/static/{Error-10dff66c.js → Error-5606eccd.js} +1 -1
  6. package/frontend/build/static/FeatureArchiveDialog-c311c641.js +4 -0
  7. package/frontend/build/static/{FeatureMetricsChart-d5c6311d.js → FeatureMetricsChart-1c6bb078.js} +1 -1
  8. package/frontend/build/static/{FeatureViewLazyExport-e52ae7b0.js → FeatureViewLazyExport-06cf4baa.js} +2 -2
  9. package/frontend/build/static/{LazyAdminExport-2554e446.js → LazyAdminExport-04c8032d.js} +2 -2
  10. package/frontend/build/static/{LazyProjectExport-682e75c0.js → LazyProjectExport-d9663a8c.js} +1 -1
  11. package/frontend/build/static/{NetworkOverview-4653e26c.js → NetworkOverview-2bce4916.js} +1 -1
  12. package/frontend/build/static/{NetworkTraffic-4332556b.js → NetworkTraffic-7db94d86.js} +1 -1
  13. package/frontend/build/static/{Playground-130e9113.js → Playground-6602cb1a.js} +1 -1
  14. package/frontend/build/static/{StrategyItemContainer-893b13f0.js → StrategyItemContainer-0140b94f.js} +1 -1
  15. package/frontend/build/static/{chartjs-adapter-date-fns.esm-23b8f0d9.js → chartjs-adapter-date-fns.esm-c75aa905.js} +1 -1
  16. package/frontend/build/static/{index-66ec1ba9.js → index-1f392976.js} +2 -2
  17. package/frontend/build/static/{index-4d0a5ffb.js → index-b3def5eb.js} +1 -1
  18. package/frontend/build/static/{index-e7efdb59.js → index-f8439975.js} +1 -1
  19. package/frontend/build/static/{unknownify-6ed6e58e.js → unknownify-6683037a.js} +1 -1
  20. package/frontend/build/static/{useProjectRole-ce09b03e.js → useProjectRole-122ac4bb.js} +1 -1
  21. package/package.json +1 -1
  22. package/frontend/build/static/FeatureArchiveDialog-365cb2af.js +0 -4
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const events_1 = require("../types/events");
3
4
  const anyEventEmitter_1 = require("../util/anyEventEmitter");
4
5
  const EVENT_COLUMNS = [
5
6
  'id',
@@ -86,7 +87,7 @@ class EventStore {
86
87
  const row = await this.db(TABLE)
87
88
  .max('id')
88
89
  .whereNotNull('feature_name')
89
- .orWhere('type', 'segment-update')
90
+ .orWhere('type', events_1.SEGMENT_UPDATED)
90
91
  .andWhere('id', '>=', largerThan)
91
92
  .first();
92
93
  return row ? row.max : -1;
@@ -1 +1 @@
1
- {"version":3,"file":"event-store.js","sourceRoot":"","sources":["../../../src/lib/db/event-store.ts"],"names":[],"mappings":";;AAKA,6DAA6D;AAK7D,MAAM,aAAa,GAAG;IAClB,IAAI;IACJ,MAAM;IACN,YAAY;IACZ,YAAY;IACZ,MAAM;IACN,UAAU;IACV,MAAM;IACN,cAAc;IACd,SAAS;IACT,aAAa;CACP,CAAC;AAwDX,MAAM,KAAK,GAAG,QAAQ,CAAC;AAEvB,MAAM,UAAU;IAQZ,8CAA8C;IAC9C,YAAY,EAAM,EAAE,SAAsB;QAN1C,8EAA8E;QACtE,iBAAY,GAAiB,oCAAkB,CAAC;QAMpD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,uBAAuB,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAAiB;QACzB,IAAI;YACA,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC;iBAC5B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;iBAChC,SAAS,CAAC,aAAa,CAAC,CAAC;YAC9B,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CA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O,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;CACJ;AAED,kBAAe,UAAU,CAAC"}
@@ -16,7 +16,7 @@
16
16
  href="https://fonts.googleapis.com/css2?family=Sen:wght@400;700;800&display=swap"
17
17
  rel="stylesheet"
18
18
  />
19
- <script type="module" crossorigin src="/static/index-66ec1ba9.js"></script>
19
+ <script type="module" crossorigin src="/static/index-1f392976.js"></script>
20
20
  <link rel="stylesheet" href="/static/index-66c635eb.css">
21
21
  </head>
22
22
  <body>
@@ -1,4 +1,4 @@
1
- import{a2 as k,an as R,H as w,ao as O,ap as U,aq as D,ar as J,j as e,as as b,at as x,au as B,av as F,aw as L,a4 as K,ax as $}from"./index-66ec1ba9.js";const q="CREATE_PROJECT_BTN",Y=()=>{const{setToastData:n,setToastApiError:i}=k(),{refetchUser:d}=R(),{uiConfig:l}=w(),t=O(),{trackEvent:u}=U(),{projectId:a,projectName:p,projectMode:j,projectDesc:m,setProjectId:P,setProjectName:C,setProjectDesc:T,getProjectPayload:o,clearErrors:r,validateProjectId:s,validateName:h,setProjectStickiness:E,setProjectMode:f,projectStickiness:c,errors:g}=D(),{createProject:A,loading:_}=J();return e(b,{loading:_,title:"Create project",description:"Projects allows you to group feature toggles together in the management UI.",documentationLink:"https://docs.getunleash.io/reference/projects",documentationLinkLabel:"Projects documentation",formatApiCode:()=>`curl --location --request POST '${l.unleashUrl}/api/admin/projects' \\
1
+ import{a2 as k,an as R,H as w,ao as O,ap as U,aq as D,ar as J,j as e,as as b,at as x,au as B,av as F,aw as L,a4 as K,ax as $}from"./index-1f392976.js";const q="CREATE_PROJECT_BTN",Y=()=>{const{setToastData:n,setToastApiError:i}=k(),{refetchUser:d}=R(),{uiConfig:l}=w(),t=O(),{trackEvent:u}=U(),{projectId:a,projectName:p,projectMode:j,projectDesc:m,setProjectId:P,setProjectName:C,setProjectDesc:T,getProjectPayload:o,clearErrors:r,validateProjectId:s,validateName:h,setProjectStickiness:E,setProjectMode:f,projectStickiness:c,errors:g}=D(),{createProject:A,loading:_}=J();return e(b,{loading:_,title:"Create project",description:"Projects allows you to group feature toggles together in the management UI.",documentationLink:"https://docs.getunleash.io/reference/projects",documentationLinkLabel:"Projects documentation",formatApiCode:()=>`curl --location --request POST '${l.unleashUrl}/api/admin/projects' \\
2
2
  --header 'Authorization: INSERT_API_KEY' \\
3
3
  --header 'Content-Type: application/json' \\
4
4
  --data-raw '${JSON.stringify(o(),void 0,2)}'`,children:e(x,{errors:g,handleSubmit:async N=>{N.preventDefault(),r();const v=h(),S=await s();if(v&&S){const y=o();try{await A(y),d(),t(`/projects/${a}`),n({title:"Project created",text:"Now you can add toggles to this project",confetti:!0,type:"success"}),c!==L&&u("project_stickiness_set")}catch(I){i(K(I))}}},handleCancel:()=>{t($)},projectId:a,setProjectId:P,projectName:p,projectMode:j,projectStickiness:c,setProjectStickiness:E,setProjectMode:f,setProjectName:C,projectDesc:m,setProjectDesc:T,mode:"Create",clearErrors:r,validateProjectId:s,children:e(B,{name:"project",permission:F,"data-testid":q})})})};export{Y as default};
@@ -1 +1 @@
1
- import{c as r,j as o}from"./index-66ec1ba9.js";const a=r(o("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}),"Error");export{a as E};
1
+ import{c as r,j as o}from"./index-1f392976.js";const a=r(o("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}),"Error");export{a as E};
@@ -0,0 +1,4 @@
1
+ import{c as se,j as n,u as ne,aF as U,aX as M,f as b,b8 as q,C as _,A as pe,T as w,c5 as fe,e_ as ee,r as v,eT as ye,e$ as me,aZ as Te,aW as re,a2 as $,H as oe,ao as ie,aG as K,a$ as ce,ap as le,fe as be,ff as Ee,as as ve,aY as Ce,fg as Se,fh as Ae,fi as Re,fj as we,b0 as ue,b9 as xe,a4 as x,fk as ke,s as I,bm as H,F as Y,aK as te,a as Pe,dY as _e,bN as N,fl as Oe,dT as Fe,fm as De,fn as qe,fo as $e,bb as Be,bc as Le,bd as Ue,ad as de,ac as ge,bQ as Ie,c7 as Ye,d5 as Ve,w as ze,fp as We,d4 as je,Z as Ge,bL as Je,aR as Ke,aP as He,aQ as Me,ar as Ne}from"./index-1f392976.js";const Qe=se(n("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z"}),"Cloud"),yt=se(n("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"),mt=({enabled:t,className:s})=>{const e=ne(),o=t?"Environment enabled":"Environment disabled",a={backgroundColor:t?e.palette.primary.light:e.palette.neutral.border,borderRadius:"50%",width:"28px",height:"28px",minWidth:"28px",display:"flex",alignItems:"center",justifyContent:"center",marginRight:e.spacing(1)},r={fill:e.palette.common.white,width:"16px",height:"16px"};return n("div",{style:a,className:s,children:n(Qe,{style:r,titleAccess:o})})},Ze=({isOpen:t,onConfirm:s,onClose:e,showBanner:o,environment:a,messageComponent:r})=>{const i=U("projectId"),{data:p}=M(i),{changeRequestInReviewOrApproved:l,alert:d}=fe(p),g=l(a||"");return b(q,{open:t,primaryButtonText:g?"Add to existing change request":"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:s,onClose:e,title:"Request changes",fullWidth:!0,children:[n(_,{condition:g,show:d}),n(_,{condition:!!o,show:b(pe,{severity:"info",sx:{mb:2},children:["Change requests feature is enabled for ",a,". Your changes need to be approved before they will be live. All the changes you do now will be added into a draft that you can submit for review."]})}),n(w,{variant:"body2",color:"text.secondary",children:"Your suggestion:"}),r]})},Tt="UPDATE_FEATURE_STRATEGY",bt="DELETE_FEATURE_STRATEGY",Et="UPDATE_PROJECT",vt="READ_PROJECT_API_TOKEN",Ct="CREATE_PROJECT_API_TOKEN",St="DELETE_PROJECT_API_TOKEN",Xe=(t,s)=>{const e={};return s.parameters.forEach(o=>{e[o.name]=et(t,o)}),{name:s.name,constraints:[],parameters:e}},et=(t,s)=>s.name==="rollout"||s.name==="percentage"||s.type==="percentage"?"50":s.name==="stickiness"?"":s.name==="groupId"?t:s.type==="boolean"?"false":"",At=()=>{const t=U("projectId"),s=U("featureId"),e=ee("environmentId"),o=ee("strategyName"),[a,r]=v.useState({}),[i,p]=v.useState([]),{strategyDefinition:l}=ye(o),d=me(),{addStrategyToFeature:g,loading:T}=Te(),{addChange:c}=re(),{setToastData:u,setToastApiError:f}=$(),{uiConfig:h}=oe(),{unleashUrl:E}=h,C=ie(),{feature:S,refetchFeature:A}=K(t,s),y=v.useRef(S),{isChangeRequestConfigured:B}=ce(t),{refetch:V}=M(t),{trackEvent:O}=le(),{data:k,staleDataNotification:F,forceRefreshCache:z}=be({unleashGetter:K,params:[t,s],dataKey:"feature",refetchFunctionKey:"refetchFeature",options:{}},S,{afterSubmitAction:A},ke);v.useEffect(()=>{y.current.name===""&&S.name&&(z(S),y.current=S)},[S.name]),v.useEffect(()=>{l&&r(Xe(s,l))},[s,l]);const W=async R=>{await g(t,s,e,R),u({title:"Strategy created",type:"success",confetti:!0})},j=async R=>{await c(t,e,{action:"addStrategy",feature:s,payload:R}),u({title:"Strategy added to draft",type:"success",confetti:!0}),V()},D=Ee(a,i),L=async()=>{O("strategyTitle",{props:{hasTitle:!!a.title,on:"create"}});try{B(e)?await j(D):await W(D),A(),C(xe(t,s))}catch(R){f(x(R))}};return!k||!k.project?null:b(ve,{modal:!0,title:Ce(o),description:Se,documentationLink:Ae,documentationLinkLabel:Re,formatApiCode:()=>at(t,s,e,D,E),children:[n(we,{projectId:t,feature:k,strategy:a,setStrategy:r,segments:i,setSegments:p,environmentId:e,onSubmit:L,loading:T,permission:ue,errors:d,isChangeRequest:B(e)}),F]})},tt=(t,s,e,o)=>{const a=new URLSearchParams({environmentId:e,strategyName:o});return`/projects/${t}/features/${s}/strategies/create?${a}`},at=(t,s,e,o,a)=>{if(!a)return"";const r=`${a}/api/admin/projects/${t}/features/${s}/environments/${e}/strategies`,i=JSON.stringify(o,void 0,2);return`curl --location --request POST '${r}' \\
2
+ --header 'Authorization: INSERT_API_KEY' \\
3
+ --header 'Content-Type: application/json' \\
4
+ --data-raw '${i}'`},ae=I("p")(({theme:t})=>({marginBottom:t.spacing(.5),fontSize:t.fontSizes.bodySize})),Rt=({open:t,environmentName:s,featureId:e,projectId:o,onClose:a})=>{const r=ie(),i=tt(o,e,s,"default");return b(q,{open:t,maxWidth:"sm",onClose:()=>a(),title:"You need to add a strategy to your toggle",primaryButtonText:"Take me directly to add strategy",permissionButton:n(H,{type:"button",permission:ue,projectId:o,environmentId:s,onClick:()=>{a(),r(i)},children:"Take me directly to add strategy"}),secondaryButtonText:"Cancel",children:[n(ae,{children:"Before you can enable the toggle in the environment, you need to add an activation strategy."}),n(ae,{children:"You can add the activation strategy by selecting the toggle, open the environment accordion and add the activation strategy."})]})},st="You can not enable the environment before it has strategies",nt=t=>{const{setToastData:s,setToastApiError:e}=$(),{addChange:o}=re(),{refetch:a}=M(t),[r,i]=v.useState({isOpen:!1}),p=v.useCallback((g,T,c,u)=>{i({featureName:g,environment:T,enabled:c,shouldActivateDisabledStrategies:u,isOpen:!0})},[]),l=v.useCallback(()=>{i(g=>({...g,isOpen:!1}))},[]),d=v.useCallback(async()=>{try{await o(t,r.environment,{feature:r.featureName,action:"updateEnabled",payload:{enabled:!!r.enabled,shouldActivateDisabledStrategies:!!r.shouldActivateDisabledStrategies}}),a(),i(g=>({...g,isOpen:!1})),s({type:"success",title:"Changes added to the draft!"})}catch(g){e(x(g)),i(T=>({...T,isOpen:!1}))}},[o]);return{onChangeRequestToggle:p,onChangeRequestToggleClose:l,onChangeRequestToggleConfirm:d,changeRequestDialogDetails:r}},rt=({isOpen:t,onAddDefaultStrategy:s,onActivateDisabledStrategies:e,onClose:o,environment:a,disabledStrategiesCount:r=0})=>{const i=U("projectId");return b(q,{open:t,secondaryButtonText:"Cancel",permissionButton:b(Y,{children:[n(H,{type:"button",permission:te,projectId:i,environmentId:a,onClick:s,children:"Add default strategy"}),n(H,{type:"button",variant:"text",permission:te,projectId:i,environmentId:a,onClick:e,children:"Enable all strategies"})]}),onClose:o,title:"Enable feature toggle",fullWidth:!0,children:[b(w,{variant:"body1",color:"text.primary",sx:{mb:p=>p.spacing(2)},children:["The feature toggle has ",r," disabled",r===1?" strategy":" strategies","."]}),n(w,{variant:"body1",color:"text.primary",children:"You can choose to enable all the disabled strategies or you can add the default strategy to enable this feature toggle."})]})},ot=({enabled:t,featureName:s,environment:e})=>b(w,{"data-testid":"update-enabled-message",children:[n("strong",{children:t?"Enable":"Disable"})," feature toggle"," ",n("strong",{children:s})," in ",n("strong",{children:e})]}),it=I(Pe)(()=>({mx:"auto",..._e})),wt=({projectId:t,featureId:s,environmentName:e,value:o,onToggle:a,onError:r})=>{var R;const{toggleFeatureEnvironmentOn:i,toggleFeatureEnvironmentOff:p}=N(),{setToastData:l,setToastApiError:d}=$(),{isChangeRequestConfigured:g}=ce(t),{onChangeRequestToggle:T,onChangeRequestToggleClose:c,onChangeRequestToggleConfirm:u,changeRequestDialogDetails:f}=nt(t),[h,E,C]=Oe(o),[S,A]=v.useState(!1),{feature:y}=K(t,s),B=((R=y==null?void 0:y.environments.find(m=>m.name===e))==null?void 0:R.strategies.filter(m=>m.disabled).length)??0,{uiConfig:V}=oe(),O=!!V.flags.strategyImprovements,{trackEvent:k}=le(),F=async(m=!1)=>{try{E(!h),await i(t,y.name,e,m),l({type:"success",title:`Available in ${e}`,text:`${y.name} is now available in ${e} based on its defined strategies.`}),a==null||a(t,y.name,e,!h)}catch(P){P instanceof Error&&P.message===st?r==null||r():d(x(P)),C()}},z=async()=>{try{E(!h),await p(t,y.name,e),l({type:"success",title:`Unavailable in ${e}`,text:`${y.name} is unavailable in ${e} and its strategies will no longer have any effect.`}),a==null||a(t,y.name,e,!h)}catch(m){d(x(m)),C()}},W=async m=>{if(g(e)){m.preventDefault(),L()&&O?A(!0):T(y.name,e,!h,!1);return}if(h){await z();return}L()&&O?A(!0):await F()},j=async()=>{await k("strategyImprovements",{props:{eventType:"activate disabled strategies"}}),g(e)?T(y.name,e,!h,!0):await F(!0),A(!1)},D=async()=>{await k("strategyImprovements",{props:{eventType:"add default strategy"}}),g(e)?T(y.name,e,!h,!1):await F(),A(!1)},L=()=>{var P,Z,X;const m=(P=y==null?void 0:y.environments)==null?void 0:P.find(J=>J.name===e);return(m==null?void 0:m.strategies)&&((Z=m==null?void 0:m.strategies)==null?void 0:Z.length)>0&&((X=m==null?void 0:m.strategies)==null?void 0:X.every(J=>J.disabled))},G=`${y.name}-${e}`;return b(Y,{children:[n(it,{"data-testid":`TOGGLE-${G}`,children:n(Fe,{tooltip:h?`Disable feature in ${e}`:`Enable feature in ${e}`,checked:h,environmentId:e,projectId:t,permission:De,inputProps:{"aria-label":e},onClick:W})},G),O&&n(rt,{isOpen:S,onClose:()=>A(!1),environment:e,disabledStrategiesCount:B,onActivateDisabledStrategies:j,onAddDefaultStrategy:D}),n(Ze,{isOpen:f.isOpen,onClose:c,environment:f==null?void 0:f.environment,onConfirm:u,messageComponent:n(ot,{enabled:f==null?void 0:f.enabled,featureName:f==null?void 0:f.featureName,environment:f.environment})})]})},ct=I(qe)(({theme:t})=>({color:t.palette.warning.main,fontSize:t.fontSizes.bodySize})),xt=()=>n($e,{arrow:!0,title:b(Y,{children:["This environment has no variants enabled. If you check this feature's variants in this environment, you will get the"," ",n("a",{href:"https://docs.getunleash.io/reference/feature-toggle-variants#the-disabled-variant",target:"_blank",rel:"noreferrer",children:"disabled variant"}),"."]}),children:n(ct,{})});var Q={},lt=Le;Object.defineProperty(Q,"__esModule",{value:!0});var he=Q.default=void 0,ut=lt(Be()),dt=Ue,gt=(0,ut.default)((0,dt.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10H7v-2h10v2z"}),"IndeterminateCheckBox");he=Q.default=gt;const ht=We(),kt=({options:t,selectedOptions:s,indeterminateOptions:e,tagType:o,existingTags:a,disabled:r=!1,onChange:i})=>{const p=n(je,{fontSize:"small"});return n(de,{multiple:!0,id:"checkboxes-tag",sx:{marginTop:c=>c.spacing(2),width:500},disableCloseOnSelect:!0,placeholder:"Select Values",options:t,value:s,renderTags:(c,u)=>c.map((f,h)=>a.some(C=>C.value===f.title&&C.type===o.name)&&e===void 0?null:n(ze,{...u({index:h}),label:f.title})),isOptionEqualToValue:(c,u)=>u.inputValue&&u.inputValue!==""?c.title===u.inputValue:c.title===u.title,getOptionLabel:c=>c.inputValue?c.inputValue:c.title,renderOption:(c,u,{selected:f})=>{const h=(e==null?void 0:e.some(E=>E.title===u.title))??!1;return b("li",{...c,children:[n(_,{condition:!!u.inputValue,show:n(Ie,{sx:{mr:E=>E.spacing(.5)}}),elseShow:n(Ye,{icon:p,checkedIcon:n(Ve,{fontSize:"small"}),indeterminateIcon:n(he,{fontSize:"small"}),sx:{mr:E=>E.spacing(.5)},checked:f&&!h,indeterminate:h})}),u.title]})},filterOptions:(c,u)=>{const f=ht(c,u),{inputValue:h}=u,E=c.some(C=>h===C.title);return h!==""&&!E&&f.push({inputValue:h,title:`Create new value "${h}"`}),f},ListboxProps:{style:{maxHeight:200,overflow:"auto"}},onChange:i,renderInput:c=>n(ge,{...c,label:"Select values",placeholder:"Select values"}),disabled:r})},pt=I("li")({flexDirection:"column"}),Pt=({options:t,value:s,disabled:e=!1,onChange:o})=>{const a=ne();return n(de,{disablePortal:!0,disabled:e,id:"tag-type-select",sx:{marginTop:r=>r.spacing(2),width:500},options:t,disableClearable:!0,value:s,getOptionLabel:r=>r.name,renderOption:(r,i)=>b(pt,{...r,style:{alignItems:"flex-start",gap:a.spacing(.5)},children:[n(w,{variant:"body1",children:i.name}),n(w,{variant:"caption",children:i.description})]}),renderInput:r=>n(ge,{...r,label:"Tag type",value:s}),onChange:o,ListboxProps:{style:{maxHeight:200,overflow:"auto"}}})},_t=()=>{const{makeRequest:t,createRequest:s,errors:e,loading:o}=Ge({propagateErrors:!0});return{createTag:async i=>{const l=s("api/admin/tags",{method:"POST",body:JSON.stringify(i)});try{return await t(l.caller,l.id)}catch(d){throw d}},bulkUpdateTags:async i=>{const l=s("api/admin/tags/features",{method:"PUT",body:JSON.stringify(i)});try{return await t(l.caller,l.id)}catch(d){throw d}},errors:e,loading:o}},Ot=(t,s={})=>{const e=async()=>{const d=He(`api/admin/tags/${t}`);return(await fetch(d,{method:"GET"}).then(Me("Tags"))).json()},o=`api/admin/tags/${t}`,{data:a,error:r}=Je(!!t,{tags:[]},o,e,s),[i,p]=v.useState(!r&&!a),l=()=>{Ke(o)};return v.useEffect(()=>{p(!r&&!a)},[a,r]),{tags:(a==null?void 0:a.tags)||[],error:r,loading:i,refetch:l}},Ft=({isStale:t,isOpen:s,projectId:e,featureId:o,onClose:a})=>{const{setToastData:r,setToastApiError:i}=$(),{patchFeatureToggle:p}=N(),l=n(w,{children:"Setting a toggle to stale marks it for cleanup"}),d=n(w,{children:"Setting a toggle to active marks it as in active use"}),g=t?"active":"stale",T=async c=>{c.stopPropagation();try{await p(e,o,[{op:"replace",path:"/stale",value:!t}]),a()}catch(u){i(x(u))}r(t?{type:"success",title:"And we're back!",text:"The toggle is no longer marked as stale."}:{type:"success",title:"A job well done.",text:"The toggle has been marked as stale."})};return n(q,{open:s,secondaryButtonText:"Cancel",primaryButtonText:`Flip to ${g}`,title:`Set feature state to ${g}`,onClick:T,onClose:a,children:n(_,{condition:t,show:d,elseShow:l})})},Dt=({isOpen:t,onClose:s,onConfirm:e,projectId:o,featureIds:a})=>{const{archiveFeatureToggle:r}=N(),{archiveFeatures:i}=Ne(),{setToastData:p,setToastApiError:l}=$(),d=(a==null?void 0:a.length)>1;return n(q,{onClick:d?async()=>{try{await i(o,a),p({text:"Selected feature toggles have been archived",type:"success",title:"Feature toggles archived"}),e(),s()}catch(c){l(x(c)),s()}}:async()=>{try{await r(o,a[0]),p({text:"Your feature toggle has been archived",type:"success",title:"Feature archived"}),e(),s()}catch(c){l(x(c)),s()}},open:t,onClose:s,primaryButtonText:d?"Archive toggles":"Archive toggle",secondaryButtonText:"Cancel",title:d?"Archive feature toggles":"Archive feature toggle",children:n(_,{condition:d,show:b(Y,{children:[b("p",{children:["Are you sure you want to archive"," ",n("strong",{children:a==null?void 0:a.length})," feature toggles?"]}),n(_,{condition:(a==null?void 0:a.length)<=5,show:n("ul",{children:a==null?void 0:a.map(c=>n("li",{children:c},c))})})]}),elseShow:n("p",{children:"Are you sure you want to archive these feature toggles?"})})})};export{Ze as C,bt as D,mt as E,wt as F,vt as R,Pt as T,Tt as U,xt as V,yt as W,Rt as a,Ot as b,kt as c,At as d,Dt as e,tt as f,Ft as g,nt as h,ot as i,Et as j,St as k,Ct as l,_t as u};
@@ -1,2 +1,2 @@
1
- import{fu as c,u as m,bF as g,r as d,j as u}from"./index-66ec1ba9.js";import{d as b,L as x,C as f,a as C,b as v,P as S,c as h,T as q,p as k,e as M,f as L}from"./chartjs-adapter-date-fns.esm-23b8f0d9.js";import"./index-4d0a5ffb.js";import"./index-e7efdb59.js";const $=(e,s,n)=>{const a={label:"Total requests",borderColor:e.palette.primary.main,backgroundColor:e.palette.primary.main,data:p(s,n,o=>o.yes+o.no),elements:{point:{radius:6,pointStyle:"circle"},line:{borderDash:[8,4]}}},t={label:"Exposed",borderColor:e.palette.success.main,backgroundColor:e.palette.success.main,data:p(s,n,o=>o.yes),elements:{point:{radius:6,pointStyle:"triangle"}}},r={label:"Not exposed",borderColor:e.palette.error.main,backgroundColor:e.palette.error.main,data:p(s,n,o=>o.no),elements:{point:{radius:6,pointStyle:"triangle",pointRotation:180}}};return{datasets:[t,r,a]}},p=(e,s,n)=>e.map(a=>({x:a.timestamp,y:n(a),variants:a.variants})),E=(e,s)=>{if(s===0)return"";const[n,a]=e,t=Math.floor(Number(a)/s*100);return`${a} (${t}%) - ${n}`},P=(e,s,n,a)=>({locale:a.locale,responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},color:e.palette.text.secondary,plugins:{tooltip:{backgroundColor:e.palette.background.paper,bodyColor:e.palette.text.primary,titleColor:e.palette.text.secondary,borderColor:e.palette.primary.main,borderWidth:1,padding:10,boxPadding:5,usePointStyle:!0,itemSort:(t,r)=>{const o=["Total requests","Exposed","Not exposed"],l=o.indexOf(t.dataset.label),i=o.indexOf(r.dataset.label);return l-i},callbacks:{label:t=>`${t.formattedValue} - ${t.dataset.label}`,afterLabel:t=>{const r=t.dataset.data[t.dataIndex];if(t.dataset.label!=="Exposed"||r.variants===void 0)return"";const{disabled:o,...l}=r.variants;return Object.entries(l).map(i=>E(i,r.y)).join(`
1
+ import{fu as c,u as m,bF as g,r as d,j as u}from"./index-1f392976.js";import{d as b,L as x,C as f,a as C,b as v,P as S,c as h,T as q,p as k,e as M,f as L}from"./chartjs-adapter-date-fns.esm-c75aa905.js";import"./index-b3def5eb.js";import"./index-f8439975.js";const $=(e,s,n)=>{const a={label:"Total requests",borderColor:e.palette.primary.main,backgroundColor:e.palette.primary.main,data:p(s,n,o=>o.yes+o.no),elements:{point:{radius:6,pointStyle:"circle"},line:{borderDash:[8,4]}}},t={label:"Exposed",borderColor:e.palette.success.main,backgroundColor:e.palette.success.main,data:p(s,n,o=>o.yes),elements:{point:{radius:6,pointStyle:"triangle"}}},r={label:"Not exposed",borderColor:e.palette.error.main,backgroundColor:e.palette.error.main,data:p(s,n,o=>o.no),elements:{point:{radius:6,pointStyle:"triangle",pointRotation:180}}};return{datasets:[t,r,a]}},p=(e,s,n)=>e.map(a=>({x:a.timestamp,y:n(a),variants:a.variants})),E=(e,s)=>{if(s===0)return"";const[n,a]=e,t=Math.floor(Number(a)/s*100);return`${a} (${t}%) - ${n}`},P=(e,s,n,a)=>({locale:a.locale,responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},color:e.palette.text.secondary,plugins:{tooltip:{backgroundColor:e.palette.background.paper,bodyColor:e.palette.text.primary,titleColor:e.palette.text.secondary,borderColor:e.palette.primary.main,borderWidth:1,padding:10,boxPadding:5,usePointStyle:!0,itemSort:(t,r)=>{const o=["Total requests","Exposed","Not exposed"],l=o.indexOf(t.dataset.label),i=o.indexOf(r.dataset.label);return l-i},callbacks:{label:t=>`${t.formattedValue} - ${t.dataset.label}`,afterLabel:t=>{const r=t.dataset.data[t.dataIndex];if(t.dataset.label!=="Exposed"||r.variants===void 0)return"";const{disabled:o,...l}=r.variants;return Object.entries(l).map(i=>E(i,r.y)).join(`
2
2
  `)},title:t=>`Time: ${c(t[0].parsed.x,a.locale)}`}},legend:{position:"top",align:"end",labels:{boxWidth:10,boxHeight:10,usePointStyle:!0}},title:{text:T(n),position:"top",align:"start",display:!0,font:{size:16,weight:"400"},color:e.palette.text.primary}},scales:{y:{type:"linear",title:{display:!0,text:"Number of requests",color:e.palette.text.secondary},suggestedMin:0,ticks:{precision:0,color:e.palette.text.secondary},grid:{color:e.palette.divider,borderColor:e.palette.divider}},x:{type:"time",time:{unit:"hour"},grid:{display:!1},ticks:{callback:(t,r,o)=>c(o[r].value,a.locale),color:e.palette.text.secondary}}}}),T=e=>e===1?"Requests in the last hour":`Requests in the last ${e} hours`;b.font={...b.font,family:"Sen",size:13,weight:"400"};const _=({metrics:e,hoursBack:s,statsSectionId:n})=>{const a=m(),{locationSettings:t}=g(),r=d.useMemo(()=>[...e].sort((i,y)=>i.timestamp.localeCompare(y.timestamp)),[e]),o=d.useMemo(()=>P(a,r,s,t),[a,r,s,t]),l=d.useMemo(()=>$(a,r,t),[a,r,t]);return u("div",{style:{height:400},children:u(x,{options:o,data:l,"aria-label":"A feature metrics line chart, with three lines: all requests, positive requests, and negative requests.","aria-describedby":n})})};f.register(C,v,S,h,q,k,M,L);export{_ as FeatureMetricsChart,_ as default};
@@ -1,7 +1,7 @@
1
- import{ay as yn,az as Sn,s as u,r as f,aA as bn,aB as Cn,aC as yt,j as t,aD as vn,aE as wn,c as qt,aF as I,aG as z,aH as Tn,f as c,aI as xn,C as x,aJ as Z,aK as ge,aL as J,aM as ye,aN as An,aO as nt,aP as we,aQ as Oe,aR as at,aS as En,aT as Rn,aU as In,aV as Dn,a2 as q,aW as Te,aX as ie,a4 as j,T as N,aY as xe,aZ as ce,a_ as Fn,a$ as te,b0 as he,b1 as K,m as Ae,b2 as kn,b3 as $n,b4 as Ee,a8 as me,b5 as ke,b6 as Ht,b7 as Se,b8 as ee,ao as le,A as se,b9 as ot,ba as Bn,bb as Pn,bc as On,bd as Vn,be as Je,F as V,a as U,bf as _n,bg as Mn,bh as Ln,bi as Nn,bj as Xe,bk as St,bl as st,bm as oe,H as rt,bn as zn,bo as jn,bp as Wn,p as qn,u as Ut,N as Ve,B as be,bq as it,a9 as de,br as Hn,x as ct,bs as $e,E as Un,bt as lt,bu as Be,P as Gn,bv as Yn,bw as ae,bx as Kn,by as Jn,D as Xn,bz as Qn,bA as Zn,bB as ea,bC as Gt,bD as ta,bE as na,bF as aa,bG as oa,bH as sa,bI as ra,bJ as ia,bK as dt,bL as ca,bM as la,bN as _e,ap as Yt,bO as da,w as Kt,af as Ce,bP as ua,bQ as pa,bR as Qe,bS as Jt,bT as Xt,bU as re,bV as Ze,bW as ga,ac as Qt,bX as Zt,a3 as ut,ad as ha,bY as ma,bZ as en,b_ as fa,b$ as ya,c0 as tn,c1 as Sa,c2 as ba,am as Ca,as as va,c3 as pe,c4 as bt,c5 as wa,c6 as Ta,c7 as xa,ak as pt,al as Aa,V as Ct,c8 as Ea,c9 as Ra,ca as Ia,cb as Da,d as Ne,l as Fa,U as ka,g as $a,S as Ba,h as Pa,i as Oa,k as Va,I as _a,cc as Ma,cd as La,ce as vt,cf as Na,cg as nn,ch as za,ae as ja,ci as wt,cj as Wa,ck as qa,cl as Ha,cm as Ua,cn as Ga,co as Ya,M as Ka,cp as Ja,cq as Xa,cr as Qa,cs as Za,ct as eo,cu as to}from"./index-66ec1ba9.js";import{C as gt,U as no,D as ao,f as oo,E as so,F as ro,V as io,a as co,u as lo,b as uo,T as po,c as go,d as ho,W as mo,e as fo,g as yo}from"./FeatureArchiveDialog-365cb2af.js";import{S as So}from"./StrategyItemContainer-893b13f0.js";import{v as ze}from"./v4-a960c1f4.js";function bo(e){return yn("MuiCardContent",e)}Sn("MuiCardContent",["root"]);const Co=["className","component"],vo=e=>{const{classes:n}=e;return wn({root:["root"]},bo,n)},wo=u("div",{name:"MuiCardContent",slot:"Root",overridesResolver:(e,n)=>n.root})(()=>({padding:16,"&:last-child":{paddingBottom:24}})),To=f.forwardRef(function(n,a){const s=bn({props:n,name:"MuiCardContent"}),{className:o,component:i="div"}=s,r=Cn(s,Co),l=yt({},s,{component:i}),d=vo(l);return t(wo,yt({as:i,className:vn(d.root,o),ownerState:l,ref:a},r))}),xo=To,Ao=qt(t("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"),Eo=qt(t("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z"}),"Assessment"),Ro=u("div")(({theme:e})=>({borderRadius:e.spacing(1.5),backgroundColor:e.palette.background.paper,padding:e.spacing(4)})),Io=()=>{const e=I("projectId"),n=I("featureId"),{feature:a}=z(e,n);return a.name?t(Ro,{children:t(Tn,{title:"Event log",feature:n,displayInline:!0})}):null},Do=u("div")(({theme:e})=>({borderRadius:e.shape.borderRadiusLarge,color:e.palette.primary.contrastText,backgroundColor:e.palette.background.alternative,display:"flex",flexDirection:"column",maxWidth:"350px",minWidth:"350px",marginRight:e.spacing(2),[e.breakpoints.down(1e3)]:{width:"100%",maxWidth:"none",minWidth:"auto"}})),Fo=u("div")({padding:"1.5rem 1.5rem 0 1.5rem"}),ko=u("div")({display:"flex",alignItems:"center"}),$o=u("h2")(({theme:e})=>({fontSize:e.fontSizes.bodySize,fontWeight:"normal",margin:0})),Bo=u("div")(({theme:e})=>({margin:e.spacing(2,0),display:"flex",flexDirection:"column"})),Tt=u("span")(({theme:e})=>({margin:e.spacing(1,0),fontSize:e.fontSizes.bodySize,wordBreak:"break-all"})),xt=u("div")(({theme:e})=>({display:"flex",alignItems:"center",color:e.palette.primary.contrastText})),Po=()=>{const e=I("projectId"),n=I("featureId"),{feature:a}=z(e,n),{project:s,description:o,type:i}=a,r=An(i);return t(Do,{children:c(Fo,{children:[c(ko,{"data-loading":!0,children:[t(r,{sx:l=>({marginRight:l.spacing(2),height:"40px",width:"40px",fill:l.palette.primary.contrastText})})," ",c($o,{children:[xn(i||"")," toggle"]})]}),c(Bo,{children:[c(Tt,{"data-loading":!0,children:["Project: ",s]}),t(x,{condition:!!o,show:c(Tt,{"data-loading":!0,children:[t("div",{children:"Description:"}),c(xt,{children:[t("p",{children:o}),t(Z,{projectId:e,permission:ge,component:J,to:`/projects/${e}/features/${n}/settings`,tooltipProps:{title:"Edit description"},children:t(ye,{sx:l=>({color:l.palette.primary.contrastText})})})]})]}),elseShow:t("span",{"data-loading":!0,children:c(xt,{children:["No description."," ",t(Z,{projectId:e,permission:ge,component:J,to:`/projects/${e}/features/${n}/settings`,tooltipProps:{title:"Edit description"},children:t(ye,{sx:l=>({color:l.palette.primary.contrastText})})})]})})})]})]})})},At={lastHourUsage:[],seenApplications:[]},Oo=(e,n,a={})=>{const s=async()=>{const h=we(`api/admin/client-metrics/features/${n}`),g=await fetch(h,{method:"GET"}).then(Oe("feature metrics"));return g.ok?g.json():At},o=`${e}_${n}_metrics`,{data:i,error:r}=nt(o,s,{...a}),[l,d]=f.useState(!r&&!i),p=()=>{at(o)};return f.useEffect(()=>{d(!r&&!i)},[i,r]),{metrics:i||At,error:r,loading:l,refetch:p,FEATURE_METRICS_CACHE_KEY:o}},Vo=e=>({yes:0,no:0,environment:e,timestamp:""}),_o=(e,n)=>e.map(a=>n.lastHourUsage.find(o=>o.environment===a.name)||Vo(a.name)),Mo=e=>(n,a,s)=>(s.revalidateOnFocus=!1,s.revalidateIfStale=!1,s.revalidateOnReconnect=!1,e(n,a,s)),Lo=En(nt,Mo),an=(e,n)=>{const{refetchFeature:a}=z(e,n),s=Rn(e,n),{data:o,error:i,mutate:r}=Lo(["useFeatureImmutable",s],()=>In(s)),l=f.useCallback(async()=>{await r(),await a()},[r,a]);return{feature:(o==null?void 0:o.body)||Dn,refetchFeature:l,loading:!i&&!o,status:o==null?void 0:o.status,error:i}},ht=(e,n,a)=>{const{setToastData:s,setToastApiError:o}=q(),{addChange:i}=Te(),{refetch:r}=ie(e),[l,d]=f.useState({isOpen:!1}),p=f.useCallback((T,E,S)=>{d({featureName:n,environment:T,fromEnvironment:S,strategy:E,isOpen:!0})},[]),h=f.useCallback((T,E,S)=>{d({featureName:n,environment:T,fromEnvironment:S,strategies:E,isOpen:!0})},[]),g=f.useCallback(()=>{d({isOpen:!1})},[]),y=f.useCallback(async()=>{try{await i(e,l.environment,{feature:l.featureName,action:a,payload:l.strategy}),r(),d({isOpen:!1}),s({type:"success",title:"Changes added to the draft!"})}catch(T){o(j(T)),d({isOpen:!1})}},[i]),b=f.useCallback(async()=>{try{await Promise.all(l.strategies.map(T=>i(e,l.environment,{feature:l.featureName,action:a,payload:T}))),r(),d({isOpen:!1}),s({type:"success",title:"Changes added to the draft!"})}catch(T){o(j(T)),d({isOpen:!1})}},[i]);return{onChangeRequestAddStrategy:p,onChangeRequestAddStrategies:h,onChangeRequestAddStrategyClose:g,onChangeRequestAddStrategyConfirm:y,onChangeRequestAddStrategiesConfirm:b,changeRequestDialogDetails:l}},No=({payload:e,fromEnvironment:n,environment:a})=>c(N,{children:[c("strong",{children:["Copy ",xe((e==null?void 0:e.name)||"")," strategy"," "]})," ","from ",n," to ",a]}),zo=({environmentId:e,environments:n,strategy:a})=>{const s=I("projectId"),o=I("featureId"),[i,r]=f.useState(null),l=!!i,{addStrategyToFeature:d}=ce(),{setToastData:p,setToastApiError:h}=q(),{refetchFeature:g}=z(s,o),{refetchFeature:y}=an(s,o),b=()=>{r(null)},T=Fn(s),{isChangeRequestConfigured:E}=te(s),{changeRequestDialogDetails:S,onChangeRequestAddStrategyClose:C,onChangeRequestAddStrategy:w,onChangeRequestAddStrategyConfirm:F}=ht(s,o,"addStrategy"),$=async k=>{const{id:P,...O}={...a,targetEnvironment:k};if(E(k)){await w(k,{id:P,...O},e);return}try{await d(s,o,k,a),g(),y(),p({title:"Strategy created",text:`Successfully copied a strategy to ${k}`,type:"success"})}catch(G){h(j(G))}b()},M=n.some(k=>T(he,k));return c("div",{children:[t(gt,{isOpen:S.isOpen,onClose:C,environment:S==null?void 0:S.environment,onConfirm:F,messageComponent:t(No,{fromEnvironment:S.fromEnvironment,payload:S.strategy})}),t(K,{title:`Copy to another environment${M?"":" (Access denied)"}`,children:t("div",{children:t(Ae,{size:"large",id:`copy-strategy-icon-menu-${a.id}`,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,onClick:k=>{r(k.currentTarget)},"data-testid":kn,disabled:!M,children:t($n,{})})})}),t(Ee,{id:"basic-menu",anchorEl:i,open:l,onClose:b,MenuListProps:{"aria-labelledby":`copy-strategy-icon-menu-${a.id}`},children:n.map(k=>{const P=T(he,k);return t(K,{title:P?"":"You don't have access to add a strategy to this environment",children:t("div",{children:c(me,{onClick:()=>$(k),disabled:!P,children:[t(x,{condition:!P,show:t(ke,{children:t(Ht,{fontSize:"small"})})}),c(Se,{children:["Copy to ",k]})]})})},k)})})]})},on=()=>t(se,{severity:"error",children:"Removing the strategy will change which users receive access to the feature."}),jo=({onRemove:e,onClose:n,isOpen:a})=>t(ee,{title:"Are you sure you want to delete this strategy?",open:a,primaryButtonText:"Remove strategy",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:t(on,{})}),Wo=u("div")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1)})),qo=({onRemove:e,onClose:n,isOpen:a})=>c(ee,{title:"Suggest changes",open:a,primaryButtonText:"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:[t(on,{}),t(Wo,{children:t(N,{variant:"body2",color:"text.secondary",children:"Your suggestion:"})}),t(N,{fontWeight:"bold",children:"Remove strategy"})]}),Ho=({projectId:e,featureId:n,environmentId:a,strategyId:s})=>{const{deleteStrategyFromFeature:o}=ce(),{setToastData:i,setToastApiError:r}=q(),l=le(),{refetchFeature:d}=z(e,n);return async h=>{try{h.preventDefault(),await o(e,n,a,s),i({title:"Strategy deleted",type:"success"}),d(),l(ot(e,n))}catch(g){r(j(g))}}},Uo=({projectId:e,featureId:n,environmentId:a,strategyId:s})=>{const{addChange:o}=Te(),{refetch:i}=ie(e),{setToastData:r,setToastApiError:l}=q();return async p=>{try{p.preventDefault(),await o(e,a,{action:"deleteStrategy",feature:n,payload:{id:s}}),r({title:"Changes added to the draft!",type:"success"}),await i()}catch(h){l(j(h))}}},Go=({projectId:e,featureId:n,environmentId:a,strategyId:s,text:o,isOpen:i,onClose:r})=>{const{isChangeRequestConfigured:l}=te(e),d=Ho({featureId:n,projectId:e,strategyId:s,environmentId:a}),p=Uo({featureId:n,projectId:e,strategyId:s,environmentId:a});return l(a)?t(qo,{isOpen:i,onClose:()=>r(),onRemove:async h=>{await p(h),r()}}):t(jo,{isOpen:i,onClose:()=>r(),onRemove:d})},Yo=({projectId:e,environmentId:n,featureId:a,strategy:s})=>{const{refetchFeature:o}=z(e,a),{setStrategyDisabledState:i}=ce(),{setToastData:r,setToastApiError:l}=q(),d=p=>async()=>{try{await i(e,a,n,s.id,!p),r({title:`Strategy ${p?"enabled":"disabled"}`,type:"success"}),o()}catch(h){l(j(h))}};return{onDisable:d(!1),onEnable:d(!0)}},Ko=({projectId:e,environmentId:n,featureId:a,strategy:s})=>{const{addChange:o}=Te(),{refetch:i}=ie(e),{setToastData:r,setToastApiError:l}=q(),d=p=>async()=>{try{await o(e,n,{action:"updateStrategy",feature:a,payload:{...s,disabled:!p}}),r({title:"Changes added to the draft!",type:"success"}),await i()}catch(h){l(j(h))}};return{onSuggestDisable:d(!1),onSuggestEnable:d(!0)}},Jo=({isOpen:e,onClose:n,...a})=>{var b;const{projectId:s,environmentId:o}=a,{isChangeRequestConfigured:i}=te(s),r=i(o),{onSuggestEnable:l,onSuggestDisable:d}=Ko({...a}),{onEnable:p,onDisable:h}=Yo({...a}),g=!!((b=a.strategy)!=null&&b.disabled);return t(ee,{title:r?`Add ${g?"enable":"disable"} strategy to change request?`:`Are you sure you want to ${g?"enable":"disable"} this strategy?`,open:e,primaryButtonText:r?"Add to draft":`${g?"Enable":"Disable"} strategy`,secondaryButtonText:"Cancel",onClick:T=>{T.preventDefault(),r?g?l():d():g?p():h(),n()},onClose:()=>n(),children:t(x,{condition:r,show:t(Bn,{environment:o}),elseShow:c(se,{severity:"error",children:[g?"Enabling":"Disabling"," the strategy will change which users receive access to the feature."]})})})};var mt={},Xo=On;Object.defineProperty(mt,"__esModule",{value:!0});var sn=mt.default=void 0,Qo=Xo(Pn()),Zo=Vn,es=(0,Qo.default)((0,Zo.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"}),"Delete");sn=mt.default=es;const ts=({projectId:e,strategy:n,featureId:a,environmentId:s})=>{const[o,i]=f.useState(null),[r,l]=f.useState(!1),[d,p]=f.useState(!1),h=!!o,g=E=>{i(E.currentTarget)},y=E=>{i(null),E.stopPropagation()},b=Je(no,e,s),T=Je(ao,e,s);return c(V,{children:[t(U,{sx:{display:"flex",alignItems:"center",textAlign:"center"},children:t(K,{title:"More actions",children:t(Ae,{onClick:g,size:"small","aria-controls":h?"actions-menu":void 0,"aria-haspopup":"true","aria-expanded":h?"true":void 0,"data-testid":_n,children:t(Mn,{sx:{width:32,height:32}})})})}),c(Ee,{anchorEl:o,id:"actions-menu",open:h,onClose:y,onClick:y,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},children:[t(K,{title:n.disabled?"Enable strategy":"Disable strategy",arrow:!0,placement:"left",children:c(me,{disabled:!b,onClick:()=>l(!0),children:[t(ke,{children:n.disabled?t(Ln,{}):t(Nn,{})}),t(Se,{children:n.disabled?"Enable":"Disable"})]})}),t(K,{title:"Remove strategy",arrow:!0,placement:"left",children:c(me,{disabled:!T,onClick:()=>p(!0),"data-testid":Xe,children:[t(ke,{children:t(sn,{})}),t(Se,{children:"Remove"})]})})]}),t(Jo,{isOpen:r,onClose:()=>l(!1),projectId:e,featureId:a,environmentId:s,strategy:n}),t(Go,{isOpen:d,onClose:()=>p(!1),projectId:e,featureId:a,environmentId:s,strategyId:n.id})]})},rn=()=>t(se,{severity:"error",children:"Removing the strategy will change which users receive access to the feature."}),ns=({onRemove:e,onClose:n,isOpen:a})=>t(ee,{title:"Are you sure you want to delete this strategy?",open:a,primaryButtonText:"Remove strategy",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:t(rn,{})}),as=u("div")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1)})),os=({onRemove:e,onClose:n,isOpen:a})=>c(ee,{title:"Suggest changes",open:a,primaryButtonText:"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:[t(rn,{}),t(as,{children:t(N,{variant:"body2",color:"text.secondary",children:"Your suggestion:"})}),t(N,{fontWeight:"bold",children:"Remove strategy"})]}),ss=({projectId:e,featureId:n,environmentId:a,strategyId:s})=>{const{deleteStrategyFromFeature:o}=ce(),{setToastData:i,setToastApiError:r}=q(),l=le(),{refetchFeature:d}=z(e,n);return async h=>{try{h.preventDefault(),await o(e,n,a,s),i({title:"Strategy deleted",type:"success"}),d(),l(ot(e,n))}catch(g){r(j(g))}}},rs=({projectId:e,featureId:n,environmentId:a,strategyId:s})=>{const{addChange:o}=Te(),{refetch:i}=ie(e),{setToastData:r,setToastApiError:l}=q();return async p=>{try{p.preventDefault(),await o(e,a,{action:"deleteStrategy",feature:n,payload:{id:s}}),r({title:"Changes added to the draft!",type:"success"}),await i()}catch(h){l(j(h))}}},is=({projectId:e,featureId:n,environmentId:a,strategyId:s,disabled:o,icon:i,text:r})=>{const[l,d]=f.useState(!1),{isChangeRequestConfigured:p}=te(e),h=ss({featureId:n,projectId:e,strategyId:s,environmentId:a}),g=rs({featureId:n,projectId:e,strategyId:s,environmentId:a});return c(V,{children:[t(x,{condition:!!i,show:c(Z,{onClick:()=>d(!0),projectId:e,environmentId:a,disabled:o,permission:St,"data-testid":Xe,tooltipProps:{title:"Remove strategy"},type:"button",children:[t(st,{}),t(x,{condition:!!r,show:t(N,{variant:"body1",color:"text.secondary",sx:{ml:y=>y.spacing(1)},children:"Remove"})})]}),elseShow:t(oe,{onClick:()=>d(!0),projectId:e,environmentId:a,disabled:o,permission:St,"data-testid":Xe,color:"secondary",variant:"text",type:"button",children:"Remove strategy"})}),t(x,{condition:p(a),show:t(os,{isOpen:l,onClose:()=>d(!1),onRemove:async y=>{await g(y),d(!1)}}),elseShow:t(ns,{isOpen:l,onClose:()=>d(!1),onRemove:h})})]})},cs=({environmentId:e,strategy:n,onDragStart:a,onDragEnd:s,otherEnvironments:o,orderNumber:i,headerChildren:r})=>{var g;const{uiConfig:l}=rt(),d=I("projectId"),p=I("featureId"),h=zn(d,p,e,n.id);return t(So,{strategy:n,onDragStart:a,onDragEnd:s,orderNumber:i,actions:c(V,{children:[r,t(x,{condition:!!(o&&(o==null?void 0:o.length)>0),show:()=>t(zo,{environmentId:e,environments:o,strategy:n})}),t(Z,{permission:jn,environmentId:e,projectId:d,component:J,to:h,tooltipProps:{title:"Edit strategy"},"data-testid":`STRATEGY_EDIT-${n.name}`,children:t(ye,{})}),t(x,{condition:!!((g=l==null?void 0:l.flags)!=null&&g.strategyImprovements),show:()=>t(ts,{projectId:d,featureId:p,environmentId:e,strategy:n}),elseShow:()=>t(is,{projectId:d,featureId:p,environmentId:e,strategyId:n.id,icon:!0})})]}),children:t(Wn,{strategy:n})})},ls=(e,n,a,s)=>{const{data:o}=ie(e),i=o==null?void 0:o.find(d=>d.environment===a),r=i==null?void 0:i.features.find(d=>d.name===n);return r==null?void 0:r.changes.find(d=>d.action==="updateStrategy"||d.action==="deleteStrategy"?d.payload.id===s:!1)},ds=({strategy:e,index:n,environmentName:a,otherEnvironments:s,isDragging:o,onDragStartRef:i,onDragOver:r,onDragEnd:l})=>{const d=I("projectId"),p=I("featureId"),h=f.useRef(null),g=ls(d,p,a,e.id);return c(U,{ref:h,onDragOver:r(h,n),sx:{opacity:o?"0.5":"1"},children:[t(x,{condition:n>0,show:t(qn,{text:"OR"})}),t(cs,{strategy:e,environmentId:a,otherEnvironments:s,onDragStart:i(h,n),onDragEnd:l,orderNumber:n+1,headerChildren:t(us,{change:g})})]},e.id)},us=({change:e})=>{const n=Ut();return Ve(n.breakpoints.down("sm"))?null:c(U,{sx:{mr:1.5},children:[t(x,{condition:(e==null?void 0:e.action)==="updateStrategy",show:t(be,{color:"warning",children:"Modified in draft"})}),t(x,{condition:(e==null?void 0:e.action)==="deleteStrategy",show:t(be,{color:"error",children:"Deleted in draft"})})]})},ps=u("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",margin:"1rem 0",position:"relative","&:before":{content:'""',position:"absolute",top:"50%",transform:"translateY(-50%)",height:2,width:"100%",backgroundColor:e.palette.divider}})),gs=u("span")(({theme:e})=>({fontSize:e.fontSizes.bodySize,textAlign:"center",padding:"0 1rem",background:e.palette.envAccordion.expanded,position:"relative",maxWidth:"80%",color:e.palette.text.primary})),cn=({children:e})=>t(ps,{children:t(gs,{children:e})}),hs=({environmentId:e,environments:n,onClick:a})=>{const s=I("projectId"),[o,i]=f.useState(null),r=!!o,{hasAccess:l}=f.useContext(it),d=n.some(p=>l(he,s,p));return c("div",{children:[t(K,{title:d?"":"(Access denied)",children:t("div",{children:t(de,{id:`copy-all-strategies-${e}`,"aria-controls":r?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":r?"true":void 0,onClick:p=>{i(p.currentTarget)},disabled:!d,variant:"outlined",children:"Copy from another environment"})})}),t(Ee,{id:"basic-menu",anchorEl:o,open:r,onClose:()=>{i(null)},MenuListProps:{"aria-labelledby":`copy-all-strategies-${e}`},children:n.map(p=>{const h=l(he,s,p);return t(K,{title:h?"":"You don't have access to add a strategy to this environment",children:t("div",{children:c(me,{onClick:()=>a(p),disabled:!h,children:[t(x,{condition:!h,show:t(ke,{children:t(Ht,{fontSize:"small"})})}),c(Se,{children:["Copy from ",p]})]})})},p)})})]})},ms=u("div")(({theme:e})=>({"&>*:nth-child(n)":{margin:e.spacing(1,0)}})),fs=({payload:e,fromEnvironment:n,environment:a})=>c(ms,{children:[t(N,{children:t("strong",{children:"Copy: "})}),e==null?void 0:e.map(s=>c(N,{children:[c("strong",{children:[xe((s==null?void 0:s.name)||"")," strategy"," "]})," "]})),c(N,{children:["from ",n," to ",a]})]}),ys=({payload:e,environment:n})=>c(V,{children:[t(N,{component:"span",children:"Add "}),c("strong",{children:[xe((e==null?void 0:e.name)||"")," strategy"]})," to ",t("strong",{children:n})]}),Ss=u(Hn)(({theme:e})=>({display:"flex",flexDirection:"column",borderRadius:e.shape.borderRadiusMedium})),Et=({title:e,children:n,featureId:a,projectId:s,environmentId:o,strategy:i,Icon:r,onAfterAddStrategy:l})=>{const{addStrategyToFeature:d}=ce(),{setToastApiError:p}=q(),{isChangeRequestConfigured:h}=te(s),{changeRequestDialogDetails:g,onChangeRequestAddStrategy:y,onChangeRequestAddStrategyConfirm:b,onChangeRequestAddStrategyClose:T}=ht(s,a,"addStrategy");return c(V,{children:[t(Ss,{variant:"outlined",children:c(xo,{sx:{display:"flex",flexDirection:"column",flexGrow:1},children:[c(N,{variant:"body1",fontWeight:"medium",sx:{mb:.5,display:"flex",alignItems:"center"},children:[t(r,{color:"disabled",sx:{mr:1}})," ",e]}),t(N,{variant:"body2",color:"text.secondary",component:"p",children:n}),t(U,{sx:{ml:"auto",mt:"auto",pt:1,mr:{xs:"auto",sm:0}},children:t(oe,{permission:he,projectId:s,environmentId:o,variant:"outlined",size:"small",onClick:async()=>{try{h(o)?y(o,i):(await d(s,a,o,i),l())}catch(S){p(j(S))}},children:"Use template"})})]})}),t(gt,{isOpen:g.isOpen,onClose:T,environment:g==null?void 0:g.environment,onConfirm:b,messageComponent:t(ys,{environment:o,payload:g.strategy})})]})},bs=u("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}})),Cs=u("div")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),vs=u(ct)(({theme:e})=>({fontWeight:e.fontWeight.bold})),ws=u(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}})),Ts=({projectId:e,featureId:n,environmentId:a,strategy:s})=>{const o=$e(s.name),i=xe(s.name),r=oo(e,n,a,s.name);return c(ws,{to:r,children:[t(bs,{children:t(o,{})}),c("div",{children:[t(vs,{text:s.displayName||i,maxWidth:"200",maxLength:25}),t(Cs,{children:s.description})]})]})},xs=({projectId:e,featureId:n,environmentId:a})=>{const{strategies:s}=Un(),o=f.useMemo(()=>s.filter(i=>!i.deprecated),[s]);return t(lt,{dense:!0,children:o.map(i=>t(Be,{children:t(Ts,{projectId:e,featureId:n,environmentId:a,strategy:i})},i.name))})},et=({label:e,projectId:n,featureId:a,environmentId:s,variant:o,matchWidth:i})=>{const[r,l]=f.useState(),d=!!r,p=d?"FeatureStrategyMenuPopover":void 0,h=()=>{l(void 0)};return c("div",{onClick:y=>y.stopPropagation(),children:[t(oe,{permission:he,projectId:n,environmentId:s,onClick:y=>{l(y.currentTarget)},"aria-labelledby":p,variant:o,sx:{minWidth:i?"282px":"auto"},children:e}),t(Gn,{id:p,open:d,anchorEl:r,onClose:h,onClick:h,children:t(xs,{projectId:n,featureId:a,environmentId:s})})]})},As=u("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingTop:e.spacing(2)})),Es=u("div")(({theme:e})=>({fontSize:e.fontSizes.bodySize,textAlign:"center",color:e.palette.text.primary,marginBottom:e.spacing(1)})),Rs=u("p")(({theme:e})=>({color:e.palette.text.secondary,fontSize:e.fontSizes.smallBody,textAlign:"center",marginBottom:e.spacing(3),a:{color:e.palette.links}})),Is=({projectId:e,featureId:n,environmentId:a})=>{const{addStrategyToFeature:s}=ce(),{setToastData:o,setToastApiError:i}=q(),{refetchFeature:r}=z(e,n),{refetchFeature:l}=an(e,n),{feature:d}=z(e,n),p=d==null?void 0:d.environments.filter(w=>w.name!==a&&w.strategies&&w.strategies.length>0),{isChangeRequestConfigured:h}=te(e),{changeRequestDialogDetails:g,onChangeRequestAddStrategies:y,onChangeRequestAddStrategiesConfirm:b,onChangeRequestAddStrategyClose:T}=ht(e,n,"addStrategy"),E=(w=!1)=>{r(),l(),o({title:w?"Strategies created":"Strategy created",text:w?"Successfully copied from another environment":"Successfully created strategy",type:"success"})},S=async w=>{var $;const F=(($=p==null?void 0:p.find(M=>M.name===w))==null?void 0:$.strategies)||[];if(h(a)){await y(a,F,w);return}try{await Promise.all(F.map(M=>{const{id:k,...P}={...M,environment:a};return s(e,n,a,P)})),E(!0)}catch(M){i(j(M))}},C=p&&p.length>0;return c(V,{children:[t(gt,{isOpen:g.isOpen,onClose:T,environment:g==null?void 0:g.environment,onConfirm:b,messageComponent:t(fs,{fromEnvironment:g.fromEnvironment,payload:g.strategies})}),c(As,{children:[t(Es,{children:"You have not defined any strategies yet."}),c(Rs,{children:["Strategies added in this environment will only be executed if the SDK is using an"," ",t(J,{to:"/admin/api",children:"API key configured"})," for this environment."]}),c(U,{sx:{w:"100%",display:"flex",flexWrap:"wrap",gap:2,alignItems:"center",justifyContent:"center"},children:[t(et,{label:"Add your first strategy",projectId:e,featureId:n,environmentId:a,matchWidth:C}),t(x,{condition:C,show:t(hs,{environmentId:a,environments:p.map(w=>w.name),onClick:S})})]}),t(U,{sx:{width:"100%",mt:3},children:t(cn,{children:"Or use a strategy template"})}),c(U,{sx:{display:"grid",width:"100%",gap:2,gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"}},children:[t(Et,{title:"Standard strategy",projectId:e,featureId:n,environmentId:a,onAfterAddStrategy:E,Icon:$e("default"),strategy:{name:"default",parameters:{},constraints:[]},children:"The standard strategy is strictly on/off for your entire userbase."}),t(Et,{title:"Gradual rollout",projectId:e,featureId:n,environmentId:a,onAfterAddStrategy:E,Icon:$e("flexibleRollout"),strategy:{name:"flexibleRollout",parameters:{rollout:"50",stickiness:"default",groupId:d.name},constraints:[]},children:"Roll out to a percentage of your userbase."})]})]})]})},Ds=u("div")(({theme:e})=>({width:"100%",position:"relative",paddingBottom:e.spacing(2)})),Fs=u("div")(({theme:e})=>({[e.breakpoints.down(400)]:{padding:e.spacing(1)}})),ks=({featureEnvironment:e,isDisabled:n,otherEnvironments:a})=>{const s=I("projectId"),o=I("featureId"),{setStrategiesSortOrder:i}=ce(),{setToastData:r,setToastApiError:l}=q(),{refetchFeature:d}=z(s,o),[p,h]=f.useState((e==null?void 0:e.strategies)||[]),[g,y]=f.useState(null);if(f.useEffect(()=>{h((e==null?void 0:e.strategies)||[])},[e==null?void 0:e.strategies]),!e)return null;const b=async C=>{try{await i(s,o,e.name,C),d(),r({title:"Order of strategies updated",type:"success"})}catch(w){l(j(w))}},T=(C,w)=>F=>{var $;y({id:p[w].id,index:w,height:(($=C.current)==null?void 0:$.offsetHeight)||0}),C!=null&&C.current&&(F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/html",C.current.outerHTML),F.dataTransfer.setDragImage(C.current,20,20))},E=C=>(w,F)=>$=>{if(g===null||w.current===null||g.index===F||C===g.id)return;const{top:M,bottom:k}=w.current.getBoundingClientRect(),P=$.clientY-M<g.height,O=k-$.clientY<g.height,G=g.index>F;if(P&&G||O&&!G){const Y=[...p],X=Y.splice(g.index,1)[0];Y.splice(F,0,X),h(Y),y({...g,index:F})}},S=()=>{y(null),b(p.map((C,w)=>({id:C.id,sortOrder:w})))};return t(Ds,{children:c(Fs,{children:[t(x,{condition:p.length>0&&n,show:()=>t(se,{severity:"warning",sx:{mb:2},children:"This environment is disabled, which means that none of your strategies are executing."})}),t(x,{condition:p.length>0,show:t(V,{children:p.map((C,w)=>t(ds,{strategy:C,index:w,environmentName:e.name,otherEnvironments:a,isDragging:(g==null?void 0:g.id)===C.id,onDragStartRef:T,onDragOver:E(C.id),onDragEnd:S},C.id))}),elseShow:t(Is,{projectId:s,featureId:o,environmentId:e.name})})]})})},ln=(e,n)=>e===0?0:Math.round(n/e*100);var Me={},Le={};Object.defineProperty(Le,"__esModule",{value:!0});Le.defaultOptions=void 0;Le.defaultOptions={decimalSeparator:".",lowercase:!1,precision:1,space:!1,units:["","K","M","B","T","P","E"]};var fe={};Object.defineProperty(fe,"__esModule",{value:!0});fe.roundTo=fe.parseValue=void 0;function $s(e){const n=parseFloat(e==null?void 0:e.toString());if(isNaN(n))throw new Error("Input value is not a number");if(n>Number.MAX_SAFE_INTEGER||n<Number.MIN_SAFE_INTEGER)throw new RangeError("Input value is outside of safe integer range");return n}fe.parseValue=$s;function Bs(e,n){if(!Number.isFinite(e))throw new Error("Input value is not a finite number");if(!Number.isInteger(n)||n<0)throw new Error("Precision is not a positive integer");return Number.isInteger(e)?e:parseFloat(e.toFixed(n))}fe.roundTo=Bs;Object.defineProperty(Me,"__esModule",{value:!0});Me.millify=void 0;const je=Le,Rt=fe,It=1e3;function*Dt(e){let n=It;for(;;){const a=e/n;if(a<1)return;yield a,n*=It}}function dn(e,n){var a;const s=n?Object.assign(Object.assign({},je.defaultOptions),n):je.defaultOptions;if(!Array.isArray(s.units)||!s.units.length)throw new Error("Option `units` must be a non-empty array");let o;try{o=Rt.parseValue(e)}catch(b){return b instanceof Error&&console.warn(`WARN: ${b.message} (millify)`),String(e)}const i=o<0?"-":"";o=Math.abs(o);let r=0;for(const b of Dt(o))o=b,r+=1;if(r>=s.units.length)return e.toString();let d=Rt.roundTo(o,s.precision);for(const b of Dt(d))d=b,r+=1;const p=(a=s.units[r])!==null&&a!==void 0?a:"",h=s.lowercase?p.toLowerCase():p,g=s.space?" ":"",y=d.toString().replace(je.defaultOptions.decimalSeparator,s.decimalSeparator);return`${i}${y}${g}${h}`}Me.millify=dn;var Ps=Me.default=dn;const Pe=({value:e,threshold:n=1e6,precision:a=2})=>{let s,o=!1;e<n?s=e.toLocaleString():(s=Ps(e,{precision:a}),o=!0);const i=t("span",{"data-testid":Yn,children:s});return t(x,{condition:o,show:t(K,{title:e.toLocaleString(),arrow:!0,children:i}),elseShow:i})},We=u("article")(({theme:e})=>({padding:e.spacing(2),background:"transparent",borderRadius:e.spacing(2),textAlign:"center",[e.breakpoints.up("md")]:{padding:e.spacing(4)}})),qe=u("h3")(({theme:e})=>({margin:0,fontSize:e.fontSizes.bodySize,fontWeight:e.fontWeight.thin})),He=u("p")(({theme:e})=>({fontSize:"2.25rem",fontWeight:e.fontWeight.bold,color:e.palette.primary.main})),Ue=u("p")(({theme:e})=>({margin:e.spacing(1,0,0,0),padding:e.spacing(2,0,0,0),borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:e.palette.divider,fontSize:e.fontSizes.smallerBody,color:e.palette.text.secondary})),un=({totalYes:e,totalNo:n,hoursBack:a,statsSectionId:s,tableSectionId:o})=>{const i=a===1?"in the last hour":`in the last ${a} hours`;return c(ae,{container:!0,spacing:2,id:s,"aria-describedby":o,"aria-label":"Feature metrics summary",component:"section",children:[t(ae,{item:!0,xs:12,sm:4,children:c(We,{children:[t(qe,{children:"Exposure"}),t(He,{children:t(Pe,{value:e})}),c(Ue,{children:["Total exposure of the feature in the environment"," ",i,"."]})]})}),t(ae,{item:!0,xs:12,sm:4,children:c(We,{children:[t(qe,{children:"Exposure %"}),c(He,{children:[ln(e+n,e),"%"]}),c(Ue,{children:["% total exposure of the feature in the environment"," ",i,"."]})]})}),t(ae,{item:!0,xs:12,sm:4,children:c(We,{children:[t(qe,{children:"Requests"}),t(He,{children:t(Pe,{value:e+n})}),c(Ue,{children:["Total requests for the feature in the environment"," ",i,"."]})]})})]})},Os=({environmentMetric:e})=>e?c(V,{children:[t(cn,{children:"Feature toggle exposure"}),t("div",{children:t(un,{totalYes:e.yes,totalNo:e.no,hoursBack:1})})]}):null,Ft=u("div")({marginLeft:"auto",display:"flex",alignItems:"center"}),kt=u("div")(({theme:e})=>({marginRight:e.spacing(1),display:"flex",flexDirection:"column"})),$t=u("p")(({theme:e})=>({color:e.palette.primary.main,textAlign:"right",fontSize:e.fontSizes.bodySize})),Bt=u("p")(({theme:e})=>({maxWidth:"270px",marginTop:e.spacing(.5),fontSize:e.fontSizes.smallBody,textAlign:"right",[e.breakpoints.down(700)]:{display:"none"}})),Vs=u(Kn)(({theme:e})=>({fill:e.palette.background.elevation2,height:"75px",width:"75px",[e.breakpoints.down(500)]:{display:"none"}})),_s=u("div")(({theme:e})=>({margin:e.spacing(0,2),[e.breakpoints.down(500)]:{display:"none"}})),Ms=({environmentMetric:e,disabled:n=!1})=>{const a=Jn();if(!e)return null;const s=e.yes+e.no,o=ln(s,e==null?void 0:e.yes);return!e||e.yes===0&&e.no===0?c(Ft,{children:[c(kt,{children:[c($t,{style:{color:n?a.palette.text.secondary:void 0},"data-loading":!0,children:[o,"%"]}),c(Bt,{style:{color:n?a.palette.text.secondary:a.palette.text.primary},"data-loading":!0,children:["The feature has been requested ",t("b",{children:"0 times"})," and exposed",t("b",{children:" 0 times"})," in the last hour"]})]}),t(Vs,{style:{transform:"scale(1.1)"},"data-loading":!0})]}):c(Ft,{children:[c(kt,{children:[c($t,{children:[o,"%"]}),c(Bt,{children:["The feature has been requested"," ",c("b",{children:[t(Pe,{value:s})," times"]})," ","and exposed"," ",c("b",{children:[t(Pe,{value:e.yes})," ","times"]})," ","in the last hour"]})]}),t(_s,{"data-loading":!0,children:t(Xn,{percentage:o,size:"3rem"})})]})},Ls=({strategyName:e})=>{const n=$e(e);return t(K,{title:xe(e),arrow:!0,children:t(Ns,{children:t(n,{})})})},Ns=u("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.palette.action.disabled,"& svg":{width:e.spacing(2.5),height:e.spacing(2.5)}})),zs=({strategies:e})=>e!=null&&e.length?t(js,{"aria-label":"Feature strategies",children:e.map(n=>t(Ws,{children:t(Ls,{strategyName:n.name})},n.id))}):null,js=u("ul")(()=>({all:"unset",display:"flex",alignItems:"center",alignContent:"center"})),Ws=u("li")(()=>({all:"unset",minWidth:30,textAlign:"center"})),qs=u("div",{shouldForwardProp:e=>e!=="enabled"})(({theme:e,enabled:n})=>({borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2),backgroundColor:n?e.palette.background.paper:e.palette.envAccordion.disabled})),Hs=u(Qn)({boxShadow:"none",background:"none"}),Us=u(Zn)(({theme:e})=>({boxShadow:"none",padding:e.spacing(2,4),[e.breakpoints.down(400)]:{padding:e.spacing(1,2)}})),Gs=u(ea,{shouldForwardProp:e=>e!=="enabled"})(({theme:e})=>({padding:e.spacing(3),background:e.palette.envAccordion.expanded,borderBottomLeftRadius:e.shape.borderRadiusLarge,borderBottomRightRadius:e.shape.borderRadiusLarge,boxShadow:"inset 0px 2px 4px rgba(32, 32, 33, 0.05)",[e.breakpoints.down("md")]:{padding:e.spacing(2,1)}})),Ys=u(ks)(({theme:e})=>({width:"100%",position:"relative",paddingBottom:e.spacing(2)})),Ks=u("div",{shouldForwardProp:e=>e!=="enabled"})(({theme:e,enabled:n})=>({display:"flex",justifyContent:"center",flexDirection:"column",color:n?e.palette.text.primary:e.palette.text.secondary})),Js=u("div")(({theme:e})=>({display:"flex",alignItems:"center",[e.breakpoints.down(560)]:{flexDirection:"column",textAlign:"center"}})),Xs=u(so)(({theme:e})=>({[e.breakpoints.down(560)]:{marginBottom:"0.5rem"}})),Qs=u(ct)(({theme:e})=>({fontSize:e.fontSizes.bodySize,fontWeight:e.typography.fontWeightMedium,[e.breakpoints.down(560)]:{textAlign:"center"}})),Zs=u("div")(({theme:e})=>({display:"flex",alignItems:"center",marginLeft:"1.8rem",[e.breakpoints.down(560)]:{flexDirection:"column",marginLeft:"0"}})),er=({env:e})=>{var p;const n=I("projectId"),a=I("featureId"),{metrics:s}=Oo(n,a),{feature:o}=z(n,a),{value:i}=Gt(),l=_o(o==null?void 0:o.environments,s).find(h=>h.environment===e.name),d=o==null?void 0:o.environments.find(h=>h.name===e.name);return t(x,{condition:!new Set(i.hiddenEnvironments).has(e.name),show:t(qs,{enabled:e.enabled,children:c(Hs,{"data-testid":`${ta}_${e.name}`,className:`environment-accordion ${e.enabled?"":"accordion-disabled"}`,children:[c(Us,{expandIcon:t(na,{titleAccess:"Toggle"}),children:[c(Ks,{"data-loading":!0,enabled:e.enabled,children:[c(Js,{children:[t(Xs,{enabled:e.enabled}),t("div",{children:t(Qs,{text:e.name,maxWidth:"100",maxLength:15})}),t(x,{condition:!e.enabled,show:t(be,{color:"neutral",sx:{ml:1},children:"Disabled"})})]}),c(Zs,{children:[t(et,{label:"Add strategy",projectId:n,featureId:a,environmentId:e.name,variant:"text"}),t(zs,{strategies:d==null?void 0:d.strategies})]})]}),t(Ms,{environmentMetric:l,disabled:!e.enabled})]}),c(Gs,{enabled:e.enabled,children:[t(Ys,{featureEnvironment:d,isDisabled:!e.enabled,otherEnvironments:o==null?void 0:o.environments.map(({name:h})=>h).filter(h=>h!==e.name)}),t(x,{condition:(((p=d==null?void 0:d.strategies)==null?void 0:p.length)||0)>0,show:c(V,{children:[t(U,{sx:{display:"flex",justifyContent:"center",py:1},children:t(et,{label:"Add strategy",projectId:n,featureId:a,environmentId:e.name})}),t(Os,{environmentMetric:l})]})})]})]})})})},tr=()=>{const e=I("projectId"),n=I("featureId"),{feature:a}=z(e,n);if(!a)return null;const{environments:s}=a;return t(V,{children:s==null?void 0:s.map(o=>t(er,{env:o},o.name))})},nr=u("div")(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(3),fontSize:e.fontSizes.smallBody})),ar=u("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)})),or=({feature:e,header:n})=>{const{locationSettings:a}=aa();return c(nr,{children:[n,c("div",{"data-loading":!0,children:[t(ar,{children:"Created at:"}),t("span",{children:oa(sa(e.createdAt),a.locale)})]})]})},sr=u(Ae,{shouldForwardProp:e=>e!=="visibilityOff"})(({theme:e,visibilityOff:n})=>({marginLeft:"auto",marginRight:e.spacing(-1),color:n?e.palette.action.active:e.palette.action.focus,"&:hover":{color:e.palette.action.active}})),rr=({environment:e,hiddenEnvironments:n,setHiddenEnvironments:a})=>t(sr,{onClick:()=>{a(e.name)},visibilityOff:n.has(e.name),children:t(x,{condition:n.has(e.name),show:t(ra,{}),elseShow:t(ia,{})})}),ir=u("div")(({theme:e})=>({marginLeft:e.spacing(-1.5),"&:not(:last-of-type)":{marginBottom:e.spacing(2)},display:"flex",alignItems:"center"})),cr=u("label")(()=>({display:"inline-flex",alignItems:"center",cursor:"pointer"})),lr=({environment:e,callback:n,showInfoBox:a,children:s,hiddenEnvironments:o,setHiddenEnvironments:i})=>{const{name:r,enabled:l}=e,d=I("projectId"),p=I("featureId"),{feature:h,refetchFeature:g}=z(d,p),y=c(V,{children:[" ",c("span",{"data-loading":!0,children:[l?"enabled":"disabled"," in"]})," ",t(ct,{text:r,maxWidth:"120",maxLength:15})]}),b=()=>{g(),n&&n()};return c(ir,{children:[c(cr,{children:[t(ro,{featureId:h.name,projectId:d,environmentName:e.name,onToggle:b,onError:a,value:l}),s??y]}),t(rr,{environment:e,hiddenEnvironments:o,setHiddenEnvironments:i})]})},dr=u("div")(({theme:e})=>({padding:e.spacing(3)})),ur=u("div")(()=>({display:"flex",flexDirection:"column"})),pr=u("p")(({theme:e})=>({fontSize:e.fontSizes.bodySize})),gr=u("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,display:"flex",alignItems:"center"})),Pt=u("span")(({theme:e})=>({padding:e.spacing(0,.5),"::after":{content:'"-"'}})),hr=u(dt)(()=>({"&:hover, &:focus":{textDecoration:"underline"}})),mr=({feature:e,header:n,hiddenEnvironments:a,setHiddenEnvironments:s})=>{const[o,i]=f.useState(!1),[r,l]=f.useState(""),d=e.environments.some(p=>{var h;return p.enabled&&((h=p.variants)==null?void 0:h.length)});return c(dr,{"data-testid":"feature-toggle-status",children:[n,e.environments.map(p=>{const h=p.strategies.length===1?"1 strategy":`${p.strategies.length} strategies`,g=p.variants??[],y=g.length>0&&c(V,{children:[t(Pt,{}),t(K,{title:"View variants",arrow:!0,describeChild:!0,children:t(hr,{component:J,to:`/projects/${e.project}/features/${e.name}/variants`,underline:"hover",children:g.length===1?"1 variant":`${g.length} variants`})})]}),b=p.enabled&&g.length===0&&d;return t(lr,{environment:p,hiddenEnvironments:a,setHiddenEnvironments:s,showInfoBox:()=>{l(p.name),i(!0)},children:c(ur,{children:[t(pr,{children:p.name}),c(gr,{children:[h,y,t(x,{condition:b,show:c(V,{children:[t(Pt,{}),t(io,{})]})})]})]})},p.name)}),t(co,{open:o,onClose:()=>i(!1),projectId:e.project,featureId:e.name,environmentName:r})]})},pn=(e,n={})=>{const a=async()=>{const p=we(`api/admin/features/${e}/tags`);return(await fetch(p,{method:"GET"}).then(Oe("Tags"))).json()},s=`api/admin/features/${e}/tags`,{data:o,error:i}=ca(!!e,{tags:[]},s,a,n),[r,l]=f.useState(!i&&!o),d=()=>{at(s)};return f.useEffect(()=>{l(!i&&!o)},[o,i]),{tags:(o==null?void 0:o.tags)||[],error:i,loading:r,refetch:d}},fr=u("section")(({theme:e})=>({["& > *"]:{margin:e.spacing(1,0)}})),Ge=e=>e.map(n=>({title:n.value})),Ot=(e,n)=>e.map(a=>({value:a.title,type:n})),gn=({open:e,setOpen:n})=>{const{tagTypes:a}=la(),s=I("featureId"),{createTag:o}=lo(),{updateFeatureTags:i,loading:r}=_e(),{tags:l,refetch:d,loading:p}=pn(s),{setToastData:h}=q(),[g,y]=f.useState({name:"simple",description:"Simple tag to get you started",icon:""}),b=r||p,[T,E]=f.useState(0),{trackEvent:S}=Yt(),[C,w]=f.useState(Ge(l.filter(m=>m.type===g.name))),{tags:F,refetch:$}=uo(g.name),M=f.useMemo(()=>Ge(F),[F]);f.useEffect(()=>{l&&g&&w(Ge(l.filter(m=>m.type===g.name)))},[JSON.stringify(l),g]);const k=()=>{n(!1),w([])};function P(m,v){const D=m.filter(L=>L.type===g.name).filter(L=>!v.find(_=>L.value===_.value&&L.type===_.type)),W=v.filter(L=>L.type===g.name).filter(L=>!m.find(_=>L.value===_.value&&L.type===_.type));return E(D.length+W.length),{added:D,removed:W}}const O=m=>m.filter(v=>!v.title.startsWith("Create")),G=async(m,v)=>{try{await i(s,{addedTags:m,removedTags:v}),await d()}catch(D){const W=j(D);h({type:"error",title:"Failed to add tag",text:W,confetti:!1})}},Y=(m,v)=>{let D="We successfully";return m>0&&(D=D.concat(` added ${m} new tag${m>1?"s":""}`)),m>0&&v>0&&(D=D.concat(" and ")),v>0&&(D=D.concat(` removed ${v} tag${v>1?"s":""}`)),D},X=async m=>{m.preventDefault();const v=Ot(O(C),g.name),{added:D,removed:W}=P(v,l);T>0&&(await G(D,W),T>1&&S("suggest_tags",{props:{eventType:"multiple_tags_added"}}),T>0&&h({type:"success",title:`Updated tag${D.length>1?"s":""} to toggle`,text:Y(D.length,W.length),confetti:!0})),E(0),w([]),n(!1)},ne=(m,v)=>{v!=null&&typeof v!="string"&&(m.preventDefault(),y(v),w([]),E(0))},A=(m,v,D)=>{const W=da(v);D==="selectOption"&&v.forEach((_,Re)=>{if(typeof _!="string"&&_.inputValue&&_.inputValue!==""){const Ie={value:_.inputValue,type:g.name};o(Ie).then(()=>{S("suggest_tags",{props:{eventType:"tag_created"}}),$()}),_.title=_.inputValue,_.inputValue="",W[Re]=_}});const L=Ot(O(W),g.name);P(L,l),w(W)},B="add-tag-form";return t(ee,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update tags to feature toggle",onClick:X,disabledPrimaryButton:b||T===0,onClose:k,formId:B,children:c(V,{children:[t(N,{paragraph:!0,sx:{marginBottom:m=>m.spacing(2.5)},children:"Tags allow you to group features together"}),t("form",{id:B,onSubmit:X,children:c(fr,{children:[t(po,{options:a,value:g,onChange:ne}),t(go,{options:M,existingTags:l,tagType:g,selectedOptions:C,onChange:A})]})})]})})},yr=u("div")(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(3)})),Sr=u("div")(({theme:e})=>({display:"flex",gap:e.spacing(1),flexWrap:"wrap"})),br=u(Kt)(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Cr=u(Ce)(({theme:e})=>({margin:e.spacing(3),borderStyle:"dashed"})),vr=u(de)(({theme:e})=>({maxWidth:e.spacing(20),alignSelf:"center"})),wr=({feature:e,header:n})=>{const{tags:a,refetch:s}=pn(e.name),{deleteTagFromFeature:o}=_e(),[i,r]=f.useState(!1),[l,d]=f.useState(!1),[p,h]=f.useState(),{setToastData:g,setToastApiError:y}=q(),{hasAccess:b}=f.useContext(it),T=b(ge,e.project),E=async()=>{if(p)try{await o(e.name,p.type,p.value),s(),g({type:"success",title:"Tag deleted",text:"Successfully deleted tag"})}catch(S){y(j(S))}};return c(yr,{children:[n,t(Sr,{children:a.map(S=>{const C=`${S.type}:${S.value}`;return t(br,{label:C,deleteIcon:t(ua,{titleAccess:"Remove"}),onDelete:T?()=>{d(!0),h(S)}:void 0},C)})}),t(x,{condition:T,show:c(V,{children:[t(x,{condition:a.length>0,show:t(Cr,{})}),t(vr,{"data-loading":!0,variant:"outlined",startIcon:t(pa,{}),onClick:()=>r(!0),children:"Add new tag"})]})}),t(gn,{open:i,setOpen:r}),c(ee,{open:l,primaryButtonText:"Delete tag",secondaryButtonText:"Cancel",onClose:()=>{d(!1),h(void 0)},onClick:()=>{d(!1),E(),h(void 0)},title:"Delete tag?",children:["You are about to delete tag:"," ",c("strong",{children:[p==null?void 0:p.type,":",p==null?void 0:p.value]})]})]})},Tr=u("div")(({theme:e})=>({position:"sticky",top:e.spacing(2),borderRadius:e.shape.borderRadiusLarge,backgroundColor:e.palette.background.paper,display:"flex",flexDirection:"column",maxWidth:"350px",minWidth:"350px",marginRight:"1rem",marginTop:"1rem",[e.breakpoints.down(1e3)]:{marginBottom:"1rem",width:"100%",maxWidth:"none",minWidth:"auto"}})),Ye=u("h3")(({theme:e})=>({display:"flex",gap:e.spacing(1),alignItems:"center",fontSize:e.fontSizes.bodySize,margin:0,marginBottom:e.spacing(3),"& > :last-child":{position:"relative",top:1}})),xr=({hiddenEnvironments:e,setHiddenEnvironments:n})=>{const a=I("projectId"),s=I("featureId"),{feature:o}=z(a,s);return c(Tr,{children:[t(mr,{header:c(Ye,{"data-loading":!0,children:["Enabled in environments (",o.environments.filter(({enabled:i})=>i).length,")",t(Qe,{tooltip:"When a feature is switched off in an environment, it will always return false. When switched on, it will return true or false depending on its strategies.",placement:"top"})]}),feature:o,hiddenEnvironments:e,setHiddenEnvironments:n}),t(Ce,{}),t(or,{header:t(Ye,{"data-loading":!0,children:"Feature toggle details"}),feature:o}),t(Ce,{}),t(wr,{header:t(Ye,{"data-loading":!0,children:"Tags for this feature toggle"}),feature:o})]})},Ar=()=>{const{trackEvent:e}=Yt(),{value:n,setValue:a}=Gt(),[s,o]=f.useState(new Set(n.hiddenEnvironments));return{hiddenEnvironments:s,setHiddenEnvironments:r=>{a(l=>{const d=new Set(l.hiddenEnvironments);return d.has(r)?(d.delete(r),e("hidden_environment",{props:{eventType:"environment unhidden"}})):(d.add(r),e("hidden_environment",{props:{eventType:"environment hidden"}})),o(d),{...n,hiddenEnvironments:d}})}}},Er=u("div")(({theme:e})=>({display:"flex",width:"100%",[e.breakpoints.down(1e3)]:{flexDirection:"column"}})),Rr=u("div")(({theme:e})=>({display:"flex",flexDirection:"column",width:"calc(100% - (350px + 1rem))",[e.breakpoints.down(1e3)]:{width:"100%"}})),Ir=()=>{const e=le(),n=I("projectId"),a=I("featureId"),s=ot(n,a),{hiddenEnvironments:o,setHiddenEnvironments:i}=Ar(),r=()=>e(s);return Jt(a),c(Er,{children:[c("div",{children:[t(Po,{}),t(xr,{hiddenEnvironments:o,setHiddenEnvironments:i})]}),t(Rr,{children:t(tr,{})}),c(Xt,{children:[t(re,{path:"strategies/create",element:t(Ze,{label:"Create feature strategy",onClose:r,open:!0,children:t(ho,{})})}),t(re,{path:"strategies/edit",element:t(Ze,{label:"Edit feature strategy",onClose:r,open:!0,children:t(ga,{})})})]})]})},Dr=({values:e=[],updateValues:n,placeholder:a="",error:s,...o})=>{const i=l=>{const p=l.target.value.split(/,\s?/).map(h=>h.trim());n(p)},r=l=>{if(l.key==="Backspace"){const d=l.target.value;if(d.endsWith(", ")){l.preventDefault();const p=d.slice(0,-2);n(p.split(/,\s*/))}}};return t(Qt,{...o,error:s,placeholder:a,value:e?e.join(", "):"",onKeyDown:r,onChange:i,style:{width:"100%"},variant:"outlined",size:"small"})},Fr=u("div")(({theme:e})=>({display:"flex",alignItems:"center",rowGap:e.spacing(1.5),marginBottom:e.spacing(2),[e.breakpoints.down("sm")]:{flexDirection:"column","& > div, .MuiInputBase-root":{width:"100%",alignItems:"flex-start"}}})),kr=u(Zt)(({theme:e})=>({marginRight:e.spacing(10),[e.breakpoints.up("sm")]:{minWidth:e.spacing(20)}})),$r=u("div")(({theme:e})=>({width:"100%",gap:e.spacing(1.5),display:"flex"})),Br=u(Dr)(()=>({width:"100%"})),Pr=u(Qt)(()=>({width:"100%"})),Or=({overrides:e,overridesDispatch:n})=>{const{context:a}=ut(),s=a.map(({name:r})=>({key:r,label:r})),o=r=>l=>{n({type:"UPDATE_VALUES_AT",payload:[r,l]})},i=r=>(l,d)=>{l==null||l.preventDefault(),n({type:"UPDATE_VALUES_AT",payload:[r,d||[]]})};return t(V,{children:e.map((r,l)=>{var g;const d=a.find(({name:y})=>y===r.contextName),p=((g=d==null?void 0:d.legalValues)==null?void 0:g.map(({value:y})=>y))||[],h=r.values.filter(y=>p.includes(y));return c(Fr,{children:[t(kr,{id:"override-context-name",name:"contextName",label:"Context Field","data-testid":"context_field",value:r.contextName,options:s,onChange:y=>n({type:"UPDATE_TYPE_AT",payload:[l,y.target.value]})}),c($r,{children:[t(x,{condition:!!(p&&p.length>0),show:t(ha,{multiple:!0,id:`override-select-${l}`,isOptionEqualToValue:(y,b)=>y===b,options:p,onChange:i(l),getOptionLabel:y=>y,value:h,style:{width:"100%"},filterSelectedOptions:!0,size:"small",renderInput:y=>t(Pr,{...y,variant:"outlined",label:"Legal values"})}),elseShow:t(Br,{label:"Values (v1, v2, ...)",name:"values",placeholder:"",values:r.values,updateValues:o(l),"data-testid":"OVERRIDE_VALUES"})}),t(K,{title:"Remove",arrow:!0,children:t(Ae,{onClick:y=>{y.preventDefault(),n({type:"REMOVE",payload:l})},children:t(st,{})})})]})]},`override=${l}`)})})},Vr=(e,n)=>{switch(n.type){case"SET":return n.payload;case"CLEAR":return[];case"ADD":return[...e,n.payload];case"REMOVE":return e.filter((r,l)=>l!==n.payload);case"UPDATE_VALUES_AT":const[a,s]=n.payload;return e.map((r,l)=>l===a?{...r,values:s}:r);case"UPDATE_TYPE_AT":const[o,i]=n.payload;return e.map((r,l)=>l===o?{...r,contextName:i}:r)}},_r=(e=[])=>f.useReducer(Vr,e);var Q=(e=>(e.FIX="fix",e.VARIABLE="variable",e))(Q||{});const Mr=u("div")(({theme:e})=>({position:"relative",backgroundColor:e.palette.neutral.light,display:"flex",flexDirection:"column",padding:e.spacing(3),marginBottom:e.spacing(3),borderRadius:e.shape.borderRadiusLarge})),Lr=u(K)(({theme:e})=>({position:"absolute",top:e.spacing(2),right:e.spacing(2)})),hn=u("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Vt=u(hn)(({theme:e})=>({display:"flex",color:e.palette.text.primary,marginTop:e.spacing(1),marginBottom:e.spacing(2)})),Nr=u("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(2)})),zr=u(ma)(({theme:e})=>({marginBottom:e.spacing(1),"& > span":{fontSize:e.fontSizes.smallBody},[e.breakpoints.down("sm")]:{marginTop:e.spacing(1),marginBottom:e.spacing(1.5)}})),jr=u("div")(({theme:e})=>({width:"100%",gap:e.spacing(1.5),display:"flex","& > div":{width:"100%"}})),_t=u(en)(()=>({width:"100%"})),Wr=u("div")(({theme:e})=>({marginLeft:e.spacing(3)})),qr=u(en)(({theme:e})=>({width:e.spacing(24),[e.breakpoints.down("sm")]:{width:"100%"}})),Hr=u("div")(({theme:e})=>({marginTop:e.spacing(3),flexGrow:1})),mn=u("div")(({theme:e})=>({display:"flex",rowGap:e.spacing(1.5),marginBottom:e.spacing(2),[e.breakpoints.down("sm")]:{flexDirection:"column","& > div, .MuiInputBase-root":{width:"100%"}}})),Ur=u(mn)({alignItems:"end",justifyContent:"space-between"}),Gr=u(Zt)(({theme:e})=>({marginRight:e.spacing(10),[e.breakpoints.up("sm")]:{minWidth:e.spacing(20)}})),Yr=u(de)(({theme:e})=>({marginTop:e.spacing(-1),marginLeft:e.spacing(-1)})),Kr=[{key:"string",label:"string"},{key:"json",label:"json"},{key:"csv",label:"csv"}],Jr={type:"string",value:""},Xr=({variant:e,variants:n,updateVariant:a,removeVariant:s,apiPayload:o})=>{const[i,r]=f.useState(e.name),[l,d]=f.useState(e.weightType===Q.FIX),[p,h]=f.useState(String(e.weight/10)),[g,y]=f.useState(e.payload||Jr),[b,T]=_r(e.overrides||[]),{context:E}=ut(),[S,C]=f.useState({}),w=m=>{C(v=>({...v,[m]:void 0}))},F=(m,v)=>{C(D=>({...D,[m]:v}))};f.useEffect(()=>{var m;w("percentage"),(m=o.error)!=null&&m.includes("%")&&F("percentage","Total weight must equal 100%")},[o.error]);const $=!e.new,M=n.filter(({id:m,weightType:v})=>m!==e.id&&v===Q.VARIABLE).length>0,k=m=>{const v=m.weightType===Q.VARIABLE,D=n.some(L=>L.weightType===Q.FIX),W=n.filter(L=>L.weightType===Q.VARIABLE).length===1;return D&&W&&v},P=m=>{w("name"),ne(m,e.id)||F("name","A variant with that name already exists for this environment."),r(m.trim())},O=m=>{(m===""||A(m))&&h(m)},G=m=>{B(m)||F("payload","Invalid JSON.")},Y=()=>{E.length>0&&T({type:"ADD",payload:{contextName:E[0].name,values:[]}})},X=m=>!!m.length,ne=(m,v)=>$||!n.some(D=>D.name===m&&D.id!==v),A=m=>{if(!l)return!0;if(m===""||m.match(/\.[0-9]{2,}$/))return!1;const v=Number(m);return v>=0&&v<=100},B=m=>{try{return m.type==="json"&&JSON.parse(m.value),!0}catch{return!1}};return f.useEffect(()=>{a({...e,name:i,weight:Number(l?p:100)*10,weightType:l?Q.FIX:Q.VARIABLE,stickiness:(n==null?void 0:n.length)>0?n[0].stickiness:"default",payload:g.value?g:void 0,overrides:b.map(m=>({contextName:m.contextName,values:m.values})).filter(m=>m.values&&m.values.length>0),isValid:X(i)&&ne(i,e.id)&&A(p)&&B(g)&&!o.error})},[i,l,p,g,b]),f.useEffect(()=>{l||h(String(e.weight/10))},[e.weight]),c(Mr,{"data-testid":"VARIANT",children:[t(Lr,{arrow:!0,title:k(e)?"You need to have at least one variable variant":"Delete variant",children:t("div",{children:t(Ae,{"data-testid":`VARIANT_DELETE_BUTTON_${e.name}`,onClick:()=>s(e.id),disabled:k(e),children:t(st,{})})})}),c(Ur,{children:[c(Hr,{children:[t(hn,{children:"Variant name"}),t(Nr,{children:"This will be used to identify the variant in your code"}),t(_t,{id:`variant-name-input-${e.id}`,"data-testid":"VARIANT_NAME_INPUT",label:"Variant name",error:!!S.name,errorText:S.name,value:i,onChange:m=>P(m.target.value),disabled:$,required:!0})]}),t(x,{condition:M,show:c(Wr,{children:[t(zr,{label:"Custom percentage",control:t(fa,{"data-testid":"VARIANT_WEIGHT_CHECK",checked:l,onChange:m=>d(m.target.checked)})}),t(qr,{"data-testid":"VARIANT_WEIGHT_INPUT",type:"number",label:"Variant weight",error:!!S.percentage,errorText:S.percentage,value:p,onChange:m=>O(m.target.value),required:l,disabled:!l,"aria-valuemin":0,"aria-valuemax":100,InputProps:{endAdornment:t(ya,{position:"end",children:"%"})}})]})})]}),c(Vt,{children:["Payload",t(Qe,{tooltip:"Passed along with the the variant object."})]}),c(mn,{children:[t(Gr,{id:"variant-payload-type",name:"type",label:"Type",value:g.type,options:Kr,onChange:m=>{w("payload"),y(v=>({...v,type:m.target.value}))}}),t(jr,{children:t(_t,{id:"variant-payload-value",name:"variant-payload-value",label:"Value",multiline:g.type!=="string",rows:g.type==="string"?1:4,value:g.value,onChange:m=>{w("payload"),y(v=>({...v,value:m.target.value}))},placeholder:g.type==="json"?'{ "hello": "world" }':"",onBlur:()=>G(g),error:!!S.payload,errorText:S.payload})})]}),c(Vt,{children:["Overrides",t(Qe,{tooltip:"Here you can specify which users should get this variant."})]}),t(Or,{overrides:b,overridesDispatch:T}),t("div",{children:t(Yr,{onClick:Y,variant:"text",color:"primary","data-testid":"VARIANT_ADD_OVERRIDE_BUTTON",children:"Add override"})})]})},Qr=u("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"},marginTop:e.spacing(-3.5),marginBottom:e.spacing(2),backgroundColor:e.palette.background.default,paddingTop:e.spacing(2),paddingBottom:e.spacing(2),position:"sticky",top:0,zIndex:2})),Zr=u(tn,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.neutral.border:e.palette.primary.main})),ei=u("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontSize:e.fontSizes.mainHeader,fontWeight:e.fontWeight.bold})),ti=u("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),ni=u(se)(({theme:e})=>({marginBottom:e.spacing(2)})),ai=u(se)(({theme:e})=>({marginTop:e.spacing(4)})),oi=u("div")({display:"flex",flexDirection:"column"}),si=u("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),Mt=u("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),ri=u(Ce)(({theme:e})=>({margin:e.spacing(4,0)})),ii=u(Sa)(({theme:e})=>({minWidth:e.spacing(20),width:"100%"})),ci=u("div")(({theme:e})=>({marginTop:"auto",paddingTop:e.spacing(4),display:"flex",justifyContent:"flex-end"})),li=u(de)(({theme:e})=>({marginLeft:e.spacing(3)})),di=({environment:e,open:n,setOpen:a,getApiPayload:s,getCrPayload:o,onConfirm:i})=>{const r=I("projectId"),l=I("featureId"),{uiConfig:d}=rt(),{context:p}=ut(),{defaultStickiness:h,loading:g}=ba(r),{isChangeRequestConfigured:y}=te(r),{data:b}=ie(r),{changeRequestInReviewOrApproved:T,alert:E}=wa(b),S=(e==null?void 0:e.variants)||[],[C,w]=f.useState([]),[F,$]=f.useState();f.useEffect(()=>{g||w(S.length?S.map(R=>({...R,isValid:!0,new:!1,id:ze()})):[{name:"",weightType:Q.VARIABLE,weight:0,overrides:[],stickiness:(C==null?void 0:C.length)>0?C[0].stickiness:h,new:!0,isValid:!1,id:ze()}])},[n,g]);const M=(R,H)=>{w(ue=>bt(ue.map(De=>De.id===H?R:De),1e3))},k=()=>{const R=ze();w(H=>[...H,{name:"",weightType:Q.VARIABLE,weight:0,overrides:[],stickiness:(H==null?void 0:H.length)>0?H[0].stickiness:h,new:!0,isValid:!1,id:R}]),$(R)};f.useEffect(()=>{if(F){const R=document.getElementById(`variant-name-input-${F}`);R==null||R.scrollIntoView({behavior:"smooth",block:"center"}),R==null||R.focus({preventScroll:!0}),$(void 0)}},[F]);const P=C.map(({new:R,isValid:H,id:ue,...De})=>De),O=s(S,P),G=o(P),Y=async R=>{R.preventDefault(),i(P)},X=()=>m?`curl --location --request POST '${d.unleashUrl}/api/admin/projects/${r}/environments/${e==null?void 0:e.name}/change-requests' \\
1
+ import{ay as yn,az as Sn,s as u,r as f,aA as bn,aB as Cn,aC as yt,j as t,aD as vn,aE as wn,c as qt,aF as I,aG as z,aH as Tn,f as c,aI as xn,C as x,aJ as Z,aK as ge,aL as J,aM as ye,aN as An,aO as nt,aP as we,aQ as Oe,aR as at,aS as En,aT as Rn,aU as In,aV as Dn,a2 as q,aW as Te,aX as ie,a4 as j,T as N,aY as xe,aZ as ce,a_ as Fn,a$ as te,b0 as he,b1 as K,m as Ae,b2 as kn,b3 as $n,b4 as Ee,a8 as me,b5 as ke,b6 as Ht,b7 as Se,b8 as ee,ao as le,A as se,b9 as ot,ba as Bn,bb as Pn,bc as On,bd as Vn,be as Je,F as V,a as U,bf as _n,bg as Mn,bh as Ln,bi as Nn,bj as Xe,bk as St,bl as st,bm as oe,H as rt,bn as zn,bo as jn,bp as Wn,p as qn,u as Ut,N as Ve,B as be,bq as it,a9 as de,br as Hn,x as ct,bs as $e,E as Un,bt as lt,bu as Be,P as Gn,bv as Yn,bw as ae,bx as Kn,by as Jn,D as Xn,bz as Qn,bA as Zn,bB as ea,bC as Gt,bD as ta,bE as na,bF as aa,bG as oa,bH as sa,bI as ra,bJ as ia,bK as dt,bL as ca,bM as la,bN as _e,ap as Yt,bO as da,w as Kt,af as Ce,bP as ua,bQ as pa,bR as Qe,bS as Jt,bT as Xt,bU as re,bV as Ze,bW as ga,ac as Qt,bX as Zt,a3 as ut,ad as ha,bY as ma,bZ as en,b_ as fa,b$ as ya,c0 as tn,c1 as Sa,c2 as ba,am as Ca,as as va,c3 as pe,c4 as bt,c5 as wa,c6 as Ta,c7 as xa,ak as pt,al as Aa,V as Ct,c8 as Ea,c9 as Ra,ca as Ia,cb as Da,d as Ne,l as Fa,U as ka,g as $a,S as Ba,h as Pa,i as Oa,k as Va,I as _a,cc as Ma,cd as La,ce as vt,cf as Na,cg as nn,ch as za,ae as ja,ci as wt,cj as Wa,ck as qa,cl as Ha,cm as Ua,cn as Ga,co as Ya,M as Ka,cp as Ja,cq as Xa,cr as Qa,cs as Za,ct as eo,cu as to}from"./index-1f392976.js";import{C as gt,U as no,D as ao,f as oo,E as so,F as ro,V as io,a as co,u as lo,b as uo,T as po,c as go,d as ho,W as mo,e as fo,g as yo}from"./FeatureArchiveDialog-c311c641.js";import{S as So}from"./StrategyItemContainer-0140b94f.js";import{v as ze}from"./v4-a960c1f4.js";function bo(e){return yn("MuiCardContent",e)}Sn("MuiCardContent",["root"]);const Co=["className","component"],vo=e=>{const{classes:n}=e;return wn({root:["root"]},bo,n)},wo=u("div",{name:"MuiCardContent",slot:"Root",overridesResolver:(e,n)=>n.root})(()=>({padding:16,"&:last-child":{paddingBottom:24}})),To=f.forwardRef(function(n,a){const s=bn({props:n,name:"MuiCardContent"}),{className:o,component:i="div"}=s,r=Cn(s,Co),l=yt({},s,{component:i}),d=vo(l);return t(wo,yt({as:i,className:vn(d.root,o),ownerState:l,ref:a},r))}),xo=To,Ao=qt(t("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"),Eo=qt(t("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z"}),"Assessment"),Ro=u("div")(({theme:e})=>({borderRadius:e.spacing(1.5),backgroundColor:e.palette.background.paper,padding:e.spacing(4)})),Io=()=>{const e=I("projectId"),n=I("featureId"),{feature:a}=z(e,n);return a.name?t(Ro,{children:t(Tn,{title:"Event log",feature:n,displayInline:!0})}):null},Do=u("div")(({theme:e})=>({borderRadius:e.shape.borderRadiusLarge,color:e.palette.primary.contrastText,backgroundColor:e.palette.background.alternative,display:"flex",flexDirection:"column",maxWidth:"350px",minWidth:"350px",marginRight:e.spacing(2),[e.breakpoints.down(1e3)]:{width:"100%",maxWidth:"none",minWidth:"auto"}})),Fo=u("div")({padding:"1.5rem 1.5rem 0 1.5rem"}),ko=u("div")({display:"flex",alignItems:"center"}),$o=u("h2")(({theme:e})=>({fontSize:e.fontSizes.bodySize,fontWeight:"normal",margin:0})),Bo=u("div")(({theme:e})=>({margin:e.spacing(2,0),display:"flex",flexDirection:"column"})),Tt=u("span")(({theme:e})=>({margin:e.spacing(1,0),fontSize:e.fontSizes.bodySize,wordBreak:"break-all"})),xt=u("div")(({theme:e})=>({display:"flex",alignItems:"center",color:e.palette.primary.contrastText})),Po=()=>{const e=I("projectId"),n=I("featureId"),{feature:a}=z(e,n),{project:s,description:o,type:i}=a,r=An(i);return t(Do,{children:c(Fo,{children:[c(ko,{"data-loading":!0,children:[t(r,{sx:l=>({marginRight:l.spacing(2),height:"40px",width:"40px",fill:l.palette.primary.contrastText})})," ",c($o,{children:[xn(i||"")," toggle"]})]}),c(Bo,{children:[c(Tt,{"data-loading":!0,children:["Project: ",s]}),t(x,{condition:!!o,show:c(Tt,{"data-loading":!0,children:[t("div",{children:"Description:"}),c(xt,{children:[t("p",{children:o}),t(Z,{projectId:e,permission:ge,component:J,to:`/projects/${e}/features/${n}/settings`,tooltipProps:{title:"Edit description"},children:t(ye,{sx:l=>({color:l.palette.primary.contrastText})})})]})]}),elseShow:t("span",{"data-loading":!0,children:c(xt,{children:["No description."," ",t(Z,{projectId:e,permission:ge,component:J,to:`/projects/${e}/features/${n}/settings`,tooltipProps:{title:"Edit description"},children:t(ye,{sx:l=>({color:l.palette.primary.contrastText})})})]})})})]})]})})},At={lastHourUsage:[],seenApplications:[]},Oo=(e,n,a={})=>{const s=async()=>{const h=we(`api/admin/client-metrics/features/${n}`),g=await fetch(h,{method:"GET"}).then(Oe("feature metrics"));return g.ok?g.json():At},o=`${e}_${n}_metrics`,{data:i,error:r}=nt(o,s,{...a}),[l,d]=f.useState(!r&&!i),p=()=>{at(o)};return f.useEffect(()=>{d(!r&&!i)},[i,r]),{metrics:i||At,error:r,loading:l,refetch:p,FEATURE_METRICS_CACHE_KEY:o}},Vo=e=>({yes:0,no:0,environment:e,timestamp:""}),_o=(e,n)=>e.map(a=>n.lastHourUsage.find(o=>o.environment===a.name)||Vo(a.name)),Mo=e=>(n,a,s)=>(s.revalidateOnFocus=!1,s.revalidateIfStale=!1,s.revalidateOnReconnect=!1,e(n,a,s)),Lo=En(nt,Mo),an=(e,n)=>{const{refetchFeature:a}=z(e,n),s=Rn(e,n),{data:o,error:i,mutate:r}=Lo(["useFeatureImmutable",s],()=>In(s)),l=f.useCallback(async()=>{await r(),await a()},[r,a]);return{feature:(o==null?void 0:o.body)||Dn,refetchFeature:l,loading:!i&&!o,status:o==null?void 0:o.status,error:i}},ht=(e,n,a)=>{const{setToastData:s,setToastApiError:o}=q(),{addChange:i}=Te(),{refetch:r}=ie(e),[l,d]=f.useState({isOpen:!1}),p=f.useCallback((T,E,S)=>{d({featureName:n,environment:T,fromEnvironment:S,strategy:E,isOpen:!0})},[]),h=f.useCallback((T,E,S)=>{d({featureName:n,environment:T,fromEnvironment:S,strategies:E,isOpen:!0})},[]),g=f.useCallback(()=>{d({isOpen:!1})},[]),y=f.useCallback(async()=>{try{await i(e,l.environment,{feature:l.featureName,action:a,payload:l.strategy}),r(),d({isOpen:!1}),s({type:"success",title:"Changes added to the draft!"})}catch(T){o(j(T)),d({isOpen:!1})}},[i]),b=f.useCallback(async()=>{try{await Promise.all(l.strategies.map(T=>i(e,l.environment,{feature:l.featureName,action:a,payload:T}))),r(),d({isOpen:!1}),s({type:"success",title:"Changes added to the draft!"})}catch(T){o(j(T)),d({isOpen:!1})}},[i]);return{onChangeRequestAddStrategy:p,onChangeRequestAddStrategies:h,onChangeRequestAddStrategyClose:g,onChangeRequestAddStrategyConfirm:y,onChangeRequestAddStrategiesConfirm:b,changeRequestDialogDetails:l}},No=({payload:e,fromEnvironment:n,environment:a})=>c(N,{children:[c("strong",{children:["Copy ",xe((e==null?void 0:e.name)||"")," strategy"," "]})," ","from ",n," to ",a]}),zo=({environmentId:e,environments:n,strategy:a})=>{const s=I("projectId"),o=I("featureId"),[i,r]=f.useState(null),l=!!i,{addStrategyToFeature:d}=ce(),{setToastData:p,setToastApiError:h}=q(),{refetchFeature:g}=z(s,o),{refetchFeature:y}=an(s,o),b=()=>{r(null)},T=Fn(s),{isChangeRequestConfigured:E}=te(s),{changeRequestDialogDetails:S,onChangeRequestAddStrategyClose:C,onChangeRequestAddStrategy:w,onChangeRequestAddStrategyConfirm:F}=ht(s,o,"addStrategy"),$=async k=>{const{id:P,...O}={...a,targetEnvironment:k};if(E(k)){await w(k,{id:P,...O},e);return}try{await d(s,o,k,a),g(),y(),p({title:"Strategy created",text:`Successfully copied a strategy to ${k}`,type:"success"})}catch(G){h(j(G))}b()},M=n.some(k=>T(he,k));return c("div",{children:[t(gt,{isOpen:S.isOpen,onClose:C,environment:S==null?void 0:S.environment,onConfirm:F,messageComponent:t(No,{fromEnvironment:S.fromEnvironment,payload:S.strategy})}),t(K,{title:`Copy to another environment${M?"":" (Access denied)"}`,children:t("div",{children:t(Ae,{size:"large",id:`copy-strategy-icon-menu-${a.id}`,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,onClick:k=>{r(k.currentTarget)},"data-testid":kn,disabled:!M,children:t($n,{})})})}),t(Ee,{id:"basic-menu",anchorEl:i,open:l,onClose:b,MenuListProps:{"aria-labelledby":`copy-strategy-icon-menu-${a.id}`},children:n.map(k=>{const P=T(he,k);return t(K,{title:P?"":"You don't have access to add a strategy to this environment",children:t("div",{children:c(me,{onClick:()=>$(k),disabled:!P,children:[t(x,{condition:!P,show:t(ke,{children:t(Ht,{fontSize:"small"})})}),c(Se,{children:["Copy to ",k]})]})})},k)})})]})},on=()=>t(se,{severity:"error",children:"Removing the strategy will change which users receive access to the feature."}),jo=({onRemove:e,onClose:n,isOpen:a})=>t(ee,{title:"Are you sure you want to delete this strategy?",open:a,primaryButtonText:"Remove strategy",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:t(on,{})}),Wo=u("div")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1)})),qo=({onRemove:e,onClose:n,isOpen:a})=>c(ee,{title:"Suggest changes",open:a,primaryButtonText:"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:[t(on,{}),t(Wo,{children:t(N,{variant:"body2",color:"text.secondary",children:"Your suggestion:"})}),t(N,{fontWeight:"bold",children:"Remove strategy"})]}),Ho=({projectId:e,featureId:n,environmentId:a,strategyId:s})=>{const{deleteStrategyFromFeature:o}=ce(),{setToastData:i,setToastApiError:r}=q(),l=le(),{refetchFeature:d}=z(e,n);return async h=>{try{h.preventDefault(),await o(e,n,a,s),i({title:"Strategy deleted",type:"success"}),d(),l(ot(e,n))}catch(g){r(j(g))}}},Uo=({projectId:e,featureId:n,environmentId:a,strategyId:s})=>{const{addChange:o}=Te(),{refetch:i}=ie(e),{setToastData:r,setToastApiError:l}=q();return async p=>{try{p.preventDefault(),await o(e,a,{action:"deleteStrategy",feature:n,payload:{id:s}}),r({title:"Changes added to the draft!",type:"success"}),await i()}catch(h){l(j(h))}}},Go=({projectId:e,featureId:n,environmentId:a,strategyId:s,text:o,isOpen:i,onClose:r})=>{const{isChangeRequestConfigured:l}=te(e),d=Ho({featureId:n,projectId:e,strategyId:s,environmentId:a}),p=Uo({featureId:n,projectId:e,strategyId:s,environmentId:a});return l(a)?t(qo,{isOpen:i,onClose:()=>r(),onRemove:async h=>{await p(h),r()}}):t(jo,{isOpen:i,onClose:()=>r(),onRemove:d})},Yo=({projectId:e,environmentId:n,featureId:a,strategy:s})=>{const{refetchFeature:o}=z(e,a),{setStrategyDisabledState:i}=ce(),{setToastData:r,setToastApiError:l}=q(),d=p=>async()=>{try{await i(e,a,n,s.id,!p),r({title:`Strategy ${p?"enabled":"disabled"}`,type:"success"}),o()}catch(h){l(j(h))}};return{onDisable:d(!1),onEnable:d(!0)}},Ko=({projectId:e,environmentId:n,featureId:a,strategy:s})=>{const{addChange:o}=Te(),{refetch:i}=ie(e),{setToastData:r,setToastApiError:l}=q(),d=p=>async()=>{try{await o(e,n,{action:"updateStrategy",feature:a,payload:{...s,disabled:!p}}),r({title:"Changes added to the draft!",type:"success"}),await i()}catch(h){l(j(h))}};return{onSuggestDisable:d(!1),onSuggestEnable:d(!0)}},Jo=({isOpen:e,onClose:n,...a})=>{var b;const{projectId:s,environmentId:o}=a,{isChangeRequestConfigured:i}=te(s),r=i(o),{onSuggestEnable:l,onSuggestDisable:d}=Ko({...a}),{onEnable:p,onDisable:h}=Yo({...a}),g=!!((b=a.strategy)!=null&&b.disabled);return t(ee,{title:r?`Add ${g?"enable":"disable"} strategy to change request?`:`Are you sure you want to ${g?"enable":"disable"} this strategy?`,open:e,primaryButtonText:r?"Add to draft":`${g?"Enable":"Disable"} strategy`,secondaryButtonText:"Cancel",onClick:T=>{T.preventDefault(),r?g?l():d():g?p():h(),n()},onClose:()=>n(),children:t(x,{condition:r,show:t(Bn,{environment:o}),elseShow:c(se,{severity:"error",children:[g?"Enabling":"Disabling"," the strategy will change which users receive access to the feature."]})})})};var mt={},Xo=On;Object.defineProperty(mt,"__esModule",{value:!0});var sn=mt.default=void 0,Qo=Xo(Pn()),Zo=Vn,es=(0,Qo.default)((0,Zo.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"}),"Delete");sn=mt.default=es;const ts=({projectId:e,strategy:n,featureId:a,environmentId:s})=>{const[o,i]=f.useState(null),[r,l]=f.useState(!1),[d,p]=f.useState(!1),h=!!o,g=E=>{i(E.currentTarget)},y=E=>{i(null),E.stopPropagation()},b=Je(no,e,s),T=Je(ao,e,s);return c(V,{children:[t(U,{sx:{display:"flex",alignItems:"center",textAlign:"center"},children:t(K,{title:"More actions",children:t(Ae,{onClick:g,size:"small","aria-controls":h?"actions-menu":void 0,"aria-haspopup":"true","aria-expanded":h?"true":void 0,"data-testid":_n,children:t(Mn,{sx:{width:32,height:32}})})})}),c(Ee,{anchorEl:o,id:"actions-menu",open:h,onClose:y,onClick:y,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},children:[t(K,{title:n.disabled?"Enable strategy":"Disable strategy",arrow:!0,placement:"left",children:c(me,{disabled:!b,onClick:()=>l(!0),children:[t(ke,{children:n.disabled?t(Ln,{}):t(Nn,{})}),t(Se,{children:n.disabled?"Enable":"Disable"})]})}),t(K,{title:"Remove strategy",arrow:!0,placement:"left",children:c(me,{disabled:!T,onClick:()=>p(!0),"data-testid":Xe,children:[t(ke,{children:t(sn,{})}),t(Se,{children:"Remove"})]})})]}),t(Jo,{isOpen:r,onClose:()=>l(!1),projectId:e,featureId:a,environmentId:s,strategy:n}),t(Go,{isOpen:d,onClose:()=>p(!1),projectId:e,featureId:a,environmentId:s,strategyId:n.id})]})},rn=()=>t(se,{severity:"error",children:"Removing the strategy will change which users receive access to the feature."}),ns=({onRemove:e,onClose:n,isOpen:a})=>t(ee,{title:"Are you sure you want to delete this strategy?",open:a,primaryButtonText:"Remove strategy",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:t(rn,{})}),as=u("div")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1)})),os=({onRemove:e,onClose:n,isOpen:a})=>c(ee,{title:"Suggest changes",open:a,primaryButtonText:"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:[t(rn,{}),t(as,{children:t(N,{variant:"body2",color:"text.secondary",children:"Your suggestion:"})}),t(N,{fontWeight:"bold",children:"Remove strategy"})]}),ss=({projectId:e,featureId:n,environmentId:a,strategyId:s})=>{const{deleteStrategyFromFeature:o}=ce(),{setToastData:i,setToastApiError:r}=q(),l=le(),{refetchFeature:d}=z(e,n);return async h=>{try{h.preventDefault(),await o(e,n,a,s),i({title:"Strategy deleted",type:"success"}),d(),l(ot(e,n))}catch(g){r(j(g))}}},rs=({projectId:e,featureId:n,environmentId:a,strategyId:s})=>{const{addChange:o}=Te(),{refetch:i}=ie(e),{setToastData:r,setToastApiError:l}=q();return async p=>{try{p.preventDefault(),await o(e,a,{action:"deleteStrategy",feature:n,payload:{id:s}}),r({title:"Changes added to the draft!",type:"success"}),await i()}catch(h){l(j(h))}}},is=({projectId:e,featureId:n,environmentId:a,strategyId:s,disabled:o,icon:i,text:r})=>{const[l,d]=f.useState(!1),{isChangeRequestConfigured:p}=te(e),h=ss({featureId:n,projectId:e,strategyId:s,environmentId:a}),g=rs({featureId:n,projectId:e,strategyId:s,environmentId:a});return c(V,{children:[t(x,{condition:!!i,show:c(Z,{onClick:()=>d(!0),projectId:e,environmentId:a,disabled:o,permission:St,"data-testid":Xe,tooltipProps:{title:"Remove strategy"},type:"button",children:[t(st,{}),t(x,{condition:!!r,show:t(N,{variant:"body1",color:"text.secondary",sx:{ml:y=>y.spacing(1)},children:"Remove"})})]}),elseShow:t(oe,{onClick:()=>d(!0),projectId:e,environmentId:a,disabled:o,permission:St,"data-testid":Xe,color:"secondary",variant:"text",type:"button",children:"Remove strategy"})}),t(x,{condition:p(a),show:t(os,{isOpen:l,onClose:()=>d(!1),onRemove:async y=>{await g(y),d(!1)}}),elseShow:t(ns,{isOpen:l,onClose:()=>d(!1),onRemove:h})})]})},cs=({environmentId:e,strategy:n,onDragStart:a,onDragEnd:s,otherEnvironments:o,orderNumber:i,headerChildren:r})=>{var g;const{uiConfig:l}=rt(),d=I("projectId"),p=I("featureId"),h=zn(d,p,e,n.id);return t(So,{strategy:n,onDragStart:a,onDragEnd:s,orderNumber:i,actions:c(V,{children:[r,t(x,{condition:!!(o&&(o==null?void 0:o.length)>0),show:()=>t(zo,{environmentId:e,environments:o,strategy:n})}),t(Z,{permission:jn,environmentId:e,projectId:d,component:J,to:h,tooltipProps:{title:"Edit strategy"},"data-testid":`STRATEGY_EDIT-${n.name}`,children:t(ye,{})}),t(x,{condition:!!((g=l==null?void 0:l.flags)!=null&&g.strategyImprovements),show:()=>t(ts,{projectId:d,featureId:p,environmentId:e,strategy:n}),elseShow:()=>t(is,{projectId:d,featureId:p,environmentId:e,strategyId:n.id,icon:!0})})]}),children:t(Wn,{strategy:n})})},ls=(e,n,a,s)=>{const{data:o}=ie(e),i=o==null?void 0:o.find(d=>d.environment===a),r=i==null?void 0:i.features.find(d=>d.name===n);return r==null?void 0:r.changes.find(d=>d.action==="updateStrategy"||d.action==="deleteStrategy"?d.payload.id===s:!1)},ds=({strategy:e,index:n,environmentName:a,otherEnvironments:s,isDragging:o,onDragStartRef:i,onDragOver:r,onDragEnd:l})=>{const d=I("projectId"),p=I("featureId"),h=f.useRef(null),g=ls(d,p,a,e.id);return c(U,{ref:h,onDragOver:r(h,n),sx:{opacity:o?"0.5":"1"},children:[t(x,{condition:n>0,show:t(qn,{text:"OR"})}),t(cs,{strategy:e,environmentId:a,otherEnvironments:s,onDragStart:i(h,n),onDragEnd:l,orderNumber:n+1,headerChildren:t(us,{change:g})})]},e.id)},us=({change:e})=>{const n=Ut();return Ve(n.breakpoints.down("sm"))?null:c(U,{sx:{mr:1.5},children:[t(x,{condition:(e==null?void 0:e.action)==="updateStrategy",show:t(be,{color:"warning",children:"Modified in draft"})}),t(x,{condition:(e==null?void 0:e.action)==="deleteStrategy",show:t(be,{color:"error",children:"Deleted in draft"})})]})},ps=u("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",margin:"1rem 0",position:"relative","&:before":{content:'""',position:"absolute",top:"50%",transform:"translateY(-50%)",height:2,width:"100%",backgroundColor:e.palette.divider}})),gs=u("span")(({theme:e})=>({fontSize:e.fontSizes.bodySize,textAlign:"center",padding:"0 1rem",background:e.palette.envAccordion.expanded,position:"relative",maxWidth:"80%",color:e.palette.text.primary})),cn=({children:e})=>t(ps,{children:t(gs,{children:e})}),hs=({environmentId:e,environments:n,onClick:a})=>{const s=I("projectId"),[o,i]=f.useState(null),r=!!o,{hasAccess:l}=f.useContext(it),d=n.some(p=>l(he,s,p));return c("div",{children:[t(K,{title:d?"":"(Access denied)",children:t("div",{children:t(de,{id:`copy-all-strategies-${e}`,"aria-controls":r?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":r?"true":void 0,onClick:p=>{i(p.currentTarget)},disabled:!d,variant:"outlined",children:"Copy from another environment"})})}),t(Ee,{id:"basic-menu",anchorEl:o,open:r,onClose:()=>{i(null)},MenuListProps:{"aria-labelledby":`copy-all-strategies-${e}`},children:n.map(p=>{const h=l(he,s,p);return t(K,{title:h?"":"You don't have access to add a strategy to this environment",children:t("div",{children:c(me,{onClick:()=>a(p),disabled:!h,children:[t(x,{condition:!h,show:t(ke,{children:t(Ht,{fontSize:"small"})})}),c(Se,{children:["Copy from ",p]})]})})},p)})})]})},ms=u("div")(({theme:e})=>({"&>*:nth-child(n)":{margin:e.spacing(1,0)}})),fs=({payload:e,fromEnvironment:n,environment:a})=>c(ms,{children:[t(N,{children:t("strong",{children:"Copy: "})}),e==null?void 0:e.map(s=>c(N,{children:[c("strong",{children:[xe((s==null?void 0:s.name)||"")," strategy"," "]})," "]})),c(N,{children:["from ",n," to ",a]})]}),ys=({payload:e,environment:n})=>c(V,{children:[t(N,{component:"span",children:"Add "}),c("strong",{children:[xe((e==null?void 0:e.name)||"")," strategy"]})," to ",t("strong",{children:n})]}),Ss=u(Hn)(({theme:e})=>({display:"flex",flexDirection:"column",borderRadius:e.shape.borderRadiusMedium})),Et=({title:e,children:n,featureId:a,projectId:s,environmentId:o,strategy:i,Icon:r,onAfterAddStrategy:l})=>{const{addStrategyToFeature:d}=ce(),{setToastApiError:p}=q(),{isChangeRequestConfigured:h}=te(s),{changeRequestDialogDetails:g,onChangeRequestAddStrategy:y,onChangeRequestAddStrategyConfirm:b,onChangeRequestAddStrategyClose:T}=ht(s,a,"addStrategy");return c(V,{children:[t(Ss,{variant:"outlined",children:c(xo,{sx:{display:"flex",flexDirection:"column",flexGrow:1},children:[c(N,{variant:"body1",fontWeight:"medium",sx:{mb:.5,display:"flex",alignItems:"center"},children:[t(r,{color:"disabled",sx:{mr:1}})," ",e]}),t(N,{variant:"body2",color:"text.secondary",component:"p",children:n}),t(U,{sx:{ml:"auto",mt:"auto",pt:1,mr:{xs:"auto",sm:0}},children:t(oe,{permission:he,projectId:s,environmentId:o,variant:"outlined",size:"small",onClick:async()=>{try{h(o)?y(o,i):(await d(s,a,o,i),l())}catch(S){p(j(S))}},children:"Use template"})})]})}),t(gt,{isOpen:g.isOpen,onClose:T,environment:g==null?void 0:g.environment,onConfirm:b,messageComponent:t(ys,{environment:o,payload:g.strategy})})]})},bs=u("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}})),Cs=u("div")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),vs=u(ct)(({theme:e})=>({fontWeight:e.fontWeight.bold})),ws=u(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}})),Ts=({projectId:e,featureId:n,environmentId:a,strategy:s})=>{const o=$e(s.name),i=xe(s.name),r=oo(e,n,a,s.name);return c(ws,{to:r,children:[t(bs,{children:t(o,{})}),c("div",{children:[t(vs,{text:s.displayName||i,maxWidth:"200",maxLength:25}),t(Cs,{children:s.description})]})]})},xs=({projectId:e,featureId:n,environmentId:a})=>{const{strategies:s}=Un(),o=f.useMemo(()=>s.filter(i=>!i.deprecated),[s]);return t(lt,{dense:!0,children:o.map(i=>t(Be,{children:t(Ts,{projectId:e,featureId:n,environmentId:a,strategy:i})},i.name))})},et=({label:e,projectId:n,featureId:a,environmentId:s,variant:o,matchWidth:i})=>{const[r,l]=f.useState(),d=!!r,p=d?"FeatureStrategyMenuPopover":void 0,h=()=>{l(void 0)};return c("div",{onClick:y=>y.stopPropagation(),children:[t(oe,{permission:he,projectId:n,environmentId:s,onClick:y=>{l(y.currentTarget)},"aria-labelledby":p,variant:o,sx:{minWidth:i?"282px":"auto"},children:e}),t(Gn,{id:p,open:d,anchorEl:r,onClose:h,onClick:h,children:t(xs,{projectId:n,featureId:a,environmentId:s})})]})},As=u("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingTop:e.spacing(2)})),Es=u("div")(({theme:e})=>({fontSize:e.fontSizes.bodySize,textAlign:"center",color:e.palette.text.primary,marginBottom:e.spacing(1)})),Rs=u("p")(({theme:e})=>({color:e.palette.text.secondary,fontSize:e.fontSizes.smallBody,textAlign:"center",marginBottom:e.spacing(3),a:{color:e.palette.links}})),Is=({projectId:e,featureId:n,environmentId:a})=>{const{addStrategyToFeature:s}=ce(),{setToastData:o,setToastApiError:i}=q(),{refetchFeature:r}=z(e,n),{refetchFeature:l}=an(e,n),{feature:d}=z(e,n),p=d==null?void 0:d.environments.filter(w=>w.name!==a&&w.strategies&&w.strategies.length>0),{isChangeRequestConfigured:h}=te(e),{changeRequestDialogDetails:g,onChangeRequestAddStrategies:y,onChangeRequestAddStrategiesConfirm:b,onChangeRequestAddStrategyClose:T}=ht(e,n,"addStrategy"),E=(w=!1)=>{r(),l(),o({title:w?"Strategies created":"Strategy created",text:w?"Successfully copied from another environment":"Successfully created strategy",type:"success"})},S=async w=>{var $;const F=(($=p==null?void 0:p.find(M=>M.name===w))==null?void 0:$.strategies)||[];if(h(a)){await y(a,F,w);return}try{await Promise.all(F.map(M=>{const{id:k,...P}={...M,environment:a};return s(e,n,a,P)})),E(!0)}catch(M){i(j(M))}},C=p&&p.length>0;return c(V,{children:[t(gt,{isOpen:g.isOpen,onClose:T,environment:g==null?void 0:g.environment,onConfirm:b,messageComponent:t(fs,{fromEnvironment:g.fromEnvironment,payload:g.strategies})}),c(As,{children:[t(Es,{children:"You have not defined any strategies yet."}),c(Rs,{children:["Strategies added in this environment will only be executed if the SDK is using an"," ",t(J,{to:"/admin/api",children:"API key configured"})," for this environment."]}),c(U,{sx:{w:"100%",display:"flex",flexWrap:"wrap",gap:2,alignItems:"center",justifyContent:"center"},children:[t(et,{label:"Add your first strategy",projectId:e,featureId:n,environmentId:a,matchWidth:C}),t(x,{condition:C,show:t(hs,{environmentId:a,environments:p.map(w=>w.name),onClick:S})})]}),t(U,{sx:{width:"100%",mt:3},children:t(cn,{children:"Or use a strategy template"})}),c(U,{sx:{display:"grid",width:"100%",gap:2,gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"}},children:[t(Et,{title:"Standard strategy",projectId:e,featureId:n,environmentId:a,onAfterAddStrategy:E,Icon:$e("default"),strategy:{name:"default",parameters:{},constraints:[]},children:"The standard strategy is strictly on/off for your entire userbase."}),t(Et,{title:"Gradual rollout",projectId:e,featureId:n,environmentId:a,onAfterAddStrategy:E,Icon:$e("flexibleRollout"),strategy:{name:"flexibleRollout",parameters:{rollout:"50",stickiness:"default",groupId:d.name},constraints:[]},children:"Roll out to a percentage of your userbase."})]})]})]})},Ds=u("div")(({theme:e})=>({width:"100%",position:"relative",paddingBottom:e.spacing(2)})),Fs=u("div")(({theme:e})=>({[e.breakpoints.down(400)]:{padding:e.spacing(1)}})),ks=({featureEnvironment:e,isDisabled:n,otherEnvironments:a})=>{const s=I("projectId"),o=I("featureId"),{setStrategiesSortOrder:i}=ce(),{setToastData:r,setToastApiError:l}=q(),{refetchFeature:d}=z(s,o),[p,h]=f.useState((e==null?void 0:e.strategies)||[]),[g,y]=f.useState(null);if(f.useEffect(()=>{h((e==null?void 0:e.strategies)||[])},[e==null?void 0:e.strategies]),!e)return null;const b=async C=>{try{await i(s,o,e.name,C),d(),r({title:"Order of strategies updated",type:"success"})}catch(w){l(j(w))}},T=(C,w)=>F=>{var $;y({id:p[w].id,index:w,height:(($=C.current)==null?void 0:$.offsetHeight)||0}),C!=null&&C.current&&(F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/html",C.current.outerHTML),F.dataTransfer.setDragImage(C.current,20,20))},E=C=>(w,F)=>$=>{if(g===null||w.current===null||g.index===F||C===g.id)return;const{top:M,bottom:k}=w.current.getBoundingClientRect(),P=$.clientY-M<g.height,O=k-$.clientY<g.height,G=g.index>F;if(P&&G||O&&!G){const Y=[...p],X=Y.splice(g.index,1)[0];Y.splice(F,0,X),h(Y),y({...g,index:F})}},S=()=>{y(null),b(p.map((C,w)=>({id:C.id,sortOrder:w})))};return t(Ds,{children:c(Fs,{children:[t(x,{condition:p.length>0&&n,show:()=>t(se,{severity:"warning",sx:{mb:2},children:"This environment is disabled, which means that none of your strategies are executing."})}),t(x,{condition:p.length>0,show:t(V,{children:p.map((C,w)=>t(ds,{strategy:C,index:w,environmentName:e.name,otherEnvironments:a,isDragging:(g==null?void 0:g.id)===C.id,onDragStartRef:T,onDragOver:E(C.id),onDragEnd:S},C.id))}),elseShow:t(Is,{projectId:s,featureId:o,environmentId:e.name})})]})})},ln=(e,n)=>e===0?0:Math.round(n/e*100);var Me={},Le={};Object.defineProperty(Le,"__esModule",{value:!0});Le.defaultOptions=void 0;Le.defaultOptions={decimalSeparator:".",lowercase:!1,precision:1,space:!1,units:["","K","M","B","T","P","E"]};var fe={};Object.defineProperty(fe,"__esModule",{value:!0});fe.roundTo=fe.parseValue=void 0;function $s(e){const n=parseFloat(e==null?void 0:e.toString());if(isNaN(n))throw new Error("Input value is not a number");if(n>Number.MAX_SAFE_INTEGER||n<Number.MIN_SAFE_INTEGER)throw new RangeError("Input value is outside of safe integer range");return n}fe.parseValue=$s;function Bs(e,n){if(!Number.isFinite(e))throw new Error("Input value is not a finite number");if(!Number.isInteger(n)||n<0)throw new Error("Precision is not a positive integer");return Number.isInteger(e)?e:parseFloat(e.toFixed(n))}fe.roundTo=Bs;Object.defineProperty(Me,"__esModule",{value:!0});Me.millify=void 0;const je=Le,Rt=fe,It=1e3;function*Dt(e){let n=It;for(;;){const a=e/n;if(a<1)return;yield a,n*=It}}function dn(e,n){var a;const s=n?Object.assign(Object.assign({},je.defaultOptions),n):je.defaultOptions;if(!Array.isArray(s.units)||!s.units.length)throw new Error("Option `units` must be a non-empty array");let o;try{o=Rt.parseValue(e)}catch(b){return b instanceof Error&&console.warn(`WARN: ${b.message} (millify)`),String(e)}const i=o<0?"-":"";o=Math.abs(o);let r=0;for(const b of Dt(o))o=b,r+=1;if(r>=s.units.length)return e.toString();let d=Rt.roundTo(o,s.precision);for(const b of Dt(d))d=b,r+=1;const p=(a=s.units[r])!==null&&a!==void 0?a:"",h=s.lowercase?p.toLowerCase():p,g=s.space?" ":"",y=d.toString().replace(je.defaultOptions.decimalSeparator,s.decimalSeparator);return`${i}${y}${g}${h}`}Me.millify=dn;var Ps=Me.default=dn;const Pe=({value:e,threshold:n=1e6,precision:a=2})=>{let s,o=!1;e<n?s=e.toLocaleString():(s=Ps(e,{precision:a}),o=!0);const i=t("span",{"data-testid":Yn,children:s});return t(x,{condition:o,show:t(K,{title:e.toLocaleString(),arrow:!0,children:i}),elseShow:i})},We=u("article")(({theme:e})=>({padding:e.spacing(2),background:"transparent",borderRadius:e.spacing(2),textAlign:"center",[e.breakpoints.up("md")]:{padding:e.spacing(4)}})),qe=u("h3")(({theme:e})=>({margin:0,fontSize:e.fontSizes.bodySize,fontWeight:e.fontWeight.thin})),He=u("p")(({theme:e})=>({fontSize:"2.25rem",fontWeight:e.fontWeight.bold,color:e.palette.primary.main})),Ue=u("p")(({theme:e})=>({margin:e.spacing(1,0,0,0),padding:e.spacing(2,0,0,0),borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:e.palette.divider,fontSize:e.fontSizes.smallerBody,color:e.palette.text.secondary})),un=({totalYes:e,totalNo:n,hoursBack:a,statsSectionId:s,tableSectionId:o})=>{const i=a===1?"in the last hour":`in the last ${a} hours`;return c(ae,{container:!0,spacing:2,id:s,"aria-describedby":o,"aria-label":"Feature metrics summary",component:"section",children:[t(ae,{item:!0,xs:12,sm:4,children:c(We,{children:[t(qe,{children:"Exposure"}),t(He,{children:t(Pe,{value:e})}),c(Ue,{children:["Total exposure of the feature in the environment"," ",i,"."]})]})}),t(ae,{item:!0,xs:12,sm:4,children:c(We,{children:[t(qe,{children:"Exposure %"}),c(He,{children:[ln(e+n,e),"%"]}),c(Ue,{children:["% total exposure of the feature in the environment"," ",i,"."]})]})}),t(ae,{item:!0,xs:12,sm:4,children:c(We,{children:[t(qe,{children:"Requests"}),t(He,{children:t(Pe,{value:e+n})}),c(Ue,{children:["Total requests for the feature in the environment"," ",i,"."]})]})})]})},Os=({environmentMetric:e})=>e?c(V,{children:[t(cn,{children:"Feature toggle exposure"}),t("div",{children:t(un,{totalYes:e.yes,totalNo:e.no,hoursBack:1})})]}):null,Ft=u("div")({marginLeft:"auto",display:"flex",alignItems:"center"}),kt=u("div")(({theme:e})=>({marginRight:e.spacing(1),display:"flex",flexDirection:"column"})),$t=u("p")(({theme:e})=>({color:e.palette.primary.main,textAlign:"right",fontSize:e.fontSizes.bodySize})),Bt=u("p")(({theme:e})=>({maxWidth:"270px",marginTop:e.spacing(.5),fontSize:e.fontSizes.smallBody,textAlign:"right",[e.breakpoints.down(700)]:{display:"none"}})),Vs=u(Kn)(({theme:e})=>({fill:e.palette.background.elevation2,height:"75px",width:"75px",[e.breakpoints.down(500)]:{display:"none"}})),_s=u("div")(({theme:e})=>({margin:e.spacing(0,2),[e.breakpoints.down(500)]:{display:"none"}})),Ms=({environmentMetric:e,disabled:n=!1})=>{const a=Jn();if(!e)return null;const s=e.yes+e.no,o=ln(s,e==null?void 0:e.yes);return!e||e.yes===0&&e.no===0?c(Ft,{children:[c(kt,{children:[c($t,{style:{color:n?a.palette.text.secondary:void 0},"data-loading":!0,children:[o,"%"]}),c(Bt,{style:{color:n?a.palette.text.secondary:a.palette.text.primary},"data-loading":!0,children:["The feature has been requested ",t("b",{children:"0 times"})," and exposed",t("b",{children:" 0 times"})," in the last hour"]})]}),t(Vs,{style:{transform:"scale(1.1)"},"data-loading":!0})]}):c(Ft,{children:[c(kt,{children:[c($t,{children:[o,"%"]}),c(Bt,{children:["The feature has been requested"," ",c("b",{children:[t(Pe,{value:s})," times"]})," ","and exposed"," ",c("b",{children:[t(Pe,{value:e.yes})," ","times"]})," ","in the last hour"]})]}),t(_s,{"data-loading":!0,children:t(Xn,{percentage:o,size:"3rem"})})]})},Ls=({strategyName:e})=>{const n=$e(e);return t(K,{title:xe(e),arrow:!0,children:t(Ns,{children:t(n,{})})})},Ns=u("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.palette.action.disabled,"& svg":{width:e.spacing(2.5),height:e.spacing(2.5)}})),zs=({strategies:e})=>e!=null&&e.length?t(js,{"aria-label":"Feature strategies",children:e.map(n=>t(Ws,{children:t(Ls,{strategyName:n.name})},n.id))}):null,js=u("ul")(()=>({all:"unset",display:"flex",alignItems:"center",alignContent:"center"})),Ws=u("li")(()=>({all:"unset",minWidth:30,textAlign:"center"})),qs=u("div",{shouldForwardProp:e=>e!=="enabled"})(({theme:e,enabled:n})=>({borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2),backgroundColor:n?e.palette.background.paper:e.palette.envAccordion.disabled})),Hs=u(Qn)({boxShadow:"none",background:"none"}),Us=u(Zn)(({theme:e})=>({boxShadow:"none",padding:e.spacing(2,4),[e.breakpoints.down(400)]:{padding:e.spacing(1,2)}})),Gs=u(ea,{shouldForwardProp:e=>e!=="enabled"})(({theme:e})=>({padding:e.spacing(3),background:e.palette.envAccordion.expanded,borderBottomLeftRadius:e.shape.borderRadiusLarge,borderBottomRightRadius:e.shape.borderRadiusLarge,boxShadow:"inset 0px 2px 4px rgba(32, 32, 33, 0.05)",[e.breakpoints.down("md")]:{padding:e.spacing(2,1)}})),Ys=u(ks)(({theme:e})=>({width:"100%",position:"relative",paddingBottom:e.spacing(2)})),Ks=u("div",{shouldForwardProp:e=>e!=="enabled"})(({theme:e,enabled:n})=>({display:"flex",justifyContent:"center",flexDirection:"column",color:n?e.palette.text.primary:e.palette.text.secondary})),Js=u("div")(({theme:e})=>({display:"flex",alignItems:"center",[e.breakpoints.down(560)]:{flexDirection:"column",textAlign:"center"}})),Xs=u(so)(({theme:e})=>({[e.breakpoints.down(560)]:{marginBottom:"0.5rem"}})),Qs=u(ct)(({theme:e})=>({fontSize:e.fontSizes.bodySize,fontWeight:e.typography.fontWeightMedium,[e.breakpoints.down(560)]:{textAlign:"center"}})),Zs=u("div")(({theme:e})=>({display:"flex",alignItems:"center",marginLeft:"1.8rem",[e.breakpoints.down(560)]:{flexDirection:"column",marginLeft:"0"}})),er=({env:e})=>{var p;const n=I("projectId"),a=I("featureId"),{metrics:s}=Oo(n,a),{feature:o}=z(n,a),{value:i}=Gt(),l=_o(o==null?void 0:o.environments,s).find(h=>h.environment===e.name),d=o==null?void 0:o.environments.find(h=>h.name===e.name);return t(x,{condition:!new Set(i.hiddenEnvironments).has(e.name),show:t(qs,{enabled:e.enabled,children:c(Hs,{"data-testid":`${ta}_${e.name}`,className:`environment-accordion ${e.enabled?"":"accordion-disabled"}`,children:[c(Us,{expandIcon:t(na,{titleAccess:"Toggle"}),children:[c(Ks,{"data-loading":!0,enabled:e.enabled,children:[c(Js,{children:[t(Xs,{enabled:e.enabled}),t("div",{children:t(Qs,{text:e.name,maxWidth:"100",maxLength:15})}),t(x,{condition:!e.enabled,show:t(be,{color:"neutral",sx:{ml:1},children:"Disabled"})})]}),c(Zs,{children:[t(et,{label:"Add strategy",projectId:n,featureId:a,environmentId:e.name,variant:"text"}),t(zs,{strategies:d==null?void 0:d.strategies})]})]}),t(Ms,{environmentMetric:l,disabled:!e.enabled})]}),c(Gs,{enabled:e.enabled,children:[t(Ys,{featureEnvironment:d,isDisabled:!e.enabled,otherEnvironments:o==null?void 0:o.environments.map(({name:h})=>h).filter(h=>h!==e.name)}),t(x,{condition:(((p=d==null?void 0:d.strategies)==null?void 0:p.length)||0)>0,show:c(V,{children:[t(U,{sx:{display:"flex",justifyContent:"center",py:1},children:t(et,{label:"Add strategy",projectId:n,featureId:a,environmentId:e.name})}),t(Os,{environmentMetric:l})]})})]})]})})})},tr=()=>{const e=I("projectId"),n=I("featureId"),{feature:a}=z(e,n);if(!a)return null;const{environments:s}=a;return t(V,{children:s==null?void 0:s.map(o=>t(er,{env:o},o.name))})},nr=u("div")(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(3),fontSize:e.fontSizes.smallBody})),ar=u("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)})),or=({feature:e,header:n})=>{const{locationSettings:a}=aa();return c(nr,{children:[n,c("div",{"data-loading":!0,children:[t(ar,{children:"Created at:"}),t("span",{children:oa(sa(e.createdAt),a.locale)})]})]})},sr=u(Ae,{shouldForwardProp:e=>e!=="visibilityOff"})(({theme:e,visibilityOff:n})=>({marginLeft:"auto",marginRight:e.spacing(-1),color:n?e.palette.action.active:e.palette.action.focus,"&:hover":{color:e.palette.action.active}})),rr=({environment:e,hiddenEnvironments:n,setHiddenEnvironments:a})=>t(sr,{onClick:()=>{a(e.name)},visibilityOff:n.has(e.name),children:t(x,{condition:n.has(e.name),show:t(ra,{}),elseShow:t(ia,{})})}),ir=u("div")(({theme:e})=>({marginLeft:e.spacing(-1.5),"&:not(:last-of-type)":{marginBottom:e.spacing(2)},display:"flex",alignItems:"center"})),cr=u("label")(()=>({display:"inline-flex",alignItems:"center",cursor:"pointer"})),lr=({environment:e,callback:n,showInfoBox:a,children:s,hiddenEnvironments:o,setHiddenEnvironments:i})=>{const{name:r,enabled:l}=e,d=I("projectId"),p=I("featureId"),{feature:h,refetchFeature:g}=z(d,p),y=c(V,{children:[" ",c("span",{"data-loading":!0,children:[l?"enabled":"disabled"," in"]})," ",t(ct,{text:r,maxWidth:"120",maxLength:15})]}),b=()=>{g(),n&&n()};return c(ir,{children:[c(cr,{children:[t(ro,{featureId:h.name,projectId:d,environmentName:e.name,onToggle:b,onError:a,value:l}),s??y]}),t(rr,{environment:e,hiddenEnvironments:o,setHiddenEnvironments:i})]})},dr=u("div")(({theme:e})=>({padding:e.spacing(3)})),ur=u("div")(()=>({display:"flex",flexDirection:"column"})),pr=u("p")(({theme:e})=>({fontSize:e.fontSizes.bodySize})),gr=u("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,display:"flex",alignItems:"center"})),Pt=u("span")(({theme:e})=>({padding:e.spacing(0,.5),"::after":{content:'"-"'}})),hr=u(dt)(()=>({"&:hover, &:focus":{textDecoration:"underline"}})),mr=({feature:e,header:n,hiddenEnvironments:a,setHiddenEnvironments:s})=>{const[o,i]=f.useState(!1),[r,l]=f.useState(""),d=e.environments.some(p=>{var h;return p.enabled&&((h=p.variants)==null?void 0:h.length)});return c(dr,{"data-testid":"feature-toggle-status",children:[n,e.environments.map(p=>{const h=p.strategies.length===1?"1 strategy":`${p.strategies.length} strategies`,g=p.variants??[],y=g.length>0&&c(V,{children:[t(Pt,{}),t(K,{title:"View variants",arrow:!0,describeChild:!0,children:t(hr,{component:J,to:`/projects/${e.project}/features/${e.name}/variants`,underline:"hover",children:g.length===1?"1 variant":`${g.length} variants`})})]}),b=p.enabled&&g.length===0&&d;return t(lr,{environment:p,hiddenEnvironments:a,setHiddenEnvironments:s,showInfoBox:()=>{l(p.name),i(!0)},children:c(ur,{children:[t(pr,{children:p.name}),c(gr,{children:[h,y,t(x,{condition:b,show:c(V,{children:[t(Pt,{}),t(io,{})]})})]})]})},p.name)}),t(co,{open:o,onClose:()=>i(!1),projectId:e.project,featureId:e.name,environmentName:r})]})},pn=(e,n={})=>{const a=async()=>{const p=we(`api/admin/features/${e}/tags`);return(await fetch(p,{method:"GET"}).then(Oe("Tags"))).json()},s=`api/admin/features/${e}/tags`,{data:o,error:i}=ca(!!e,{tags:[]},s,a,n),[r,l]=f.useState(!i&&!o),d=()=>{at(s)};return f.useEffect(()=>{l(!i&&!o)},[o,i]),{tags:(o==null?void 0:o.tags)||[],error:i,loading:r,refetch:d}},fr=u("section")(({theme:e})=>({["& > *"]:{margin:e.spacing(1,0)}})),Ge=e=>e.map(n=>({title:n.value})),Ot=(e,n)=>e.map(a=>({value:a.title,type:n})),gn=({open:e,setOpen:n})=>{const{tagTypes:a}=la(),s=I("featureId"),{createTag:o}=lo(),{updateFeatureTags:i,loading:r}=_e(),{tags:l,refetch:d,loading:p}=pn(s),{setToastData:h}=q(),[g,y]=f.useState({name:"simple",description:"Simple tag to get you started",icon:""}),b=r||p,[T,E]=f.useState(0),{trackEvent:S}=Yt(),[C,w]=f.useState(Ge(l.filter(m=>m.type===g.name))),{tags:F,refetch:$}=uo(g.name),M=f.useMemo(()=>Ge(F),[F]);f.useEffect(()=>{l&&g&&w(Ge(l.filter(m=>m.type===g.name)))},[JSON.stringify(l),g]);const k=()=>{n(!1),w([])};function P(m,v){const D=m.filter(L=>L.type===g.name).filter(L=>!v.find(_=>L.value===_.value&&L.type===_.type)),W=v.filter(L=>L.type===g.name).filter(L=>!m.find(_=>L.value===_.value&&L.type===_.type));return E(D.length+W.length),{added:D,removed:W}}const O=m=>m.filter(v=>!v.title.startsWith("Create")),G=async(m,v)=>{try{await i(s,{addedTags:m,removedTags:v}),await d()}catch(D){const W=j(D);h({type:"error",title:"Failed to add tag",text:W,confetti:!1})}},Y=(m,v)=>{let D="We successfully";return m>0&&(D=D.concat(` added ${m} new tag${m>1?"s":""}`)),m>0&&v>0&&(D=D.concat(" and ")),v>0&&(D=D.concat(` removed ${v} tag${v>1?"s":""}`)),D},X=async m=>{m.preventDefault();const v=Ot(O(C),g.name),{added:D,removed:W}=P(v,l);T>0&&(await G(D,W),T>1&&S("suggest_tags",{props:{eventType:"multiple_tags_added"}}),T>0&&h({type:"success",title:`Updated tag${D.length>1?"s":""} to toggle`,text:Y(D.length,W.length),confetti:!0})),E(0),w([]),n(!1)},ne=(m,v)=>{v!=null&&typeof v!="string"&&(m.preventDefault(),y(v),w([]),E(0))},A=(m,v,D)=>{const W=da(v);D==="selectOption"&&v.forEach((_,Re)=>{if(typeof _!="string"&&_.inputValue&&_.inputValue!==""){const Ie={value:_.inputValue,type:g.name};o(Ie).then(()=>{S("suggest_tags",{props:{eventType:"tag_created"}}),$()}),_.title=_.inputValue,_.inputValue="",W[Re]=_}});const L=Ot(O(W),g.name);P(L,l),w(W)},B="add-tag-form";return t(ee,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update tags to feature toggle",onClick:X,disabledPrimaryButton:b||T===0,onClose:k,formId:B,children:c(V,{children:[t(N,{paragraph:!0,sx:{marginBottom:m=>m.spacing(2.5)},children:"Tags allow you to group features together"}),t("form",{id:B,onSubmit:X,children:c(fr,{children:[t(po,{options:a,value:g,onChange:ne}),t(go,{options:M,existingTags:l,tagType:g,selectedOptions:C,onChange:A})]})})]})})},yr=u("div")(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(3)})),Sr=u("div")(({theme:e})=>({display:"flex",gap:e.spacing(1),flexWrap:"wrap"})),br=u(Kt)(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Cr=u(Ce)(({theme:e})=>({margin:e.spacing(3),borderStyle:"dashed"})),vr=u(de)(({theme:e})=>({maxWidth:e.spacing(20),alignSelf:"center"})),wr=({feature:e,header:n})=>{const{tags:a,refetch:s}=pn(e.name),{deleteTagFromFeature:o}=_e(),[i,r]=f.useState(!1),[l,d]=f.useState(!1),[p,h]=f.useState(),{setToastData:g,setToastApiError:y}=q(),{hasAccess:b}=f.useContext(it),T=b(ge,e.project),E=async()=>{if(p)try{await o(e.name,p.type,p.value),s(),g({type:"success",title:"Tag deleted",text:"Successfully deleted tag"})}catch(S){y(j(S))}};return c(yr,{children:[n,t(Sr,{children:a.map(S=>{const C=`${S.type}:${S.value}`;return t(br,{label:C,deleteIcon:t(ua,{titleAccess:"Remove"}),onDelete:T?()=>{d(!0),h(S)}:void 0},C)})}),t(x,{condition:T,show:c(V,{children:[t(x,{condition:a.length>0,show:t(Cr,{})}),t(vr,{"data-loading":!0,variant:"outlined",startIcon:t(pa,{}),onClick:()=>r(!0),children:"Add new tag"})]})}),t(gn,{open:i,setOpen:r}),c(ee,{open:l,primaryButtonText:"Delete tag",secondaryButtonText:"Cancel",onClose:()=>{d(!1),h(void 0)},onClick:()=>{d(!1),E(),h(void 0)},title:"Delete tag?",children:["You are about to delete tag:"," ",c("strong",{children:[p==null?void 0:p.type,":",p==null?void 0:p.value]})]})]})},Tr=u("div")(({theme:e})=>({position:"sticky",top:e.spacing(2),borderRadius:e.shape.borderRadiusLarge,backgroundColor:e.palette.background.paper,display:"flex",flexDirection:"column",maxWidth:"350px",minWidth:"350px",marginRight:"1rem",marginTop:"1rem",[e.breakpoints.down(1e3)]:{marginBottom:"1rem",width:"100%",maxWidth:"none",minWidth:"auto"}})),Ye=u("h3")(({theme:e})=>({display:"flex",gap:e.spacing(1),alignItems:"center",fontSize:e.fontSizes.bodySize,margin:0,marginBottom:e.spacing(3),"& > :last-child":{position:"relative",top:1}})),xr=({hiddenEnvironments:e,setHiddenEnvironments:n})=>{const a=I("projectId"),s=I("featureId"),{feature:o}=z(a,s);return c(Tr,{children:[t(mr,{header:c(Ye,{"data-loading":!0,children:["Enabled in environments (",o.environments.filter(({enabled:i})=>i).length,")",t(Qe,{tooltip:"When a feature is switched off in an environment, it will always return false. When switched on, it will return true or false depending on its strategies.",placement:"top"})]}),feature:o,hiddenEnvironments:e,setHiddenEnvironments:n}),t(Ce,{}),t(or,{header:t(Ye,{"data-loading":!0,children:"Feature toggle details"}),feature:o}),t(Ce,{}),t(wr,{header:t(Ye,{"data-loading":!0,children:"Tags for this feature toggle"}),feature:o})]})},Ar=()=>{const{trackEvent:e}=Yt(),{value:n,setValue:a}=Gt(),[s,o]=f.useState(new Set(n.hiddenEnvironments));return{hiddenEnvironments:s,setHiddenEnvironments:r=>{a(l=>{const d=new Set(l.hiddenEnvironments);return d.has(r)?(d.delete(r),e("hidden_environment",{props:{eventType:"environment unhidden"}})):(d.add(r),e("hidden_environment",{props:{eventType:"environment hidden"}})),o(d),{...n,hiddenEnvironments:d}})}}},Er=u("div")(({theme:e})=>({display:"flex",width:"100%",[e.breakpoints.down(1e3)]:{flexDirection:"column"}})),Rr=u("div")(({theme:e})=>({display:"flex",flexDirection:"column",width:"calc(100% - (350px + 1rem))",[e.breakpoints.down(1e3)]:{width:"100%"}})),Ir=()=>{const e=le(),n=I("projectId"),a=I("featureId"),s=ot(n,a),{hiddenEnvironments:o,setHiddenEnvironments:i}=Ar(),r=()=>e(s);return Jt(a),c(Er,{children:[c("div",{children:[t(Po,{}),t(xr,{hiddenEnvironments:o,setHiddenEnvironments:i})]}),t(Rr,{children:t(tr,{})}),c(Xt,{children:[t(re,{path:"strategies/create",element:t(Ze,{label:"Create feature strategy",onClose:r,open:!0,children:t(ho,{})})}),t(re,{path:"strategies/edit",element:t(Ze,{label:"Edit feature strategy",onClose:r,open:!0,children:t(ga,{})})})]})]})},Dr=({values:e=[],updateValues:n,placeholder:a="",error:s,...o})=>{const i=l=>{const p=l.target.value.split(/,\s?/).map(h=>h.trim());n(p)},r=l=>{if(l.key==="Backspace"){const d=l.target.value;if(d.endsWith(", ")){l.preventDefault();const p=d.slice(0,-2);n(p.split(/,\s*/))}}};return t(Qt,{...o,error:s,placeholder:a,value:e?e.join(", "):"",onKeyDown:r,onChange:i,style:{width:"100%"},variant:"outlined",size:"small"})},Fr=u("div")(({theme:e})=>({display:"flex",alignItems:"center",rowGap:e.spacing(1.5),marginBottom:e.spacing(2),[e.breakpoints.down("sm")]:{flexDirection:"column","& > div, .MuiInputBase-root":{width:"100%",alignItems:"flex-start"}}})),kr=u(Zt)(({theme:e})=>({marginRight:e.spacing(10),[e.breakpoints.up("sm")]:{minWidth:e.spacing(20)}})),$r=u("div")(({theme:e})=>({width:"100%",gap:e.spacing(1.5),display:"flex"})),Br=u(Dr)(()=>({width:"100%"})),Pr=u(Qt)(()=>({width:"100%"})),Or=({overrides:e,overridesDispatch:n})=>{const{context:a}=ut(),s=a.map(({name:r})=>({key:r,label:r})),o=r=>l=>{n({type:"UPDATE_VALUES_AT",payload:[r,l]})},i=r=>(l,d)=>{l==null||l.preventDefault(),n({type:"UPDATE_VALUES_AT",payload:[r,d||[]]})};return t(V,{children:e.map((r,l)=>{var g;const d=a.find(({name:y})=>y===r.contextName),p=((g=d==null?void 0:d.legalValues)==null?void 0:g.map(({value:y})=>y))||[],h=r.values.filter(y=>p.includes(y));return c(Fr,{children:[t(kr,{id:"override-context-name",name:"contextName",label:"Context Field","data-testid":"context_field",value:r.contextName,options:s,onChange:y=>n({type:"UPDATE_TYPE_AT",payload:[l,y.target.value]})}),c($r,{children:[t(x,{condition:!!(p&&p.length>0),show:t(ha,{multiple:!0,id:`override-select-${l}`,isOptionEqualToValue:(y,b)=>y===b,options:p,onChange:i(l),getOptionLabel:y=>y,value:h,style:{width:"100%"},filterSelectedOptions:!0,size:"small",renderInput:y=>t(Pr,{...y,variant:"outlined",label:"Legal values"})}),elseShow:t(Br,{label:"Values (v1, v2, ...)",name:"values",placeholder:"",values:r.values,updateValues:o(l),"data-testid":"OVERRIDE_VALUES"})}),t(K,{title:"Remove",arrow:!0,children:t(Ae,{onClick:y=>{y.preventDefault(),n({type:"REMOVE",payload:l})},children:t(st,{})})})]})]},`override=${l}`)})})},Vr=(e,n)=>{switch(n.type){case"SET":return n.payload;case"CLEAR":return[];case"ADD":return[...e,n.payload];case"REMOVE":return e.filter((r,l)=>l!==n.payload);case"UPDATE_VALUES_AT":const[a,s]=n.payload;return e.map((r,l)=>l===a?{...r,values:s}:r);case"UPDATE_TYPE_AT":const[o,i]=n.payload;return e.map((r,l)=>l===o?{...r,contextName:i}:r)}},_r=(e=[])=>f.useReducer(Vr,e);var Q=(e=>(e.FIX="fix",e.VARIABLE="variable",e))(Q||{});const Mr=u("div")(({theme:e})=>({position:"relative",backgroundColor:e.palette.neutral.light,display:"flex",flexDirection:"column",padding:e.spacing(3),marginBottom:e.spacing(3),borderRadius:e.shape.borderRadiusLarge})),Lr=u(K)(({theme:e})=>({position:"absolute",top:e.spacing(2),right:e.spacing(2)})),hn=u("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Vt=u(hn)(({theme:e})=>({display:"flex",color:e.palette.text.primary,marginTop:e.spacing(1),marginBottom:e.spacing(2)})),Nr=u("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(2)})),zr=u(ma)(({theme:e})=>({marginBottom:e.spacing(1),"& > span":{fontSize:e.fontSizes.smallBody},[e.breakpoints.down("sm")]:{marginTop:e.spacing(1),marginBottom:e.spacing(1.5)}})),jr=u("div")(({theme:e})=>({width:"100%",gap:e.spacing(1.5),display:"flex","& > div":{width:"100%"}})),_t=u(en)(()=>({width:"100%"})),Wr=u("div")(({theme:e})=>({marginLeft:e.spacing(3)})),qr=u(en)(({theme:e})=>({width:e.spacing(24),[e.breakpoints.down("sm")]:{width:"100%"}})),Hr=u("div")(({theme:e})=>({marginTop:e.spacing(3),flexGrow:1})),mn=u("div")(({theme:e})=>({display:"flex",rowGap:e.spacing(1.5),marginBottom:e.spacing(2),[e.breakpoints.down("sm")]:{flexDirection:"column","& > div, .MuiInputBase-root":{width:"100%"}}})),Ur=u(mn)({alignItems:"end",justifyContent:"space-between"}),Gr=u(Zt)(({theme:e})=>({marginRight:e.spacing(10),[e.breakpoints.up("sm")]:{minWidth:e.spacing(20)}})),Yr=u(de)(({theme:e})=>({marginTop:e.spacing(-1),marginLeft:e.spacing(-1)})),Kr=[{key:"string",label:"string"},{key:"json",label:"json"},{key:"csv",label:"csv"}],Jr={type:"string",value:""},Xr=({variant:e,variants:n,updateVariant:a,removeVariant:s,apiPayload:o})=>{const[i,r]=f.useState(e.name),[l,d]=f.useState(e.weightType===Q.FIX),[p,h]=f.useState(String(e.weight/10)),[g,y]=f.useState(e.payload||Jr),[b,T]=_r(e.overrides||[]),{context:E}=ut(),[S,C]=f.useState({}),w=m=>{C(v=>({...v,[m]:void 0}))},F=(m,v)=>{C(D=>({...D,[m]:v}))};f.useEffect(()=>{var m;w("percentage"),(m=o.error)!=null&&m.includes("%")&&F("percentage","Total weight must equal 100%")},[o.error]);const $=!e.new,M=n.filter(({id:m,weightType:v})=>m!==e.id&&v===Q.VARIABLE).length>0,k=m=>{const v=m.weightType===Q.VARIABLE,D=n.some(L=>L.weightType===Q.FIX),W=n.filter(L=>L.weightType===Q.VARIABLE).length===1;return D&&W&&v},P=m=>{w("name"),ne(m,e.id)||F("name","A variant with that name already exists for this environment."),r(m.trim())},O=m=>{(m===""||A(m))&&h(m)},G=m=>{B(m)||F("payload","Invalid JSON.")},Y=()=>{E.length>0&&T({type:"ADD",payload:{contextName:E[0].name,values:[]}})},X=m=>!!m.length,ne=(m,v)=>$||!n.some(D=>D.name===m&&D.id!==v),A=m=>{if(!l)return!0;if(m===""||m.match(/\.[0-9]{2,}$/))return!1;const v=Number(m);return v>=0&&v<=100},B=m=>{try{return m.type==="json"&&JSON.parse(m.value),!0}catch{return!1}};return f.useEffect(()=>{a({...e,name:i,weight:Number(l?p:100)*10,weightType:l?Q.FIX:Q.VARIABLE,stickiness:(n==null?void 0:n.length)>0?n[0].stickiness:"default",payload:g.value?g:void 0,overrides:b.map(m=>({contextName:m.contextName,values:m.values})).filter(m=>m.values&&m.values.length>0),isValid:X(i)&&ne(i,e.id)&&A(p)&&B(g)&&!o.error})},[i,l,p,g,b]),f.useEffect(()=>{l||h(String(e.weight/10))},[e.weight]),c(Mr,{"data-testid":"VARIANT",children:[t(Lr,{arrow:!0,title:k(e)?"You need to have at least one variable variant":"Delete variant",children:t("div",{children:t(Ae,{"data-testid":`VARIANT_DELETE_BUTTON_${e.name}`,onClick:()=>s(e.id),disabled:k(e),children:t(st,{})})})}),c(Ur,{children:[c(Hr,{children:[t(hn,{children:"Variant name"}),t(Nr,{children:"This will be used to identify the variant in your code"}),t(_t,{id:`variant-name-input-${e.id}`,"data-testid":"VARIANT_NAME_INPUT",label:"Variant name",error:!!S.name,errorText:S.name,value:i,onChange:m=>P(m.target.value),disabled:$,required:!0})]}),t(x,{condition:M,show:c(Wr,{children:[t(zr,{label:"Custom percentage",control:t(fa,{"data-testid":"VARIANT_WEIGHT_CHECK",checked:l,onChange:m=>d(m.target.checked)})}),t(qr,{"data-testid":"VARIANT_WEIGHT_INPUT",type:"number",label:"Variant weight",error:!!S.percentage,errorText:S.percentage,value:p,onChange:m=>O(m.target.value),required:l,disabled:!l,"aria-valuemin":0,"aria-valuemax":100,InputProps:{endAdornment:t(ya,{position:"end",children:"%"})}})]})})]}),c(Vt,{children:["Payload",t(Qe,{tooltip:"Passed along with the the variant object."})]}),c(mn,{children:[t(Gr,{id:"variant-payload-type",name:"type",label:"Type",value:g.type,options:Kr,onChange:m=>{w("payload"),y(v=>({...v,type:m.target.value}))}}),t(jr,{children:t(_t,{id:"variant-payload-value",name:"variant-payload-value",label:"Value",multiline:g.type!=="string",rows:g.type==="string"?1:4,value:g.value,onChange:m=>{w("payload"),y(v=>({...v,value:m.target.value}))},placeholder:g.type==="json"?'{ "hello": "world" }':"",onBlur:()=>G(g),error:!!S.payload,errorText:S.payload})})]}),c(Vt,{children:["Overrides",t(Qe,{tooltip:"Here you can specify which users should get this variant."})]}),t(Or,{overrides:b,overridesDispatch:T}),t("div",{children:t(Yr,{onClick:Y,variant:"text",color:"primary","data-testid":"VARIANT_ADD_OVERRIDE_BUTTON",children:"Add override"})})]})},Qr=u("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"},marginTop:e.spacing(-3.5),marginBottom:e.spacing(2),backgroundColor:e.palette.background.default,paddingTop:e.spacing(2),paddingBottom:e.spacing(2),position:"sticky",top:0,zIndex:2})),Zr=u(tn,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.neutral.border:e.palette.primary.main})),ei=u("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontSize:e.fontSizes.mainHeader,fontWeight:e.fontWeight.bold})),ti=u("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),ni=u(se)(({theme:e})=>({marginBottom:e.spacing(2)})),ai=u(se)(({theme:e})=>({marginTop:e.spacing(4)})),oi=u("div")({display:"flex",flexDirection:"column"}),si=u("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),Mt=u("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),ri=u(Ce)(({theme:e})=>({margin:e.spacing(4,0)})),ii=u(Sa)(({theme:e})=>({minWidth:e.spacing(20),width:"100%"})),ci=u("div")(({theme:e})=>({marginTop:"auto",paddingTop:e.spacing(4),display:"flex",justifyContent:"flex-end"})),li=u(de)(({theme:e})=>({marginLeft:e.spacing(3)})),di=({environment:e,open:n,setOpen:a,getApiPayload:s,getCrPayload:o,onConfirm:i})=>{const r=I("projectId"),l=I("featureId"),{uiConfig:d}=rt(),{context:p}=ut(),{defaultStickiness:h,loading:g}=ba(r),{isChangeRequestConfigured:y}=te(r),{data:b}=ie(r),{changeRequestInReviewOrApproved:T,alert:E}=wa(b),S=(e==null?void 0:e.variants)||[],[C,w]=f.useState([]),[F,$]=f.useState();f.useEffect(()=>{g||w(S.length?S.map(R=>({...R,isValid:!0,new:!1,id:ze()})):[{name:"",weightType:Q.VARIABLE,weight:0,overrides:[],stickiness:(C==null?void 0:C.length)>0?C[0].stickiness:h,new:!0,isValid:!1,id:ze()}])},[n,g]);const M=(R,H)=>{w(ue=>bt(ue.map(De=>De.id===H?R:De),1e3))},k=()=>{const R=ze();w(H=>[...H,{name:"",weightType:Q.VARIABLE,weight:0,overrides:[],stickiness:(H==null?void 0:H.length)>0?H[0].stickiness:h,new:!0,isValid:!1,id:R}]),$(R)};f.useEffect(()=>{if(F){const R=document.getElementById(`variant-name-input-${F}`);R==null||R.scrollIntoView({behavior:"smooth",block:"center"}),R==null||R.focus({preventScroll:!0}),$(void 0)}},[F]);const P=C.map(({new:R,isValid:H,id:ue,...De})=>De),O=s(S,P),G=o(P),Y=async R=>{R.preventDefault(),i(P)},X=()=>m?`curl --location --request POST '${d.unleashUrl}/api/admin/projects/${r}/environments/${e==null?void 0:e.name}/change-requests' \\
2
2
  --header 'Authorization: INSERT_API_KEY' \\
3
3
  --header 'Content-Type: application/json' \\
4
4
  --data-raw '${JSON.stringify(G,void 0,2)}'`:`curl --location --request PATCH '${d.unleashUrl}/api/admin/projects/${r}/features/${l}/environments/${e==null?void 0:e.name}/variants' \\
5
5
  --header 'Authorization: INSERT_API_KEY' \\
6
6
  --header 'Content-Type: application/json' \\
7
- --data-raw '${JSON.stringify(O.patch,void 0,2)}'`,ne=C.every(({isValid:R})=>R),A=T((e==null?void 0:e.name)||""),B=A?"Add to existing change request":"Add change to draft",m=y((e==null?void 0:e.name)||""),v=f.useMemo(()=>{var R;return g?"":((R=P[0])==null?void 0:R.stickiness)||h},[g,h,JSON.stringify(P[0]??{})]),D=f.useMemo(()=>["default",...p.filter(R=>R.stickiness).map(R=>R.name)],[p]),W=D.map(R=>({key:R,label:R}));D.includes(v)||W.push({key:v,label:v});const L=async R=>{w(H=>H.map(ue=>({...ue,stickiness:R})))},_=R=>{L(R)},[Re,Ie]=f.useState();f.useEffect(()=>{Ie(void 0),O.error&&Ie(O.error)},[O.error]);const ft=()=>{L(h),a(!1)};return g||v===""?t(Ca,{}):t(Ze,{open:n,onClose:ft,label:"",children:c(va,{modal:!0,title:"",description:"Variants allows you to return a variant object if the feature toggle is considered enabled for the current request.",documentationLink:"https://docs.getunleash.io/reference/feature-toggle-variants",documentationLinkLabel:"Feature toggle variants documentation",formatApiCode:X,loading:!n,children:[c(Qr,{children:[c("div",{children:[t(Zr,{deprecated:!(e!=null&&e.enabled)}),t(ei,{deprecated:!(e!=null&&e.enabled),children:e==null?void 0:e.name})]}),t(oe,{"data-testid":"MODAL_ADD_VARIANT_BUTTON",onClick:k,variant:"outlined",permission:pe,projectId:r,environmentId:e==null?void 0:e.name,children:"Add variant"})]}),c(ti,{onSubmit:Y,children:[t(x,{condition:A,show:E,elseShow:t(x,{condition:!!m,show:c(ni,{severity:"info",children:[t("strong",{children:"Change requests"})," are enabled",e?` for ${e.name}`:"",". Your changes need to be approved before they will be live. All the changes you do now will be added into a draft that you can submit for review."]})})}),t(oi,{children:C.map(R=>t(Xr,{variant:R,variants:C,updateVariant:H=>M(H,R.id),removeVariant:()=>w(H=>bt(H.filter(ue=>ue.id!==R.id),1e3)),projectId:r,apiPayload:O},R.id))}),t(oe,{onClick:k,variant:"outlined",permission:pe,projectId:r,environmentId:e==null?void 0:e.name,children:"Add variant"}),t(ri,{}),t(x,{condition:C.length>0,show:c(V,{children:[t(si,{children:t("p",{children:"Stickiness"})}),c(Mt,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t(dt,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]}),t("div",{children:t(ii,{value:v,label:"",editable:!0,onChange:R=>_(R.target.value)})})]}),elseShow:t(Mt,{children:"This environment has no variants. Get started by adding a variant."})}),c(ai,{severity:"error",hidden:!Re,children:[t("strong",{children:"Error: "}),Re]}),c(ci,{children:[t(de,{"data-testid":"DIALOGUE_CONFIRM_ID",type:"submit",variant:"contained",color:"primary",disabled:!ne,children:m?B:"Save variants"}),t(li,{onClick:ft,children:"Cancel"})]})]})]})})},ui=u("div")(({theme:e})=>({padding:e.spacing(3),borderRadius:e.shape.borderRadiusLarge,border:`1px solid ${e.palette.divider}`,"&:not(:last-child)":{marginBottom:e.spacing(3)}})),pi=u("div")({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"}}),gi=u(tn,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.neutral.border:e.palette.primary.main})),hi=u("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontWeight:e.fontWeight.bold})),mi=u("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),fi=u("div")(({theme:e})=>({margin:e.spacing(3,0)})),yi=u("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),Si=({environment:e,searchValue:n,children:a})=>{var i;const s=e.variants??[],o=((i=s[0])==null?void 0:i.stickiness)||"default";return c(ui,{children:[c(pi,{children:[c("div",{children:[t(gi,{deprecated:!e.enabled}),t(hi,{deprecated:!e.enabled,children:e.name})]}),a]}),t(x,{condition:s.length>0,show:c(V,{children:[t(fi,{children:t(Ta,{variants:s,searchValue:n})}),t(x,{condition:s.length>1,show:c(V,{children:[c(yi,{children:[t("p",{children:"Stickiness:"}),t(be,{children:o})]}),c(mi,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t(dt,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]})]})})]})})]})},bi=u(Se)(({theme:e})=>({"& span":{fontSize:e.fontSizes.smallBody}})),Ci=({environment:e,permission:n,projectId:a,environmentId:s,onCopyVariantsFrom:o,otherEnvsWithVariants:i})=>{const[r,l]=f.useState(null),d=!!r,p=e.variants??[];return t(x,{condition:i.length>0&&p.length===0,show:c(V,{children:[t(oe,{onClick:h=>{l(h.currentTarget)},id:`copy-from-menu-${e.name}`,"aria-controls":d?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":d?"true":void 0,variant:"outlined",permission:n,projectId:a,environmentId:s,children:"Copy variants from"}),t(Ee,{anchorEl:r,open:d,onClose:()=>l(null),MenuListProps:{"aria-labelledby":`copy-from-menu-${e.name}`},children:i.map(h=>t(me,{onClick:()=>o(h,e),children:t(bi,{children:`Copy from ${h.name}`})},h.name))})]})})},vi=({permission:e,projectId:n,environment:a,checked:s,onClick:o,...i})=>{const r=Je(e,n,a);return c(me,{disabled:!r,onClick:o,...i,children:[t(xa,{checked:s}),a]})},wi=u(Ee)(({theme:e})=>({"& > div > ul":{display:"flex",flexDirection:"column",justifyContent:"center","& > li":{padding:e.spacing(0,1)}}})),Ti=u("div")(({theme:e})=>({margin:e.spacing(1,2)})),xi=u(de)(({theme:e})=>({marginTop:e.spacing(2)})),Ai=({current:e,environments:n,permission:a,projectId:s,onSubmit:o})=>{var E;const[i,r]=f.useState(null),l=!!i,[d,p]=f.useState([]),h=S=>{p(C=>[...C,S])},g=S=>{p(C=>C.filter(({name:w})=>w!==S.name))},y=S=>{d.includes(S)?g(S):h(S)},b=()=>{p([]),r(null)},T=((E=n.find(S=>S.name===e))==null?void 0:E.variants)??[];return t(x,{condition:T.length>0&&n.length>1,show:c(V,{children:[t(de,{onClick:S=>{r(S.currentTarget)},id:`push-to-menu-${e}`,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,variant:"outlined",children:"Push to environment"}),c(wi,{anchorEl:i,open:l,onClose:()=>r(null),MenuListProps:{"aria-labelledby":`push-to-menu-${e}`},children:[n.filter(S=>S.name!==e).map(S=>t(vi,{projectId:s,permission:a,environment:S.name,checked:d.includes(S),onClick:()=>y(S)},S.name)),c(Ti,{children:[t(Ce,{}),c(xi,{variant:"outlined",onClick:()=>{o(d),b()},disabled:d.length===0,children:["Push to selected (",d.length,")"]})]})]})]})})},Ei=u(se)(({theme:e})=>({marginBottom:e.spacing(4),"& code":{fontWeight:e.fontWeight.bold}})),Ri=u("div")(({theme:e})=>({display:"flex",gap:e.spacing(1.5)})),Ii=()=>{const{setToastData:e,setToastApiError:n}=q(),a=Ut(),s=Ve(a.breakpoints.down("md")),o=I("projectId"),i=I("featureId"),{feature:r,refetchFeature:l,loading:d}=z(o,i),{patchFeatureEnvironmentVariants:p,overrideVariantsInEnvironments:h}=_e(),{refetch:g}=ie(o),{addChange:y}=Te(),{isChangeRequestConfigured:b}=te(o),[T,E]=f.useState(""),[S,C]=f.useState(),[w,F]=f.useState(!1),$=f.useMemo(()=>{var A;return((A=r==null?void 0:r.environments)==null?void 0:A.map(B=>({...B,crEnabled:b(B.name)})))||[]},[r.environments]),M=(A,B)=>Ra(A,B),k=(A,B)=>{try{const m=Ea(B,1e3);return{patch:M(A,m)}}catch(m){return{patch:[],error:j(m)}}},P=A=>({feature:i,action:"patchVariant",payload:{variants:A}}),O=async(A,B)=>{if(A.crEnabled)await y(o,A.name,P(B)),g();else{const m=A.variants??[],{patch:v,error:D}=k(m,B);if(v.length===0)return;if(D){e({type:"error",title:D});return}await p(o,i,A.name,v)}l()},G=async(A,B)=>{try{const m=B.filter(({crEnabled:_})=>_),v=B.filter(({crEnabled:_})=>!_);m.length&&await Promise.all(m.map(_=>y(o,_.name,P(A)))),v.length&&await h(o,i,A,v.map(({name:_})=>_)),g(),l();const D=v.length?`Variants pushed to ${v.length===1?v[0].name:`${v.length} environments`}`:"",W=m.length?`Variants push added to ${m.length===1?`${m[0].name} draft`:`${m.length} drafts`}`:"",L=`${D}${D&&W?". ":""}${W}`;e({title:L,type:"success"})}catch(m){n(j(m))}},Y=A=>{C(A),F(!0)},X=async A=>{if(S)try{await O(S,A),F(!1),e({title:S.crEnabled?"Variant changes added to draft":"Variants updated successfully",type:"success"})}catch(B){n(j(B))}},ne=async(A,B)=>{try{const m=A.variants??[];await O(B,m),e({title:B.crEnabled?"Variants copy added to draft":"Variants copied successfully",type:"success"})}catch(m){n(j(m))}};return c(pt,{isLoading:d,header:t(Aa,{title:"Variants",actions:t(x,{condition:!s,show:t(V,{children:t(Ct,{initialValue:T,onChange:E})})}),children:t(x,{condition:s,show:t(Ct,{initialValue:T,onChange:E})})}),children:[c(Ei,{severity:"info",children:["Variants allows you to return a variant object if the feature toggle is considered enabled for the current request. When using variants you should use the ",t("code",{children:"getVariant()"})," method in the Client SDK."]}),$.map(A=>{var m;const B=$.filter(({name:v,variants:D})=>v!==A.name&&(D==null?void 0:D.length));return t(Si,{environment:A,searchValue:T,children:c(Ri,{children:[t(Ai,{current:A.name,environments:$,permission:pe,projectId:o,onSubmit:v=>G(A.variants??[],v)}),t(Ci,{environment:A,permission:pe,projectId:o,environmentId:A.name,onCopyVariantsFrom:ne,otherEnvsWithVariants:B}),t(x,{condition:!!((m=A.variants)!=null&&m.length),show:t(Z,{"data-testid":"EDIT_VARIANTS_BUTTON",onClick:()=>Y(A),permission:pe,projectId:o,environmentId:A.name,tooltipProps:{title:"Edit variants"},children:t(ye,{})}),elseShow:t(oe,{"data-testid":"ADD_VARIANT_BUTTON",onClick:()=>Y(A),variant:"outlined",permission:pe,projectId:o,environmentId:A.name,children:"Add variant"})})]})},A.name)}),t(di,{environment:S,open:w,setOpen:F,getApiPayload:k,getCrPayload:P,onConfirm:X})]})},Di=we("api/admin/client-metrics/features"),fn=(e,n)=>{const a=we(`api/admin/client-metrics/features/${e}/raw?hoursBack=${n}`),{data:s,error:o}=nt(a,()=>Fi(a)),i=f.useCallback(()=>{at(Di).catch(console.warn)},[]);return{featureMetrics:s==null?void 0:s.data,loading:!o&&!s,refetchFeatureMetrics:i,error:o}},Fi=e=>fetch(e).then(Oe("Features")).then(n=>n.json()).then(),ki=u("h2")(({theme:e})=>({margin:0,marginBottom:e.spacing(1),fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.thin,color:e.palette.text.secondary})),ve=48,$i=({hoursBack:e,setHoursBack:n})=>{const a=s=>{n(Bi(s))};return c("div",{children:[t(ki,{children:"Period"}),t(Ia,{name:"feature-metrics-period",id:"feature-metrics-period",options:Pi,value:String(e),onChange:a,fullWidth:!0})]})},Bi=e=>{switch(e){case"1":return 1;case"24":return 24;default:return ve}},Pi=[{key:"1",label:"Last hour"},{key:"24",label:"Last 24 hours"},{key:`${ve}`,label:`Last ${ve} hours`}],Oi=({metrics:e,tableSectionId:n})=>{const a=Ve(Da.breakpoints.down("md")),s=f.useMemo(()=>({sortBy:[{id:"timestamp"}]}),[]),{getTableProps:o,getTableBodyProps:i,headerGroups:r,rows:l,prepareRow:d,setHiddenColumns:p}=Ne.useTable({initialState:s,columns:Lt,data:e,autoResetHiddenColumns:!1,disableSortRemove:!0,defaultColumn:{Cell:Fa}},Ne.useGlobalFilter,Ne.useSortBy);return ka([{condition:a,columns:["appName","environment"]}],p,Lt),e.length===0?null:c($a,{...o(),rowHeight:"standard",id:n,children:[t(Ba,{headerGroups:r}),t(Pa,{...i(),children:l.map(h=>(d(h),t(Oa,{hover:!0,...h.getRowProps(),children:h.cells.map(g=>t(Va,{...g.getCellProps(),children:g.render("Cell")}))})))})]})},Lt=[{id:"Icon",width:"1%",disableSortBy:!0,Cell:()=>t(_a,{icon:t(Eo,{color:"disabled"})})},{Header:"Time",accessor:"timestamp",Cell:e=>t(Ma,{value:e.row.original.timestamp})},{Header:"Application",accessor:"appName"},{Header:"Environment",accessor:"environment"},{id:"requested",Header:"Requested",accessor:e=>e.yes+e.no},{Header:"Exposed",accessor:"yes"}],Vi=({metrics:e,...n})=>{const a=f.useMemo(()=>e.reduce((o,i)=>o+i.yes,0),[e]),s=f.useMemo(()=>e.reduce((o,i)=>o+i.no,0),[e]);return t(un,{...n,totalYes:a,totalNo:s})},_i=({metrics:e,hoursBack:n})=>{const a=vt(),s=vt();return e.length===0?c(U,{mt:6,children:[t(N,{variant:"body1",paragraph:!0,children:"We have yet to receive any metrics for this feature toggle in the selected time period."}),t(N,{variant:"body1",paragraph:!0,children:"Please note that, since the SDKs send metrics on an interval, it might take some time before metrics appear."})]}):c(f.Suspense,{fallback:null,children:[t(U,{borderTop:1,pt:2,mt:3,borderColor:"divider",children:t(Mi,{metrics:e,hoursBack:n,statsSectionId:a})}),t(U,{mt:4,children:t(Vi,{metrics:e,hoursBack:n,statsSectionId:a,tableSectionId:s})}),t(U,{mt:4,children:t(Oi,{metrics:e,tableSectionId:s})})]})},Mi=La.lazy(()=>import("./FeatureMetricsChart-d5c6311d.js")),tt=e=>{const{search:n}=window.location,a=le(),s=f.useMemo(()=>new URLSearchParams(n),[n]),o=f.useCallback(i=>{const r=new URLSearchParams(n);r.set(e,i),a({search:r.toString()},{replace:!0})},[e,n,a]);return[s.get(e)||void 0,o]},Li=e=>{const[n,a]=tt(e),s=f.useCallback(o=>a(String(o)),[a]);return[Number.isFinite(Number(n))?Number(n):void 0,s]},Ni=u("h2")(({theme:e})=>({margin:0,marginBottom:e.spacing(1.5),fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.thin,color:e.palette.text.secondary})),zi=u("ul")(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing(1),listStyleType:"none",padding:0,minHeight:"100%"})),ji=u("li")(({theme:e})=>({"& > [aria-pressed=true]":{backgroundColor:e.palette.background.alternative,color:e.palette.primary.contrastText},"& > [aria-pressed=true]:hover":{backgroundColor:e.palette.primary.light}})),Nt=({title:e,values:n,value:a,setValue:s})=>{const o=r=>()=>{n.has(r)&&s(r)},i=f.useMemo(()=>Array.from(n).sort((r,l)=>r.localeCompare(l)),[n]);return c("div",{children:[t(Ni,{children:e}),t(zi,{children:i.map(r=>t(ji,{children:t(Kt,{label:r,onClick:o(r),"aria-pressed":r===a,sx:Na})},r))})]})},Wi=()=>{const e=I("projectId"),n=I("featureId"),a=qi(e,n),s=Hi(n);Jt("Metrics");const[o=ve,i]=Li("hoursBack"),{featureMetrics:r}=fn(n,o),[l,d]=f.useState(r);f.useEffect(()=>{r&&d(r)},[r]);const p=Array.from(a)[0],h=Array.from(s)[0],[g=p,y]=tt("environment"),[b=h,T]=tt("application"),E=f.useMemo(()=>l==null?void 0:l.filter(S=>S.environment===g).filter(S=>S.appName===b),[l,g,b]);return E?c(pt,{children:[c(ae,{container:!0,component:"header",spacing:2,children:[t(ae,{item:!0,xs:12,md:5,children:t(x,{condition:a.size>0,show:t(Nt,{title:"Environments",values:a,value:g,setValue:y})})}),t(ae,{item:!0,xs:12,md:5,children:t(x,{condition:s.size>0,show:t(Nt,{title:"Applications",values:s,value:b,setValue:T})})}),t(ae,{item:!0,xs:12,md:2,children:t($i,{hoursBack:o,setHoursBack:i})})]}),t(_i,{metrics:E,hoursBack:o})]}):null},qi=(e,n)=>{const{feature:a}=z(e,n),s=a.environments.map(o=>o.name);return new Set(s)},Hi=e=>{const{featureMetrics:n=[]}=fn(e,ve),a=n.map(s=>s.appName);return new Set(a)},Ui=(e,n)=>{const a=new Set(e),s=new Set(n);return a.size!==s.size?!1:[...a].every(o=>s.has(o))},zt=u("div")(({theme:e})=>({display:"grid",gap:e.spacing(2)})),jt=u(se)(({theme:e})=>({marginBottom:e.spacing(1)})),Gi=u(lt)({padding:0}),Yi=({projectId:e,open:n,onClose:a,onClick:s,feature:o,changeRequests:i})=>{const r=I("projectId"),{project:l}=nn(e),{isChangeRequestConfiguredInAnyEnv:d}=te(e),p=d(),h=f.useMemo(()=>Ui(o.environments.map(y=>y.name),l.environments.map(y=>y.environment)),[o,l]),g=i?i.length>0:!1;return t(x,{condition:h&&!g&&!p,show:t(ee,{open:n,onClose:a,onClick:s,title:"Confirm change project",primaryButtonText:"Change project",secondaryButtonText:"Cancel",children:c(zt,{children:[t(jt,{severity:"success",children:"This feature toggle is compatible with the new project."}),t("p",{children:"Are you sure you want to change the project for this toggle?"})]})}),elseShow:t(ee,{open:n,onClick:a,title:"Confirm change project",primaryButtonText:"Close",children:c(zt,{children:[t(jt,{severity:"warning",children:"Cannot proceed with the move"}),t(x,{condition:!h,show:t("p",{children:"In order to move a feature toggle between two projects, both projects must have the exact same environments enabled."})}),t(x,{condition:g,show:c(V,{children:[t("p",{children:"The feature toggle must not have any pending change requests. This feature toggle is currently referenced in the following change requests:"}),t(Gi,{children:i==null?void 0:i.map(y=>t(Be,{children:c(J,{to:`/projects/${r}/change-requests/${y.id}`,children:["View change request"," ",y.id]})},y.id))})]})}),t(x,{condition:p,show:c("p",{children:["You're not allowed to move the feature to project"," ",t(J,{to:`/projects/${e}/settings/change-requests`,children:e}),". This project has change requests enabled."]})})]})})})},Ki=e=>fetch(e).then(Oe("ChangeRequest")).then(n=>n.json()),Ji=(e,n)=>{const{data:a,error:s,mutate:o}=za([],we(`api/admin/projects/${e}/change-requests/pending/${n}`),Ki);return{changeRequests:a,loading:!s&&!a,refetch:o,error:s}},Xi=()=>{const{hasAccess:e}=f.useContext(it),n=I("projectId"),a=I("featureId"),{feature:s,refetchFeature:o}=z(n,a),[i,r]=f.useState(!1),{changeFeatureProject:l}=_e(),{setToastData:d,setToastApiError:p}=q(),[h,g]=f.useState(n),{projects:y}=ja(),b=le(),{changeRequests:T}=Ji(n,a),E=async()=>{try{h&&(await l(n,a,h),o(),d({title:"Project changed",type:"success"}),r(!1),b(`/projects/${h}/features/${a}/settings`,{replace:!0}))}catch(C){p(j(C))}},S=f.useMemo(()=>y.map(C=>C.id).filter(C=>e(wt,C)),[y,e]);return S.length===0?null:c(V,{children:[t(Wa,{value:h,onChange:g,label:"Project",filter:C=>S.includes(C),enabled:!0}),t(oe,{permission:wt,onClick:()=>r(!0),disabled:h===n,projectId:n,children:"Save"}),t(Yi,{changeRequests:T,projectId:h,open:i,feature:s,onClose:()=>r(!1),onClick:E})]})},Qi=u("div")({display:"flex",alignItems:"center"}),Zi=u(N)(({theme:e})=>({fontSize:e.fontSizes.mainHeader})),ec=({projectId:e,featureId:n})=>{var i;const{feature:a}=z(e,n),s=le();return c(V,{children:[c(Qi,{children:[t(Zi,{children:"Feature information"}),t(Z,{permission:ge,projectId:e,"data-loading":!0,onClick:()=>{s(`/projects/${e}/features/${n}/edit`)},tooltipProps:{title:"Edit"},children:t(ye,{})})]}),c(N,{children:["Name: ",t("strong",{children:a.name})]}),c(N,{children:["Description:"," ",t("strong",{children:(i=a.description)!=null&&i.length?a.description:"no description"})]}),c(N,{children:["Type: ",t("strong",{children:a.type})]}),c(N,{children:["Impression Data:"," ",t("strong",{children:a.impressionData?"enabled":"disabled"})]})]})},Fe="metadata",Ke="project",tc=u("div")(({theme:e})=>({width:"20%",borderRight:`1px solid ${e.palette.divider}`,padding:e.spacing(2,0),[e.breakpoints.down("md")]:{width:"35%"}})),nc=u("div")(({theme:e})=>({padding:e.spacing(4),display:"flex",flexDirection:"column",width:400,["& > *"]:{margin:e.spacing(1,0)}})),ac=()=>{const e=I("projectId"),n=I("featureId"),[a,s]=f.useState(Fe),{uiConfig:o}=rt();return t(pt,{header:"Settings",sx:{padding:0},children:c(U,{sx:{display:"flex"},children:[t(tc,{children:c(lt,{children:[t(Be,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>s(Fe),selected:a===Fe,children:"Metadata"},0),t(Be,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>s(Ke),selected:a===Ke,hidden:!o.flags.P,children:"Project"},1)]})}),c(nc,{children:[t(x,{condition:a===Fe,show:t(ec,{projectId:e,featureId:n})}),t(x,{condition:a===Ke&&o.flags.P,show:t(Xi,{})})]})]})})},oc=({stale:e,showActive:n=!0})=>!e&&!n?null:t("div",{"data-loading":!0,style:{marginLeft:"8px"},children:t(be,{color:e?"error":"success",title:e?"Feature toggle is deprecated.":"Feature toggle is active.",children:e?"Stale":"Active"})}),Wt=u("strong")({wordBreak:"break-all"}),sc=()=>{const e=I("projectId"),n=I("featureId"),{archivedFeatures:a}=qa(),s=Ha(e,{name:n});return a?a.some(i=>i.name===n)?c("p",{children:["The feature ",t(Wt,{children:n})," has been archived. You can find it on the"," ",t(J,{to:`/projects/${e}/archive`,children:"project archive page"}),"."]}):c("p",{children:["The feature ",t(Wt,{children:n})," does not exist. Would you like to"," ",t(J,{to:s,children:"create it"}),"?"]}):null},rc=u("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),ic=u("div")(({theme:e})=>({padding:e.spacing(2,4,2,2),display:"flex",justifyContent:"space-between",alignItems:"center",[e.breakpoints.down(500)]:{flexDirection:"column"}})),cc=u("div")({display:"flex",alignItems:"center"}),lc=u("h1")(({theme:e})=>({fontSize:e.fontSizes.mainHeader,fontWeight:"normal",display:"flex",alignItems:"center",wordBreak:"break-all"})),dc=u("div")({flexShrink:0,display:"flex"}),uc=u("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.divider,height:"1px"})),pc=u("div")(({theme:e})=>({padding:e.spacing(0,4)})),gc=u(Ua)(({theme:e})=>({textTransform:"none",width:"auto",fontSize:e.fontSizes.bodySize,padding:"0 !important",[e.breakpoints.up("md")]:{minWidth:160}})),Sc=()=>{const e=I("projectId"),n=I("featureId"),{refetch:a}=nn(e),{favorite:s,unfavorite:o}=Ga(),{refetchFeature:i}=z(e,n),[r,l]=f.useState(!1),[d,p]=f.useState(!1),[h,g]=f.useState(!1),y=Ve("(max-width:500px)"),{feature:b,loading:T,error:E,status:S}=z(e,n),C=le(),{pathname:w}=Ya(),F=Ka(T),$=`/projects/${e}/features/${n}`,M=[{title:"Overview",path:`${$}`,name:"overview"},{title:"Metrics",path:`${$}/metrics`,name:"Metrics"},{title:"Variants",path:`${$}/variants`,name:"Variants"},{title:"Settings",path:`${$}/settings`,name:"Settings"},{title:"Event log",path:`${$}/logs`,name:"Event log"}],k=M.find(O=>O.path===w)??M[0],P=async()=>{b!=null&&b.favorite?await o(e,b.name):await s(e,b.name),i()};return S===404?t(sc,{}):E!==void 0?t("div",{ref:F}):c("div",{ref:F,children:[c(rc,{children:[c(ic,{children:[c(cc,{children:[t(Ja,{onClick:P,isFavorite:b==null?void 0:b.favorite}),c(lc,{"data-loading":!0,children:[b.name," "]}),t(x,{condition:!y,show:t(oc,{stale:b==null?void 0:b.stale})})]}),c(dc,{children:[t(Z,{permission:Xa,projectId:e,"data-loading":!0,component:J,to:`/projects/${e}/features/${n}/strategies/copy`,tooltipProps:{title:"Copy feature toggle"},children:t(Qa,{})}),t(Z,{permission:Za,projectId:e,tooltipProps:{title:"Archive feature toggle"},"data-loading":!0,onClick:()=>p(!0),children:t(Ao,{})}),t(Z,{onClick:()=>g(!0),permission:ge,projectId:e,tooltipProps:{title:"Toggle stale state"},"data-loading":!0,children:t(mo,{})}),t(Z,{onClick:()=>l(!0),permission:ge,projectId:e,tooltipProps:{title:"Add tag"},"data-loading":!0,children:t(eo,{})})]})]}),t(uc,{}),t(pc,{children:t(to,{value:k.path,indicatorColor:"primary",textColor:"primary",children:M.map(O=>t(gc,{label:O.title,value:O.path,onClick:()=>C(O.path),"data-testid":`TAB-${O.title}`},O.title))})})]}),c(Xt,{children:[t(re,{path:"metrics",element:t(Wi,{})}),t(re,{path:"logs",element:t(Io,{})}),t(re,{path:"variants",element:t(Ii,{})}),t(re,{path:"settings",element:t(ac,{})}),t(re,{path:"*",element:t(Ir,{})})]}),t(fo,{isOpen:d,onConfirm:()=>{a(),C(`/projects/${e}`)},onClose:()=>p(!1),projectId:e,featureIds:[n]}),t(yo,{isStale:b.stale,isOpen:h,onClose:()=>{g(!1),i()},featureId:n,projectId:e}),t(gn,{open:r,setOpen:l})]})};export{Sc as default};
7
+ --data-raw '${JSON.stringify(O.patch,void 0,2)}'`,ne=C.every(({isValid:R})=>R),A=T((e==null?void 0:e.name)||""),B=A?"Add to existing change request":"Add change to draft",m=y((e==null?void 0:e.name)||""),v=f.useMemo(()=>{var R;return g?"":((R=P[0])==null?void 0:R.stickiness)||h},[g,h,JSON.stringify(P[0]??{})]),D=f.useMemo(()=>["default",...p.filter(R=>R.stickiness).map(R=>R.name)],[p]),W=D.map(R=>({key:R,label:R}));D.includes(v)||W.push({key:v,label:v});const L=async R=>{w(H=>H.map(ue=>({...ue,stickiness:R})))},_=R=>{L(R)},[Re,Ie]=f.useState();f.useEffect(()=>{Ie(void 0),O.error&&Ie(O.error)},[O.error]);const ft=()=>{L(h),a(!1)};return g||v===""?t(Ca,{}):t(Ze,{open:n,onClose:ft,label:"",children:c(va,{modal:!0,title:"",description:"Variants allows you to return a variant object if the feature toggle is considered enabled for the current request.",documentationLink:"https://docs.getunleash.io/reference/feature-toggle-variants",documentationLinkLabel:"Feature toggle variants documentation",formatApiCode:X,loading:!n,children:[c(Qr,{children:[c("div",{children:[t(Zr,{deprecated:!(e!=null&&e.enabled)}),t(ei,{deprecated:!(e!=null&&e.enabled),children:e==null?void 0:e.name})]}),t(oe,{"data-testid":"MODAL_ADD_VARIANT_BUTTON",onClick:k,variant:"outlined",permission:pe,projectId:r,environmentId:e==null?void 0:e.name,children:"Add variant"})]}),c(ti,{onSubmit:Y,children:[t(x,{condition:A,show:E,elseShow:t(x,{condition:!!m,show:c(ni,{severity:"info",children:[t("strong",{children:"Change requests"})," are enabled",e?` for ${e.name}`:"",". Your changes need to be approved before they will be live. All the changes you do now will be added into a draft that you can submit for review."]})})}),t(oi,{children:C.map(R=>t(Xr,{variant:R,variants:C,updateVariant:H=>M(H,R.id),removeVariant:()=>w(H=>bt(H.filter(ue=>ue.id!==R.id),1e3)),projectId:r,apiPayload:O},R.id))}),t(oe,{onClick:k,variant:"outlined",permission:pe,projectId:r,environmentId:e==null?void 0:e.name,children:"Add variant"}),t(ri,{}),t(x,{condition:C.length>0,show:c(V,{children:[t(si,{children:t("p",{children:"Stickiness"})}),c(Mt,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t(dt,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]}),t("div",{children:t(ii,{value:v,label:"",editable:!0,onChange:R=>_(R.target.value)})})]}),elseShow:t(Mt,{children:"This environment has no variants. Get started by adding a variant."})}),c(ai,{severity:"error",hidden:!Re,children:[t("strong",{children:"Error: "}),Re]}),c(ci,{children:[t(de,{"data-testid":"DIALOGUE_CONFIRM_ID",type:"submit",variant:"contained",color:"primary",disabled:!ne,children:m?B:"Save variants"}),t(li,{onClick:ft,children:"Cancel"})]})]})]})})},ui=u("div")(({theme:e})=>({padding:e.spacing(3),borderRadius:e.shape.borderRadiusLarge,border:`1px solid ${e.palette.divider}`,"&:not(:last-child)":{marginBottom:e.spacing(3)}})),pi=u("div")({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"}}),gi=u(tn,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.neutral.border:e.palette.primary.main})),hi=u("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontWeight:e.fontWeight.bold})),mi=u("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),fi=u("div")(({theme:e})=>({margin:e.spacing(3,0)})),yi=u("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),Si=({environment:e,searchValue:n,children:a})=>{var i;const s=e.variants??[],o=((i=s[0])==null?void 0:i.stickiness)||"default";return c(ui,{children:[c(pi,{children:[c("div",{children:[t(gi,{deprecated:!e.enabled}),t(hi,{deprecated:!e.enabled,children:e.name})]}),a]}),t(x,{condition:s.length>0,show:c(V,{children:[t(fi,{children:t(Ta,{variants:s,searchValue:n})}),t(x,{condition:s.length>1,show:c(V,{children:[c(yi,{children:[t("p",{children:"Stickiness:"}),t(be,{children:o})]}),c(mi,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t(dt,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]})]})})]})})]})},bi=u(Se)(({theme:e})=>({"& span":{fontSize:e.fontSizes.smallBody}})),Ci=({environment:e,permission:n,projectId:a,environmentId:s,onCopyVariantsFrom:o,otherEnvsWithVariants:i})=>{const[r,l]=f.useState(null),d=!!r,p=e.variants??[];return t(x,{condition:i.length>0&&p.length===0,show:c(V,{children:[t(oe,{onClick:h=>{l(h.currentTarget)},id:`copy-from-menu-${e.name}`,"aria-controls":d?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":d?"true":void 0,variant:"outlined",permission:n,projectId:a,environmentId:s,children:"Copy variants from"}),t(Ee,{anchorEl:r,open:d,onClose:()=>l(null),MenuListProps:{"aria-labelledby":`copy-from-menu-${e.name}`},children:i.map(h=>t(me,{onClick:()=>o(h,e),children:t(bi,{children:`Copy from ${h.name}`})},h.name))})]})})},vi=({permission:e,projectId:n,environment:a,checked:s,onClick:o,...i})=>{const r=Je(e,n,a);return c(me,{disabled:!r,onClick:o,...i,children:[t(xa,{checked:s}),a]})},wi=u(Ee)(({theme:e})=>({"& > div > ul":{display:"flex",flexDirection:"column",justifyContent:"center","& > li":{padding:e.spacing(0,1)}}})),Ti=u("div")(({theme:e})=>({margin:e.spacing(1,2)})),xi=u(de)(({theme:e})=>({marginTop:e.spacing(2)})),Ai=({current:e,environments:n,permission:a,projectId:s,onSubmit:o})=>{var E;const[i,r]=f.useState(null),l=!!i,[d,p]=f.useState([]),h=S=>{p(C=>[...C,S])},g=S=>{p(C=>C.filter(({name:w})=>w!==S.name))},y=S=>{d.includes(S)?g(S):h(S)},b=()=>{p([]),r(null)},T=((E=n.find(S=>S.name===e))==null?void 0:E.variants)??[];return t(x,{condition:T.length>0&&n.length>1,show:c(V,{children:[t(de,{onClick:S=>{r(S.currentTarget)},id:`push-to-menu-${e}`,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,variant:"outlined",children:"Push to environment"}),c(wi,{anchorEl:i,open:l,onClose:()=>r(null),MenuListProps:{"aria-labelledby":`push-to-menu-${e}`},children:[n.filter(S=>S.name!==e).map(S=>t(vi,{projectId:s,permission:a,environment:S.name,checked:d.includes(S),onClick:()=>y(S)},S.name)),c(Ti,{children:[t(Ce,{}),c(xi,{variant:"outlined",onClick:()=>{o(d),b()},disabled:d.length===0,children:["Push to selected (",d.length,")"]})]})]})]})})},Ei=u(se)(({theme:e})=>({marginBottom:e.spacing(4),"& code":{fontWeight:e.fontWeight.bold}})),Ri=u("div")(({theme:e})=>({display:"flex",gap:e.spacing(1.5)})),Ii=()=>{const{setToastData:e,setToastApiError:n}=q(),a=Ut(),s=Ve(a.breakpoints.down("md")),o=I("projectId"),i=I("featureId"),{feature:r,refetchFeature:l,loading:d}=z(o,i),{patchFeatureEnvironmentVariants:p,overrideVariantsInEnvironments:h}=_e(),{refetch:g}=ie(o),{addChange:y}=Te(),{isChangeRequestConfigured:b}=te(o),[T,E]=f.useState(""),[S,C]=f.useState(),[w,F]=f.useState(!1),$=f.useMemo(()=>{var A;return((A=r==null?void 0:r.environments)==null?void 0:A.map(B=>({...B,crEnabled:b(B.name)})))||[]},[r.environments]),M=(A,B)=>Ra(A,B),k=(A,B)=>{try{const m=Ea(B,1e3);return{patch:M(A,m)}}catch(m){return{patch:[],error:j(m)}}},P=A=>({feature:i,action:"patchVariant",payload:{variants:A}}),O=async(A,B)=>{if(A.crEnabled)await y(o,A.name,P(B)),g();else{const m=A.variants??[],{patch:v,error:D}=k(m,B);if(v.length===0)return;if(D){e({type:"error",title:D});return}await p(o,i,A.name,v)}l()},G=async(A,B)=>{try{const m=B.filter(({crEnabled:_})=>_),v=B.filter(({crEnabled:_})=>!_);m.length&&await Promise.all(m.map(_=>y(o,_.name,P(A)))),v.length&&await h(o,i,A,v.map(({name:_})=>_)),g(),l();const D=v.length?`Variants pushed to ${v.length===1?v[0].name:`${v.length} environments`}`:"",W=m.length?`Variants push added to ${m.length===1?`${m[0].name} draft`:`${m.length} drafts`}`:"",L=`${D}${D&&W?". ":""}${W}`;e({title:L,type:"success"})}catch(m){n(j(m))}},Y=A=>{C(A),F(!0)},X=async A=>{if(S)try{await O(S,A),F(!1),e({title:S.crEnabled?"Variant changes added to draft":"Variants updated successfully",type:"success"})}catch(B){n(j(B))}},ne=async(A,B)=>{try{const m=A.variants??[];await O(B,m),e({title:B.crEnabled?"Variants copy added to draft":"Variants copied successfully",type:"success"})}catch(m){n(j(m))}};return c(pt,{isLoading:d,header:t(Aa,{title:"Variants",actions:t(x,{condition:!s,show:t(V,{children:t(Ct,{initialValue:T,onChange:E})})}),children:t(x,{condition:s,show:t(Ct,{initialValue:T,onChange:E})})}),children:[c(Ei,{severity:"info",children:["Variants allows you to return a variant object if the feature toggle is considered enabled for the current request. When using variants you should use the ",t("code",{children:"getVariant()"})," method in the Client SDK."]}),$.map(A=>{var m;const B=$.filter(({name:v,variants:D})=>v!==A.name&&(D==null?void 0:D.length));return t(Si,{environment:A,searchValue:T,children:c(Ri,{children:[t(Ai,{current:A.name,environments:$,permission:pe,projectId:o,onSubmit:v=>G(A.variants??[],v)}),t(Ci,{environment:A,permission:pe,projectId:o,environmentId:A.name,onCopyVariantsFrom:ne,otherEnvsWithVariants:B}),t(x,{condition:!!((m=A.variants)!=null&&m.length),show:t(Z,{"data-testid":"EDIT_VARIANTS_BUTTON",onClick:()=>Y(A),permission:pe,projectId:o,environmentId:A.name,tooltipProps:{title:"Edit variants"},children:t(ye,{})}),elseShow:t(oe,{"data-testid":"ADD_VARIANT_BUTTON",onClick:()=>Y(A),variant:"outlined",permission:pe,projectId:o,environmentId:A.name,children:"Add variant"})})]})},A.name)}),t(di,{environment:S,open:w,setOpen:F,getApiPayload:k,getCrPayload:P,onConfirm:X})]})},Di=we("api/admin/client-metrics/features"),fn=(e,n)=>{const a=we(`api/admin/client-metrics/features/${e}/raw?hoursBack=${n}`),{data:s,error:o}=nt(a,()=>Fi(a)),i=f.useCallback(()=>{at(Di).catch(console.warn)},[]);return{featureMetrics:s==null?void 0:s.data,loading:!o&&!s,refetchFeatureMetrics:i,error:o}},Fi=e=>fetch(e).then(Oe("Features")).then(n=>n.json()).then(),ki=u("h2")(({theme:e})=>({margin:0,marginBottom:e.spacing(1),fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.thin,color:e.palette.text.secondary})),ve=48,$i=({hoursBack:e,setHoursBack:n})=>{const a=s=>{n(Bi(s))};return c("div",{children:[t(ki,{children:"Period"}),t(Ia,{name:"feature-metrics-period",id:"feature-metrics-period",options:Pi,value:String(e),onChange:a,fullWidth:!0})]})},Bi=e=>{switch(e){case"1":return 1;case"24":return 24;default:return ve}},Pi=[{key:"1",label:"Last hour"},{key:"24",label:"Last 24 hours"},{key:`${ve}`,label:`Last ${ve} hours`}],Oi=({metrics:e,tableSectionId:n})=>{const a=Ve(Da.breakpoints.down("md")),s=f.useMemo(()=>({sortBy:[{id:"timestamp"}]}),[]),{getTableProps:o,getTableBodyProps:i,headerGroups:r,rows:l,prepareRow:d,setHiddenColumns:p}=Ne.useTable({initialState:s,columns:Lt,data:e,autoResetHiddenColumns:!1,disableSortRemove:!0,defaultColumn:{Cell:Fa}},Ne.useGlobalFilter,Ne.useSortBy);return ka([{condition:a,columns:["appName","environment"]}],p,Lt),e.length===0?null:c($a,{...o(),rowHeight:"standard",id:n,children:[t(Ba,{headerGroups:r}),t(Pa,{...i(),children:l.map(h=>(d(h),t(Oa,{hover:!0,...h.getRowProps(),children:h.cells.map(g=>t(Va,{...g.getCellProps(),children:g.render("Cell")}))})))})]})},Lt=[{id:"Icon",width:"1%",disableSortBy:!0,Cell:()=>t(_a,{icon:t(Eo,{color:"disabled"})})},{Header:"Time",accessor:"timestamp",Cell:e=>t(Ma,{value:e.row.original.timestamp})},{Header:"Application",accessor:"appName"},{Header:"Environment",accessor:"environment"},{id:"requested",Header:"Requested",accessor:e=>e.yes+e.no},{Header:"Exposed",accessor:"yes"}],Vi=({metrics:e,...n})=>{const a=f.useMemo(()=>e.reduce((o,i)=>o+i.yes,0),[e]),s=f.useMemo(()=>e.reduce((o,i)=>o+i.no,0),[e]);return t(un,{...n,totalYes:a,totalNo:s})},_i=({metrics:e,hoursBack:n})=>{const a=vt(),s=vt();return e.length===0?c(U,{mt:6,children:[t(N,{variant:"body1",paragraph:!0,children:"We have yet to receive any metrics for this feature toggle in the selected time period."}),t(N,{variant:"body1",paragraph:!0,children:"Please note that, since the SDKs send metrics on an interval, it might take some time before metrics appear."})]}):c(f.Suspense,{fallback:null,children:[t(U,{borderTop:1,pt:2,mt:3,borderColor:"divider",children:t(Mi,{metrics:e,hoursBack:n,statsSectionId:a})}),t(U,{mt:4,children:t(Vi,{metrics:e,hoursBack:n,statsSectionId:a,tableSectionId:s})}),t(U,{mt:4,children:t(Oi,{metrics:e,tableSectionId:s})})]})},Mi=La.lazy(()=>import("./FeatureMetricsChart-1c6bb078.js")),tt=e=>{const{search:n}=window.location,a=le(),s=f.useMemo(()=>new URLSearchParams(n),[n]),o=f.useCallback(i=>{const r=new URLSearchParams(n);r.set(e,i),a({search:r.toString()},{replace:!0})},[e,n,a]);return[s.get(e)||void 0,o]},Li=e=>{const[n,a]=tt(e),s=f.useCallback(o=>a(String(o)),[a]);return[Number.isFinite(Number(n))?Number(n):void 0,s]},Ni=u("h2")(({theme:e})=>({margin:0,marginBottom:e.spacing(1.5),fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.thin,color:e.palette.text.secondary})),zi=u("ul")(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing(1),listStyleType:"none",padding:0,minHeight:"100%"})),ji=u("li")(({theme:e})=>({"& > [aria-pressed=true]":{backgroundColor:e.palette.background.alternative,color:e.palette.primary.contrastText},"& > [aria-pressed=true]:hover":{backgroundColor:e.palette.primary.light}})),Nt=({title:e,values:n,value:a,setValue:s})=>{const o=r=>()=>{n.has(r)&&s(r)},i=f.useMemo(()=>Array.from(n).sort((r,l)=>r.localeCompare(l)),[n]);return c("div",{children:[t(Ni,{children:e}),t(zi,{children:i.map(r=>t(ji,{children:t(Kt,{label:r,onClick:o(r),"aria-pressed":r===a,sx:Na})},r))})]})},Wi=()=>{const e=I("projectId"),n=I("featureId"),a=qi(e,n),s=Hi(n);Jt("Metrics");const[o=ve,i]=Li("hoursBack"),{featureMetrics:r}=fn(n,o),[l,d]=f.useState(r);f.useEffect(()=>{r&&d(r)},[r]);const p=Array.from(a)[0],h=Array.from(s)[0],[g=p,y]=tt("environment"),[b=h,T]=tt("application"),E=f.useMemo(()=>l==null?void 0:l.filter(S=>S.environment===g).filter(S=>S.appName===b),[l,g,b]);return E?c(pt,{children:[c(ae,{container:!0,component:"header",spacing:2,children:[t(ae,{item:!0,xs:12,md:5,children:t(x,{condition:a.size>0,show:t(Nt,{title:"Environments",values:a,value:g,setValue:y})})}),t(ae,{item:!0,xs:12,md:5,children:t(x,{condition:s.size>0,show:t(Nt,{title:"Applications",values:s,value:b,setValue:T})})}),t(ae,{item:!0,xs:12,md:2,children:t($i,{hoursBack:o,setHoursBack:i})})]}),t(_i,{metrics:E,hoursBack:o})]}):null},qi=(e,n)=>{const{feature:a}=z(e,n),s=a.environments.map(o=>o.name);return new Set(s)},Hi=e=>{const{featureMetrics:n=[]}=fn(e,ve),a=n.map(s=>s.appName);return new Set(a)},Ui=(e,n)=>{const a=new Set(e),s=new Set(n);return a.size!==s.size?!1:[...a].every(o=>s.has(o))},zt=u("div")(({theme:e})=>({display:"grid",gap:e.spacing(2)})),jt=u(se)(({theme:e})=>({marginBottom:e.spacing(1)})),Gi=u(lt)({padding:0}),Yi=({projectId:e,open:n,onClose:a,onClick:s,feature:o,changeRequests:i})=>{const r=I("projectId"),{project:l}=nn(e),{isChangeRequestConfiguredInAnyEnv:d}=te(e),p=d(),h=f.useMemo(()=>Ui(o.environments.map(y=>y.name),l.environments.map(y=>y.environment)),[o,l]),g=i?i.length>0:!1;return t(x,{condition:h&&!g&&!p,show:t(ee,{open:n,onClose:a,onClick:s,title:"Confirm change project",primaryButtonText:"Change project",secondaryButtonText:"Cancel",children:c(zt,{children:[t(jt,{severity:"success",children:"This feature toggle is compatible with the new project."}),t("p",{children:"Are you sure you want to change the project for this toggle?"})]})}),elseShow:t(ee,{open:n,onClick:a,title:"Confirm change project",primaryButtonText:"Close",children:c(zt,{children:[t(jt,{severity:"warning",children:"Cannot proceed with the move"}),t(x,{condition:!h,show:t("p",{children:"In order to move a feature toggle between two projects, both projects must have the exact same environments enabled."})}),t(x,{condition:g,show:c(V,{children:[t("p",{children:"The feature toggle must not have any pending change requests. This feature toggle is currently referenced in the following change requests:"}),t(Gi,{children:i==null?void 0:i.map(y=>t(Be,{children:c(J,{to:`/projects/${r}/change-requests/${y.id}`,children:["View change request"," ",y.id]})},y.id))})]})}),t(x,{condition:p,show:c("p",{children:["You're not allowed to move the feature to project"," ",t(J,{to:`/projects/${e}/settings/change-requests`,children:e}),". This project has change requests enabled."]})})]})})})},Ki=e=>fetch(e).then(Oe("ChangeRequest")).then(n=>n.json()),Ji=(e,n)=>{const{data:a,error:s,mutate:o}=za([],we(`api/admin/projects/${e}/change-requests/pending/${n}`),Ki);return{changeRequests:a,loading:!s&&!a,refetch:o,error:s}},Xi=()=>{const{hasAccess:e}=f.useContext(it),n=I("projectId"),a=I("featureId"),{feature:s,refetchFeature:o}=z(n,a),[i,r]=f.useState(!1),{changeFeatureProject:l}=_e(),{setToastData:d,setToastApiError:p}=q(),[h,g]=f.useState(n),{projects:y}=ja(),b=le(),{changeRequests:T}=Ji(n,a),E=async()=>{try{h&&(await l(n,a,h),o(),d({title:"Project changed",type:"success"}),r(!1),b(`/projects/${h}/features/${a}/settings`,{replace:!0}))}catch(C){p(j(C))}},S=f.useMemo(()=>y.map(C=>C.id).filter(C=>e(wt,C)),[y,e]);return S.length===0?null:c(V,{children:[t(Wa,{value:h,onChange:g,label:"Project",filter:C=>S.includes(C),enabled:!0}),t(oe,{permission:wt,onClick:()=>r(!0),disabled:h===n,projectId:n,children:"Save"}),t(Yi,{changeRequests:T,projectId:h,open:i,feature:s,onClose:()=>r(!1),onClick:E})]})},Qi=u("div")({display:"flex",alignItems:"center"}),Zi=u(N)(({theme:e})=>({fontSize:e.fontSizes.mainHeader})),ec=({projectId:e,featureId:n})=>{var i;const{feature:a}=z(e,n),s=le();return c(V,{children:[c(Qi,{children:[t(Zi,{children:"Feature information"}),t(Z,{permission:ge,projectId:e,"data-loading":!0,onClick:()=>{s(`/projects/${e}/features/${n}/edit`)},tooltipProps:{title:"Edit"},children:t(ye,{})})]}),c(N,{children:["Name: ",t("strong",{children:a.name})]}),c(N,{children:["Description:"," ",t("strong",{children:(i=a.description)!=null&&i.length?a.description:"no description"})]}),c(N,{children:["Type: ",t("strong",{children:a.type})]}),c(N,{children:["Impression Data:"," ",t("strong",{children:a.impressionData?"enabled":"disabled"})]})]})},Fe="metadata",Ke="project",tc=u("div")(({theme:e})=>({width:"20%",borderRight:`1px solid ${e.palette.divider}`,padding:e.spacing(2,0),[e.breakpoints.down("md")]:{width:"35%"}})),nc=u("div")(({theme:e})=>({padding:e.spacing(4),display:"flex",flexDirection:"column",width:400,["& > *"]:{margin:e.spacing(1,0)}})),ac=()=>{const e=I("projectId"),n=I("featureId"),[a,s]=f.useState(Fe),{uiConfig:o}=rt();return t(pt,{header:"Settings",sx:{padding:0},children:c(U,{sx:{display:"flex"},children:[t(tc,{children:c(lt,{children:[t(Be,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>s(Fe),selected:a===Fe,children:"Metadata"},0),t(Be,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>s(Ke),selected:a===Ke,hidden:!o.flags.P,children:"Project"},1)]})}),c(nc,{children:[t(x,{condition:a===Fe,show:t(ec,{projectId:e,featureId:n})}),t(x,{condition:a===Ke&&o.flags.P,show:t(Xi,{})})]})]})})},oc=({stale:e,showActive:n=!0})=>!e&&!n?null:t("div",{"data-loading":!0,style:{marginLeft:"8px"},children:t(be,{color:e?"error":"success",title:e?"Feature toggle is deprecated.":"Feature toggle is active.",children:e?"Stale":"Active"})}),Wt=u("strong")({wordBreak:"break-all"}),sc=()=>{const e=I("projectId"),n=I("featureId"),{archivedFeatures:a}=qa(),s=Ha(e,{name:n});return a?a.some(i=>i.name===n)?c("p",{children:["The feature ",t(Wt,{children:n})," has been archived. You can find it on the"," ",t(J,{to:`/projects/${e}/archive`,children:"project archive page"}),"."]}):c("p",{children:["The feature ",t(Wt,{children:n})," does not exist. Would you like to"," ",t(J,{to:s,children:"create it"}),"?"]}):null},rc=u("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),ic=u("div")(({theme:e})=>({padding:e.spacing(2,4,2,2),display:"flex",justifyContent:"space-between",alignItems:"center",[e.breakpoints.down(500)]:{flexDirection:"column"}})),cc=u("div")({display:"flex",alignItems:"center"}),lc=u("h1")(({theme:e})=>({fontSize:e.fontSizes.mainHeader,fontWeight:"normal",display:"flex",alignItems:"center",wordBreak:"break-all"})),dc=u("div")({flexShrink:0,display:"flex"}),uc=u("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.divider,height:"1px"})),pc=u("div")(({theme:e})=>({padding:e.spacing(0,4)})),gc=u(Ua)(({theme:e})=>({textTransform:"none",width:"auto",fontSize:e.fontSizes.bodySize,padding:"0 !important",[e.breakpoints.up("md")]:{minWidth:160}})),Sc=()=>{const e=I("projectId"),n=I("featureId"),{refetch:a}=nn(e),{favorite:s,unfavorite:o}=Ga(),{refetchFeature:i}=z(e,n),[r,l]=f.useState(!1),[d,p]=f.useState(!1),[h,g]=f.useState(!1),y=Ve("(max-width:500px)"),{feature:b,loading:T,error:E,status:S}=z(e,n),C=le(),{pathname:w}=Ya(),F=Ka(T),$=`/projects/${e}/features/${n}`,M=[{title:"Overview",path:`${$}`,name:"overview"},{title:"Metrics",path:`${$}/metrics`,name:"Metrics"},{title:"Variants",path:`${$}/variants`,name:"Variants"},{title:"Settings",path:`${$}/settings`,name:"Settings"},{title:"Event log",path:`${$}/logs`,name:"Event log"}],k=M.find(O=>O.path===w)??M[0],P=async()=>{b!=null&&b.favorite?await o(e,b.name):await s(e,b.name),i()};return S===404?t(sc,{}):E!==void 0?t("div",{ref:F}):c("div",{ref:F,children:[c(rc,{children:[c(ic,{children:[c(cc,{children:[t(Ja,{onClick:P,isFavorite:b==null?void 0:b.favorite}),c(lc,{"data-loading":!0,children:[b.name," "]}),t(x,{condition:!y,show:t(oc,{stale:b==null?void 0:b.stale})})]}),c(dc,{children:[t(Z,{permission:Xa,projectId:e,"data-loading":!0,component:J,to:`/projects/${e}/features/${n}/strategies/copy`,tooltipProps:{title:"Copy feature toggle"},children:t(Qa,{})}),t(Z,{permission:Za,projectId:e,tooltipProps:{title:"Archive feature toggle"},"data-loading":!0,onClick:()=>p(!0),children:t(Ao,{})}),t(Z,{onClick:()=>g(!0),permission:ge,projectId:e,tooltipProps:{title:"Toggle stale state"},"data-loading":!0,children:t(mo,{})}),t(Z,{onClick:()=>l(!0),permission:ge,projectId:e,tooltipProps:{title:"Add tag"},"data-loading":!0,children:t(eo,{})})]})]}),t(uc,{}),t(pc,{children:t(to,{value:k.path,indicatorColor:"primary",textColor:"primary",children:M.map(O=>t(gc,{label:O.title,value:O.path,onClick:()=>C(O.path),"data-testid":`TAB-${O.title}`},O.title))})})]}),c(Xt,{children:[t(re,{path:"metrics",element:t(Wi,{})}),t(re,{path:"logs",element:t(Io,{})}),t(re,{path:"variants",element:t(Ii,{})}),t(re,{path:"settings",element:t(ac,{})}),t(re,{path:"*",element:t(Ir,{})})]}),t(fo,{isOpen:d,onConfirm:()=>{a(),C(`/projects/${e}`)},onClose:()=>p(!1),projectId:e,featureIds:[n]}),t(yo,{isStale:b.stale,isOpen:h,onClose:()=>{g(!1),i()},featureId:n,projectId:e}),t(gn,{open:r,setOpen:l})]})};export{Sc as default};