unleash-server 6.2.1 → 6.2.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 (25) hide show
  1. package/dist/lib/features/project-environments/environments.d.ts.map +1 -1
  2. package/dist/lib/features/project-environments/environments.js +1 -1
  3. package/dist/lib/features/project-environments/environments.js.map +1 -1
  4. package/frontend/build/index.html +1 -1
  5. package/frontend/build/static/{AdvancedPlayground-C-dAyAx-.js → AdvancedPlayground-CRdeeG3w.js} +1 -1
  6. package/frontend/build/static/{CreateProject-B4Jpedfs.js → CreateProject-8AyZj2dp.js} +1 -1
  7. package/frontend/build/static/{FeatureMetricsChart-CfRbEeZY.js → FeatureMetricsChart-DEo4WxO1.js} +1 -1
  8. package/frontend/build/static/FeatureStaleDialog-CrsbH2rq.js +7 -0
  9. package/frontend/build/static/{FeatureViewLazyExport--kJx8txU.js → FeatureViewLazyExport-BwY7TYmZ.js} +2 -2
  10. package/frontend/build/static/{LazyAdminExport-DY3JyvJM.js → LazyAdminExport-0g_UOhr3.js} +2 -2
  11. package/frontend/build/static/{LazyProjectExport-COo-ZbGx.js → LazyProjectExport-C1eSkT3Z.js} +18 -18
  12. package/frontend/build/static/LineChartComponent-BLXX5chp.js +1 -0
  13. package/frontend/build/static/{NetworkOverview-DiYdB1sN.js → NetworkOverview-DqGLVIJ6.js} +1 -1
  14. package/frontend/build/static/{NetworkTraffic-BIfuZ2W8.js → NetworkTraffic-BWFLlaz7.js} +1 -1
  15. package/frontend/build/static/{NetworkTrafficUsage-Cl1H-fhz.js → NetworkTrafficUsage-BvoBumVR.js} +1 -1
  16. package/frontend/build/static/{ReactJSONEditor-DlCBXnpp.js → ReactJSONEditor-Bvhd5heT.js} +1 -1
  17. package/frontend/build/static/{RoleCell-CyUjGKex.js → RoleCell-DGcue0jn.js} +1 -1
  18. package/frontend/build/static/{StrategyItemContainer-C2s-CIiO.js → StrategyItemContainer-Das6_30A.js} +1 -1
  19. package/frontend/build/static/{index-CFvoUqKv.js → index-BsIpdLcw.js} +1 -1
  20. package/frontend/build/static/{index-BkkVRgMF.js → index-Cx91uh9W.js} +16 -16
  21. package/frontend/build/static/{unknownify-B5EW5GrF.js → unknownify-8qa4PVkQ.js} +1 -1
  22. package/frontend/build/static/{useApiTokens-BQFDjDJi.js → useApiTokens-5JgqgHim.js} +1 -1
  23. package/package.json +1 -1
  24. package/frontend/build/static/FeatureStaleDialog-DX_vqibC.js +0 -7
  25. package/frontend/build/static/LineChartComponent-Bh-DtN3E.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"environments.d.ts","sourceRoot":"","sources":["../../../../src/lib/features/project-environments/environments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAGxB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAEH,KAAK,2BAA2B,EAKhC,KAAK,wBAAwB,EAChC,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAK/D,UAAU,yBAAyB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,UAAU;IAC1D,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,kBAAkB,CAAwC;IAElE,OAAO,CAAC,cAAc,CAAiB;IAEvC,OAAO,CAAC,cAAc,CAAiB;gBAGnC,MAAM,EAAE,cAAc,EACtB,EACI,+BAA+B,EAC/B,cAAc,EACd,cAAc,GACjB,EAAE,IAAI,CACH,gBAAgB,EACd,iCAAiC,GACjC,gBAAgB,GAChB,gBAAgB,CACrB;IA+EC,uBAAuB,CACzB,GAAG,EAAE,YAAY,CACb,IAAI,CAAC,yBAAyB,EAAE,aAAa,CAAC,EAC9C,IAAI,EACJ,wBAAwB,CAC3B,EACD,GAAG,EAAE,QAAQ,GACd,OAAO,CAAC,IAAI,CAAC;IAYV,4BAA4B,CAC9B,GAAG,EAAE,YAAY,CAAC,yBAAyB,CAAC,EAC5C,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,GACpB,OAAO,CAAC,IAAI,CAAC;IAcV,0CAA0C,CAC5C,GAAG,EAAE,YAAY,CACb,yBAAyB,EACzB,2BAA2B,CAC9B,EACD,GAAG,EAAE,QAAQ,CAAC,2BAA2B,CAAC,GAC3C,OAAO,CAAC,IAAI,CAAC;CAoBnB"}
