unleash-server
Version:
Unleash is an enterprise ready feature toggles service. It provides different strategies for handling feature toggles.
4 lines • 395 kB
JavaScript
import{c as ri,j as p,r as I,u as ke,C as z,B as ms,s as re,a as j,T as ie,b as If,d as Rt,e as Ca,f as L,g as Nf,S as Ff,h as Vf,i as Wf,k as Hf,F as $e,I as zf,l as Ao,m as Oi,n as Aa,P as Ma,o as Vi,p as $f,A as wn,q as Wi,t as jf,v as Oa,w as qf,x as Uf,y as Ur,z as Qs,D as cn,E as Js,G as Gf,H as Kf,J as Qf,K as Jf,L as Yf,M as Xf,N as Zf,O as Da,Q as _f,R as Ys,U as Mo,V as eu,W as tu,X as iu,Y as gs,Z as nu,_ as su,$ as ru,a0 as Ta,a1 as ou,a2 as lu,a3 as Pa,a4 as au,a5 as kn,a6 as hu,a7 as cu,a8 as fu,a9 as uu,aa as Ra,ab as Oo,ac as Do,ad as wi,ae as Xs,af as du,ag as Zs,ah as pu,ai as Ba,aj as mu,ak as gu,al as yu,am as bu,an as xu}from"./index.e6fe1fcd.js";const Xn=ri(p("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"),wu=ri(p("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"CheckCircleOutline"),ku=ri(p("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"),vu=ri(p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}),"Error"),Su=ri(p("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"),Cu=ri(p("path",{d:"M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"}),"WarningOutlined"),Au=n=>I.exports.createElement("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},I.exports.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"})),Mu=n=>I.exports.createElement("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},I.exports.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"})),vn=({enabled:n,label:e,showIcon:t=!0})=>{const i=ke(),s=p(z,{condition:n==="unknown"||n==="unevaluated",show:p(Cu,{color:"warning",fontSize:"inherit"}),elseShow:p(z,{condition:typeof n=="boolean"&&Boolean(n),show:p(Au,{color:i.palette.success.main,strokeWidth:"0.25"}),elseShow:p(Mu,{color:i.palette.error.main,strokeWidth:"0.25"})})});return p(z,{condition:n==="unknown"||n==="unevaluated",show:p(ms,{icon:t?s:void 0,color:"warning",children:e}),elseShow:p(z,{condition:typeof n=="boolean"&&Boolean(n),show:p(ms,{color:"success",icon:t?s:void 0,children:e}),elseShow:p(ms,{color:"error",icon:t?s:void 0,children:e})})})},Ou=re(j)(({theme:n})=>({display:"flex",alignItems:"center",padding:n.spacing(1,2)})),Du=re(j)(()=>({marginRight:"auto"})),Tu=({feature:n})=>{const[e,t]=(()=>{var i;return n!=null&&n.isEnabled?[!0,"True"]:((i=n==null?void 0:n.strategies)==null?void 0:i.result)==="unknown"?["unknown","Unknown"]:[!1,"False"]})();return p(Ou,{children:p(Du,{"data-loading":!0,children:p(vn,{enabled:e,label:t,showIcon:e!=="unknown"})})})},Pu=re("div")(({theme:n})=>({padding:n.spacing(4),maxWidth:"400px"})),ys=re(ie)(({theme:n})=>({marginBottom:n.spacing(2)})),Ru=re(ku)(({theme:n})=>({color:n.palette.success.main})),Bu=({variants:n,selectedVariant:e})=>{const t=ke(),i=I.exports.useMemo(()=>n.map(c=>({name:c.name,weight:`${If(c.weight)}%`,selected:c.name===e})),[n,e]),s=I.exports.useMemo(()=>({sortBy:[{id:"name",desc:!1}]}),[]),{getTableProps:r,getTableBodyProps:o,headerGroups:l,rows:a,prepareRow:h}=Rt.exports.useTable({initialState:s,columns:Lu,data:i,sortTypes:Ca,autoResetGlobalFilter:!1,autoResetSortBy:!1,disableSortRemove:!0},Rt.exports.useGlobalFilter,Rt.exports.useSortBy);return L(Pu,{children:[p(ys,{variant:"subtitle2",children:"Variant Information"}),p(ys,{variant:"body2",children:"The following table shows the variants defined on this feature toggle and the variant result based on your context configuration."}),p(ys,{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.'}),L(Nf,{...r(),rowHeight:"dense",children:[p(Ff,{headerGroups:l}),p(Vf,{...o(),children:a.map(c=>{let f={};return c.original.selected||(f.color=t.palette.text.secondary),h(c),p(Wf,{hover:!0,...c.getRowProps(),children:c.cells.map(u=>p(Hf,{...u.getCellProps(),style:f,children:u.render("Cell")}))})})})]})]})},Lu=[{id:"Icon",Cell:({row:{original:{selected:n}}})=>p($e,{children:p(z,{condition:n,show:p(zf,{icon:p(Ru,{})})})}),maxWidth:25,disableGlobalFilter:!0},{Header:"Name",accessor:"name",searchable:!0,Cell:({row:{original:{name:n}}})=>p(Ao,{children:n}),maxWidth:175,width:175},{Header:"Weight",accessor:"weight",sortType:"alphanumeric",searchable:!0,maxWidth:75,Cell:({row:{original:{weight:n}}})=>p(Ao,{children:n})}],Eu=re("div")(()=>({maxWidth:"100%",display:"flex",alignItems:"center",wordBreak:"break-all"})),Iu=({variant:n,variants:e,feature:t,isEnabled:i})=>{const s=ke(),[r,o]=I.exports.useState(null),l=c=>o(c.currentTarget),a=()=>o(null),h=Boolean(r);return L(Eu,{children:[n,p(z,{condition:Boolean(e)&&e.length>0&&i,show:L($e,{children:[p(Oi,{onClick:l,children:p(Aa,{})}),p(Ma,{open:h,id:`${t}-result-variants`,PaperProps:{sx:{borderRadius:`${s.shape.borderRadiusLarge}px`}},onClose:a,anchorEl:r,anchorOrigin:{vertical:"bottom",horizontal:-320},children:p(Bu,{variants:e,selectedVariant:n})})]})})]})},Nu=Vi()(n=>({popoverPaper:{display:"flex",flexDirection:"column",padding:n.spacing(6),width:728,maxWidth:"100%",height:"auto",overflowY:"auto",backgroundColor:n.palette.tertiary.light,borderRadius:n.shape.borderRadiusLarge}})),Fu=Vi()(n=>({titleRowWrapper:{display:"flex",justifyContent:"space-between",width:"100%"},titleRow:{display:"inline-flex",alignItems:"center",gap:n.spacing(1.5),marginTop:n.spacing(1.5)},alertRow:{margin:n.spacing(1,0)},descriptionRow:{margin:n.spacing(1,.5)},name:{fontWeight:600,padding:n.spacing(.5)},icon:{textAlign:"right"}})),La=["default","applicationHostname","flexibleRollout","gradualRolloutRandom","gradualRolloutSessionId","gradualRolloutUserId","remoteAddress","userWithId"];function Ea(n){return n===void 0?!0:Object.values(n).every(e=>e&&typeof e=="object"?Ea(e):e===null)}const To=n=>{var e,t;return(t=(e=n.strategies)==null?void 0:e.data)==null?void 0:t.find(i=>!La.includes(i.name))},Vu=n=>{var e,t;return!((t=(e=n.strategies)==null?void 0:e.data)!=null&&t.find(i=>La.includes(i.name)))},Wu=({feature:n,input:e,onClose:t})=>{var f;const{classes:i}=Fu(),s=ke(),[r,o,l]=(()=>n.isEnabled?[`This feature toggle is True in ${e==null?void 0:e.environment} because `,"at least one strategy is True",s.palette.success.main]:n.isEnabledInCurrentEnvironment?Vu(n)?[`This feature toggle is Unknown in ${e==null?void 0:e.environment} because `,"no strategies could be fully evaluated",s.palette.warning.main]:To(n)?[`This feature toggle is Unknown in ${e==null?void 0:e.environment} because `,"not all strategies could be fully evaluated",s.palette.warning.main]:[`This feature toggle is False in ${e==null?void 0:e.environment} because `,"all strategies are either False or could not be fully evaluated",s.palette.error.main]:[`This feature toggle is False in ${e==null?void 0:e.environment} because `,"the environment is disabled",s.palette.error.main])(),a=Ea(e==null?void 0:e.context)?"You did not provide a value for your context field in step 2 of the configuration":void 0,h=To(n)?"This feature uses custom strategies. Custom strategies can't be evaluated, so they will be marked accordingly.":void 0,c=t&&(u=>{u.stopPropagation(),t()});return L($e,{children:[L("div",{className:i.titleRowWrapper,children:[L("div",{className:i.titleRow,children:[p(ie,{variant:"subtitle1",className:i.name,children:n.name}),p(z,{condition:((f=n==null?void 0:n.strategies)==null?void 0:f.result)!=="unknown",show:()=>p(vn,{enabled:n.isEnabled,label:n.isEnabled?"True":"False"}),elseShow:()=>p(vn,{enabled:"unknown",label:"Unknown",showIcon:!1})})]}),p(Oi,{onClick:c,className:i.icon,children:p($f,{})})]}),L("div",{className:i.descriptionRow,children:[p(ie,{variant:"body1",component:"span",children:r}),p(ie,{variant:"subtitle1",color:l,component:"span",children:o}),p(ie,{variant:"body1",component:"span",children:"."})]}),p(z,{condition:Boolean(a),show:p("div",{className:i.alertRow,children:p(wn,{color:"info",children:a})})}),p(z,{condition:Boolean(h),show:p("div",{className:i.alertRow,children:p(wn,{severity:"warning",color:"info",children:h})})})]})},Ia=Vi()(n=>({valueContainer:{display:"flex",alignItems:"center",gap:"1ch"},valueSeparator:{color:n.palette.grey[700]},summary:{width:"auto",height:"auto",padding:n.spacing(2,3),borderRadius:n.shape.borderRadiusMedium,border:`1px solid ${n.palette.dividerAlternative}`}})),Hu=re("div")(({theme:n})=>({display:"flex",alignItems:"center",marginTop:n.spacing(1),color:n.palette.error.main})),zu=({constraint:n,input:e})=>L(Hu,{children:[p(Xn,{style:{marginRight:"0.25rem"}}),p(ie,{variant:"body2",children:(()=>{const i=e==null?void 0:e.context[n.contextName];return i?`Constraint not met \u2013 the value in the context: { ${i} } is not ${n.operator} ${n.contextName}`:`Constraint not met \u2013 no value was specified for ${n.contextName}`})()})]}),$u=re(wu)(({theme:n})=>({color:n.palette.success.main})),ju=re("div")(({theme:n})=>({display:"flex",alignItems:"center",marginTop:n.spacing(1),color:n.palette.success.main})),qu=()=>L(ju,{children:[p($u,{style:{marginRight:"0.25rem"}}),p(ie,{variant:"body2",children:"Constraint met by value in context"})]}),Uu=re("div")(()=>({width:"100%",display:"flex",flexDirection:"column"})),Na=({constraints:n,input:e})=>n?p(Uu,{children:n==null?void 0:n.map((t,i)=>L(I.exports.Fragment,{children:[p(z,{condition:i>0,show:p(Wi,{text:"AND"})}),p(jf,{constraint:t,compact:!0,renderAfter:p(z,{condition:t.result,show:p(qu,{}),elseShow:p(zu,{input:e,constraint:t})})})]},Oa(t)))}):null,Gu=re("div")(({theme:n})=>({color:n.palette.error.main,display:"inline-flex",justifyContent:"center",marginLeft:"auto",gap:n.spacing(1)})),Ku=({segments:n,input:e})=>n?p($e,{children:n.map((t,i)=>L(I.exports.Fragment,{children:[p(qf,{segment:t,constraintList:p(Na,{constraints:t.constraints,input:e}),headerContent:p(z,{condition:!Boolean(t.result),show:L(Gu,{children:[p(ie,{variant:"subtitle2",sx:{pt:.25},children:"segment is false"}),p("span",{children:p(Xn,{})})]})}),isExpanded:!0}),p(z,{condition:i>=0&&n.length>1&&i!==n.length-1,show:p(Wi,{text:"AND"})})]},t.id))}):null,Qu=Vi()(n=>({container:{width:"100%",padding:n.spacing(2,3),borderRadius:n.shape.borderRadiusMedium,border:`1px solid ${n.palette.dividerAlternative}`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:n.spacing(2)},disabled:{backgroundColor:n.palette.neutral.light,opacity:"90%"},chip:{margin:"0.25rem"},column:{flexDirection:"column"},paragraph:{display:"inline",margin:"0.25rem 0",maxWidth:"95%",textAlign:"center",wordBreak:"break-word"}})),bs=({value:n,text:e,input:t,showReason:i=!1})=>{const{classes:s}=Qu(),r=ke(),o=t==="no value"?"error":"neutral",l=`value does not match any ${e}`;return L("div",{className:Uf(s.container,i?s.disabled:""),children:[p(ie,{variant:"subtitle1",color:r.palette[o].main,children:`${t}`}),L("div",{className:s.column,children:[p(z,{condition:Boolean(i),show:p(ie,{variant:"subtitle1",color:r.palette.error.main,children:l})}),p(z,{condition:n.length===0,show:L("p",{children:["No ",e,"s added yet."]}),elseShow:L("div",{children:[L("p",{className:s.paragraph,children:[n.length," ",n.length>1?`${e}s`:e," will get access."]}),n.map(a=>p(Ur,{label:p(Qs,{maxWidth:"300",text:a.toString(),maxLength:50}),className:s.chip},a))]})})]}),p(z,{condition:Boolean(i),show:p(Xn,{color:"error"}),elseShow:p("div",{})})]})},at=n=>{switch(n.toUpperCase()){case"USERIDS":return"userId";case"IPS":return"remoteAddress";default:return n}},Ju=({parameters:n,constraints:e,input:t})=>{const{classes:i}=Ia();return p($e,{children:Object.keys(n).map(s=>{var r,o,l,a,h,c,f,u;switch(s){case"rollout":case"Rollout":const d=Js(n[s]);return L(j,{className:i.summary,sx:{display:"flex",alignItems:"center"},children:[p(j,{sx:{mr:"1rem"},children:p(Gf,{percentage:d,size:"2rem"})}),L("div",{children:[p(Ur,{color:"success",variant:"outlined",size:"small",label:`${d}%`})," ","of your base"," ",e.length>0?"who match constraints":""," ","is included."]})]},s);case"userIds":case"UserIds":const m=cn(n[s]);return p(bs,{value:m,text:"user",input:Boolean((r=t==null?void 0:t.context)==null?void 0:r[at(s)])?(o=t==null?void 0:t.context)==null?void 0:o[at(s)]:"no value",showReason:Boolean((l=t==null?void 0:t.context)==null?void 0:l[at(s)])?!m.includes((a=t==null?void 0:t.context)==null?void 0:a[at(s)]):void 0},s);case"hostNames":case"HostNames":const y=cn(n[s]);return p(bs,{value:y,text:"host",input:"no value",showReason:void 0},s);case"IPs":const x=cn(n[s]);return p(bs,{value:x,text:"IP",input:Boolean((h=t==null?void 0:t.context)==null?void 0:h[at(s)])?(c=t==null?void 0:t.context)==null?void 0:c[at(s)]:"no value",showReason:Boolean((f=t==null?void 0:t.context)==null?void 0:f[at(s)])?!x.includes((u=t==null?void 0:t.context)==null?void 0:u[at(s)]):void 0},s);case"stickiness":case"groupId":return null;default:return null}})})},Yu=re(j)(({theme:n})=>({width:"100%",padding:n.spacing(2,3),borderRadius:n.shape.borderRadiusMedium,border:`1px solid ${n.palette.dividerAlternative}`,display:"flex",flexDirection:"row",alignItems:"center",gap:2})),hi=({text:n,input:e=null,isRequired:t=!1})=>{const i=ke(),s=e===null?"error":"neutral",r=t&&e===null;return L(Yu,{children:[p(ie,{variant:"subtitle1",color:i.palette[s].main,sx:{minWidth:118},children:`${e===null?"no value":e}`}),p(j,{sx:{flexGrow:1,flexDirection:"column"},children:p(j,{sx:{flexGrow:1},children:p(z,{condition:Boolean(r),show:L($e,{children:[p(ie,{component:"span",color:i.palette.error.main,children:" required parameter "}),p(Qs,{maxWidth:"300",text:n,maxLength:50}),p(ie,{component:"span",color:i.palette.error.main,children:" is not set "})]}),elseShow:L($e,{children:[p(ie,{component:"span",color:"text.disabled",children:" set on parameter "}),p(Qs,{maxWidth:"300",text:n,maxLength:50})]})})})}),p(z,{condition:Boolean(r),show:p(Xn,{color:"error"}),elseShow:p("div",{})})]})},Xu=({strategyName:n,parameters:e})=>{const{strategies:t}=Kf(),i=t.find(r=>r.name===n);if(!(i!=null&&i.editable))return null;const s=i==null?void 0:i.parameters.map(r=>{const o=e[r.name],l=r.required;switch(r==null?void 0:r.type){case"list":const a=cn(o);return p(hi,{isRequired:l,text:r.name,input:(a==null?void 0:a.length)>0?a.join(", "):null});case"percentage":const h=Js(o),c=!(o===void 0||o===""||h<0||h>100);return p(hi,{text:r.name,isRequired:l,input:c?`${h}%`:void 0});case"boolean":const f=["true","false"].includes(o)?o:void 0;return p(hi,{isRequired:l,text:r.name,input:o!==void 0?f:void 0});case"string":const u=Qf(o);return p(hi,{text:r.name,isRequired:l,input:u!==void 0?u:void 0});case"number":const d=!(o===void 0||o===""),m=Js(o);return p(hi,{text:r.name,isRequired:l,input:d?`${m}`:void 0});case"default":return null}return null});return p($e,{children:s.map((r,o)=>L(I.exports.Fragment,{children:[p(z,{condition:o>0,show:p(Wi,{text:"AND"})}),r]},o))})},Zu=re("div")(({theme:n})=>({padding:n.spacing(0)})),_u=({strategyResult:n,input:e})=>{const{name:t,constraints:i,segments:s,parameters:r}=n,{uiConfig:o}=Jf(),{classes:l}=Ia(),a=Boolean(o.flags.SE)&&Boolean(s&&s.length>0),h=Boolean(i&&(i==null?void 0:i.length)>0),c=t!=="default"&&Object.keys(Yf).includes(t),f=Object.keys(r).length>0&&n.result.evaluationStatus==="incomplete";if(!r)return null;const u=[a&&p(Ku,{segments:s,input:e}),h&&p(Na,{constraints:i,input:e}),c&&p(Ju,{parameters:r,constraints:i,input:e}),f&&p(Xu,{strategyName:t,parameters:r}),t==="default"&&L(j,{sx:{width:"100%"},className:l.summary,children:["The standard strategy is"," ",p(Ur,{variant:"outlined",size:"small",color:"success",label:"ON"})," ","for all users."]})].filter(Boolean);return p(Zu,{children:u.map((d,m)=>L(I.exports.Fragment,{children:[p(z,{condition:m>0,show:p(Wi,{text:"AND"})}),d]},m))})},ed=Vi()(n=>({header:{display:"flex",padding:n.spacing(2,2),justifyContent:"space-between"},headerName:{padding:n.spacing(.5,2),display:"flex",gap:n.spacing(1),alignItems:"center",borderBottom:`1px solid ${n.palette.divider}`,fontWeight:n.typography.fontWeightMedium},icon:{fill:n.palette.inactiveIcon},resultChip:{marginLeft:"auto"},body:{padding:n.spacing(2),justifyItems:"center"},innerContainer:{[n.breakpoints.down(400)]:{padding:"0.5rem"},width:"100%",flexShrink:0,paddingBottom:"1rem",borderRadius:n.shape.borderRadiusMedium,background:n.palette.background.default},successBorder:{borderColor:n.palette.success.main}})),td=({strategy:n,input:e,index:t})=>{const{result:i}=n,{classes:s}=ed(),r=ke(),o=i.evaluationStatus==="incomplete"?"Unevaluated":i.enabled?"True":"False";return p(Xf,{className:i.enabled&&i.evaluationStatus==="complete"?s.successBorder:void 0,strategy:{...n,id:`${Oa(n)}`},orderNumber:t+1,actions:p(vn,{showIcon:!1,enabled:i.enabled,label:o}),children:p(_u,{strategyResult:n,input:e,percentageFill:r.palette.tertiary.light})})},id=re("div")(({theme:n})=>({display:"flex",padding:"0, 4px",flexDirection:"column",borderRadius:n.shape.borderRadiusMedium,border:`1px solid ${n.palette.warning.border}`})),nd=re("div")(({theme:n})=>({padding:n.spacing(1,.5)})),sd=re(wn)(({theme:n})=>({border:"0!important",borderBottomLeftRadius:0,borderBottomRightRadius:0,borderBottom:`1px solid ${n.palette.warning.border}!important`})),Fa=({strategies:n,input:e})=>p(z,{condition:n.length>0,show:L($e,{children:[p(ie,{variant:"subtitle1",sx:{mt:2,ml:1,mb:2,color:"text.secondary"},children:`Strategies (${n==null?void 0:n.length})`}),p(j,{sx:{width:"100%"},children:n==null?void 0:n.map((t,i)=>L(I.exports.Fragment,{children:[p(z,{condition:i>0,show:p(Wi,{text:"OR"})}),p(td,{strategy:t,index:i,input:e},t.id)]},t.id))})]})}),rd=({strategies:n,input:e})=>L(id,{sx:{pb:1,mt:2},children:[L(sd,{severity:"info",color:"warning",children:["If environment was enabled, then this feature toggle would be"," ",n!=null&&n.result?"TRUE":"FALSE"," with strategies evaluated like so:"," "]}),p(nd,{sx:{p:2.5},children:p(Fa,{strategies:(n==null?void 0:n.data)||[],input:e})})]}),od=({feature:n,input:e})=>{var t,i,s,r;return L($e,{children:[p(z,{condition:((i=(t=n==null?void 0:n.strategies)==null?void 0:t.data)==null?void 0:i.length)===0,show:p(wn,{severity:"warning",sx:{mt:2},children:"There are no strategies added to this feature toggle in selected environment."})}),p(z,{condition:!n.isEnabledInCurrentEnvironment&&Boolean((s=n==null?void 0:n.strategies)==null?void 0:s.data),show:p(rd,{strategies:n==null?void 0:n.strategies,input:e}),elseShow:p(Fa,{strategies:((r=n==null?void 0:n.strategies)==null?void 0:r.data)||[],input:e})})]})},ld=re("div")(({theme:n})=>({alignItems:"flex-end",color:n.palette.tertiary.main})),ad=({feature:n,input:e})=>{const[t,i]=I.exports.useState(!1),{classes:s}=Nu(),r=I.exports.useRef(null),o=()=>{i(!t)};return n?L(ld,{children:[p(Oi,{onClick:o,children:p(Aa,{ref:r})}),L(Ma,{open:t,onClose:()=>i(!1),anchorEl:r.current,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},classes:{paper:s.popoverPaper},children:[p(Wu,{feature:n,input:e,onClose:()=>i(!1)}),p(od,{feature:n,input:e})]})]}):null},hd={id:"name"},{value:Po,setValue:cd}=Zf("PlaygroundResultsTable:v1",hd),fd=({features:n,input:e,loading:t})=>{const[i,s]=Da(),r=_f(t),[o,l]=I.exports.useState(i.get("search")||""),a=ke(),h=Ys(a.breakpoints.down("sm")),c=Ys(a.breakpoints.down("md")),f=I.exports.useMemo(()=>[{Header:"Name",accessor:"name",searchable:!0,minWidth:160,Cell:({value:k,row:{original:O}})=>p(Mo,{title:k,to:`/projects/${O==null?void 0:O.projectId}/features/${k}`})},{Header:"Project ID",accessor:"projectId",sortType:"alphanumeric",filterName:"projectId",searchable:!0,maxWidth:170,Cell:({value:k})=>p(Mo,{title:k,to:`/projects/${k}`})},{Header:"Variant",id:"variant",accessor:"variant.name",sortType:"alphanumeric",filterName:"variant",searchable:!0,maxWidth:200,Cell:({value:k,row:{original:{variant:O,feature:F,variants:T,isEnabled:E}}})=>p(Iu,{variant:O!=null&&O.enabled?k:"",variants:T,feature:F,isEnabled:E})},{id:"isEnabled",Header:"isEnabled",filterName:"isEnabled",accessor:k=>{var O;return k!=null&&k.isEnabled?"true":((O=k==null?void 0:k.strategies)==null?void 0:O.result)==="unknown"?"unknown":"false"},Cell:({row:k})=>p(Tu,{feature:k.original}),sortType:"playgroundResultState",maxWidth:120,sortInverted:!0},{Header:"",maxWidth:70,id:"info",Cell:({row:k})=>p(ad,{feature:k.original,input:e})}],[e]),{data:u,getSearchText:d,getSearchContext:m}=eu(f,o,n||[]),y=I.exports.useMemo(()=>t?Array(5).fill({name:"Feature name",projectId:"FeatureProject",variant:{name:"FeatureVariant",variants:[]},enabled:!0}):u,[u,t]),[x]=I.exports.useState(()=>({sortBy:[{id:i.get("sort")||Po.id,desc:i.has("order")?i.get("order")==="desc":Po.desc}]})),{headerGroups:b,rows:v,state:{sortBy:M},prepareRow:S,setHiddenColumns:C}=Rt.exports.useTable({initialState:x,columns:f,data:y,sortTypes:Ca,autoResetGlobalFilter:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0,defaultColumn:{Cell:tu}},Rt.exports.useGlobalFilter,Rt.exports.useFlexLayout,Rt.exports.useSortBy);return I.exports.useEffect(()=>{const k=[];c&&k.push("projectId"),h&&k.push("variant"),C(k)},[C,h,c]),I.exports.useEffect(()=>{if(t)return;const k=Object.fromEntries(i);k.sort=M[0].id,M[0].desc?k.order="desc":k.order&&delete k.order,o?k.search=o:delete k.search,s(k,{replace:!0}),cd({id:M[0].id,desc:M[0].desc||!1})},[t,M,o]),L($e,{children:[L(j,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:[p(ie,{variant:"subtitle1",sx:{ml:1},children:n!==void 0&&!t?`Results (${v.length<y.length?`${v.length} of ${y.length}`:y.length})`:"Results"}),p(iu,{initialValue:o,onChange:l,hasFilters:!0,getSearchContext:m,disabled:t,containerStyles:{marginLeft:"1rem",maxWidth:"400px"}})]}),p(z,{condition:!t&&!y,show:()=>p(gs,{children:y===void 0?"None of the feature toggles were evaluated yet.":"No results found."}),elseShow:()=>L(j,{ref:r,children:[p(nu,{value:d(o),children:p(su,{rows:v,headerGroups:b,prepareRow:S})}),p(z,{condition:y.length===0&&(o==null?void 0:o.length)>0,show:L(gs,{children:["No feature toggles found matching \u201C",o,"\u201D"]})}),p(z,{condition:y&&y.length===0&&!o,show:p(gs,{children:"No features toggles to display"})})]})})]})},ud=()=>{const{makeRequest:n,createRequest:e,errors:t,loading:i}=ru({propagateErrors:!0}),s="api/admin/playground";return{evaluatePlayground:async o=>{const a=e(s,{method:"POST",body:JSON.stringify(o)});try{return(await n(a.caller,a.id)).json()}catch(h){throw h}},errors:t,loading:i}},dd=re("div")(({style:n,theme:e})=>({width:"25px",height:"25px",borderRadius:"50%",color:e.palette.text.tertiaryContrast,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"bold",...n})),Zn=({style:n,children:e,type:t})=>{const i=ke(),s={backgroundColor:i.palette.primary.main};return t==="secondary"&&(s.backgroundColor=i.palette.tertiary.dark),p(dd,{style:{...s,...n},children:e})},pd=n=>!n||n.length===0||n.length===1&&n[0]==="*"?"*":n,md=n=>{const e=Va(n);return e.length>0?e[0]:""},Va=n=>n.filter(({enabled:e})=>Boolean(e)).sort((e,t)=>e.sortOrder-t.sortOrder).map(({name:e})=>e),gd=(n,e)=>n?"100%":e&&!n?"65%":"50%";function _s(n,e,t){var i,s,r,o,l;e==null&&(e=100);function a(){var c=Date.now()-o;c<e&&c>=0?i=setTimeout(a,e-c):(i=null,t||(l=n.apply(r,s),r=s=null))}var h=function(){r=this,s=arguments,o=Date.now();var c=t&&!i;return i||(i=setTimeout(a,e)),c&&(l=n.apply(r,s),r=s=null),l};return h.clear=function(){i&&(clearTimeout(i),i=null)},h.flush=function(){i&&(l=n.apply(r,s),r=s=null,clearTimeout(i),i=null)},h}_s.debounce=_s;var yd=_s;function er(){return er=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},er.apply(this,arguments)}function bd(n,e){if(n==null)return{};var t={},i=Object.keys(n),s,r;for(r=0;r<i.length;r++)s=i[r],!(e.indexOf(s)>=0)&&(t[s]=n[s]);return t}class U{constructor(){}lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),Je.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){let i=[];return this.decompose(e,t,i,0),Je.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new ki(this),r=new ki(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new ki(this,e)}iterRange(e,t=this.length){return new Wa(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Ha(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?U.empty:e.length<=32?new ne(e):Je.from(ne.split(e,[]))}}class ne extends U{constructor(e,t=xd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new wd(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new ne(Ro(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=fn(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new ne(l,o.length+r.length));else{let a=l.length>>1;i.push(new ne(l.slice(0,a)),new ne(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof ne))return super.replace(e,t,i);let s=fn(this.text,fn(i.text,Ro(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new ne(s,r):Je.from(ne.split(s,[]),r)}sliceString(e,t=this.length,i=`
`){let s="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(s+=i),e<a&&t>r&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let r of e)i.push(r),s+=r.length+1,i.length==32&&(t.push(new ne(i,s)),i=[],s=-1);return s>-1&&t.push(new ne(i,s)),t}}class Je extends U{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,s);s=l+1,i=a+1}}decompose(e,t,i,s){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let h=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if(i.lines<this.lines)for(let s=0,r=0;s<this.children.length;s++){let o=this.children[s],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>5-1&&a.lines>h>>5+1){let c=this.children.slice();return c[s]=a,new Je(c,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
`){let s="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(s+=i),e<a&&t>o&&(s+=l.sliceString(e-o,t-o,i)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Je))return 0;let i=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return i;let a=this.children[s],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let m of e)m.flatten(d);return new ne(d,t)}let s=Math.max(32,i>>5),r=s<<1,o=s>>1,l=[],a=0,h=-1,c=[];function f(d){let m;if(d.lines>r&&d instanceof Je)for(let y of d.children)f(y);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof ne&&a&&(m=c[c.length-1])instanceof ne&&d.lines+m.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new ne(m.text.concat(d.text),m.length+1+d.length)):(a+d.lines>s&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:Je.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new Je(l,t)}}U.empty=new ne([""],0);function xd(n){let e=-1;for(let t of n)e+=t.length+1;return e}function fn(n,e,t=0,i=1e9){for(let s=0,r=0,o=!0;r<n.length&&s<=i;r++){let l=n[r],a=s+l.length;a>=t&&(a>i&&(l=l.slice(0,i-s)),s<t&&(l=l.slice(t-s)),o?(e[e.length-1]+=l,o=!1):e.push(l)),s=a+1}return e}function Ro(n,e,t){return fn(n,[""],e,t)}class ki{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof ne?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],o=r>>1,l=s instanceof ne?s.text.length:s.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
`,this;e--}else if(s instanceof ne){let a=s.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ne?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Wa{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new ki(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Ha{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(U.prototype[Symbol.iterator]=function(){return this.iter()},ki.prototype[Symbol.iterator]=Wa.prototype[Symbol.iterator]=Ha.prototype[Symbol.iterator]=function(){return this});class wd{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}let Kt="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(n=>n?parseInt(n,36):1);for(let n=1;n<Kt.length;n++)Kt[n]+=Kt[n-1];function kd(n){for(let e=1;e<Kt.length;e+=2)if(Kt[e]>n)return Kt[e-1]<=n;return!1}function Bo(n){return n>=127462&&n<=127487}const Lo=8205;function Le(n,e,t=!0,i=!0){return(t?za:vd)(n,e,i)}function za(n,e,t){if(e==n.length)return e;e&&$a(n.charCodeAt(e))&&ja(n.charCodeAt(e-1))&&e--;let i=ue(n,e);for(e+=Re(i);e<n.length;){let s=ue(n,e);if(i==Lo||s==Lo||t&&kd(s))e+=Re(s),i=s;else if(Bo(s)){let r=0,o=e-2;for(;o>=0&&Bo(ue(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function vd(n,e,t){for(;e>0;){let i=za(n,e-2,t);if(i<e)return i;e--}return 0}function $a(n){return n>=56320&&n<57344}function ja(n){return n>=55296&&n<56320}function ue(n,e){let t=n.charCodeAt(e);if(!ja(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return $a(i)?(t-55296<<10)+(i-56320)+65536:t}function Gr(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Re(n){return n<65536?1:2}const tr=/\r\n?|\n/;var Se=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(Se||(Se={}));class Ze{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,s=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,s,r),s+=r):s+=o,i+=r}}iterChangedRanges(e,t=!1){ir(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?e.push(i,s):e.push(s,i)}return new Ze(e)}composeDesc(e){return this.empty?e:e.empty?this:qa(this,e)}mapDesc(e,t=!1){return e.empty?this:nr(this,e,t)}mapPos(e,t=-1,i=Se.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=s+l;if(a<0){if(h>e)return r+(e-s);r+=l}else{if(i!=Se.Simple&&h>=e&&(i==Se.TrackDel&&s<e&&h>e||i==Se.TrackBefore&&s<e||i==Se.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i<this.sections.length&&s<=t;){let r=this.sections[i++],o=this.sections[i++],l=s+r;if(o>=0&&s<=t&&l>=e)return s<e&&l>t?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+i+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ze(e)}static create(e){return new Ze(e)}}class ae extends Ze{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ir(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return nr(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s<t.length;s+=2){let o=t[s],l=t[s+1];if(l>=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;i.length<a;)i.push(U.empty);i.push(o?e.slice(r,r+o):U.empty)}r+=o}return new ae(t,i)}compose(e){return this.empty?e:e.empty?this:qa(this,e,!0)}map(e,t=!1){return e.empty?this:nr(this,e,t,!0)}iterChanges(e,t=!1){ir(this,e,t)}get desc(){return Ze.create(this.sections)}filter(e){let t=[],i=[],s=[],r=new Di(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);xe(s,c,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;xe(t,c,f),f>0&&dt(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l<h;){if(r.done)break e;let c=Math.min(r.len,h-l);xe(t,c,-1),xe(s,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new ae(t,i),filtered:Ze.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],s=this.sections[t+1];s<0?e.push(i):s==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!s.length)return;o<t&&xe(s,t-o,-1);let f=new ae(s,r);l=l?l.compose(f.map(l)):f,s=[],r=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof ae){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let m=d?typeof d=="string"?U.of(d.split(i||tr)):d:U.empty,y=m.length;if(f==u&&y==0)return;f<o&&a(),f>o&&xe(s,f-o,-1),xe(s,u-f,y),dt(r,s,m),o=u}}return h(e),a(!l),l}static empty(e){return new ae(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;s<e.length;s++){let r=e[s];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<s;)i.push(U.empty);i[s]=U.of(r.slice(1)),t.push(r[0],i[s].length)}}}return new ae(t,i)}static createSet(e,t){return new ae(e,t)}}function xe(n,e,t,i=!1){if(e==0&&t<=0)return;let s=n.length-2;s>=0&&t<=0&&t==n[s+1]?n[s]+=e:e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function dt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(U.empty);n.push(t)}}function ir(n,e,t){let i=n.inserted;for(let s=0,r=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)s+=l,r+=l;else{let h=s,c=r,f=U.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(s,h,r,c,f),s=h,r=c}}}function nr(n,e,t,i=!1){let s=[],r=i?[]:null,o=new Di(n),l=new Di(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);xe(s,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(xe(s,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(xe(s,0,o.ins),r&&dt(r,s,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;xe(s,h,a<o.i?o.ins:0),r&&a<o.i&&dt(r,s,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?ae.createSet(s,r):Ze.create(s);throw new Error("Mismatched change set lengths")}}function qa(n,e,t=!1){let i=[],s=t?[]:null,r=new Di(n),o=new Di(e);for(let l=!1;;){if(r.done&&o.done)return s?ae.createSet(i,s):Ze.create(i);if(r.ins==0)xe(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)xe(i,0,o.ins,l),s&&dt(s,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;xe(i,a,c,l),s&&c&&dt(s,i,o.text)}else o.ins==-1?(xe(i,r.off?0:r.len,a,l),s&&dt(s,i,r.textBit(a))):(xe(i,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&dt(s,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class Di{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?U.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?U.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Bt{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&16?this.to:this.from}get head(){return this.flags&16?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&4?-1:this.flags&8?1:0}get bidiLevel(){let e=this.flags&3;return e==3?null:e}get goalColumn(){let e=this.flags>>5;return e==33554431?void 0:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new Bt(i,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return w.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return w.range(this.anchor,i)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return w.range(e.anchor,e.head)}static create(e,t,i){return new Bt(e,t,i)}}class w{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:w.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;t<this.ranges.length;t++)if(!this.ranges[t].eq(e.ranges[t]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new w([this.main],0)}addRange(e,t=!0){return w.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,w.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new w(e.ranges.map(t=>Bt.fromJSON(t)),e.main)}static single(e,t=e){return new w([w.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;s<e.length;s++){let r=e[s];if(r.empty?r.from<=i:r.from<i)return w.normalized(e.slice(),t);i=r.to}return new w(e,t)}static cursor(e,t=0,i,s){return Bt.create(e,e,(t==0?0:t<0?4:8)|(i==null?3:Math.min(2,i))|(s!=null?s:33554431)<<5)}static range(e,t,i){let s=(i!=null?i:33554431)<<5;return t<e?Bt.create(t,e,16|s|8):Bt.create(e,t,s|(t>e?4:0))}static normalized(e,t=0){let i=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(i);for(let s=1;s<e.length;s++){let r=e[s],o=e[s-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);s<=t&&t--,e.splice(--s,2,r.anchor>r.head?w.range(a,l):w.range(l,a))}}return new w(e,t)}}function Ua(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Kr=0;class R{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=Kr++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}static define(e={}){return new R(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Qr),!!e.static,e.enables)}of(e){return new un([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new un(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new un(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Qr(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class un{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=Kr++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||sr(f,c)){let d=i(f);if(l?!Eo(d,f.values[o],s):!s(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,m=u.config.address[r];if(m!=null){let y=Cn(u,m);if(this.dependencies.every(x=>x instanceof R?u.facet(x)===f.facet(x):x instanceof ge?u.field(x,!1)==f.field(x,!1):!0)||(l?Eo(d=i(f),y,s):s(d=i(f),y)))return f.values[o]=y,0}else d=i(f);return f.values[o]=d,1}}}}function Eo(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function sr(n,e){let t=!1;for(let i of e)vi(n,i)&1&&(t=!0);return t}function Sd(n,e,t){let i=t.map(a=>n[a.id]),s=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Cn(a,i[c]);if(s[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)vi(a,h);return a.values[o]=l(a),1},update(a,h){if(!sr(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=sr(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Qr(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const Io=R.define({static:!0});class ge{constructor(e,t,i,s,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let t=new ge(Kr++,e.create,e.update,e.compare||((i,s)=>i===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Io).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,Io.of({field:this,create:e})]}get extension(){return this}}const Tt={lowest:4,low:3,default:2,high:1,highest:0};function ci(n){return e=>new Ga(e,n)}const oi={highest:ci(Tt.highest),high:ci(Tt.high),