1
+ {"version":3,"file":"environments.d.ts","sourceRoot":"","sources":["../../../../src/lib/features/project-environments/environments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAIxB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAEH,KAAK,2BAA2B,EAKhC,KAAK,wBAAwB,EAChC,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAK/D,UAAU,yBAAyB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,UAAU;IAC1D,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,kBAAkB,CAAwC;IAElE,OAAO,CAAC,cAAc,CAAiB;IAEvC,OAAO,CAAC,cAAc,CAAiB;gBAGnC,MAAM,EAAE,cAAc,EACtB,EACI,+BAA+B,EAC/B,cAAc,EACd,cAAc,GACjB,EAAE,IAAI,CACH,gBAAgB,EACd,iCAAiC,GACjC,gBAAgB,GAChB,gBAAgB,CACrB;IA+EC,uBAAuB,CACzB,GAAG,EAAE,YAAY,CACb,IAAI,CAAC,yBAAyB,EAAE,aAAa,CAAC,EAC9C,IAAI,EACJ,wBAAwB,CAC3B,EACD,GAAG,EAAE,QAAQ,GACd,OAAO,CAAC,IAAI,CAAC;IAYV,4BAA4B,CAC9B,GAAG,EAAE,YAAY,CAAC,yBAAyB,CAAC,EAC5C,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,GACpB,OAAO,CAAC,IAAI,CAAC;IAcV,0CAA0C,CAC5C,GAAG,EAAE,YAAY,CACb,yBAAyB,EACzB,2BAA2B,CAC9B,EACD,GAAG,EAAE,QAAQ,CAAC,2BAA2B,CAAC,GAC3C,OAAO,CAAC,IAAI,CAAC;CAoBnB"}
@@ -56,7 +56,7 @@ class EnvironmentsController extends controller_1.default {
56
56
  method: 'post',
57
57
  path: `${PREFIX}/:environment/default-strategy`,
58
58
  handler: this.updateDefaultStrategyForProjectEnvironment,
59
- permission: types_1.UPDATE_PROJECT,
59
+ permission: [types_1.UPDATE_PROJECT, types_1.PROJECT_DEFAULT_STRATEGY_WRITE],
60
60
  middleware: [
61
61
  openApiService.validPath({
62
62
  tags: ['Projects'],
@@ -1 +1 @@
1
- {"version":3,"file":"environments.js","sourceRoot":"","sources":["../../../../src/lib/features/project-environments/environments.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"environments.js","sourceRoot":"","sources":["../../../../src/lib/features/project-environments/environments.ts"],"names":[],"mappings":";;;;;AACA,yEAAiD;AACjD,uCAMqB;AAGrB,2CAQuB;AAKvB,MAAM,MAAM,GAAG,0BAA0B,CAAC;AAO1C,MAAqB,sBAAuB,SAAQ,oBAAU;IAS1D,YACI,MAAsB,EACtB,EACI,+BAA+B,EAC/B,cAAc,EACd,cAAc,GAMjB;QAED,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,mCAAmC,CAAC,CAAC;QACpE,IAAI,CAAC,kBAAkB,GAAG,+BAA+B,CAAC;QAC1D,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QAErC,IAAI,CAAC,KAAK,CAAC;YACP,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,IAAI,CAAC,uBAAuB;YACrC,UAAU,EAAE,sBAAc;YAC1B,UAAU,EAAE;gBACR,cAAc,CAAC,SAAS,CAAC;oBACrB,IAAI,EAAE,CAAC,UAAU,CAAC;oBAClB,WAAW,EAAE,yBAAyB;oBACtC,OAAO,EAAE,kCAAkC;oBAC3C,WAAW,EACP,yKAAyK;oBAC7K,WAAW,EAAE,IAAA,6BAAmB,EAC5B,0BAA0B,CAC7B;oBACD,SAAS,EAAE;wBACP,GAAG,EAAE,uBAAa;wBAClB,GAAG,IAAA,8BAAoB,EAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;qBACzC;iBACJ,CAAC;aACL;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC;YACP,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,GAAG,MAAM,eAAe;YAC9B,oBAAoB,EAAE,IAAI;YAC1B,OAAO,EAAE,IAAI,CAAC,4BAA4B;YAC1C,UAAU,EAAE,sBAAc;YAC1B,UAAU,EAAE;gBACR,cAAc,CAAC,SAAS,CAAC;oBACrB,IAAI,EAAE,CAAC,UAAU,CAAC;oBAClB,WAAW,EAAE,8BAA8B;oBAC3C,OAAO,EAAE,uCAAuC;oBAChD,WAAW,EACP,mEAAmE;oBACvE,SAAS,EAAE;wBACP,GAAG,EAAE,uBAAa;wBAClB,GAAG,IAAA,8BAAoB,EAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;qBACzC;iBACJ,CAAC;aACL;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC;YACP,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,GAAG,MAAM,gCAAgC;YAC/C,OAAO,EAAE,IAAI,CAAC,0CAA0C;YACxD,UAAU,EAAE,CAAC,sBAAc,EAAE,sCAA8B,CAAC;YAC5D,UAAU,EAAE;gBACR,cAAc,CAAC,SAAS,CAAC;oBACrB,IAAI,EAAE,CAAC,UAAU,CAAC;oBAClB,WAAW,EAAE,wCAAwC;oBACrD,OAAO,EAAE,kCAAkC;oBAC3C,WAAW,EACP,uLAAuL;oBAC3L,WAAW,EAAE,IAAA,6BAAmB,EAC5B,6BAA6B,CAChC;oBACD,SAAS,EAAE;wBACP,GAAG,EAAE,IAAA,8BAAoB,EACrB,6BAA6B,CAChC;wBACD,GAAG,IAAA,8BAAoB,EAAC,GAAG,CAAC;qBAC/B;iBACJ,CAAC;aACL;SACJ,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,uBAAuB,CACzB,GAIC,EACD,GAAa;QAEb,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;QACjC,MAAM,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;QACjC,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,oCAAoC;QAErF,MAAM,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,EAAE,CACpD,OAAO,CAAC,uBAAuB,CAAC,WAAW,EAAE,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,CACrE,CAAC;QAEF,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,4BAA4B,CAC9B,GAA4C,EAC5C,GAAmB;QAEnB,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;QAE9C,MAAM,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,EAAE,CACpD,OAAO,CAAC,4BAA4B,CAChC,WAAW,EACX,SAAS,EACT,GAAG,CAAC,KAAK,CACZ,CACJ,CAAC;QAEF,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,0CAA0C,CAC5C,GAGC,EACD,GAA0C;QAE1C,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;QAC9C,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAC;QAE1B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,EAAE,CAClE,OAAO,CAAC,qBAAqB,CACzB,WAAW,EACX,SAAS,EACT,QAAQ,EACR,GAAG,CAAC,KAAK,CACZ,CACJ,CAAC;QAEF,IAAI,CAAC,cAAc,CAAC,qBAAqB,CACrC,GAAG,EACH,GAAG,EACH,qCAA2B,CAAC,GAAG,EAC/B,IAAA,sBAAc,EAAC,KAAK,CAAC,CACxB,CAAC;IACN,CAAC;CACJ;AAjKD,yCAiKC"}
@@ -20,7 +20,7 @@
20
20
  rel="stylesheet"
21
21
  href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0"
22
22
  />
23
- <script type="module" crossorigin src="/static/index-BkkVRgMF.js"></script>
23
+ <script type="module" crossorigin src="/static/index-Cx91uh9W.js"></script>
24
24
  <link rel="stylesheet" crossorigin href="/static/style-DgCLnyQi.css">
25
25
  </head>
26
26
  <body>
@@ -1,3 +1,3 @@
1
- import{u as Gt,g as qt,r as x,_ as Vt,j as t,a as Ee,s as j,U as Kt,b as B,B as S,C as v,d as Jt,c as Yt,e as ot,f as Zt,h as ee,T as I,F as Qt,I as Xt,S as en,M as tn,i as ce,p as Me,k as He,l as se,A as at,m as nn,n as rn,o as sn,q as on,t as Ue,P as an,v as ze,w as _,L as ln,D as cn,x as de,y as ue,z as dn,E as it,G as un,H as J,J as lt,K as hn,N as te,O as gn,Q as G,R as ct,V as Te,W as dt,X as xn,Y as Ce,Z as oe,$ as we,a0 as mn,a1 as fn,a2 as pn,a3 as ut,a4 as Re,a5 as he,a6 as bn,a7 as O,a8 as ge,a9 as jn,aa as yn,ab as vn,ac as Sn,ad as Cn,ae as wn,af as _e,ag as ht,ah as Pe,ai as Ie,aj as gt,ak as Fe,al as xt,am as mt,an as ft,ao as pt,ap as kn,aq as Ge,ar as En,as as Tn,at as pe,au as Rn,av as Pn,aw as In,ax as Fn,ay as Bn,az as On}from"./index-BkkVRgMF.js";import{c as Dn,d as An,s as Nn,h as $n,f as Ln,a as Wn,l as Mn,b as Hn,e as Un,g as zn,i as _n,j as Gn,k as qn,m as Vn,E as ie,n as Kn,o as Be,p as Jn,q as Yn,r as Zn,t as Qn,u as Xn,v as er,w as tr,x as nr,y as rr,z as bt,A as z,H as jt,B as d,C as sr,D as or,S as ar,F as ir,G as lr}from"./index-BEpcKp7m.js";import{u as cr}from"./useApiTokens-BQFDjDJi.js";import{S as dr}from"./StrategyItemContainer-C2s-CIiO.js";const ur=()=>{const{makeRequest:e,createRequest:n,errors:r,loading:s}=Gt({propagateErrors:!0}),o="api/admin/playground";return{evaluateAdvancedPlayground:async c=>{const u=`${o}/advanced`,g=n(u,{method:"POST",body:JSON.stringify(c)});return(await e(g.caller,g.id)).json()},evaluateChangeRequestPlayground:async(c,u)=>{const g=`${o}/change-request/${c}`,l=n(g,{method:"POST",body:JSON.stringify(u)});return(await e(l.caller,l.id)).json()},errors:r,loading:s}};var Oe={exports:{}};function yt(e,n=100,r={}){if(typeof e!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof e}\`.`);if(n<0)throw new RangeError("`wait` must not be negative.");const{immediate:s}=typeof r=="boolean"?{immediate:r}:r;let o,i,a,c,u;function g(){const h=o,b=i;return o=void 0,i=void 0,u=e.apply(h,b),u}function l(){const h=Date.now()-c;h<n&&h>=0?a=setTimeout(l,n-h):(a=void 0,s||(u=g()))}const m=function(...h){if(o&&this!==o)throw new Error("Debounced method called with different contexts.");o=this,i=h,c=Date.now();const b=s&&!a;return a||(a=setTimeout(l,n)),b&&(u=g()),u};return m.clear=()=>{a&&(clearTimeout(a),a=void 0)},m.flush=()=>{a&&m.trigger()},m.trigger=()=>{u=g(),m.clear()},m}Oe.exports.debounce=yt;Oe.exports=yt;var hr=Oe.exports;const gr=qt(hr);var qe=function(n){n===void 0&&(n={});var{crosshairCursor:r=!1}=n,s=[];n.closeBracketsKeymap!==!1&&(s=s.concat(Dn)),n.defaultKeymap!==!1&&(s=s.concat(An)),n.searchKeymap!==!1&&(s=s.concat(Nn)),n.historyKeymap!==!1&&(s=s.concat($n)),n.foldKeymap!==!1&&(s=s.concat(Ln)),n.completionKeymap!==!1&&(s=s.concat(Wn)),n.lintKeymap!==!1&&(s=s.concat(Mn));var o=[];return n.lineNumbers!==!1&&o.push(Hn()),n.highlightActiveLineGutter!==!1&&o.push(Un()),n.highlightSpecialChars!==!1&&o.push(zn()),n.history!==!1&&o.push(_n()),n.foldGutter!==!1&&o.push(Gn()),n.drawSelection!==!1&&o.push(qn()),n.dropCursor!==!1&&o.push(Vn()),n.allowMultipleSelections!==!1&&o.push(ie.allowMultipleSelections.of(!0)),n.indentOnInput!==!1&&o.push(Kn()),n.syntaxHighlighting!==!1&&o.push(Be(Jn,{fallback:!0})),n.bracketMatching!==!1&&o.push(Yn()),n.closeBrackets!==!1&&o.push(Zn()),n.autocompletion!==!1&&o.push(Qn()),n.rectangularSelection!==!1&&o.push(Xn()),r!==!1&&o.push(er()),n.highlightActiveLine!==!1&&o.push(tr()),n.highlightSelectionMatches!==!1&&o.push(nr()),n.tabSize&&typeof n.tabSize=="number"&&o.push(rr.of(" ".repeat(n.tabSize))),o.concat([bt.of(s.flat())]).filter(Boolean)};const xr="#e5c07b",Ve="#e06c75",mr="#56b6c2",fr="#ffffff",ae="#abb2bf",ke="#7d8799",pr="#61afef",br="#98c379",Ke="#d19a66",jr="#c678dd",yr="#21252b",Je="#2c313a",Ye="#282c34",be="#353a42",vr="#3E4451",Ze="#528bff",Sr=z.theme({"&":{color:ae,backgroundColor:Ye},".cm-content":{caretColor:Ze},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ze},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:vr},".cm-panels":{backgroundColor:yr,color:ae},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Ye,color:ke,border:"none"},".cm-activeLineGutter":{backgroundColor:Je},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:be},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:be,borderBottomColor:be},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Je,color:ae}}},{dark:!0}),Cr=jt.define([{tag:d.keyword,color:jr},{tag:[d.name,d.deleted,d.character,d.propertyName,d.macroName],color:Ve},{tag:[d.function(d.variableName),d.labelName],color:pr},{tag:[d.color,d.constant(d.name),d.standard(d.name)],color:Ke},{tag:[d.definition(d.name),d.separator],color:ae},{tag:[d.typeName,d.className,d.number,d.changed,d.annotation,d.modifier,d.self,d.namespace],color:xr},{tag:[d.operator,d.operatorKeyword,d.url,d.escape,d.regexp,d.link,d.special(d.string)],color:mr},{tag:[d.meta,d.comment],color:ke},{tag:d.strong,fontWeight:"bold"},{tag:d.emphasis,fontStyle:"italic"},{tag:d.strikethrough,textDecoration:"line-through"},{tag:d.link,color:ke,textDecoration:"underline"},{tag:d.heading,fontWeight:"bold",color:Ve},{tag:[d.atom,d.bool,d.special(d.variableName)],color:Ke},{tag:[d.processingInstruction,d.string,d.inserted],color:br},{tag:d.invalid,color:fr}]),wr=[Sr,Be(Cr)];var kr=z.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Er=function(n){n===void 0&&(n={});var{indentWithTab:r=!0,editable:s=!0,readOnly:o=!1,theme:i="light",placeholder:a="",basicSetup:c=!0}=n,u=[];switch(r&&u.unshift(bt.of([sr])),c&&(typeof c=="boolean"?u.unshift(qe()):u.unshift(qe(c))),a&&u.unshift(or(a)),i){case"light":u.push(kr);break;case"dark":u.push(wr);break;case"none":break;default:u.push(i);break}return s===!1&&u.push(z.editable.of(!1)),o&&u.push(ie.readOnly.of(!0)),[...u]},Tr=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(n=>e.state.sliceDoc(n.from,n.to)),selectedText:e.state.selection.ranges.some(n=>!n.empty)}),Qe=ir.define(),Rr=[];function Pr(e){var{value:n,selection:r,onChange:s,onStatistics:o,onCreateEditor:i,onUpdate:a,extensions:c=Rr,autoFocus:u,theme:g="light",height:l=null,minHeight:m=null,maxHeight:h=null,width:b=null,minWidth:P=null,maxWidth:R=null,placeholder:E="",editable:N=!0,readOnly:F=!1,indentWithTab:D=!0,basicSetup:y=!0,root:f,initialState:T}=e,[p,w]=x.useState(),[k,A]=x.useState(),[L,M]=x.useState(),Z=z.theme({"&":{height:l,minHeight:m,maxHeight:h,width:b,minWidth:P,maxWidth:R},"& .cm-scroller":{height:"100% !important"}}),Q=z.updateListener.of($=>{if($.docChanged&&typeof s=="function"&&!$.transactions.some(me=>me.annotation(Qe))){var V=$.state.doc,K=V.toString();s(K,$)}o&&o(Tr($))}),xe=Er({theme:g,editable:N,readOnly:F,placeholder:E,indentWithTab:D,basicSetup:y}),q=[Q,Z,...xe];return a&&typeof a=="function"&&q.push(z.updateListener.of(a)),q=q.concat(c),x.useEffect(()=>{if(p&&!L){var $={doc:n,selection:r,extensions:q},V=T?ie.fromJSON(T.json,$,T.fields):ie.create($);if(M(V),!k){var K=new z({state:V,parent:p,root:f});A(K),i&&i(K,V)}}return()=>{k&&(M(void 0),A(void 0))}},[p,L]),x.useEffect(()=>w(e.container),[e.container]),x.useEffect(()=>()=>{k&&(k.destroy(),A(void 0))},[k]),x.useEffect(()=>{u&&k&&k.focus()},[u,k]),x.useEffect(()=>{k&&k.dispatch({effects:ar.reconfigure.of(q)})},[g,c,l,m,h,b,P,R,E,N,F,D,y,s,a]),x.useEffect(()=>{if(n!==void 0){var $=k?k.state.doc.toString():"";k&&n!==$&&k.dispatch({changes:{from:0,to:$.length,insert:n||""},annotations:[Qe.of(!0)]})}},[n,k]),{state:L,setState:M,view:k,setView:A,container:p,setContainer:w}}var Ir=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],vt=x.forwardRef((e,n)=>{var{className:r,value:s="",selection:o,extensions:i=[],onChange:a,onStatistics:c,onCreateEditor:u,onUpdate:g,autoFocus:l,theme:m="light",height:h,minHeight:b,maxHeight:P,width:R,minWidth:E,maxWidth:N,basicSetup:F,placeholder:D,indentWithTab:y,editable:f,readOnly:T,root:p,initialState:w}=e,k=Vt(e,Ir),A=x.useRef(null),{state:L,view:M,container:Z}=Pr({container:A.current,root:p,value:s,autoFocus:l,theme:m,height:h,minHeight:b,maxHeight:P,width:R,minWidth:E,maxWidth:N,basicSetup:F,placeholder:D,indentWithTab:y,editable:f,readOnly:T,selection:o,onChange:a,onStatistics:c,onCreateEditor:u,onUpdate:g,extensions:i,initialState:w});if(x.useImperativeHandle(n,()=>({editor:A.current,state:L,view:M}),[A,Z,L,M]),typeof s!="string")throw new Error("value must be typeof string but got "+typeof s);var Q=typeof m=="string"?"cm-theme-"+m:"cm-theme";return t.jsx("div",Ee({ref:A,className:""+Q+(r?" "+r:"")},k))});vt.displayName="CodeMirror";var St=e=>{var{theme:n,settings:r={},styles:s=[]}=e,o={".cm-gutters":{}},i={};r.background&&(i.backgroundColor=r.background),r.backgroundImage&&(i.backgroundImage=r.backgroundImage),r.foreground&&(i.color=r.foreground),r.fontSize&&(i.fontSize=r.fontSize),(r.background||r.foreground)&&(o["&"]=i),r.fontFamily&&(o["&.cm-editor .cm-scroller"]={fontFamily:r.fontFamily}),r.gutterBackground&&(o[".cm-gutters"].backgroundColor=r.gutterBackground),r.gutterForeground&&(o[".cm-gutters"].color=r.gutterForeground),r.gutterBorder&&(o[".cm-gutters"].borderRightColor=r.gutterBorder),r.caret&&(o[".cm-content"]={caretColor:r.caret},o[".cm-cursor, .cm-dropCursor"]={borderLeftColor:r.caret});var a={};r.gutterActiveForeground&&(a.color=r.gutterActiveForeground),r.lineHighlight&&(o[".cm-activeLine"]={backgroundColor:r.lineHighlight},a.backgroundColor=r.lineHighlight),o[".cm-activeLineGutter"]=a,r.selection&&(o["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:r.selection+" !important"}),r.selectionMatch&&(o["& .cm-selectionMatch"]={backgroundColor:r.selectionMatch});var c=z.theme(o,{dark:n==="dark"}),u=jt.define(s),g=[c,Be(u)];return g},Fr={background:"#faf8f5",foreground:"#b29762",caret:"#93abdc",selection:"#e3dcce",selectionMatch:"#e3dcce",gutterBackground:"#faf8f5",gutterForeground:"#cdc4b1",gutterBorder:"transparent",lineHighlight:"#ddceb154"},Br=[{tag:[d.comment,d.bracket],color:"#b6ad9a"},{tag:[d.atom,d.number,d.keyword,d.link,d.attributeName,d.quote],color:"#063289"},{tag:[d.emphasis,d.heading,d.tagName,d.propertyName,d.variableName],color:"#2d2006"},{tag:[d.typeName,d.url,d.string],color:"#896724"},{tag:[d.operator,d.string],color:"#1659df"},{tag:[d.propertyName],color:"#b29762"},{tag:[d.unit,d.punctuation],color:"#063289"}],Or=e=>{var{theme:n="light",settings:r={},styles:s=[]}={};return St({theme:n,settings:Ee({},Fr,r),styles:[...Br,...s]})},Dr=Or(),Ar={background:"#2a2734",foreground:"#6c6783",caret:"#ffad5c",selection:"#91ff6c26",selectionMatch:"#91ff6c26",gutterBackground:"#2a2734",gutterForeground:"#545167",lineHighlight:"#36334280"},Nr=[{tag:[d.comment,d.bracket],color:"#6c6783"},{tag:[d.atom,d.number,d.keyword,d.link,d.attributeName,d.quote],color:"#ffcc99"},{tag:[d.emphasis,d.heading,d.tagName,d.propertyName,d.className,d.variableName],color:"#eeebff"},{tag:[d.typeName,d.url],color:"#7a63ee"},{tag:d.operator,color:"#ffad5c"},{tag:d.string,color:"#ffb870"},{tag:[d.propertyName],color:"#9a86fd"},{tag:[d.unit,d.punctuation],color:"#e09142"}],$r=e=>{var{theme:n="dark",settings:r={},styles:s=[]}={};return St({theme:n,settings:Ee({},Ar,r),styles:[...Nr,...s]})},Lr=$r();const Wr=j("aside")(({theme:e})=>({height:"50px",backgroundColor:e.palette.background.paper,borderTopRightRadius:e.shape.borderRadiusMedium,borderTopLeftRadius:e.shape.borderRadiusMedium,padding:e.spacing(1,2),color:e.palette.text.primary,display:"flex",justifyContent:"space-between",alignItems:"center",border:`1px solid ${e.palette.divider}`})),Ct=j("div")(({theme:e,style:n})=>({width:e.spacing(3),height:e.spacing(3),display:"flex",alignItems:"center",color:e.palette.background.paper,justifyContent:"center",transition:"background-color 0.5s ease-in-out",borderRadius:"50%",...n})),Mr=j("div")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.error.dark,marginRight:e.spacing(1)})),Hr=()=>{const e=B();return t.jsx(Ct,{style:{backgroundColor:e.palette.success.main},children:t.jsx(Jt,{sx:n=>({width:n.spacing(2),height:n.spacing(2)})})})},Ur=()=>{const e=B();return t.jsx(Ct,{style:{backgroundColor:e.palette.error.main},children:t.jsx(Yt,{})})},zr=({context:e,setContext:n,error:r})=>{const{themeMode:s}=x.useContext(Kt),o=B(),i=x.useCallback(a=>{n(a)},[n]);return t.jsxs(S,{sx:{width:"100%"},children:[t.jsxs(Wr,{children:["JSON",t.jsx(v,{condition:!!r,show:t.jsxs(S,{sx:a=>({display:"flex",alignItems:"center"}),children:[t.jsx(Mr,{children:r}),t.jsx(Ur,{})]}),elseShow:t.jsx(Hr,{})})]}),t.jsx(vt,{value:e,height:"150px",theme:s==="dark"?Lr:Dr,extensions:[lr()],onChange:i,style:{border:`1px solid ${o.palette.divider}`,borderTop:"none"},placeholder:JSON.stringify({currentTime:"2022-07-04T14:13:03.929Z",appName:"playground",userId:"test",remoteAddress:"127.0.0.1"},null,2)})]})};function wt(e){return Array.isArray(e)?e:[e]}const _r=e=>!e||e.length===0||e.length===1&&e[0]==="*"?"*":wt(e),Gr=e=>wt(e),qr=e=>{const n=Vr(e);return n.length>0?n[0]:""},Vr=e=>e.filter(({enabled:n})=>!!n).sort((n,r)=>n.sortOrder-r.sortOrder).map(({name:n})=>n),Kr=(e,n)=>"100%",Jr=e=>typeof e=="string"?!0:Array.isArray(e)?e.every(n=>typeof n=="string"):!1,Yr=e=>{const n=new Set(["appName","environment","userId","sessionId","remoteAddress","currentTime","properties"]),r={...e};let s=!1;for(const o in e)n.has(o)||(r.properties||(r.properties={}),r.properties[o]=e[o],delete r[o],s=!0);return!s&&!e.properties&&delete r.properties,r},Zr=e=>{const[n]=e.split("."),[r,s]=n.split(":");if(!r||!s)throw new Error("Invalid token format");if(s==="*")throw new Error("Admin tokens are not supported in the playground")},Qr=e=>{const[n]=e.split(".");return n.split(":")},Xr=({context:e,setContext:n})=>{const r=B(),{setToastData:s}=ot(),{context:o}=Zt(),i=o.sort((y,f)=>y.sortOrder-f.sortOrder).map(({name:y})=>y),[a,c]=x.useState(),[u,g]=x.useState(!1),[l,m]=x.useState(""),[h,b]=x.useState(""),P=x.useMemo(()=>gr(y=>{var f;if(!y)return c(void 0);try{const T=JSON.parse(y);g(T[l]!==void 0||((f=T==null?void 0:T.properties)==null?void 0:f[l])!==void 0)}catch(T){return c(ee(T))}return c(void 0)},250),[c,l,g]);x.useEffect(()=>{P(e)},[P,e]);const R=()=>{try{const y=JSON.parse(e||"{}");n(JSON.stringify(Yr({...y,[l]:h}),null,2));const f=o.find(T=>T.name===l);if(f!=null&&f.legalValues&&f.legalValues.length>0||l==="currentTime")return b("")}catch(y){s({type:"error",title:`Error parsing context: ${ee(y)}`})}},E=(y,f)=>{if(Jr(f)){if(Array.isArray(f)){const T=(f||[]).length>1?f.join(","):f[0];return b(T)}b(f)}},N=()=>{if(!h||h==="")return[];const y=o.find(T=>T.name===l),f=((y==null?void 0:y.legalValues)||[]).length>1;return h.includes(",")&&f?h.split(","):[h]},F=()=>{if(l==="currentTime"){const f=Me(h),p=f?He(f.toISOString()):He(new Date().toISOString());return t.jsx(se,{id:"date",label:"Date",size:"small",type:"datetime-local",value:p,sx:{width:200,maxWidth:"100%"},onChange:w=>{const k=Me(w.target.value),A=k==null?void 0:k.toISOString();A&&b(A)},InputLabelProps:{shrink:!0},required:!0})}const y=o.find(f=>f.name===l);if(y!=null&&y.legalValues&&y.legalValues.length>0){const f=y.legalValues.map(({value:T})=>T);return t.jsx(at,{disablePortal:!0,limitTags:3,id:"context-legal-values",freeSolo:!0,filterSelectedOptions:!0,size:"small",value:N(),onChange:E,options:f,multiple:!0,sx:{width:370,maxWidth:"100%"},renderInput:T=>t.jsx(se,{...T,label:"Value"}),disableCloseOnSelect:!1})}return t.jsx(se,{label:"Value",id:"context-value",sx:{width:370,maxWidth:"100%"},placeholder:"value1,value2,value3",size:"small",value:h,onChange:f=>b(f.target.value||"")})},D=y=>{if(m(y.target.value||""),y.target.value==="currentTime")return b(new Date().toISOString());b("")};return t.jsxs(S,{children:[t.jsx(S,{sx:{display:"flex",alignItems:"center",mb:2},children:t.jsx(I,{variant:"body2",color:r.palette.text.primary,sx:{ml:1},children:"Unleash context"})}),t.jsxs(S,{sx:{display:"flex",gap:2,flexWrap:"wrap",mb:2},children:[t.jsxs(Qt,{children:[t.jsx(Xt,{id:"context-field-label",size:"small",children:"Context field"}),t.jsx(en,{label:"Context field",labelId:"context-field-label",id:"context-field",value:l,onChange:D,variant:"outlined",size:"small",sx:{width:200,maxWidth:"100%"},children:i.map(y=>t.jsx(tn,{value:y,children:y},y))})]}),F(),t.jsx(ce,{variant:"outlined",disabled:!l||!!a,onClick:R,sx:{width:"95px",maxHeight:"40px"},children:`${u?"Replace":"Add"} `})]}),t.jsx(zr,{context:e,setContext:n,error:a})]})},es=({environments:e,setEnvironments:n,availableEnvironments:r,disabled:s})=>{const o=[...r.map(c=>({label:c,id:c}))],i=o.filter(({id:c})=>e.includes(c)),a=(c,u,g)=>{const l=u;return g==="clear"||l===null?n([]):Array.isArray(l)?l.length===0?n([]):n(l.map(({id:m})=>m)):n([l.id])};return t.jsx(at,{disablePortal:!0,limitTags:3,id:"environment",multiple:!0,options:o,sx:{flex:1},renderInput:c=>t.jsx(se,{...c,label:"Environments"}),renderOption:nn,getOptionLabel:({label:c})=>c,disableCloseOnSelect:!1,size:"small",value:i,onChange:a,disabled:s,"data-testid":"PLAYGROUND_ENVIRONMENT_SELECT"})},je={label:"ALL",id:"*"},Xe=j(rn)({fontSize:"1.25rem"}),kt=j(sn)(()=>({width:"100%"})),ts=j(S)(({theme:e})=>({display:"grid",columnGap:e.spacing(2),rowGap:e.spacing(2),gridTemplateColumns:"1fr",[e.breakpoints.up("md")]:{gridTemplateColumns:"1fr 1fr"}})),ns=j(kt)(({theme:e})=>({"& label":{WebkitTextFillColor:e.palette.text.secondary},"& input.Mui-disabled":{WebkitTextFillColor:e.palette.text.secondary}})),rs=({environments:e,projects:n,token:r,setProjects:s,setEnvironments:o,setToken:i,availableEnvironments:a,changeRequest:c,onClearChangeRequest:u})=>{const g=B(),{tokens:l}=cr(),[m,h]=x.useState(),{projects:b}=on(),P=[je,...b.map(({name:p,id:w})=>({label:p,id:w}))],R=async p=>{const w=p.target.value;if(i==null||i(w),w===""){f();return}try{Zr(w),h(void 0),E(w)}catch(k){h(k.message)}},E=p=>{const[w,k]=Qr(p);switch(o([k]),w){case"[]":F(p);break;case"*":D();break;default:y(w)}},N=p=>{!p.projects||p.projects==="*"?s([je.id]):typeof p.projects=="string"?s([p.projects]):Array.isArray(p.projects)&&s(p.projects)},F=p=>{const w=l.find(({secret:k})=>k===p);w?N(w):h("Invalid token. Ensure you use a valid token from this Unleash instance.")},D=()=>{s([je.id])},y=p=>{P.map(w=>w.id).includes(p)?s([p]):h(`Invalid token. Project ${p} does not exist.`)},f=()=>{h(void 0)},T=()=>{i==null||i(""),f()};return t.jsxs(S,{sx:{pb:2},children:[t.jsx(S,{sx:{display:"flex",alignItems:"center",mb:2},children:t.jsx(I,{variant:"body2",color:g.palette.text.primary,sx:{ml:1},children:"Access configuration"})}),t.jsxs(ts,{children:[t.jsx(S,{children:t.jsx(Ue,{arrow:!0,title:r?"Environment is automatically selected because you are using a token":"Select environments to use in the playground",children:t.jsx(S,{children:t.jsx(es,{environments:e,setEnvironments:o,availableEnvironments:a,disabled:!!(r||c)})})})}),t.jsx(S,{children:t.jsx(Ue,{arrow:!0,title:r?"Project is automatically selected because you are using a token":"Select projects to use in the playground",children:t.jsx(an,{selectedProjects:n,onChange:s,dataTestId:"PLAYGROUND_PROJECT_SELECT",disabled:!!(r||c),limitTags:3})})}),t.jsx(S,{children:t.jsx(kt,{label:"API token",value:r||(c?" ":""),onChange:R,type:"text",error:!!m,errorText:m,placeholder:"Enter your API token","data-testid":"PLAYGROUND_TOKEN_INPUT",InputProps:{endAdornment:r?t.jsx(ze,{position:"end","data-testid":"TOKEN_INPUT_CLEAR_BTN",children:t.jsx(_,{"aria-label":"clear API token",onClick:T,edge:"end",children:t.jsx(Xe,{})})}):null},disabled:!!c})}),t.jsx(v,{condition:!!c,show:t.jsxs(S,{sx:{display:"flex",gap:2},children:[t.jsx(S,{sx:{flex:1},children:t.jsx(ns,{label:"Change request",value:c?`Change request #${c}`:"",onChange:()=>{},type:"text",disabled:!0,InputProps:{endAdornment:t.jsx(ze,{position:"end",children:t.jsx(_,{"aria-label":"clear Change request results",onClick:u,edge:"end",children:t.jsx(Xe,{})})})}})}),t.jsx(ce,{variant:"outlined",size:"small",to:`/projects/${n[0]}/change-requests/${c}`,component:ln,children:"View change request"})]})})]})]})},ss=({availableEnvironments:e,environments:n,onSubmit:r,projects:s,token:o,setToken:i,setProjects:a,setEnvironments:c,context:u,setContext:g,changeRequest:l,onClearChangeRequest:m})=>t.jsxs(S,{component:"form",onSubmit:r,sx:{display:"flex",flexDirection:"column"},children:[t.jsx(rs,{environments:Array.isArray(n)?n:[n],projects:s,token:o,setToken:i,setEnvironments:c,setProjects:a,availableEnvironments:e.map(({name:h})=>h),changeRequest:l,onClearChangeRequest:m}),t.jsx(Xr,{context:u,setContext:g}),t.jsx(S,{sx:{mt:2,display:"flex",alignItems:"center",justifyContent:"space-between"},children:t.jsx(ce,{variant:"contained",size:"large",type:"submit",sx:{marginLeft:"auto"},children:"Try configuration"})})]}),os=j("div")(({style:e,theme:n})=>({width:"25px",height:"25px",borderRadius:"50%",color:n.palette.common.white,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"bold",...e})),as=({style:e,children:n,type:r})=>{const s=B(),o={backgroundColor:s.palette.background.alternative,color:s.palette.common.white};return r==="secondary"&&(o.backgroundColor=s.palette.background.paper,o.color=s.palette.text.secondary),t.jsx(os,{style:{...o,...e},children:n})},ye=({headerText:e,bodyText:n,sectionNumber:r})=>t.jsx(S,{sx:{display:"flex",alignItems:"flex-start",mt:2,flexDirection:"column"},children:t.jsxs(S,{sx:{display:"flex"},children:[t.jsx(S,{children:t.jsx(as,{children:r})}),t.jsxs(S,{sx:{ml:2,display:"flex",flexDirection:"column"},children:[t.jsx(I,{variant:"body1",sx:{fontWeight:"bold"},children:e}),t.jsx(v,{condition:!!n,show:t.jsx(I,{variant:"body1",sx:{mt:1},children:n})})]})]})}),Et=()=>t.jsxs(S,{sx:{ml:4},children:[t.jsx(I,{variant:"body1",children:"Unleash playground is for helping you to understand how Unleash works, how feature flags are evaluated and for you to easily debug your feature flags."}),t.jsx(cn,{sx:{mt:2,mb:2}}),t.jsx(I,{variant:"body1",sx:{mb:1},children:"What you need to do is:"}),t.jsx(ye,{headerText:`Select in which environment you want to test your
1
+ import{u as Gt,g as qt,r as x,_ as Vt,j as t,a as Ee,s as j,U as Kt,b as B,B as S,C as v,d as Jt,c as Yt,e as ot,f as Zt,h as ee,T as I,F as Qt,I as Xt,S as en,M as tn,i as ce,p as Me,k as He,l as se,A as at,m as nn,n as rn,o as sn,q as on,t as Ue,P as an,v as ze,w as _,L as ln,D as cn,x as de,y as ue,z as dn,E as it,G as un,H as J,J as lt,K as hn,N as te,O as gn,Q as G,R as ct,V as Te,W as dt,X as xn,Y as Ce,Z as oe,$ as we,a0 as mn,a1 as fn,a2 as pn,a3 as ut,a4 as Re,a5 as he,a6 as bn,a7 as O,a8 as ge,a9 as jn,aa as yn,ab as vn,ac as Sn,ad as Cn,ae as wn,af as _e,ag as ht,ah as Pe,ai as Ie,aj as gt,ak as Fe,al as xt,am as mt,an as ft,ao as pt,ap as kn,aq as Ge,ar as En,as as Tn,at as pe,au as Rn,av as Pn,aw as In,ax as Fn,ay as Bn,az as On}from"./index-Cx91uh9W.js";import{c as Dn,d as An,s as Nn,h as $n,f as Ln,a as Wn,l as Mn,b as Hn,e as Un,g as zn,i as _n,j as Gn,k as qn,m as Vn,E as ie,n as Kn,o as Be,p as Jn,q as Yn,r as Zn,t as Qn,u as Xn,v as er,w as tr,x as nr,y as rr,z as bt,A as z,H as jt,B as d,C as sr,D as or,S as ar,F as ir,G as lr}from"./index-BEpcKp7m.js";import{u as cr}from"./useApiTokens-5JgqgHim.js";import{S as dr}from"./StrategyItemContainer-Das6_30A.js";const ur=()=>{const{makeRequest:e,createRequest:n,errors:r,loading:s}=Gt({propagateErrors:!0}),o="api/admin/playground";return{evaluateAdvancedPlayground:async c=>{const u=`${o}/advanced`,g=n(u,{method:"POST",body:JSON.stringify(c)});return(await e(g.caller,g.id)).json()},evaluateChangeRequestPlayground:async(c,u)=>{const g=`${o}/change-request/${c}`,l=n(g,{method:"POST",body:JSON.stringify(u)});return(await e(l.caller,l.id)).json()},errors:r,loading:s}};var Oe={exports:{}};function yt(e,n=100,r={}){if(typeof e!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof e}\`.`);if(n<0)throw new RangeError("`wait` must not be negative.");const{immediate:s}=typeof r=="boolean"?{immediate:r}:r;let o,i,a,c,u;function g(){const h=o,b=i;return o=void 0,i=void 0,u=e.apply(h,b),u}function l(){const h=Date.now()-c;h<n&&h>=0?a=setTimeout(l,n-h):(a=void 0,s||(u=g()))}const m=function(...h){if(o&&this!==o)throw new Error("Debounced method called with different contexts.");o=this,i=h,c=Date.now();const b=s&&!a;return a||(a=setTimeout(l,n)),b&&(u=g()),u};return m.clear=()=>{a&&(clearTimeout(a),a=void 0)},m.flush=()=>{a&&m.trigger()},m.trigger=()=>{u=g(),m.clear()},m}Oe.exports.debounce=yt;Oe.exports=yt;var hr=Oe.exports;const gr=qt(hr);var qe=function(n){n===void 0&&(n={});var{crosshairCursor:r=!1}=n,s=[];n.closeBracketsKeymap!==!1&&(s=s.concat(Dn)),n.defaultKeymap!==!1&&(s=s.concat(An)),n.searchKeymap!==!1&&(s=s.concat(Nn)),n.historyKeymap!==!1&&(s=s.concat($n)),n.foldKeymap!==!1&&(s=s.concat(Ln)),n.completionKeymap!==!1&&(s=s.concat(Wn)),n.lintKeymap!==!1&&(s=s.concat(Mn));var o=[];return n.lineNumbers!==!1&&o.push(Hn()),n.highlightActiveLineGutter!==!1&&o.push(Un()),n.highlightSpecialChars!==!1&&o.push(zn()),n.history!==!1&&o.push(_n()),n.foldGutter!==!1&&o.push(Gn()),n.drawSelection!==!1&&o.push(qn()),n.dropCursor!==!1&&o.push(Vn()),n.allowMultipleSelections!==!1&&o.push(ie.allowMultipleSelections.of(!0)),n.indentOnInput!==!1&&o.push(Kn()),n.syntaxHighlighting!==!1&&o.push(Be(Jn,{fallback:!0})),n.bracketMatching!==!1&&o.push(Yn()),n.closeBrackets!==!1&&o.push(Zn()),n.autocompletion!==!1&&o.push(Qn()),n.rectangularSelection!==!1&&o.push(Xn()),r!==!1&&o.push(er()),n.highlightActiveLine!==!1&&o.push(tr()),n.highlightSelectionMatches!==!1&&o.push(nr()),n.tabSize&&typeof n.tabSize=="number"&&o.push(rr.of(" ".repeat(n.tabSize))),o.concat([bt.of(s.flat())]).filter(Boolean)};const xr="#e5c07b",Ve="#e06c75",mr="#56b6c2",fr="#ffffff",ae="#abb2bf",ke="#7d8799",pr="#61afef",br="#98c379",Ke="#d19a66",jr="#c678dd",yr="#21252b",Je="#2c313a",Ye="#282c34",be="#353a42",vr="#3E4451",Ze="#528bff",Sr=z.theme({"&":{color:ae,backgroundColor:Ye},".cm-content":{caretColor:Ze},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ze},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:vr},".cm-panels":{backgroundColor:yr,color:ae},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Ye,color:ke,border:"none"},".cm-activeLineGutter":{backgroundColor:Je},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:be},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:be,borderBottomColor:be},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Je,color:ae}}},{dark:!0}),Cr=jt.define([{tag:d.keyword,color:jr},{tag:[d.name,d.deleted,d.character,d.propertyName,d.macroName],color:Ve},{tag:[d.function(d.variableName),d.labelName],color:pr},{tag:[d.color,d.constant(d.name),d.standard(d.name)],color:Ke},{tag:[d.definition(d.name),d.separator],color:ae},{tag:[d.typeName,d.className,d.number,d.changed,d.annotation,d.modifier,d.self,d.namespace],color:xr},{tag:[d.operator,d.operatorKeyword,d.url,d.escape,d.regexp,d.link,d.special(d.string)],color:mr},{tag:[d.meta,d.comment],color:ke},{tag:d.strong,fontWeight:"bold"},{tag:d.emphasis,fontStyle:"italic"},{tag:d.strikethrough,textDecoration:"line-through"},{tag:d.link,color:ke,textDecoration:"underline"},{tag:d.heading,fontWeight:"bold",color:Ve},{tag:[d.atom,d.bool,d.special(d.variableName)],color:Ke},{tag:[d.processingInstruction,d.string,d.inserted],color:br},{tag:d.invalid,color:fr}]),wr=[Sr,Be(Cr)];var kr=z.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Er=function(n){n===void 0&&(n={});var{indentWithTab:r=!0,editable:s=!0,readOnly:o=!1,theme:i="light",placeholder:a="",basicSetup:c=!0}=n,u=[];switch(r&&u.unshift(bt.of([sr])),c&&(typeof c=="boolean"?u.unshift(qe()):u.unshift(qe(c))),a&&u.unshift(or(a)),i){case"light":u.push(kr);break;case"dark":u.push(wr);break;case"none":break;default:u.push(i);break}return s===!1&&u.push(z.editable.of(!1)),o&&u.push(ie.readOnly.of(!0)),[...u]},Tr=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(n=>e.state.sliceDoc(n.from,n.to)),selectedText:e.state.selection.ranges.some(n=>!n.empty)}),Qe=ir.define(),Rr=[];function Pr(e){var{value:n,selection:r,onChange:s,onStatistics:o,onCreateEditor:i,onUpdate:a,extensions:c=Rr,autoFocus:u,theme:g="light",height:l=null,minHeight:m=null,maxHeight:h=null,width:b=null,minWidth:P=null,maxWidth:R=null,placeholder:E="",editable:N=!0,readOnly:F=!1,indentWithTab:D=!0,basicSetup:y=!0,root:f,initialState:T}=e,[p,w]=x.useState(),[k,A]=x.useState(),[L,M]=x.useState(),Z=z.theme({"&":{height:l,minHeight:m,maxHeight:h,width:b,minWidth:P,maxWidth:R},"& .cm-scroller":{height:"100% !important"}}),Q=z.updateListener.of($=>{if($.docChanged&&typeof s=="function"&&!$.transactions.some(me=>me.annotation(Qe))){var V=$.state.doc,K=V.toString();s(K,$)}o&&o(Tr($))}),xe=Er({theme:g,editable:N,readOnly:F,placeholder:E,indentWithTab:D,basicSetup:y}),q=[Q,Z,...xe];return a&&typeof a=="function"&&q.push(z.updateListener.of(a)),q=q.concat(c),x.useEffect(()=>{if(p&&!L){var $={doc:n,selection:r,extensions:q},V=T?ie.fromJSON(T.json,$,T.fields):ie.create($);if(M(V),!k){var K=new z({state:V,parent:p,root:f});A(K),i&&i(K,V)}}return()=>{k&&(M(void 0),A(void 0))}},[p,L]),x.useEffect(()=>w(e.container),[e.container]),x.useEffect(()=>()=>{k&&(k.destroy(),A(void 0))},[k]),x.useEffect(()=>{u&&k&&k.focus()},[u,k]),x.useEffect(()=>{k&&k.dispatch({effects:ar.reconfigure.of(q)})},[g,c,l,m,h,b,P,R,E,N,F,D,y,s,a]),x.useEffect(()=>{if(n!==void 0){var $=k?k.state.doc.toString():"";k&&n!==$&&k.dispatch({changes:{from:0,to:$.length,insert:n||""},annotations:[Qe.of(!0)]})}},[n,k]),{state:L,setState:M,view:k,setView:A,container:p,setContainer:w}}var Ir=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],vt=x.forwardRef((e,n)=>{var{className:r,value:s="",selection:o,extensions:i=[],onChange:a,onStatistics:c,onCreateEditor:u,onUpdate:g,autoFocus:l,theme:m="light",height:h,minHeight:b,maxHeight:P,width:R,minWidth:E,maxWidth:N,basicSetup:F,placeholder:D,indentWithTab:y,editable:f,readOnly:T,root:p,initialState:w}=e,k=Vt(e,Ir),A=x.useRef(null),{state:L,view:M,container:Z}=Pr({container:A.current,root:p,value:s,autoFocus:l,theme:m,height:h,minHeight:b,maxHeight:P,width:R,minWidth:E,maxWidth:N,basicSetup:F,placeholder:D,indentWithTab:y,editable:f,readOnly:T,selection:o,onChange:a,onStatistics:c,onCreateEditor:u,onUpdate:g,extensions:i,initialState:w});if(x.useImperativeHandle(n,()=>({editor:A.current,state:L,view:M}),[A,Z,L,M]),typeof s!="string")throw new Error("value must be typeof string but got "+typeof s);var Q=typeof m=="string"?"cm-theme-"+m:"cm-theme";return t.jsx("div",Ee({ref:A,className:""+Q+(r?" "+r:"")},k))});vt.displayName="CodeMirror";var St=e=>{var{theme:n,settings:r={},styles:s=[]}=e,o={".cm-gutters":{}},i={};r.background&&(i.backgroundColor=r.background),r.backgroundImage&&(i.backgroundImage=r.backgroundImage),r.foreground&&(i.color=r.foreground),r.fontSize&&(i.fontSize=r.fontSize),(r.background||r.foreground)&&(o["&"]=i),r.fontFamily&&(o["&.cm-editor .cm-scroller"]={fontFamily:r.fontFamily}),r.gutterBackground&&(o[".cm-gutters"].backgroundColor=r.gutterBackground),r.gutterForeground&&(o[".cm-gutters"].color=r.gutterForeground),r.gutterBorder&&(o[".cm-gutters"].borderRightColor=r.gutterBorder),r.caret&&(o[".cm-content"]={caretColor:r.caret},o[".cm-cursor, .cm-dropCursor"]={borderLeftColor:r.caret});var a={};r.gutterActiveForeground&&(a.color=r.gutterActiveForeground),r.lineHighlight&&(o[".cm-activeLine"]={backgroundColor:r.lineHighlight},a.backgroundColor=r.lineHighlight),o[".cm-activeLineGutter"]=a,r.selection&&(o["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:r.selection+" !important"}),r.selectionMatch&&(o["& .cm-selectionMatch"]={backgroundColor:r.selectionMatch});var c=z.theme(o,{dark:n==="dark"}),u=jt.define(s),g=[c,Be(u)];return g},Fr={background:"#faf8f5",foreground:"#b29762",caret:"#93abdc",selection:"#e3dcce",selectionMatch:"#e3dcce",gutterBackground:"#faf8f5",gutterForeground:"#cdc4b1",gutterBorder:"transparent",lineHighlight:"#ddceb154"},Br=[{tag:[d.comment,d.bracket],color:"#b6ad9a"},{tag:[d.atom,d.number,d.keyword,d.link,d.attributeName,d.quote],color:"#063289"},{tag:[d.emphasis,d.heading,d.tagName,d.propertyName,d.variableName],color:"#2d2006"},{tag:[d.typeName,d.url,d.string],color:"#896724"},{tag:[d.operator,d.string],color:"#1659df"},{tag:[d.propertyName],color:"#b29762"},{tag:[d.unit,d.punctuation],color:"#063289"}],Or=e=>{var{theme:n="light",settings:r={},styles:s=[]}={};return St({theme:n,settings:Ee({},Fr,r),styles:[...Br,...s]})},Dr=Or(),Ar={background:"#2a2734",foreground:"#6c6783",caret:"#ffad5c",selection:"#91ff6c26",selectionMatch:"#91ff6c26",gutterBackground:"#2a2734",gutterForeground:"#545167",lineHighlight:"#36334280"},Nr=[{tag:[d.comment,d.bracket],color:"#6c6783"},{tag:[d.atom,d.number,d.keyword,d.link,d.attributeName,d.quote],color:"#ffcc99"},{tag:[d.emphasis,d.heading,d.tagName,d.propertyName,d.className,d.variableName],color:"#eeebff"},{tag:[d.typeName,d.url],color:"#7a63ee"},{tag:d.operator,color:"#ffad5c"},{tag:d.string,color:"#ffb870"},{tag:[d.propertyName],color:"#9a86fd"},{tag:[d.unit,d.punctuation],color:"#e09142"}],$r=e=>{var{theme:n="dark",settings:r={},styles:s=[]}={};return St({theme:n,settings:Ee({},Ar,r),styles:[...Nr,...s]})},Lr=$r();const Wr=j("aside")(({theme:e})=>({height:"50px",backgroundColor:e.palette.background.paper,borderTopRightRadius:e.shape.borderRadiusMedium,borderTopLeftRadius:e.shape.borderRadiusMedium,padding:e.spacing(1,2),color:e.palette.text.primary,display:"flex",justifyContent:"space-between",alignItems:"center",border:`1px solid ${e.palette.divider}`})),Ct=j("div")(({theme:e,style:n})=>({width:e.spacing(3),height:e.spacing(3),display:"flex",alignItems:"center",color:e.palette.background.paper,justifyContent:"center",transition:"background-color 0.5s ease-in-out",borderRadius:"50%",...n})),Mr=j("div")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.error.dark,marginRight:e.spacing(1)})),Hr=()=>{const e=B();return t.jsx(Ct,{style:{backgroundColor:e.palette.success.main},children:t.jsx(Jt,{sx:n=>({width:n.spacing(2),height:n.spacing(2)})})})},Ur=()=>{const e=B();return t.jsx(Ct,{style:{backgroundColor:e.palette.error.main},children:t.jsx(Yt,{})})},zr=({context:e,setContext:n,error:r})=>{const{themeMode:s}=x.useContext(Kt),o=B(),i=x.useCallback(a=>{n(a)},[n]);return t.jsxs(S,{sx:{width:"100%"},children:[t.jsxs(Wr,{children:["JSON",t.jsx(v,{condition:!!r,show:t.jsxs(S,{sx:a=>({display:"flex",alignItems:"center"}),children:[t.jsx(Mr,{children:r}),t.jsx(Ur,{})]}),elseShow:t.jsx(Hr,{})})]}),t.jsx(vt,{value:e,height:"150px",theme:s==="dark"?Lr:Dr,extensions:[lr()],onChange:i,style:{border:`1px solid ${o.palette.divider}`,borderTop:"none"},placeholder:JSON.stringify({currentTime:"2022-07-04T14:13:03.929Z",appName:"playground",userId:"test",remoteAddress:"127.0.0.1"},null,2)})]})};function wt(e){return Array.isArray(e)?e:[e]}const _r=e=>!e||e.length===0||e.length===1&&e[0]==="*"?"*":wt(e),Gr=e=>wt(e),qr=e=>{const n=Vr(e);return n.length>0?n[0]:""},Vr=e=>e.filter(({enabled:n})=>!!n).sort((n,r)=>n.sortOrder-r.sortOrder).map(({name:n})=>n),Kr=(e,n)=>"100%",Jr=e=>typeof e=="string"?!0:Array.isArray(e)?e.every(n=>typeof n=="string"):!1,Yr=e=>{const n=new Set(["appName","environment","userId","sessionId","remoteAddress","currentTime","properties"]),r={...e};let s=!1;for(const o in e)n.has(o)||(r.properties||(r.properties={}),r.properties[o]=e[o],delete r[o],s=!0);return!s&&!e.properties&&delete r.properties,r},Zr=e=>{const[n]=e.split("."),[r,s]=n.split(":");if(!r||!s)throw new Error("Invalid token format");if(s==="*")throw new Error("Admin tokens are not supported in the playground")},Qr=e=>{const[n]=e.split(".");return n.split(":")},Xr=({context:e,setContext:n})=>{const r=B(),{setToastData:s}=ot(),{context:o}=Zt(),i=o.sort((y,f)=>y.sortOrder-f.sortOrder).map(({name:y})=>y),[a,c]=x.useState(),[u,g]=x.useState(!1),[l,m]=x.useState(""),[h,b]=x.useState(""),P=x.useMemo(()=>gr(y=>{var f;if(!y)return c(void 0);try{const T=JSON.parse(y);g(T[l]!==void 0||((f=T==null?void 0:T.properties)==null?void 0:f[l])!==void 0)}catch(T){return c(ee(T))}return c(void 0)},250),[c,l,g]);x.useEffect(()=>{P(e)},[P,e]);const R=()=>{try{const y=JSON.parse(e||"{}");n(JSON.stringify(Yr({...y,[l]:h}),null,2));const f=o.find(T=>T.name===l);if(f!=null&&f.legalValues&&f.legalValues.length>0||l==="currentTime")return b("")}catch(y){s({type:"error",title:`Error parsing context: ${ee(y)}`})}},E=(y,f)=>{if(Jr(f)){if(Array.isArray(f)){const T=(f||[]).length>1?f.join(","):f[0];return b(T)}b(f)}},N=()=>{if(!h||h==="")return[];const y=o.find(T=>T.name===l),f=((y==null?void 0:y.legalValues)||[]).length>1;return h.includes(",")&&f?h.split(","):[h]},F=()=>{if(l==="currentTime"){const f=Me(h),p=f?He(f.toISOString()):He(new Date().toISOString());return t.jsx(se,{id:"date",label:"Date",size:"small",type:"datetime-local",value:p,sx:{width:200,maxWidth:"100%"},onChange:w=>{const k=Me(w.target.value),A=k==null?void 0:k.toISOString();A&&b(A)},InputLabelProps:{shrink:!0},required:!0})}const y=o.find(f=>f.name===l);if(y!=null&&y.legalValues&&y.legalValues.length>0){const f=y.legalValues.map(({value:T})=>T);return t.jsx(at,{disablePortal:!0,limitTags:3,id:"context-legal-values",freeSolo:!0,filterSelectedOptions:!0,size:"small",value:N(),onChange:E,options:f,multiple:!0,sx:{width:370,maxWidth:"100%"},renderInput:T=>t.jsx(se,{...T,label:"Value"}),disableCloseOnSelect:!1})}return t.jsx(se,{label:"Value",id:"context-value",sx:{width:370,maxWidth:"100%"},placeholder:"value1,value2,value3",size:"small",value:h,onChange:f=>b(f.target.value||"")})},D=y=>{if(m(y.target.value||""),y.target.value==="currentTime")return b(new Date().toISOString());b("")};return t.jsxs(S,{children:[t.jsx(S,{sx:{display:"flex",alignItems:"center",mb:2},children:t.jsx(I,{variant:"body2",color:r.palette.text.primary,sx:{ml:1},children:"Unleash context"})}),t.jsxs(S,{sx:{display:"flex",gap:2,flexWrap:"wrap",mb:2},children:[t.jsxs(Qt,{children:[t.jsx(Xt,{id:"context-field-label",size:"small",children:"Context field"}),t.jsx(en,{label:"Context field",labelId:"context-field-label",id:"context-field",value:l,onChange:D,variant:"outlined",size:"small",sx:{width:200,maxWidth:"100%"},children:i.map(y=>t.jsx(tn,{value:y,children:y},y))})]}),F(),t.jsx(ce,{variant:"outlined",disabled:!l||!!a,onClick:R,sx:{width:"95px",maxHeight:"40px"},children:`${u?"Replace":"Add"} `})]}),t.jsx(zr,{context:e,setContext:n,error:a})]})},es=({environments:e,setEnvironments:n,availableEnvironments:r,disabled:s})=>{const o=[...r.map(c=>({label:c,id:c}))],i=o.filter(({id:c})=>e.includes(c)),a=(c,u,g)=>{const l=u;return g==="clear"||l===null?n([]):Array.isArray(l)?l.length===0?n([]):n(l.map(({id:m})=>m)):n([l.id])};return t.jsx(at,{disablePortal:!0,limitTags:3,id:"environment",multiple:!0,options:o,sx:{flex:1},renderInput:c=>t.jsx(se,{...c,label:"Environments"}),renderOption:nn,getOptionLabel:({label:c})=>c,disableCloseOnSelect:!1,size:"small",value:i,onChange:a,disabled:s,"data-testid":"PLAYGROUND_ENVIRONMENT_SELECT"})},je={label:"ALL",id:"*"},Xe=j(rn)({fontSize:"1.25rem"}),kt=j(sn)(()=>({width:"100%"})),ts=j(S)(({theme:e})=>({display:"grid",columnGap:e.spacing(2),rowGap:e.spacing(2),gridTemplateColumns:"1fr",[e.breakpoints.up("md")]:{gridTemplateColumns:"1fr 1fr"}})),ns=j(kt)(({theme:e})=>({"& label":{WebkitTextFillColor:e.palette.text.secondary},"& input.Mui-disabled":{WebkitTextFillColor:e.palette.text.secondary}})),rs=({environments:e,projects:n,token:r,setProjects:s,setEnvironments:o,setToken:i,availableEnvironments:a,changeRequest:c,onClearChangeRequest:u})=>{const g=B(),{tokens:l}=cr(),[m,h]=x.useState(),{projects:b}=on(),P=[je,...b.map(({name:p,id:w})=>({label:p,id:w}))],R=async p=>{const w=p.target.value;if(i==null||i(w),w===""){f();return}try{Zr(w),h(void 0),E(w)}catch(k){h(k.message)}},E=p=>{const[w,k]=Qr(p);switch(o([k]),w){case"[]":F(p);break;case"*":D();break;default:y(w)}},N=p=>{!p.projects||p.projects==="*"?s([je.id]):typeof p.projects=="string"?s([p.projects]):Array.isArray(p.projects)&&s(p.projects)},F=p=>{const w=l.find(({secret:k})=>k===p);w?N(w):h("Invalid token. Ensure you use a valid token from this Unleash instance.")},D=()=>{s([je.id])},y=p=>{P.map(w=>w.id).includes(p)?s([p]):h(`Invalid token. Project ${p} does not exist.`)},f=()=>{h(void 0)},T=()=>{i==null||i(""),f()};return t.jsxs(S,{sx:{pb:2},children:[t.jsx(S,{sx:{display:"flex",alignItems:"center",mb:2},children:t.jsx(I,{variant:"body2",color:g.palette.text.primary,sx:{ml:1},children:"Access configuration"})}),t.jsxs(ts,{children:[t.jsx(S,{children:t.jsx(Ue,{arrow:!0,title:r?"Environment is automatically selected because you are using a token":"Select environments to use in the playground",children:t.jsx(S,{children:t.jsx(es,{environments:e,setEnvironments:o,availableEnvironments:a,disabled:!!(r||c)})})})}),t.jsx(S,{children:t.jsx(Ue,{arrow:!0,title:r?"Project is automatically selected because you are using a token":"Select projects to use in the playground",children:t.jsx(an,{selectedProjects:n,onChange:s,dataTestId:"PLAYGROUND_PROJECT_SELECT",disabled:!!(r||c),limitTags:3})})}),t.jsx(S,{children:t.jsx(kt,{label:"API token",value:r||(c?" ":""),onChange:R,type:"text",error:!!m,errorText:m,placeholder:"Enter your API token","data-testid":"PLAYGROUND_TOKEN_INPUT",InputProps:{endAdornment:r?t.jsx(ze,{position:"end","data-testid":"TOKEN_INPUT_CLEAR_BTN",children:t.jsx(_,{"aria-label":"clear API token",onClick:T,edge:"end",children:t.jsx(Xe,{})})}):null},disabled:!!c})}),t.jsx(v,{condition:!!c,show:t.jsxs(S,{sx:{display:"flex",gap:2},children:[t.jsx(S,{sx:{flex:1},children:t.jsx(ns,{label:"Change request",value:c?`Change request #${c}`:"",onChange:()=>{},type:"text",disabled:!0,InputProps:{endAdornment:t.jsx(ze,{position:"end",children:t.jsx(_,{"aria-label":"clear Change request results",onClick:u,edge:"end",children:t.jsx(Xe,{})})})}})}),t.jsx(ce,{variant:"outlined",size:"small",to:`/projects/${n[0]}/change-requests/${c}`,component:ln,children:"View change request"})]})})]})]})},ss=({availableEnvironments:e,environments:n,onSubmit:r,projects:s,token:o,setToken:i,setProjects:a,setEnvironments:c,context:u,setContext:g,changeRequest:l,onClearChangeRequest:m})=>t.jsxs(S,{component:"form",onSubmit:r,sx:{display:"flex",flexDirection:"column"},children:[t.jsx(rs,{environments:Array.isArray(n)?n:[n],projects:s,token:o,setToken:i,setEnvironments:c,setProjects:a,availableEnvironments:e.map(({name:h})=>h),changeRequest:l,onClearChangeRequest:m}),t.jsx(Xr,{context:u,setContext:g}),t.jsx(S,{sx:{mt:2,display:"flex",alignItems:"center",justifyContent:"space-between"},children:t.jsx(ce,{variant:"contained",size:"large",type:"submit",sx:{marginLeft:"auto"},children:"Try configuration"})})]}),os=j("div")(({style:e,theme:n})=>({width:"25px",height:"25px",borderRadius:"50%",color:n.palette.common.white,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"bold",...e})),as=({style:e,children:n,type:r})=>{const s=B(),o={backgroundColor:s.palette.background.alternative,color:s.palette.common.white};return r==="secondary"&&(o.backgroundColor=s.palette.background.paper,o.color=s.palette.text.secondary),t.jsx(os,{style:{...o,...e},children:n})},ye=({headerText:e,bodyText:n,sectionNumber:r})=>t.jsx(S,{sx:{display:"flex",alignItems:"flex-start",mt:2,flexDirection:"column"},children:t.jsxs(S,{sx:{display:"flex"},children:[t.jsx(S,{children:t.jsx(as,{children:r})}),t.jsxs(S,{sx:{ml:2,display:"flex",flexDirection:"column"},children:[t.jsx(I,{variant:"body1",sx:{fontWeight:"bold"},children:e}),t.jsx(v,{condition:!!n,show:t.jsx(I,{variant:"body1",sx:{mt:1},children:n})})]})]})}),Et=()=>t.jsxs(S,{sx:{ml:4},children:[t.jsx(I,{variant:"body1",children:"Unleash playground is for helping you to understand how Unleash works, how feature flags are evaluated and for you to easily debug your feature flags."}),t.jsx(cn,{sx:{mt:2,mb:2}}),t.jsx(I,{variant:"body1",sx:{mb:1},children:"What you need to do is:"}),t.jsx(ye,{headerText:`Select in which environment you want to test your
2
2
  feature flag configuration`,bodyText:`You can also specify specific projects, or check
3
3
  flags in all projects.`,sectionNumber:"1"}),t.jsx(ye,{headerText:"Select a context field that you'd like to check",bodyText:"You can configure as many context fields as you want. You can also leave the context empty to test against an empty context.",sectionNumber:"2"}),t.jsx(ye,{headerText:"Submit the form to try the configuration",bodyText:"The results of evaluating your feature flags will appear after you submit the form. Then view the results.",sectionNumber:"3"})]});var De={},is=ue;Object.defineProperty(De,"__esModule",{value:!0});var Tt=De.default=void 0,ls=is(de()),cs=t,ds=(0,ls.default)((0,cs.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"}),"Help");Tt=De.default=ds;const us=()=>{const[e,n]=x.useState(null),r=a=>n(a.currentTarget),s=()=>n(null),o=!!e,i="playground-guidance-popper";return t.jsxs(S,{children:[t.jsx(_,{onClick:r,"aria-describedby":i,children:t.jsx(Tt,{})}),t.jsx(dn,{id:i,open:o,anchorEl:e,sx:a=>({zIndex:a.zIndex.tooltip}),children:t.jsxs(it,{sx:a=>({padding:a.spacing(8,4),maxWidth:"500px",borderRadius:`${a.shape.borderRadiusExtraLarge}px`}),children:[t.jsx(_,{onClick:s,sx:{position:"absolute",right:25,top:15},children:t.jsx(un,{})}),t.jsx(Et,{})]})})]})},hs=e=>x.createElement("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},x.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.84818 0.184159C8.56367 -0.0789547 8.1234 -0.0575747 7.86482 0.231912C7.60623 0.521399 7.62724 0.96937 7.91175 1.23248C9.48292 2.68551 10.6076 4.74934 10.6076 7C10.6076 9.25066 9.48292 11.3145 7.91175 12.7675C7.62724 13.0306 7.60623 13.4786 7.86482 13.7681C8.1234 14.0576 8.56367 14.079 8.84818 13.8158C10.6396 12.1592 11.9998 9.73702 11.9998 7C11.9998 4.26298 10.6396 1.84083 8.84818 0.184159ZM6.04105 2.23302C6.29109 1.93586 6.73054 1.90121 7.02259 2.15563C8.33146 3.29586 9.35426 5.02309 9.35426 6.99995C9.35426 8.97682 8.33145 10.7039 7.02259 11.8441C6.73054 12.0986 6.29109 12.0639 6.04105 11.7668C5.79101 11.4696 5.82506 11.0225 6.11711 10.768C7.19425 9.82969 7.96199 8.46967 7.96199 6.99995C7.96199 5.53021 7.19423 4.17007 6.11711 3.23173C5.82506 2.97731 5.79101 2.53017 6.04105 2.23302ZM6.56908 7.00015C6.56908 8.56492 5.3224 9.83342 3.78454 9.83342C2.24668 9.83342 1 8.56492 1 7.00015C1 5.43539 2.24668 4.16689 3.78454 4.16689C5.3224 4.16689 6.56908 5.43539 6.56908 7.00015Z",fill:"currentColor"})),gs=e=>x.createElement("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},x.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.84835 0.184159C8.56384 -0.0789547 8.12358 -0.0575747 7.86499 0.231912C7.6064 0.521399 7.62741 0.96937 7.91192 1.23248C9.4831 2.68551 10.6078 4.74934 10.6078 7C10.6078 7.40738 10.5709 7.80863 10.5012 8.20125L11.6597 9.35972C11.8783 8.60937 12 7.81877 12 7C12 4.26298 10.6397 1.84083 8.84835 0.184159ZM9.35443 6.99995L9.35418 7.0542L7.63252 5.33255C7.30901 4.52372 6.76993 3.80029 6.11728 3.23173C5.82523 2.97731 5.79118 2.53017 6.04122 2.23302C6.29127 1.93586 6.73072 1.90121 7.02276 2.15563C8.33164 3.29586 9.35443 5.02309 9.35443 6.99995ZM7.57827 8.79752L6.48307 7.70233C6.17606 8.92745 5.08437 9.83342 3.78471 9.83342C2.24685 9.83342 1.00017 8.56492 1.00017 7.00015C1.00017 5.69492 1.8676 4.59583 3.04789 4.26714L0.458225 1.67748C0.172794 1.39205 0.178843 0.923223 0.471736 0.63033C0.764629 0.337437 1.23345 0.331388 1.51889 0.616819L13.2132 12.3111C13.4986 12.5965 13.4926 13.0654 13.1997 13.3583C12.9068 13.6511 12.4379 13.6572 12.1525 13.3718L10.556 11.7753C10.0694 12.539 9.48623 13.2259 8.84835 13.8158C8.56384 14.079 8.12358 14.0576 7.86499 13.7681C7.6064 13.4786 7.62741 13.0306 7.91192 12.7675C8.54021 12.1865 9.0971 11.5078 9.53922 10.7585L8.62356 9.84281C8.20906 10.6195 7.64861 11.2989 7.02276 11.8441C6.73072 12.0986 6.29127 12.0639 6.04122 11.7668C5.79118 11.4696 5.82523 11.0225 6.11728 10.768C6.73471 10.2302 7.25048 9.55374 7.57827 8.79752Z",fill:"currentColor"}));var Ae={},xs=ue;Object.defineProperty(Ae,"__esModule",{value:!0});var Rt=Ae.default=void 0,ms=xs(de()),fs=t,ps=(0,ms.default)((0,fs.jsx)("path",{d:"M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"}),"WarningOutlined");Rt=Ae.default=ps;const Y=({enabled:e,label:n,showIcon:r=!0})=>{const s=B(),o=t.jsx(v,{condition:e==="unknown"||e==="unevaluated",show:t.jsx(Rt,{color:"warning",fontSize:"inherit"}),elseShow:t.jsx(v,{condition:typeof e=="boolean"&&!!e,show:t.jsx(hs,{color:s.palette.success.main,strokeWidth:"0.25"}),elseShow:t.jsx(gs,{color:s.palette.error.main,strokeWidth:"0.25"})})});return t.jsx(v,{condition:e==="unknown"||e==="unevaluated",show:t.jsx(J,{icon:r?o:void 0,color:"warning",children:n}),elseShow:t.jsx(v,{condition:typeof e=="boolean"&&!!e,show:t.jsx(J,{color:"success",icon:r?o:void 0,children:n}),elseShow:t.jsx(J,{color:"error",icon:r?o:void 0,children:n})})})},bs=j(S)(({theme:e})=>({display:"flex",alignItems:"center",padding:e.spacing(1,0,1,2)})),js=j(S)(()=>({marginRight:"auto"})),Pt=({feature:e})=>{const[n,r]=(()=>{var s;return e!=null&&e.isEnabled?[!0,"True"]:((s=e==null?void 0:e.strategies)==null?void 0:s.result)==="unknown"?["unknown","Unknown"]:[!1,"False"]})();return t.jsx(bs,{children:t.jsx(js,{"data-loading":!0,children:t.jsx(Y,{enabled:n,label:r,showIcon:n!=="unknown"})})})};function It(e){return e===void 0?!0:Object.values(e).every(n=>n&&typeof n=="object"?It(n):n===null)}const et=e=>{var n,r;return(r=(n=e.strategies)==null?void 0:n.data)==null?void 0:r.find(s=>!lt.includes(s.name))},ys=e=>{var n,r,s,o;return((r=(n=e.strategies)==null?void 0:n.data)==null?void 0:r.length)>0&&!((o=(s=e.strategies)==null?void 0:s.data)!=null&&o.find(i=>lt.includes(i.name)))},vs=j("div")({display:"flex",justifyContent:"space-between",width:"100%"}),Ss=j("div")(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:e.spacing(1.5),marginTop:e.spacing(1.5)})),tt=j("div")(({theme:e})=>({margin:e.spacing(1,0)})),Cs=j("div")(({theme:e})=>({margin:e.spacing(1,.5)})),ws=j(I)(({theme:e})=>({fontWeight:600,padding:e.spacing(.5)})),ks=j(_)({textAlign:"right"}),Es=({feature:e,input:n,onClose:r})=>{var l;const s=B(),[o,i,a]=e.isEnabled?[`This feature flag is True in ${n==null?void 0:n.environment} because `,"at least one strategy is True",s.palette.success.main]:e.hasUnsatisfiedDependency&&!e.isEnabledInCurrentEnvironment?[`This feature flag is False in ${n==null?void 0:n.environment} because `,"parent dependency is not satisfied and the environment is disabled",s.palette.error.main]:e.isEnabledInCurrentEnvironment?ys(e)?[`This feature flag is Unknown in ${n==null?void 0:n.environment} because `,"no strategies could be fully evaluated",s.palette.warning.main]:et(e)?[`This feature flag is Unknown in ${n==null?void 0:n.environment} because `,"not all strategies could be fully evaluated",s.palette.warning.main]:e.hasUnsatisfiedDependency?[`This feature flag is False in ${n==null?void 0:n.environment} because `,"parent dependency is not satisfied",s.palette.error.main]:[`This feature flag is False in ${n==null?void 0:n.environment} because `,"all strategies are either False or could not be fully evaluated",s.palette.error.main]:[`This feature flag is False in ${n==null?void 0:n.environment} because `,"the environment is disabled",s.palette.error.main],c=It(n==null?void 0:n.context)?"You did not provide a value for your context field in step 2 of the configuration":void 0,u=et(e)?"This feature uses custom strategies. Custom strategies can't be evaluated, so they will be marked accordingly.":void 0,g=r&&(m=>{m.stopPropagation(),r()});return t.jsxs(t.Fragment,{children:[t.jsxs(vs,{children:[t.jsxs(Ss,{children:[t.jsx(ws,{variant:"subtitle1",children:e.name}),t.jsx(v,{condition:((l=e==null?void 0:e.strategies)==null?void 0:l.result)!=="unknown",show:()=>t.jsx(Y,{enabled:e.isEnabled,label:e.isEnabled?"True":"False"}),elseShow:()=>t.jsx(Y,{enabled:"unknown",label:"Unknown",showIcon:!1})})]}),t.jsx(ks,{onClick:g,children:t.jsx(hn,{})})]}),t.jsxs(Cs,{children:[t.jsx(I,{variant:"body1",component:"span",children:o}),t.jsx(I,{variant:"subtitle1",color:a,component:"span",children:i}),t.jsx(I,{variant:"body1",component:"span",children:"."})]}),t.jsx(v,{condition:!!c,show:t.jsx(tt,{children:t.jsx(te,{color:"info",children:c})})}),t.jsx(v,{condition:!!u,show:t.jsx(tt,{children:t.jsx(te,{severity:"warning",color:"info",children:u})})})]})};var Ne={},Ts=ue;Object.defineProperty(Ne,"__esModule",{value:!0});var ne=Ne.default=void 0,Rs=Ts(de()),Ps=t,Is=(0,Rs.default)((0,Ps.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm3.59-13L12 10.59 8.41 7 7 8.41 10.59 12 7 15.59 8.41 17 12 13.41 15.59 17 17 15.59 13.41 12 17 8.41z"}),"CancelOutlined");ne=Ne.default=Is;const Fs=j("div")(({theme:e})=>({display:"flex",alignItems:"center",marginTop:e.spacing(1),color:e.palette.error.main})),Bs=({constraint:e,input:n})=>{const r=()=>{const s=n==null?void 0:n.context[e.contextName];return s?`Constraint not met – the value in the context: { ${s} } is not ${e.operator} ${e.contextName}`:`Constraint not met – no value was specified for ${e.contextName}`};return t.jsxs(Fs,{children:[t.jsx(ne,{style:{marginRight:"0.25rem"}}),t.jsx(I,{variant:"body2",children:r()})]})},Os=j(gn)(({theme:e})=>({color:e.palette.success.main})),Ds=j("div")(({theme:e})=>({display:"flex",alignItems:"center",marginTop:e.spacing(1),color:e.palette.success.main})),As=()=>t.jsxs(Ds,{children:[t.jsx(Os,{style:{marginRight:"0.25rem"}}),t.jsx(I,{variant:"body2",children:"Constraint met by value in context"})]}),Ns=j("div")(()=>({width:"100%",display:"flex",flexDirection:"column"})),Ft=({constraints:e,input:n})=>e?t.jsx(Ns,{children:e==null?void 0:e.map((r,s)=>t.jsxs(x.Fragment,{children:[t.jsx(v,{condition:s>0,show:t.jsx(G,{text:"AND"})}),t.jsx(ct,{constraint:r,compact:!0,renderAfter:t.jsx(v,{condition:r.result,show:t.jsx(As,{}),elseShow:t.jsx(Bs,{input:n,constraint:r})})})]},Te(r)))}):null,$s=j("div")(({theme:e})=>({color:e.palette.error.main,display:"inline-flex",justifyContent:"center",marginLeft:"auto",gap:e.spacing(1)})),Ls=({segments:e,input:n})=>e?t.jsx(t.Fragment,{children:e.map((r,s)=>t.jsxs(x.Fragment,{children:[t.jsx(dt,{segment:r,constraintList:t.jsx(Ft,{constraints:r.constraints,input:n}),headerContent:t.jsx(v,{condition:!r.result,show:t.jsxs($s,{children:[t.jsx(I,{variant:"subtitle2",sx:{pt:.25},children:"segment is false"}),t.jsx("span",{children:t.jsx(ne,{})})]}),elseShow:void 0}),isExpanded:!0}),t.jsx(v,{condition:s>=0&&e.length>1&&s!==e.length-1,show:t.jsx(G,{text:"AND"})})]},r.id))}):null,Ws=j("div",{shouldForwardProp:e=>e!=="showReason"})(({theme:e,showReason:n})=>({width:"100%",padding:e.spacing(2,3),borderRadius:e.shape.borderRadiusMedium,border:`1px solid ${e.palette.divider}`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:e.spacing(2),opacity:n?.9:1,backgroundColor:n?e.palette.background.paper:"inherit"})),Ms=j("div")(({theme:e})=>({flexDirection:"column"})),Hs=j(xn)(({theme:e})=>({margin:e.spacing(.5)})),Us=j("p",{shouldForwardProp:e=>e!=="disabled"})(({theme:e,disabled:n})=>({display:"inline",margin:e.spacing(.5,0),maxWidth:"95%",textAlign:"center",wordBreak:"break-word",color:n?e.palette.text.secondary:"inherit"})),ve=({value:e,text:n,input:r,showReason:s=!1,disabled:o=!1})=>{const i=B(),a=r==="no value"&&!o?"error":"neutral",c=`value does not match any ${n}`;return t.jsxs(Ws,{showReason:s,children:[t.jsx(I,{variant:"subtitle1",color:i.palette[a].main,children:`${r}`}),t.jsxs(Ms,{children:[t.jsx(v,{condition:!!s,show:t.jsx(I,{variant:"subtitle1",color:o?i.palette.text.secondary:i.palette.error.main,children:c})}),t.jsx(v,{condition:e.length===0,show:t.jsxs("p",{children:["No ",n,"s added yet."]}),elseShow:t.jsxs("div",{children:[t.jsxs(Us,{disabled:o,children:[e.length," ",e.length>1?`${n}s`:n," will get access."]}),e.map(u=>t.jsx(Hs,{disabled:o,label:t.jsx(Ce,{maxWidth:"300",text:u.toString(),maxLength:50})},u))]})})]}),t.jsx(v,{condition:!!s,show:t.jsx(ne,{color:o?"disabled":"error"}),elseShow:t.jsx("div",{})})]})},$e=j(S)(({theme:e})=>({width:"auto",height:"auto",padding:e.spacing(2,3),borderRadius:e.shape.borderRadiusMedium,border:`1px solid ${e.palette.divider}`})),U=e=>{switch(e.toUpperCase()){case"USERIDS":return"userId";case"IPS":return"remoteAddress";default:return e}},zs=({percentage:e,size:n="4rem"})=>{const r=B(),s={display:"block",borderRadius:"100%",transform:"rotate(-90deg)",height:n,width:n,background:r.palette.background.elevation2},o=100/(2*Math.PI),i=2*o;return t.jsxs("svg",{viewBox:`0 0 ${i} ${i}`,style:s,"aria-hidden":!0,children:[t.jsxs("title",{children:["A circle progress bar with ",e,"% completion."]}),t.jsx("circle",{r:o,cx:o,cy:o,fill:"none",stroke:r.palette.neutral.border,strokeWidth:i,strokeDasharray:`${e} 100`})]})},_s=j("div",{shouldForwardProp:e=>e!=="disabled"})(({theme:e,disabled:n})=>({color:n?e.palette.text.secondary:e.palette.neutral.main})),Bt=({parameters:e,constraints:n,input:r,disabled:s=!1})=>{const o=e==null?void 0:e.stickiness,i=typeof o=="string"&&o!=="default";return t.jsx(t.Fragment,{children:Object.keys(e).map(a=>{var c,u,g,l,m,h,b,P;switch(a){case"rollout":case"Rollout":{const R=we(e[a]);return t.jsxs($e,{sx:{display:"flex",alignItems:"center"},children:[t.jsx(S,{sx:E=>({mr:"1rem",color:s?E.palette.neutral.border:E.palette.text.secondary}),children:t.jsx(v,{condition:s,show:t.jsx(zs,{percentage:R,size:"2rem"}),elseShow:t.jsx(mn,{percentage:R,size:"2rem"})})}),t.jsxs(_s,{disabled:s,children:[t.jsxs(J,{color:s?"disabled":"success",children:[R,"%"]})," ","of your base"," ",t.jsxs("span",{children:[i?t.jsxs(t.Fragment,{children:["with"," ",t.jsx("strong",{children:o})]}):""," "]}),n.length>0?"who match constraints":""," ","is included."]})]},a)}case"userIds":case"UserIds":{const R=oe(e[a]);return t.jsx(ve,{value:R,text:"user",input:(c=r==null?void 0:r.context)!=null&&c[U(a)]?(u=r==null?void 0:r.context)==null?void 0:u[U(a)]:"no value",showReason:(g=r==null?void 0:r.context)!=null&&g[U(a)]?!R.includes((l=r==null?void 0:r.context)==null?void 0:l[U(a)]):void 0},a)}case"hostNames":case"HostNames":{const R=oe(e[a]);return t.jsx(ve,{value:R,text:"host",input:"no value",showReason:void 0,disabled:s},a)}case"IPs":{const R=oe(e[a]);return t.jsx(ve,{value:R,text:"IP",disabled:s,input:(m=r==null?void 0:r.context)!=null&&m[U(a)]?(h=r==null?void 0:r.context)==null?void 0:h[U(a)]:"no value",showReason:(b=r==null?void 0:r.context)!=null&&b[U(a)]?!R.includes((P=r==null?void 0:r.context)==null?void 0:P[U(a)]):void 0},a)}case"stickiness":case"groupId":return null;default:return null}})})},Gs=j(S)(({theme:e})=>({width:"100%",padding:e.spacing(2,3),borderRadius:e.shape.borderRadiusMedium,border:`1px solid ${e.palette.divider}`,display:"flex",flexDirection:"row",alignItems:"center",gap:2})),X=({text:e,input:n=null,isRequired:r=!1})=>{const s=B(),o=n===null?"error":"neutral",i=r&&n===null;return t.jsxs(Gs,{children:[t.jsx(I,{variant:"subtitle1",color:s.palette[o].main,sx:{minWidth:118},children:`${n===null?"no value":n}`}),t.jsx(S,{sx:{flexGrow:1,flexDirection:"column"},children:t.jsx(S,{sx:{flexGrow:1},children:t.jsx(v,{condition:!!i,show:t.jsxs(t.Fragment,{children:[t.jsx(I,{component:"span",color:s.palette.error.main,children:" required parameter "}),t.jsx(Ce,{maxWidth:"300",text:e,maxLength:50}),t.jsx(I,{component:"span",color:s.palette.error.main,children:" is not set "})]}),elseShow:t.jsxs(t.Fragment,{children:[t.jsx(I,{component:"span",color:"text.disabled",children:" set on parameter "}),t.jsx(Ce,{maxWidth:"300",text:e,maxLength:50})]})})})}),t.jsx(v,{condition:!!i,show:t.jsx(ne,{color:"error"}),elseShow:t.jsx("div",{})})]})},Ot=({strategyName:e,parameters:n})=>{const{strategies:r}=fn(),s=r.find(i=>i.name===e);if(!(s!=null&&s.editable))return null;const o=s==null?void 0:s.parameters.map(i=>{const a=n[i.name],c=i.required;switch(i==null?void 0:i.type){case"list":{const u=oe(a);return t.jsx(X,{isRequired:c,text:i.name,input:(u==null?void 0:u.length)>0?u.join(", "):null})}case"percentage":{const u=we(a),g=!(a===void 0||a===""||u<0||u>100);return t.jsx(X,{text:i.name,isRequired:c,input:g?`${u}%`:void 0})}case"boolean":{const u=["true","false"].includes(a)?a:void 0;return t.jsx(X,{isRequired:c,text:i.name,input:a!==void 0?u:void 0})}case"string":{const u=pn(a);return t.jsx(X,{text:i.name,isRequired:c,input:u!==void 0?u:void 0})}case"number":{const u=!(a===void 0||a===""),g=we(a);return t.jsx(X,{text:i.name,isRequired:c,input:u?`${g}`:void 0})}case"default":return null}return null});return t.jsx(t.Fragment,{children:o.map((i,a)=>t.jsxs(x.Fragment,{children:[t.jsx(v,{condition:a>0,show:t.jsx(G,{text:"AND"})}),i]},a))})},qs=j("div")(({theme:e})=>({padding:e.spacing(0)})),Vs=({strategyResult:e,input:n})=>{const{name:r,constraints:s,segments:o,parameters:i}=e,a=!!(o&&o.length>0),c=!!(s&&(s==null?void 0:s.length)>0),u=r!=="default"&&Object.keys(ut).includes(r),g=Object.keys(i).length>0&&e.result.evaluationStatus==="incomplete";if(!i)return null;const l=[a&&t.jsx(Ls,{segments:o,input:n}),c&&t.jsx(Ft,{constraints:s,input:n}),u&&t.jsx(Bt,{parameters:i,constraints:s,input:n}),g&&t.jsx(Ot,{strategyName:r,parameters:i}),r==="default"&&t.jsxs($e,{sx:{width:"100%"},children:["The standard strategy is ",t.jsx(J,{color:"success",children:"ON"})," for all users."]})].filter(Boolean);return t.jsx(qs,{children:l.map((m,h)=>t.jsxs(x.Fragment,{children:[t.jsx(v,{condition:h>0&&(e.name==="flexibleRollout"?h<l.length:h<l.length-1),show:t.jsx(G,{text:"AND"})}),m]},h))})},Ks=j("div")(()=>({width:"100%",display:"flex",flexDirection:"column"})),Dt=({constraints:e})=>e?t.jsx(Ks,{children:e==null?void 0:e.map((n,r)=>t.jsxs(x.Fragment,{children:[t.jsx(v,{condition:r>0,show:t.jsx(G,{text:"AND"})}),t.jsx(ct,{constraint:n,compact:!0,disabled:!0})]},Te(n)))}):null,Js=({segments:e})=>e?t.jsx(t.Fragment,{children:e.map((n,r)=>t.jsxs(x.Fragment,{children:[t.jsx(dt,{segment:n,constraintList:t.jsx(Dt,{constraints:n.constraints}),isExpanded:!0,disabled:!0}),t.jsx(v,{condition:r>=0&&e.length>1&&r!==e.length-1,show:t.jsx(G,{text:"AND"})})]},n.id))}):null,Ys=j("div")(({theme:e})=>({padding:e.spacing(0)})),Zs=({strategyResult:e,input:n,percentageFill:r})=>{const{name:s,constraints:o,segments:i,parameters:a}=e,c=!!(i&&i.length>0),u=!!(o&&(o==null?void 0:o.length)>0),g=s!=="default"&&Object.keys(ut).includes(s),l=Object.keys(a).length>0&&e.result.evaluationStatus==="incomplete";if(!a)return null;const m=[c&&t.jsx(Js,{segments:i}),u&&t.jsx(Dt,{constraints:o}),g&&t.jsx(Bt,{parameters:a,constraints:o,input:n,disabled:!0}),l&&t.jsx(Ot,{strategyName:s,parameters:a}),s==="default"&&t.jsxs($e,{sx:h=>({width:"100%",color:h.palette.text.secondary}),children:["The standard strategy is ",t.jsx(J,{color:"disabled",children:"ON"})," ","for all users."]})].filter(Boolean);return t.jsx(Ys,{children:m.map((h,b)=>t.jsxs(x.Fragment,{children:[t.jsx(v,{condition:b>0&&(e.name==="flexibleRollout"?b<m.length:b<m.length-1),show:t.jsx(G,{text:"AND"})}),h]},b))})},Qs=({strategy:e,input:n,index:r})=>{const{result:s}=e,o=B(),i=s.evaluationStatus==="incomplete"||s.evaluationStatus==="unevaluated"?"Unevaluated":s.enabled?"True":"False";return t.jsx(dr,{style:{borderColor:s.enabled&&s.evaluationStatus==="complete"?o.palette.success.main:"none"},strategy:{...e,id:`${Te(e)}`},orderNumber:r+1,actions:t.jsx(Y,{showIcon:!1,enabled:s.enabled,label:i}),children:t.jsx(v,{condition:!!e.disabled,show:t.jsx(Zs,{strategyResult:e,input:n}),elseShow:t.jsx(Vs,{strategyResult:e,input:n,percentageFill:o.palette.background.elevation2})})})},Xs=j("div")(({theme:e})=>({display:"flex",padding:"0, 4px",flexDirection:"column",borderRadius:e.shape.borderRadiusMedium,border:`1px solid ${e.palette.warning.border}`})),nt=j("div")(({theme:e})=>({padding:e.spacing(1,.5)})),eo=j(te)(({theme:e})=>({border:"0!important",borderBottomLeftRadius:0,borderBottomRightRadius:0,borderBottom:`1px solid ${e.palette.warning.border}!important`})),rt=j(I)(({theme:e})=>({margin:e.spacing(2,1,2,0),color:"text.secondary"})),le=({strategies:e,input:n,titlePrefix:r,infoText:s})=>t.jsx(v,{condition:e.length>0,show:t.jsxs(t.Fragment,{children:[t.jsx(rt,{variant:"subtitle1",children:`${r?r.concat(" strategies"):"Strategies"} (${e==null?void 0:e.length})`}),t.jsx(v,{condition:!!s,show:t.jsx(rt,{variant:"subtitle2",children:s})}),t.jsx(S,{sx:{width:"100%"},children:e==null?void 0:e.map((o,i)=>t.jsxs(x.Fragment,{children:[t.jsx(v,{condition:i>0,show:t.jsx(G,{text:"OR"})}),t.jsx(Qs,{strategy:o,index:i,input:n},o.id)]},o.id))})]})}),to=e=>e.hasUnsatisfiedDependency&&!e.isEnabledInCurrentEnvironment?"If environment was enabled and parent dependencies were satisfied":e.hasUnsatisfiedDependency?"If parent dependencies were satisfied":e.isEnabledInCurrentEnvironment?"":"If environment was enabled",no=({feature:e,input:n})=>{var i,a,c,u,g;const r=(a=(i=e.strategies)==null?void 0:i.data)==null?void 0:a.filter(l=>!l.disabled),s=(u=(c=e.strategies)==null?void 0:c.data)==null?void 0:u.filter(l=>l.disabled),o=(s==null?void 0:s.length)>0;return t.jsxs(Xs,{sx:{pb:1,mt:2},children:[t.jsxs(eo,{severity:"info",color:"warning",children:[to(e),", then this feature flag would be"," ",(g=e.strategies)!=null&&g.result?"TRUE":"FALSE"," with strategies evaluated like so:"," "]}),t.jsx(nt,{sx:{p:2.5},children:t.jsx(le,{strategies:r||[],input:n,titlePrefix:o?"Enabled":""})}),t.jsx(v,{condition:o,show:t.jsx(nt,{sx:{p:2.5},children:t.jsx(le,{strategies:s,input:n,titlePrefix:"Disabled",infoText:"Disabled strategies are not evaluated for the overall result."})})})]})},ro=({feature:e,input:n})=>{var i,a,c,u,g,l,m;const r=(a=(i=e.strategies)==null?void 0:i.data)==null?void 0:a.filter(h=>!h.disabled),s=(u=(c=e.strategies)==null?void 0:c.data)==null?void 0:u.filter(h=>h.disabled),o=(s==null?void 0:s.length)>0;return t.jsxs(t.Fragment,{children:[t.jsx(v,{condition:((l=(g=e==null?void 0:e.strategies)==null?void 0:g.data)==null?void 0:l.length)===0,show:t.jsx(te,{severity:"warning",sx:{mt:2},children:"There are no strategies added to this feature flag in selected environment."})}),t.jsx(v,{condition:(e.hasUnsatisfiedDependency||!e.isEnabledInCurrentEnvironment)&&!!((m=e==null?void 0:e.strategies)!=null&&m.data),show:t.jsx(no,{feature:e,input:n}),elseShow:t.jsxs(t.Fragment,{children:[t.jsx(le,{strategies:r||[],input:n,titlePrefix:o?"Enabled":""}),t.jsx(v,{condition:o,show:t.jsx(le,{strategies:s,input:n,titlePrefix:"Disabled",infoText:"Disabled strategies are not evaluated for the overall result."})})]})})]})},so=j("div")(({theme:e})=>({alignItems:"flex-end",color:e.palette.divider})),At=({feature:e,input:n})=>{const[r,s]=x.useState(!1),o=x.useRef(null),i=()=>{s(!r)};return e?t.jsxs(so,{children:[t.jsx(_,{onClick:i,children:t.jsx(Re,{ref:o})}),t.jsxs(he,{open:r,onClose:()=>s(!1),anchorEl:o.current,PaperProps:{sx:a=>({display:"flex",flexDirection:"column",padding:a.spacing(6),width:728,maxWidth:"100%",height:"auto",overflowY:"auto",backgroundColor:a.palette.background.elevation2,borderRadius:a.shape.borderRadius})},anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:[t.jsx(Es,{feature:e,input:n,onClose:()=>s(!1)}),t.jsx(ro,{feature:e,input:n})]})]}):null};var Le={},oo=ue;Object.defineProperty(Le,"__esModule",{value:!0});var Nt=Le.default=void 0,ao=oo(de()),io=t,lo=(0,ao.default)((0,io.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"}),"CheckCircleOutlined");Nt=Le.default=lo;const co=j("div")(({theme:e})=>({padding:e.spacing(4),maxWidth:"400px"})),Se=j(I)(({theme:e})=>({marginBottom:e.spacing(2)})),uo=j(Nt)(({theme:e})=>({color:e.palette.success.main})),ho=({variants:e,selectedVariant:n})=>{const r=B(),s=x.useMemo(()=>e.map(l=>({name:l.name,weight:`${bn(l.weight)}%`,selected:l.name===n})),[e,n]),o=x.useMemo(()=>({sortBy:[{id:"name",desc:!1}]}),[]),{getTableProps:i,getTableBodyProps:a,headerGroups:c,rows:u,prepareRow:g}=O.useTable({initialState:o,columns:go,data:s,sortTypes:ge,autoResetGlobalFilter:!1,autoResetSortBy:!1,disableSortRemove:!0},O.useGlobalFilter,O.useSortBy);return t.jsxs(co,{children:[t.jsx(Se,{variant:"subtitle2",children:"Variant Information"}),t.jsx(Se,{variant:"body2",children:"The following table shows the variants defined on this feature toggle and the variant result based on your context configuration."}),t.jsx(Se,{variant:"body2",children:'If you include "userId" or "sessionId" in your context, the variant will be the same every time because unleash uses these properties to ensure that the user receives the same experience.'}),t.jsxs(jn,{...i(),rowHeight:"dense",children:[t.jsx(yn,{headerGroups:c}),t.jsx(vn,{...a(),children:u.map(l=>{const m={};return l.original.selected||(m.color=r.palette.text.secondary),g(l),t.jsx(Sn,{hover:!0,...l.getRowProps(),children:l.cells.map(h=>t.jsx(Cn,{...h.getCellProps(),style:m,children:h.render("Cell")}))})})})]})]})},go=[{id:"Icon",Cell:({row:{original:{selected:e}}})=>t.jsx(t.Fragment,{children:t.jsx(v,{condition:e,show:t.jsx(wn,{icon:t.jsx(uo,{})})})}),maxWidth:25,disableGlobalFilter:!0},{Header:"Name",accessor:"name",searchable:!0,Cell:({row:{original:{name:e}}})=>t.jsx(_e,{children:e}),maxWidth:175,width:175},{Header:"Weight",accessor:"weight",sortType:"alphanumeric",searchable:!0,maxWidth:75,Cell:({row:{original:{weight:e}}})=>t.jsx(_e,{children:e})}],xo=j("div")(()=>({maxWidth:"100%",display:"flex",alignItems:"center",wordBreak:"break-all"})),mo=({variant:e,variants:n,feature:r,isEnabled:s})=>{const o=B(),[i,a]=x.useState(null),c=l=>a(l.currentTarget),u=()=>a(null),g=!!i;return t.jsxs(xo,{children:[e,t.jsx(v,{condition:!!n&&n.length>0&&s,show:t.jsxs(t.Fragment,{children:[t.jsx(_,{onClick:c,children:t.jsx(Re,{})}),t.jsx(he,{open:g,id:`${r}-result-variants`,PaperProps:{sx:{borderRadius:`${o.shape.borderRadiusLarge}px`}},onClose:u,anchorEl:i,anchorOrigin:{vertical:"bottom",horizontal:-320},children:t.jsx(ho,{variants:n,selectedVariant:e})})]})})]})},fo=({features:e})=>{const n=B(),r=ht(n.breakpoints.down("sm")),s=Object.keys(e[0].context).map(l=>({Header:Pe(l),accessor:m=>m.context[l],minWidth:160,Cell:Ie})),o=x.useMemo(()=>[...s,{Header:"Variant",id:"variant",accessor:"variant.name",sortType:"alphanumeric",filterName:"variant",maxWidth:200,Cell:({value:l,row:{original:{variant:m,feature:h,variants:b,isEnabled:P}}})=>t.jsx(mo,{variant:m!=null&&m.enabled?l:"",variants:b,feature:h,isEnabled:P})},{id:"isEnabled",Header:"isEnabled",filterName:"isEnabled",accessor:l=>{var m;return l!=null&&l.isEnabled?"true":((m=l==null?void 0:l.strategies)==null?void 0:m.result)==="unknown"?"unknown":"false"},Cell:({row:l})=>t.jsx(Pt,{feature:l.original}),sortType:"playgroundResultState",maxWidth:120,sortInverted:!0},{Header:"",maxWidth:70,id:"info",Cell:({row:l})=>t.jsx(At,{feature:l.original,input:{environment:l.original.environment,context:l.original.context}})}],[]),{headerGroups:i,rows:a,prepareRow:c,setHiddenColumns:u}=O.useTable({columns:o,data:e,sortTypes:ge,autoResetGlobalFilter:!1,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},O.useGlobalFilter,O.useFlexLayout,O.useSortBy);gt([{condition:r,columns:["variant"]}],u,o);const g=x.useRef(null);return t.jsx(S,{ref:g,sx:{overflow:"auto",maxHeight:"800px"},children:t.jsx(Fe,{parentRef:g,rows:a,headerGroups:i,prepareRow:c})})},po=j("div",{})(({theme:e})=>({flexGrow:0,...xt,justifyContent:"flex-start",margin:e.spacing(0,1.5)})),bo=j(S)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1)})),jo=({value:e})=>{const n=B(),[r,s]=x.useState(null),o=g=>s(g.currentTarget),i=()=>s(null),a=!!r,c=(e||[]).filter(g=>g.isEnabled),u=(e||[]).filter(g=>!g.isEnabled);return t.jsxs(po,{children:[t.jsxs(bo,{children:[t.jsx(v,{condition:c.length>0,show:t.jsx(Y,{enabled:!0,label:`${c.length}`,showIcon:!0})}),t.jsx(v,{condition:u.length>0,show:t.jsx(Y,{enabled:!1,label:`${u.length}`,showIcon:!0})})]}),t.jsxs(t.Fragment,{children:[t.jsx(_,{onClick:o,children:t.jsx(Re,{})}),t.jsxs(he,{open:a,id:`${e}-result-details`,PaperProps:{sx:{borderRadius:`${n.shape.borderRadiusLarge}px`,padding:n.spacing(3)}},onClose:i,anchorEl:r,anchorOrigin:{vertical:"bottom",horizontal:-320},children:[t.jsx(I,{variant:"subtitle2",sx:{mb:3},children:e[0].environment}),t.jsx(fo,{features:e})]})]})]})},yo=({features:e})=>{const n=Object.keys(e),r=e[n[0]],s=r[0].context,o=x.useMemo(()=>r.map((h,b)=>({...Object.fromEntries(n.map(P=>[P,e[P][b]]))})),[JSON.stringify(e)]),i=Object.keys(s).map(h=>({Header:Pe(h),accessor:b=>b[n[0]].context[h],minWidth:160,Cell:Ie})),a=n.map(h=>({Header:h,accessor:b=>{var P,R,E;return(P=b[h])!=null&&P.isEnabled?"true":((E=(R=b[h])==null?void 0:R.strategies)==null?void 0:E.result)==="unknown"?"unknown":"false"},Cell:({row:b})=>t.jsxs(S,{sx:{display:"flex"},children:[t.jsx(Pt,{feature:b.original[h]}),t.jsx(At,{feature:b.original[h],input:{environment:b.original[h].environment,context:b.original[h].context}})]}),sortType:"playgroundResultState",maxWidth:140})),c=x.useMemo(()=>[...i,...a],[]),{headerGroups:u,rows:g,prepareRow:l}=O.useTable({columns:c,data:o,sortTypes:ge,autoResetGlobalFilter:!1,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},O.useGlobalFilter,O.useFlexLayout,O.useSortBy),m=x.useRef(null);return t.jsx(S,{ref:m,sx:{overflow:"auto",maxHeight:"800px"},children:t.jsx(Fe,{parentRef:m,rows:g,headerGroups:u,prepareRow:l})})},vo=j("div",{})(({theme:e})=>({flexGrow:0,...xt,justifyContent:"flex-start",margin:e.spacing(0,1.5)})),So=j(ce)(({theme:e})=>({textAlign:"left",textDecorationStyle:"dotted",textDecorationLine:"underline",textUnderlineOffset:e.spacing(.75),color:e.palette.neutral.dark,padding:0,fontWeight:"normal"})),Co=({value:e})=>{const n=B(),[r,s]=x.useState(null),o=c=>s(c.currentTarget),i=()=>s(null),a=!!r;return t.jsx(vo,{children:t.jsxs(t.Fragment,{children:[t.jsx(So,{variant:"text",onClick:o,children:"View diff"}),t.jsxs(he,{open:a,id:`${e}-result-details`,PaperProps:{sx:{borderRadius:`${n.shape.borderRadiusLarge}px`,padding:n.spacing(3)}},onClose:i,anchorEl:r,anchorOrigin:{vertical:"bottom",horizontal:-320},children:[t.jsx(I,{variant:"subtitle2",sx:{mb:3},children:"Environments diff"}),t.jsx(yo,{features:e})]})]})})},wo=e=>e.reduce((n,r)=>n+Object.values(r.environments).flatMap(s=>Object.keys(s)).length,0),ko={id:"name"},{value:st,setValue:Eo}=mt("AdvancedPlaygroundResultsTable:v1",ko),To=({features:e,input:n,loading:r})=>{const{trackEvent:s}=ft();e&&s("playground",{props:{eventType:"number-of-combinations",count:wo(e)}});const[o,i]=pt(),a=kn(r),[c,u]=x.useState(o.get("search")||""),g=B(),l=ht(g.breakpoints.down("md")),m=e&&e.length>0?Object.keys(e[0].environments).length:0,h=x.useMemo(()=>{var p;return[{Header:"Name",accessor:"name",searchable:!0,minWidth:160,Cell:({value:w,row:{original:k}})=>t.jsx(Ge,{title:w,to:`/projects/${k==null?void 0:k.projectId}/features/${w}`})},{Header:"Project ID",accessor:"projectId",sortType:"alphanumeric",filterName:"projectId",searchable:!0,minWidth:150,Cell:({value:w})=>t.jsx(Ge,{title:w,to:`/projects/${w}`})},...((p=n==null?void 0:n.environments)==null?void 0:p.map(w=>({Header:r?()=>"":Pe(w),maxWidth:150,id:`environments.${w}`,align:"flex-start",Cell:({row:k})=>t.jsx(jo,{value:k.original.environments[w]})})))||[],...m>1?[{Header:"Diff",minWidth:150,id:"diff",align:"left",Cell:({row:w})=>t.jsx(Co,{value:w.original.environments})}]:[]]},[n]),{data:b,getSearchText:P,getSearchContext:R}=En(h,c,e||[]),E=x.useMemo(()=>r?Array(5).fill({name:"Feature name",projectId:"Feature Project",environments:{name:"Feature Environments",variants:[]},enabled:!0}):b,[b,r]),[N]=x.useState(()=>({sortBy:[{id:o.get("sort")||st.id,desc:o.has("order")?o.get("order")==="desc":st.desc}]})),{headerGroups:F,rows:D,state:{sortBy:y},prepareRow:f,setHiddenColumns:T}=O.useTable({initialState:N,columns:h,data:E,sortTypes:ge,autoResetGlobalFilter:!1,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0,defaultColumn:{Cell:Ie}},O.useGlobalFilter,O.useFlexLayout,O.useSortBy);return gt([{condition:l,columns:["projectId"]}],T,h),x.useEffect(()=>{if(r)return;const p=Object.fromEntries(o);p.sort=y[0].id,y[0].desc?p.order="desc":p.order&&delete p.order,c?p.search=c:delete p.search,i(p,{replace:!0}),Eo({id:y[0].id,desc:y[0].desc||!1})},[r,y,c]),t.jsxs(t.Fragment,{children:[t.jsxs(S,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:[t.jsx(I,{variant:"subtitle1",sx:{ml:1},children:e!==void 0&&!r?`Results (${D.length<E.length?`${D.length} of ${E.length}`:E.length})`:"Results"}),t.jsx(Tn,{initialValue:c,onChange:u,hasFilters:!0,getSearchContext:R,disabled:r,containerStyles:{marginLeft:"1rem",maxWidth:"400px"}})]}),t.jsx(v,{condition:!r&&!E,show:()=>t.jsx(pe,{children:E===void 0?"None of the feature flags were evaluated yet.":"No results found."}),elseShow:()=>t.jsxs(S,{ref:a,sx:{overflow:"auto"},children:[t.jsx(Rn,{value:P(c),children:t.jsx(Fe,{rows:D,headerGroups:F,prepareRow:f})}),t.jsx(v,{condition:E.length===0&&(c==null?void 0:c.length)>0,show:t.jsxs(pe,{children:["No feature flags found matching “",c,"”"]})}),t.jsx(v,{condition:E&&E.length===0&&!c,show:t.jsx(pe,{children:"No features flags to display"})})]})})]})},$t=j(te)(({theme:e})=>({marginBottom:e.spacing(3)})),Ro=({response:e})=>{var r;const n=(r=e==null?void 0:e.warnings)==null?void 0:r.invalidContextProperties;if(n&&n.length>0){n.sort();const s="Some context properties were not taken into account during evaluation",o=j("details")(({theme:i})=>({"* + *":{marginBlockStart:i.spacing(1)}}));return t.jsx($t,{severity:"warning",children:t.jsxs(o,{children:[t.jsx("summary",{children:s}),t.jsx("p",{children:"The context you provided for this query contained top-level properties with invalid values. These properties were not taken into consideration when evaluating your query. The properties are:"}),t.jsx("ul",{children:n.map(i=>t.jsx("li",{"data-testid":"context-warning-list-element",children:t.jsx("code",{children:i})},i))}),t.jsxs("p",{children:["Remember that context fields (with the exception of the"," ",t.jsx("code",{children:"properties"})," object) must be strings."]}),t.jsx("p",{children:"Because we didn't take these properties into account during the feature flag evaluation, they will not appear in the results table."})]})})}else return null},Oo=({FormComponent:e=ss})=>{const n={projects:[],environments:[]},{value:r,setValue:s}=mt("AdvancedPlayground:v1",n),{trackEvent:o}=ft(),{environments:i}=Pn(),a=B(),c=!0,[u,g]=x.useState(),[l,m]=x.useState(r.environments),[h,b]=x.useState(r.projects),[P,R]=x.useState(r.token),[E,N]=x.useState(r.context),[F,D]=x.useState(),{setToastData:y}=ot(),[f,T]=pt(),[p,w]=x.useState(),{evaluateAdvancedPlayground:k,evaluateChangeRequestPlayground:A,loading:L,errors:M}=ur(),[Z,Q]=x.useState(!1);x.useEffect(()=>{(l==null?void 0:l.length)===0&&i.length>0&&m([qr(i)])},[JSON.stringify(l),JSON.stringify(i)]),x.useEffect(()=>{xe()},[]);const xe=async()=>{try{const C=q(),W=$(),re=V();K(),me(),C&&re&&await We(C||[],W||"*",re)}catch(C){y({type:"error",title:`Failed to parse URL parameters: ${ee(C)}`})}},q=()=>{let C=null;const W=f.get("environments");return W&&(C=W.split(","),m(C)),C},$=()=>{let C=null;const W=f.get("projects");return W&&(C=W.split(","),b(C)),C},V=()=>{let C=f.get("context");return C&&(C=decodeURI(C),N(C)),C},K=()=>{let C=f.get("token");return C&&(C=decodeURI(C),R(C)),C},me=()=>{const C=f.get("changeRequest");C&&w(C)},We=async(C,W,re,fe)=>{try{g(void 0);const H={appName:"playground",...JSON.parse(re||"{}")},_t=p?await A(p,{context:H}):await k({environments:Gr(C),projects:_r(W),context:H});fe&&typeof fe=="function"&&fe(),D(_t)}catch(H){H instanceof In?g(H.message):H instanceof SyntaxError?y({type:"error",title:`Error parsing context: ${ee(H)}`}):y({type:"error",title:ee(H)})}},Lt=()=>{let C="default";P&&P!==""?C="api_token":p&&(C="change_request"),o("playground",{props:{eventType:"try-configuration",mode:C}})},Wt=async C=>{C.preventDefault(),Q(!0),Lt(),await We(l,h,E,()=>{Ht(),p||s({environments:l,projects:h,context:E})})},Mt=()=>{w(void 0)},Ht=()=>{f.set("context",encodeURI(E||"")),Array.isArray(l)&&l.length>0&&!(l.length===1&&l[0]==="*")?f.set("environments",l.join(",")):f.delete("projects"),Array.isArray(h)&&h.length>0&&!(h.length===1&&h[0]==="*")?f.set("projects",h.join(",")):f.delete("projects"),p?f.set("changeRequest",p):f.delete("changeRequest"),T(f)},Ut=F&&!c?"35%":"auto",zt=Kr();return t.jsx(Fn,{header:t.jsx(Bn,{title:"Unleash playground",actions:t.jsx(us,{})}),disableLoading:!0,bodyClass:"no-padding",children:t.jsxs(S,{sx:{display:"flex",flexDirection:"column"},children:[t.jsx(S,{sx:{background:a.palette.background.elevation2,borderBottomLeftRadius:a.shape.borderRadiusMedium,isolation:"isolate",zIndex:2},children:t.jsx(it,{elevation:0,sx:{px:4,py:3,background:a.palette.background.elevation2,transition:"width 0.4s ease",minWidth:"auto",width:Ut,position:"sticky",top:0},children:t.jsx(e,{onSubmit:Wt,context:E,setContext:N,availableEnvironments:i,projects:h,environments:l,token:P,setToken:R,setProjects:b,setEnvironments:m,changeRequest:p||void 0,onClearChangeRequest:Mt})})}),t.jsxs(S,{sx:C=>({width:zt,transition:"width 0.4s ease",padding:C.spacing(4,4),isolation:"isolate",zIndex:1}),children:[t.jsx(v,{condition:!!u,show:t.jsx($t,{severity:"warning",children:u})}),t.jsx(v,{condition:L,show:t.jsx(On,{}),elseShow:t.jsxs(t.Fragment,{children:[t.jsx(v,{condition:!!F&&Object.values(M).length===0,show:t.jsxs(t.Fragment,{children:[t.jsx(Ro,{response:F}),t.jsx(To,{loading:L,features:F==null?void 0:F.features,input:F==null?void 0:F.input})]})}),t.jsx(v,{condition:!F&&!Z,show:t.jsx(Et,{})})]})})]})]})})};export{Oo as AdvancedPlayground,Oo as default};
@@ -1 +1 @@
1
- import{j as e,e2 as t}from"./index-BkkVRgMF.js";const a=()=>e.jsx(t,{to:"/projects?create=true",replace:!0});export{a as default};
1
+ import{j as e,e2 as t}from"./index-Cx91uh9W.js";const a=()=>e.jsx(t,{to:"/projects?create=true",replace:!0});export{a as default};
@@ -1,2 +1,2 @@
1
- import{ih as c,d3 as m,ii as u,bf as x,b as f,bb as g,r as d,j as b,i7 as C,i8 as v,i9 as M,ia as S,ib as q,ic as j,ie as D,id as E,ij as L}from"./index-BkkVRgMF.js";import{L as T}from"./index-CFvoUqKv.js";import{d as $}from"./FeatureViewLazyExport--kJx8txU.js";import"./FeatureStaleDialog-DX_vqibC.js";import"./StrategyItemContainer-C2s-CIiO.js";const h=(e,i,s)=>{const a={label:"Total requests",borderColor:e.palette.primary.main,backgroundColor:e.palette.primary.main,data:p(i,s,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(i,s,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(i,s,o=>o.no),elements:{point:{radius:6,pointStyle:"triangle",pointRotation:180}}};return{datasets:[t,r,a]}},p=(e,i,s)=>e.map(a=>({x:a.timestamp,y:s(a),variants:a.variants||{}})),k=(e,i)=>{if(i===0)return"";const[s,a]=e,t=Math.floor(Number(a)/i*100);return`${a} (${t}%) - ${s}`},O=(e,i,s,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),n=o.indexOf(r.dataset.label);return l-n},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(n=>k(n,r.y)).join(`
1
+ import{ij as c,d3 as m,ik as u,bf as x,b as f,bb as g,r as d,j as b,i9 as C,ia as v,ib as M,ic as S,id as q,ie as j,ih as D,ig as E,il as L}from"./index-Cx91uh9W.js";import{L as T}from"./index-BsIpdLcw.js";import{d as $}from"./FeatureViewLazyExport-BwY7TYmZ.js";import"./FeatureStaleDialog-CrsbH2rq.js";import"./StrategyItemContainer-Das6_30A.js";const h=(e,i,s)=>{const a={label:"Total requests",borderColor:e.palette.primary.main,backgroundColor:e.palette.primary.main,data:p(i,s,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(i,s,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(i,s,o=>o.no),elements:{point:{radius:6,pointStyle:"triangle",pointRotation:180}}};return{datasets:[t,r,a]}},p=(e,i,s)=>e.map(a=>({x:a.timestamp,y:s(a),variants:a.variants||{}})),k=(e,i)=>{if(i===0)return"";const[s,a]=e,t=Math.floor(Number(a)/i*100);return`${a} (${t}%) - ${s}`},O=(e,i,s,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),n=o.indexOf(r.dataset.label);return l-n},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(n=>k(n,r.y)).join(`
2
2
  `)},title:t=>`Time: ${s>48?m(t[0].parsed.x,a.locale,"UTC"):u(t[0].parsed.x,a.locale)}`}},legend:{position:"top",align:"end",labels:{boxWidth:10,boxHeight:10,usePointStyle:!0}},title:{text:P(s),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:s>48?"day":"hour"},grid:{display:!1},ticks:{callback:(t,r,o)=>s>48?x(o[r].value,a.locale,"UTC"):u(o[r].value,a.locale),color:e.palette.text.secondary}}}}),P=e=>e===1?"Requests in the last hour":`Requests in the last ${$(e)}`;c.font={...c.font,family:"Sen",size:13,weight:"400"};const I=({metrics:e,hoursBack:i,statsSectionId:s})=>{const a=f(),{locationSettings:t}=g(),r=d.useMemo(()=>[...e].sort((n,y)=>n.timestamp.localeCompare(y.timestamp)),[e]),o=d.useMemo(()=>O(a,r,i,t),[a,r,i,t]),l=d.useMemo(()=>h(a,r,t),[a,r,t]);return b.jsx("div",{style:{height:400},children:b.jsx(T,{options:o,data:l,"aria-label":"A feature metrics line chart, with three lines: all requests, positive requests, and negative requests.","aria-describedby":s})})};C.register(v,M,S,q,j,D,E,L);export{I as FeatureMetricsChart,I as default};
@@ -0,0 +1,7 @@
1
+ import{x as M,y as H,j as e,c4 as Re,b5 as z,b7 as he,aN as q,C as S,N as _,T as C,L,aV as pe,aW as ge,e as B,cF as J,fc as I,aT as fe,aU as K,h as O,r as x,fE as me,fF as ve,s as $,A as Q,aP as xe,l as X,aQ as je,aR as be,hR as $e,an as Z,B as Y,eK as Pe,hS as W,eL as G,aK as ee,cZ as De,b as ye,cV as re,cK as _e,cD as Oe,hT as Ve,cT as Fe,cY as ie,b3 as N,c3 as qe,cX as Be,cW as Le,hU as Ne,bU as Me,ca as Te,ba as Se,b8 as Ce,hV as He,hW as ze,hX as Ue,hY as We,hb as Ge,h0 as we,hZ as Ye,i as Je,h_ as Ie,dd as Ee,c7 as Ke,cb as Qe,c9 as Xe,ce as Ze,bK as et,he as tt,h$ as at,al as nt,fe as st,i0 as rt,aL as it,be as oe,i1 as ot,i2 as lt,i3 as ct,fH as dt,cI as ut,i4 as ht,u as pt,b6 as gt,bk as ft}from"./index-Cx91uh9W.js";var te={},mt=H;Object.defineProperty(te,"__esModule",{value:!0});var vt=te.default=void 0,xt=mt(M()),jt=e,bt=(0,xt.default)((0,jt.jsx)("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM12 17.5 6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z"}),"Archive");vt=te.default=bt;var ae={},yt=H;Object.defineProperty(ae,"__esModule",{value:!0});var Tt=ae.default=void 0,St=yt(M()),Ct=e,wt=(0,St.default)((0,Ct.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm4.2 14.2L11 13V7h1.5v5.2l4.5 2.7-.8 1.3z"}),"WatchLater");Tt=ae.default=wt;var ne={},Et=H;Object.defineProperty(ne,"__esModule",{value:!0});var At=ne.default=void 0,kt=Et(M()),Rt=e,$t=(0,kt.default)((0,Rt.jsx)("path",{d:"M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-1 9h-4v4h-2v-4H9V9h4V5h2v4h4v2z"}),"LibraryAdd");At=ne.default=$t;const Pt=t=>fetch(t).then(he("ChangeRequest")).then(a=>a.json()),Dt=(t,a)=>{const r=a.map(i=>`feature=${i}`).join("&"),{data:n,error:s,mutate:l}=Re([],z(`api/admin/projects/${t}/change-requests/scheduled?${r}`),Pt);return{changeRequests:n,loading:!s&&!n,refetch:l,error:s}},le=()=>e.jsx(_,{severity:"warning",sx:{m:t=>t.spacing(2,0)},children:"Archiving features with dependencies will also remove those dependencies."}),_t=({ids:t,projectId:a})=>{const r=n=>`/projects/${a}/features/${n}`;return t?e.jsxs(_,{severity:"warning",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(C,{fontWeight:"bold",variant:"body2",display:"inline",children:`${t.length} feature flags `}),e.jsx("span",{children:"have usage from applications. If you archive these feature flags they will not be available to Client SDKs:"}),e.jsx("ul",{children:t==null?void 0:t.map(n=>e.jsx("li",{children:e.jsx(L,{to:r(n),children:n})},n))})]}):null},ce=({ids:t,projectId:a})=>{const r=n=>`/projects/${a}/features/${n}`;return t&&t.length>1?e.jsxs(_,{severity:"error",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(C,{fontWeight:"bold",variant:"body2",display:"inline",children:`${t.length} feature flags `}),e.jsx("span",{children:"have child features that depend on them and are not part of the archive operation. These parent features can not be archived:"}),e.jsx("ul",{children:t==null?void 0:t.map(n=>e.jsx("li",{children:e.jsx(L,{to:r(n),children:n})},n))})]}):t&&t.length===1?e.jsxs(_,{severity:"error",sx:{m:n=>n.spacing(2,0)},children:[e.jsx(L,{to:r(t[0]),children:t[0]})," has child features that depend on it and are not part of the archive operation."]}):null},de=({changeRequests:t,projectId:a})=>t&&t.length>0?e.jsxs(_,{severity:"warning",sx:{m:r=>r.spacing(2,0)},children:[e.jsxs("p",{children:["This archive operation would conflict with"," ",t.length," scheduled change request(s). The change request(s) that would be affected by this are:"]}),e.jsx("ul",{children:t.map(({id:r,title:n})=>{const s=n?`#${r} (${n})`:`Change request #${r}`;return e.jsx("li",{children:e.jsx(L,{to:`/projects/${a}/change-requests/${r}`,target:"_blank",rel:"noopener noreferrer",title:`Change request ${r}`,children:s})},r)})})]}):t===void 0?e.jsx(_,{severity:"warning",children:e.jsx("p",{children:"This archive operation might conflict with one or more scheduled change requests. If you complete it, those change requests can no longer be applied."})}):null,Ot=(t,a)=>{const n=pe(t)(),{isChangeRequestConfiguredForReview:s}=ge(t);return n&&s(n)&&a?"Add to change request":n&&s(n)?"Add change to draft":a?"Archive flags":"Archive flag"},Vt=({projectId:t,featureIds:a,onSuccess:r,onError:n})=>{const{setToastData:s,setToastApiError:l}=B(),{archiveFeatureToggle:i}=J(),{archiveFeatures:c}=I(),{isChangeRequestConfiguredForReview:d}=ge(t),{addChange:g}=fe(),{refetch:f}=K(t),p=pe(t),h=(a==null?void 0:a.length)>1,o=p(),m=async()=>{if(!o){console.error("No change request environment");return}await g(t,o,a.map(k=>({action:"archiveFeature",feature:k,payload:void 0}))),f(),s({text:h?"Your archive feature flags changes have been added to change request":"Your archive feature flag change has been added to change request",type:"success",title:h?"Changes added to a draft":"Change added to a draft"})},v=async()=>{await i(t,a[0]),s({text:"Your feature flag has been archived",type:"success",title:"Feature archived"})},y=async()=>{await c(t,a),s({text:"Selected feature flags have been archived",type:"success",title:"Features archived"})};return async()=>{try{o&&d(o)?await m():h?await y():await v(),r()}catch(k){l(O(k)),n()}}},Ft=(t,a,r)=>{const[n,s]=x.useState(!0),[l,i]=x.useState([]),[c,d]=x.useState(!1),{verifyArchiveFeatures:g}=I();return x.useEffect(()=>{r&&g(a,t).then(f=>f.json()).then(({hasDeletedDependencies:f,parentsWithChildFeatures:p})=>{p.length===0?(s(!1),i(p)):(s(!0),i(p)),d(f)})},[JSON.stringify(t),r,a,i,s,d]),{disableArchive:n,offendingParents:l,hasDeletedDependencies:c}},ga=({isOpen:t,onClose:a,onConfirm:r,projectId:n,featureIds:s,featuresWithUsage:l})=>{const i=(s==null?void 0:s.length)>1,c=Ot(n,i),d=i?"Archive feature flags":"Archive feature flag",g=Vt({projectId:n,featureIds:s,onSuccess(){r(),a()},onError(){a()}}),{changeRequests:f}=Dt(n,s),{disableArchive:p,offendingParents:h,hasDeletedDependencies:o}=Ft(s,n,t),m=h.length===0&&o;return e.jsx(q,{onClick:g,open:t,onClose:a,primaryButtonText:c,secondaryButtonText:"Cancel",title:d,disabledPrimaryButton:p,children:e.jsx(S,{condition:i,show:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Are you sure you want to archive"," ",e.jsx("strong",{children:s==null?void 0:s.length})," feature flags?"]}),e.jsx(S,{condition:!!(l&&(l==null?void 0:l.length)>0),show:e.jsx(_t,{ids:l,projectId:n})}),e.jsx(S,{condition:h.length>0,show:e.jsx(ce,{ids:h,projectId:n})}),e.jsx(S,{condition:m,show:e.jsx(le,{})}),e.jsx(de,{changeRequests:f,projectId:n}),e.jsx(S,{condition:(s==null?void 0:s.length)<=5,show:e.jsx("ul",{children:s==null?void 0:s.map(v=>e.jsx("li",{children:v},v))})})]}),elseShow:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Are you sure you want to archive"," ",i?"these feature flags":"this feature flag","?"]}),e.jsx(S,{condition:h.length>0,show:e.jsx(ce,{ids:h,projectId:n})}),e.jsx(S,{condition:m,show:e.jsx(le,{})}),e.jsx(de,{changeRequests:f,projectId:n})]})})})},qt=(t,a)=>`/api/admin/projects/${t}/features/${a}/parents`,fa=(t,a)=>{const r=z(qt(t,a)),{data:n,refetch:s,loading:l,error:i}=me(r,()=>ve(r,"Parent Options"));return{parentOptions:n,loading:l,error:i}},Bt=(t,a)=>`/api/admin/projects/${t}/features/${a}/parent-variants`,Ae=(t,a)=>{const r=z(Bt(t,a)),{data:n,refetch:s,loading:l,error:i}=me(r,()=>ve(r,"Parent Variant Options"));return{parentVariantOptions:n||[],loading:l,error:i}},Lt=$(Q)(({theme:t})=>({marginTop:t.spacing(2),marginBottom:t.spacing(1.5)})),Nt=({project:t,parent:a,onSelect:r})=>{const{parentVariantOptions:n}=Ae(t,a),s=e.jsx(je,{fontSize:"small"}),l=e.jsx(be,{fontSize:"small"});return e.jsx(Lt,{id:"single-variant-options",options:n,renderOption:(i,c,{selected:d})=>e.jsxs("li",{...i,children:[e.jsx(xe,{icon:s,checkedIcon:l,style:{marginRight:8},checked:d}),c]}),renderInput:i=>e.jsx(X,{...i,placeholder:"Select variant"}),fullWidth:!0,onChange:(i,c)=>{r(String(c))}})},ma=({projectId:t,featureId:a,isOpen:r,setIsOpen:n,onComplete:s})=>{const{markFeatureCompleted:l}=$e(),{parentVariantOptions:i}=Ae(t,a),[c,d]=x.useState("kept"),[g,f]=x.useState(void 0),{trackEvent:p}=Z(),h=async()=>{const o=c==="kept-with-variant"?"kept":c;await l(a,t,{status:o,statusValue:g}),n(!1),s(),p("feature-lifecycle",{props:{eventType:"complete",status:o}})};return e.jsx(q,{open:r,title:"Mark completed",onClose:()=>{n(!1)},disabledPrimaryButton:c==="kept-with-variant"&&g===null,onClick:h,primaryButtonText:"Mark completed",secondaryButtonText:"Cancel",children:e.jsxs(Y,{children:[e.jsx(Y,{sx:{mt:2,mb:4},children:"Marking the feature flag as complete does not affect any configuration, but it moves the feature flag into it’s next life cycle stage and is an indication that you have learned what you needed in order to progress with the feature. It serves as a reminder to start cleaning up the feature flag and removing it from the code."}),e.jsx(C,{sx:{mb:2},children:e.jsx("b",{children:"What was the outcome of this feature?"})}),e.jsxs(Pe,{"aria-label":"selected-value",name:"selected",sx:{gap:o=>o.spacing(.5)},onChange:(o,m)=>{d(m)},children:[e.jsx(W,{value:"kept",legal:{value:"We decided to keep the feature"},control:e.jsx(G,{})},"kept"),e.jsx(W,{value:"discarded",legal:{value:"We decided to discard the feature"},control:e.jsx(G,{})},"discarded"),e.jsx(S,{condition:i.length>0,show:e.jsx(W,{value:"kept-with-variant",legal:{value:"We decided to keep the feature variant",description:"Choose to specify which feature variant will be kept"},control:e.jsx(G,{})},"kept-with-variant")}),e.jsx(S,{condition:i.length>0&&c==="kept-with-variant",show:e.jsx(Nt,{parent:a,project:t,onSelect:o=>{f(o)}})})]})]})})},Mt=({isOpen:t,disabled:a=!1,onConfirm:r,onClose:n,showBanner:s,environment:l,messageComponent:i})=>{const c=ee("projectId"),{data:d}=K(c),{changeRequestInReviewOrApproved:g,alert:f}=De(d),p=g(l||""),h=p?"Add to existing change request":"Add suggestion to draft";return e.jsxs(q,{open:t,primaryButtonText:h,secondaryButtonText:"Cancel",disabledPrimaryButton:a,onClick:r,onClose:n,title:"Request changes",fullWidth:!0,children:[e.jsx(S,{condition:p,show:f}),e.jsx(S,{condition:!!s,show:e.jsxs(_,{severity:"info",sx:{mb:2},children:["Change requests feature is enabled for ",l,". 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."]})}),e.jsx(C,{variant:"body2",color:"text.secondary",children:"Your suggestion:"}),i]})},Ht=$("div")({display:"flex",flexDirection:"column"}),zt=({strategy:t,setStrategy:a,projectId:r,environment:n,editable:s,permission:l=Be})=>{const{trackEvent:i}=Z(),[c,d]=x.useState([]),g=ye(),f=t!=null&&t.parameters&&"stickiness"in(t==null?void 0:t.parameters)?String(t.parameters.stickiness):"default";x.useEffect(()=>{d((t.variants||[]).map(o=>({...o,new:s||!1,isValid:!0,id:re(),overrides:[]})))},[]),x.useEffect(()=>{a(o=>({...o,variants:c.map(m=>({stickiness:f,name:m.name,weight:m.weight,payload:m.payload,weightType:m.weightType}))}))},[f,JSON.stringify(c)]);const p=(o,m)=>{d(v=>ie(v.map(y=>y.id===m?o:y),1e3))},h=()=>{const o=re();d(m=>[...m,{name:"",weightType:Le.VARIABLE,weight:0,stickiness:f,new:!0,isValid:!1,id:o}]),i("strategy-variants",{props:{eventType:"variant added"}})};return e.jsxs(e.Fragment,{children:[e.jsxs(C,{component:"h3",sx:{m:0,display:"flex",gap:"1ch"},variant:"h3",children:["Variants",e.jsx(_e,{htmlTooltip:!0,tooltip:e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"Variants allow to attach one or more values to this strategy. Variants at the strategy level override variants at the feature level."}),e.jsx(Oe,{target:"_blank",href:"https://docs.getunleash.io/reference/strategy-variants",children:"Learn more"})]})})]}),e.jsxs(Ht,{children:[e.jsx(Ve,{}),c.map((o,m)=>e.jsx(Fe,{disableOverrides:!0,variant:o,variants:c,updateVariant:v=>p(v,o.id),removeVariant:()=>d(v=>ie(v.filter(y=>y.id!==o.id),1e3)),decorationColor:g.palette.variants[m%g.palette.variants.length]},o.id))]}),e.jsx(N,{onClick:h,variant:"outlined",permission:l,projectId:r,environmentId:n,"data-testid":"ADD_STRATEGY_VARIANT_BUTTON",children:"Add variant"}),e.jsx(qe,{variants:c})]})},Ut=$("form")(({theme:t})=>({display:"grid",gap:t.spacing(2)})),ue=$("hr")(({theme:t})=>({width:"100%",height:"1px",margin:t.spacing(2,0),border:"none",background:t.palette.background.elevation2})),Wt=$("div")(({theme:t})=>({display:"flex",justifyContent:"end",gap:t.spacing(2),paddingBottom:t.spacing(10)})),Gt=({projectId:t,environmentId:a,permission:r,onSubmit:n,onCancel:s,loading:l,strategy:i,setStrategy:c,segments:d,setSegments:g,errors:f})=>{const p=Ne(i.constraints),h=Me(r,t,a),{strategyDefinition:o}=Te(i==null?void 0:i.name),m=Se(),{uiConfig:v,error:y,loading:k}=Ce();if(y)throw y;if(k||!o)return null;const V=b=>o.parameters.find(w=>w.name===b),E=(b,w)=>{const A=V(b);if(b!=="groupId"){const D=Ie(A,w);return D?(f.setFormError(b,D),!1):(f.removeFormError(b),!0)}return!0},u=()=>o.parameters.map(b=>b.name).map(b=>{var w;return E(b,(w=i.parameters)==null?void 0:w[b])}).every(Boolean),P=()=>{m(`/projects/${t}/settings/default-strategy`)},F=async b=>{if(b.preventDefault(),u())n();else return};return e.jsxs(Ut,{onSubmit:F,children:[e.jsx(He,{title:i.title||"",setTitle:b=>{c(w=>({...w,title:b}))}}),e.jsx(ze,{segments:d,setSegments:g,projectId:t}),e.jsx(Ue,{projectId:t,environmentId:a,strategy:i,setStrategy:c}),e.jsx(ue,{}),e.jsx(We,{strategy:i,strategyDefinition:o,setStrategy:c,validateParameter:E,errors:f,hasAccess:h}),e.jsx(S,{condition:i.parameters!=null&&"stickiness"in i.parameters,show:e.jsx(zt,{strategy:i,setStrategy:c,environment:a,projectId:t,permission:[Ge,we]})}),e.jsx(ue,{}),e.jsxs(Wt,{children:[e.jsx(N,{permission:r,projectId:t,environmentId:a,variant:"contained",color:"primary",type:"submit",disabled:l||!p||f.hasFormErrors(),"data-testid":Ye,children:"Save strategy"}),e.jsx(Je,{type:"button",color:"primary",onClick:s||P,disabled:l,children:"Cancel"})]})]})},Yt=(t,a)=>{var i;const{project:r,refetch:n}=Ee(t),s={name:"flexibleRollout",constraints:[],parameters:{rollout:"100",stickiness:r.defaultStickiness||"default",groupId:""}},l=(i=r.environments.find(c=>c.environment===a))==null?void 0:i.defaultStrategy;return{defaultStrategyFallback:s,strategy:l,refetch:n}},va=()=>{const t=ee("projectId"),a=Ke("environmentId"),{refetch:r}=Ee(t),{defaultStrategyFallback:n,strategy:s,refetch:l}=Yt(t,a),[i,c]=x.useState(s||n),[d,g]=x.useState([]),{updateDefaultStrategy:f,loading:p}=I(),{strategyDefinition:h}=Te(i==null?void 0:i.name),{setToastData:o,setToastApiError:m}=B(),v=Qe(),{uiConfig:y}=Ce(),{unleashUrl:k}=y,V=Se(),{trackEvent:E}=Z(),{segments:u,refetchSegments:P}=Xe();x.useEffect(()=>{if(u&&(s!=null&&s.segments)){const A=[];for(const D of s==null?void 0:s.segments)A.push(...u.filter(T=>T.id===D));g(A)}},[JSON.stringify(u),JSON.stringify(s==null?void 0:s.segments)]);const F=Jt(i,d),b=async A=>{await f(t,a,A),E("default_strategy",{props:{action:"edit",hasTitle:!!A.title}}),P(),r(),o({title:"Default Strategy updated",type:"success",confetti:!0})},w=async()=>{const A=`/projects/${t}/settings/default-strategy`;try{await b(F),await l(),V(A)}catch(D){m(O(D))}};return!h||!i?null:e.jsx(Ze,{modal:!0,title:et((i==null?void 0:i.name)??""),description:Kt,documentationLink:Qt,documentationLinkLabel:Xt,formatApiCode:()=>It(t,a,F,h,k),children:e.jsx(Gt,{projectId:t,strategy:i,setStrategy:c,segments:d,setSegments:g,environmentId:a,onSubmit:w,loading:p,permission:[tt,we],errors:v,isChangeRequest:!1})})},Jt=(t,a)=>({name:t.name,title:t.title,constraints:t.constraints??[],parameters:t.parameters??{},variants:t.variants??[],segments:a.map(r=>r.id),disabled:t.disabled??!1}),It=(t,a,r,n,s)=>{if(!s)return"";const l={...r,parameters:at(r.parameters??{},n)},i=`${s}/api/admin/projects/${t}/environments/${a}/default-strategy}`,c=JSON.stringify(l,void 0,2);return`curl --location --request PUT '${i}' \\
2
+ --header 'Authorization: INSERT_API_KEY' \\
3
+ --header 'Content-Type: application/json' \\
4
+ --data-raw '${c}'`},Kt=`
5
+ An activation strategy will only run when a feature flag is enabled and provides a way to control who will get access to the feature.
6
+ If any of a feature flag's activation strategies returns true, the user will get access.
7
+ `,Qt="https://docs.getunleash.io/reference/projects#project-default-strategy",Xt="Default strategy documentation",Zt=t=>{const[a,r]=x.useState(t),n=x.useCallback(()=>r(t),[t]);return x.useEffect(()=>{r(t)},[t]),[a,r,n]},ea=$(Y)(()=>({mx:"auto",...nt})),xa=({projectId:t,featureId:a,environmentName:r,value:n,onToggle:s})=>{const[l,i,c]=Zt(n),d=()=>{i(!l),requestAnimationFrame(()=>{s(!l,c)})},g=`${a}-${r}`;return e.jsx(e.Fragment,{children:e.jsx(ea,{"data-testid":`TOGGLE-${g}`,children:e.jsx(st,{tooltip:l?`Disable feature in ${r}`:`Enable feature in ${r}`,checked:n,environmentId:r,projectId:t,permission:rt,inputProps:{"aria-label":r},onClick:d,"data-testid":"permission-switch",disableRipple:!0,disabled:n!==l})},g)})},ta=t=>{const{setToastData:a,setToastApiError:r}=B(),{addChange:n}=fe(),{refetch:s}=K(t),[l,i]=x.useState(!1),[c,d]=x.useState({isOpen:!1}),g=x.useCallback((h,o,m,v)=>{d({featureName:h,environment:o,enabled:m,shouldActivateDisabledStrategies:v,isOpen:!0})},[]),f=x.useCallback(()=>{d(h=>({...h,isOpen:!1}))},[]),p=x.useCallback(async()=>{try{i(!0),await n(t,c.environment,{feature:c.featureName,action:"updateEnabled",payload:{enabled:!!c.enabled,shouldActivateDisabledStrategies:!!c.shouldActivateDisabledStrategies}}),s(),d(h=>({...h,isOpen:!1})),a({type:"success",title:"Changes added to the draft!"})}catch(h){r(O(h)),d(o=>({...o,isOpen:!1}))}finally{i(!1)}},[n]);return{pending:l,onChangeRequestToggle:g,onChangeRequestToggleClose:f,onChangeRequestToggleConfirm:p,changeRequestDialogDetails:c}},aa=({enabled:t,featureName:a,environment:r})=>e.jsxs(C,{"data-testid":"update-enabled-message",children:[e.jsx("strong",{children:t?"Enable":"Disable"})," feature flag"," ",e.jsx("strong",{children:a})," in ",e.jsx("strong",{children:r})]}),na=$("ul")(({theme:t})=>({margin:t.spacing(1),paddingLeft:t.spacing(2)})),sa=({isOpen:t,onAddDefaultStrategy:a,onActivateDisabledStrategies:r,onClose:n,environment:s,featureId:l})=>{var f,p,h;const i=ee("projectId"),{feature:c}=it(i,l),d=(h=(p=(f=c.environments)==null?void 0:f.find(({name:o})=>o===s))==null?void 0:p.strategies)==null?void 0:h.filter(({disabled:o})=>o).length,g=d?d===1?"1 disabled strategy":`${d} disabled strategies`:"disabled strategies";return e.jsxs(q,{open:t,secondaryButtonText:"Cancel",permissionButton:e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"button",variant:"outlined",permission:oe,projectId:i,environmentId:s,onClick:a,children:"Add default strategy"}),e.jsx(N,{type:"button",variant:"outlined",permission:oe,projectId:i,environmentId:s,onClick:r,children:"Enable all strategies"})]}),onClose:n,title:`Enable feature flag in ${s}`,fullWidth:!0,children:[e.jsx(C,{sx:{mb:o=>o.spacing(3)},children:"A feature flag cannot be enabled without an enabled strategy."}),e.jsx(C,{children:"To enable this feature flag you can choose to:"}),e.jsxs(na,{children:[e.jsx("li",{children:e.jsx(C,{children:e.jsx("strong",{children:"Add the default strategy"})})}),e.jsx("li",{children:e.jsxs(C,{children:[e.jsx("strong",{children:"Enable all the disabled strategies"})," ","(this feature flag has ",g,")"]})})]})]})},ra=t=>{const a=r=>{r<t.length&&t[r](()=>a(r+1))};a(0)},ja=t=>{const{toggleFeatureEnvironmentOn:a,toggleFeatureEnvironmentOff:r}=J(),{setToastData:n,setToastApiError:s}=B(),[l,i]=x.useState({open:!1,label:"",loading:!1,onClose:()=>{},onClick:()=>{}}),[c,d]=x.useState({isOpen:!1,environment:"",featureId:"",onClose:()=>{},onActivateDisabledStrategies:()=>{},onAddDefaultStrategy:()=>{}}),{pending:g,onChangeRequestToggle:f,onChangeRequestToggleClose:p,onChangeRequestToggleConfirm:h,changeRequestDialogDetails:o}=ta(t),[m,v]=x.useState(),y=x.useCallback(async(E,u)=>{let P=!1;return ra([T=>{if(u.isChangeRequestEnabled||!lt(u.environmentType||""))return T();i({open:!0,label:`${E?"Enable":"Disable"} Environment`,loading:!1,onClose:()=>{var j;i(R=>({...R,open:!1})),(j=u.onRollback)==null||j.call(u)},onClick:()=>{i(j=>({...j,open:!1,loading:!0})),T()}})},T=>{if(E===!1||!u.hasStrategies||u.hasEnabledStrategies)return T();d({isOpen:!0,environment:u.environmentName,featureId:u.featureId,onClose:()=>{var j;d(R=>({...R,isOpen:!1})),(j=u.onRollback)==null||j.call(u)},onActivateDisabledStrategies:()=>{d(j=>({...j,isOpen:!1})),P=!0,T()},onAddDefaultStrategy:()=>{d(j=>({...j,isOpen:!1})),T()}})},T=>{if(!u.isChangeRequestEnabled)return T();v(()=>{var j;v(void 0),(j=u.onRollback)==null||j.call(u)}),f(u.featureId,u.environmentName,E,P)},async T=>{var j,R;if(E!==!1)return T();try{await r(u.projectId,u.featureId,u.environmentName),n({type:"success",title:`Disabled in ${u.environmentName}`,text:`${u.featureId} is unavailable in ${u.environmentName} and its strategies will no longer have any effect.`}),(j=u.onSuccess)==null||j.call(u)}catch(U){s(O(U)),(R=u.onRollback)==null||R.call(u)}},async T=>{var j,R;if(E!==!0)return T();try{await a(u.projectId,u.featureId,u.environmentName,P),n({type:"success",title:`Enabled in ${u.environmentName}`,text:`${u.featureId} is now available in ${u.environmentName} based on its defined strategies.`}),(j=u.onSuccess)==null||j.call(u)}catch(U){s(O(U)),(R=u.onRollback)==null||R.call(u)}}])},[i]),k=c.featureId.length!==0,V=e.jsxs(e.Fragment,{children:[e.jsx(ot,{...l}),e.jsx(S,{condition:k,show:e.jsx(sa,{...c})}),e.jsx(Mt,{isOpen:o.isOpen,onClose:()=>{m==null||m(),p()},environment:o==null?void 0:o.environment,disabled:g,onConfirm:()=>{m==null||m(),h()},messageComponent:e.jsx(aa,{enabled:o==null?void 0:o.enabled,featureName:o==null?void 0:o.featureName,environment:o.environment})})]});return{onToggle:y,modals:V}},ia=$(ct)(({theme:t})=>({color:t.palette.warning.main,fontSize:t.fontSizes.bodySize})),ba=()=>e.jsx(dt,{arrow:!0,title:e.jsxs(e.Fragment,{children:["This environment has no variants enabled. If you check this feature's variants in this environment, you will get the"," ",e.jsx("a",{href:"https://docs.getunleash.io/reference/feature-toggle-variants#the-disabled-variant",target:"_blank",rel:"noreferrer",children:"disabled variant"}),"."]}),children:e.jsx(ia,{})});var se={},oa=H;Object.defineProperty(se,"__esModule",{value:!0});var ke=se.default=void 0,la=oa(M()),ca=e,da=(0,la.default)((0,ca.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");ke=se.default=da;const ua=ht(),ya=({options:t,selectedOptions:a,indeterminateOptions:r,tagType:n,existingTags:s,disabled:l=!1,onChange:i})=>{const c=e.jsx(je,{fontSize:"small"}),d=p=>p.inputValue?p.inputValue:p.title,g=(p,h,{selected:o})=>{const m=(r==null?void 0:r.some(v=>v.title===h.title))??!1;return e.jsxs("li",{...p,children:[e.jsx(S,{condition:!!h.inputValue,show:e.jsx(ut,{sx:{mr:v=>v.spacing(.5)}}),elseShow:e.jsx(xe,{icon:c,checkedIcon:e.jsx(be,{fontSize:"small"}),indeterminateIcon:e.jsx(ke,{fontSize:"small"}),sx:{mr:v=>v.spacing(.5)},checked:o&&!m,indeterminate:m})}),h.title]})},f=(p,h)=>{const o=h.inputValue.trim(),m=ua(p,{...h,inputValue:o}),v=p.some(y=>o===y.title);return o.length>=2&&!v&&m.push({inputValue:o,title:`Create new value "${o}"`}),m};return e.jsx(Q,{multiple:!0,id:"checkboxes-tag",sx:{marginTop:p=>p.spacing(2),width:500},disableCloseOnSelect:!0,options:t,value:a,isOptionEqualToValue:(p,h)=>h.inputValue&&h.inputValue!==""?p.title===h.inputValue:p.title===h.title,getOptionLabel:d,renderOption:g,filterOptions:f,ListboxProps:{style:{maxHeight:200,overflow:"auto"}},onChange:i,renderInput:p=>e.jsx(X,{...p,label:"Select values",placeholder:"Select values"}),disabled:l})},ha=$("li")({flexDirection:"column"}),Ta=({options:t,value:a,disabled:r=!1,onChange:n})=>{const s=ye();return e.jsx(Q,{disablePortal:!0,disabled:r,id:"tag-type-select",sx:{marginTop:l=>l.spacing(2),width:500},options:t,disableClearable:!0,value:a,getOptionLabel:l=>l.name,renderOption:(l,i)=>e.jsxs(ha,{...l,style:{alignItems:"flex-start",gap:s.spacing(.5)},children:[e.jsx(C,{variant:"body1",children:i.name}),e.jsx(C,{variant:"caption",children:i.description})]}),renderInput:l=>e.jsx(X,{...l,label:"Tag type",value:a}),onChange:n,ListboxProps:{style:{maxHeight:200,overflow:"auto"}}})},Sa=()=>{const{makeRequest:t,createRequest:a,errors:r,loading:n}=pt({propagateErrors:!0});return{createTag:async i=>{const d=a("api/admin/tags",{method:"POST",body:JSON.stringify(i)});return t(d.caller,d.id)},bulkUpdateTags:async(i,c)=>{const d=`api/admin/projects/${c}/tags`,g=a(d,{method:"PUT",body:JSON.stringify(i)});return t(g.caller,g.id)},errors:r,loading:n}},Ca=(t,a={})=>{const r=async()=>{const g=z(`api/admin/tags/${t}`);return(await fetch(g,{method:"GET"}).then(he("Tags"))).json()},n=`api/admin/tags/${t}`,{data:s,error:l}=gt(!!t,{tags:[]},n,r,a),[i,c]=x.useState(!l&&!s),d=()=>{ft(n)};return x.useEffect(()=>{c(!l&&!s)},[s,l]),{tags:(s==null?void 0:s.tags)||[],error:l,loading:i,refetch:d}},wa=({isStale:t,isOpen:a,projectId:r,featureId:n,onClose:s})=>{const{setToastData:l,setToastApiError:i}=B(),{patchFeatureToggle:c}=J(),d=e.jsx(C,{children:"Setting a flag to stale marks it for cleanup"}),g=e.jsx(C,{children:"Setting a flag to active marks it as in active use"}),f=t?"active":"stale",p=async h=>{h.stopPropagation();try{await c(r,n,[{op:"replace",path:"/stale",value:!t}]),s()}catch(o){i(O(o))}l(t?{type:"success",title:"And we're back!",text:"The flag is no longer marked as stale."}:{type:"success",title:"A job well done.",text:"The flag has been marked as stale."})};return e.jsx(q,{open:a,secondaryButtonText:"Cancel",primaryButtonText:`Flip to ${f}`,title:`Set feature state to ${f}`,onClick:p,onClose:s,children:e.jsx(S,{condition:t,show:g,elseShow:d})})};export{Mt as C,va as E,ga as F,ma as M,Ta as T,ba as V,fa as a,Yt as b,ja as c,xa as d,Sa as e,Ca as f,ya as g,At as h,vt as i,Tt as j,wa as k,Ae as u};