flagsmith-toolbar 0.0.0-stage → 0.3.0

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.
@@ -0,0 +1,391 @@
1
+ "use strict";var FlagsmithToolbar=(()=>{var de=Object.defineProperty;var fs=Object.getOwnPropertyDescriptor;var cs=Object.getOwnPropertyNames;var ds=Object.prototype.hasOwnProperty;var us=(t,e)=>{for(var s in e)de(t,s,{get:e[s],enumerable:!0})},gs=(t,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of cs(e))!ds.call(t,a)&&a!==s&&de(t,a,{get:()=>e[a],enumerable:!(n=fs(e,a))||n.enumerable});return t};var hs=t=>gs(de({},"__esModule",{value:!0}),t);var Sn={};us(Sn,{default:()=>Fn,destroy:()=>ps,explainReason:()=>R,hide:()=>is,init:()=>os,parseReason:()=>me,show:()=>as,toggle:()=>ls});function ms(t,e){if(t===e)return 0;let s=Array.from({length:e.length+1},(n,a)=>a);for(let n=1;n<=t.length;n++){let a=[n];for(let o=1;o<=e.length;o++)a[o]=Math.min(s[o]+1,a[o-1]+1,s[o-1]+(t[n-1]===e[o-1]?0:1));s=a}return s[e.length]}function vs(t,e){let s=Math.max(2,Math.floor(t.length/4)),n=null,a=1/0;for(let o of e){let i=ms(t,o);i<a&&(n=o,a=i)}return a<=s?n:null}var He=t=>t.map(e=>`"${e}"`).join(", ");function ze(t){let e=[],s=t.loadingState?.source,n=s==="SERVER",a=Object.keys(t.serverFlags);if(t.environmentKey?.startsWith("ser.")&&e.push({id:"server-key",level:"problem",title:"A server-side key is in the browser",detail:`Server-side keys start with "ser." and are meant for your backend. Anyone can read this one in the page. Use the environment's client-side key instead, and rotate this one.`}),n&&a.length>0){let d=[...new Set([...Object.keys(t.seenOn??{}),...Object.keys(t.reads)])].filter(p=>!(p in t.serverFlags)).sort();for(let p of d){let g=vs(p,a),m=t.seenOn?.[p]??[],f=m.length?` (on ${m.slice(0,3).join(", ")}${m.length>3?", \u2026":""})`:"";e.push({id:`unknown-flag:${p}`,level:"problem",title:`This app reads "${p}"${f}, which isn't in Flagsmith`,detail:g?`There's no flag called "${p}", so it's always off. Did you mean "${g}"?`:`There's no flag called "${p}" in this environment, so it's always off. Create it in Flagsmith, or remove it from the code.`})}}let o=t.loadingState?.error;if(!t.loadingState?.isFetching&&(o||s==="CACHE"||s==="DEFAULT_FLAGS")){let d=s==="CACHE"?"your browser cache":"the default flags in your code";e.push({id:"not-from-server",level:"warning",title:"These flags didn't come from Flagsmith",detail:`The page is using flags from ${d}${o?` because Flagsmith couldn't be reached (${o instanceof Error?o.message:String(o)})`:""}.`})}n&&a.length>0&&a.every(d=>!t.serverFlags[d].reason)&&e.push({id:"no-reasons",level:"warning",title:"Flagsmith didn't say why flags have their values",detail:"Reasons need Flagsmith 2.295 or newer and @flagsmith/flagsmith 12.6 or newer. Everything else in the toolbar still works.",fix:"npm install @flagsmith/flagsmith@latest"});let i=[...new Set(t.events.filter(d=>d.status==="off").map(d=>d.name))],l=t.experiments.filter(d=>d.state==="events-off").map(d=>d.key);(i.length>0||l.length>0)&&e.push({id:"events-off",level:"warning",title:i.length?"Events are tracked, but never sent":"This user is in an experiment that can't count them",detail:`${i.length?`The page tracked ${He(i)}, but`:`This user is in the experiment behind ${He(l)}, but`} Flagsmith was started without enableEvents, so Experimentation never sees ${i.length?"them":"their exposures or conversions"}.`,fix:"flagsmith.init({ environmentID, enableEvents: true })"});for(let d of a){let p=t.serverFlags[d];p.experiment?.inExperiment&&p.reason?.toUpperCase().startsWith("SPLIT")&&!p.variant&&e.push({id:`variant-without-key:${d}`,level:"problem",title:`"${d}"'s variant has no key, so its results can't be counted`,detail:`This user sees "${String(p.value)}" in "${p.experiment.name}", but that variant has no key in Flagsmith, so their exposure arrives without a variant. Give every variant of "${d}" a key in Flagsmith.`})}for(let d of t.experiments.filter(p=>p.state==="missing"))e.push({id:`exposure-missing:${d.key}`,level:"warning",title:`"${d.key}" is in an experiment, but no exposure was recorded`,detail:`This user sees "${String(d.value)}" from "${d.name}", but the page never records that they saw it, so they won't be counted in the results. Read the flag with getExperimentFlag, or useExperiment in React.`,fix:`flagsmith.getExperimentFlag('${d.key}')`});t.identity||e.push({id:"anonymous",level:"tip",title:"No user is identified",detail:"Segments, percentage splits and experiments only apply to identified users, so an anonymous visitor always gets the defaults. Use View as to test them."});let c={problem:0,warning:1,tip:2};return e.sort((d,p)=>c[d.level]-c[p.level])}function bs(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)||"user"}function z(t,e){let s=Object.fromEntries(Object.entries(e.traits??{}).map(([a,o])=>[a,{value:o,transient:!0}])),n=e.identifier?{identifier:e.identifier,traits:s}:{identifier:`toolbar-preview-${bs(e.name)}`,transient:!0,traits:s};return{...t,identity:n}}function Ke(t){let e={};for(let s of t.split(/\r?\n/)){let n=s.indexOf("=");if(n<=0)continue;let a=s.slice(0,n).trim(),o=s.slice(n+1).trim();a&&(o==="true"||o==="false"?e[a]=o==="true":o!==""&&Number.isFinite(Number(o))?e[a]=Number(o):e[a]=o)}return e}function Be(t){return JSON.parse(JSON.stringify(t??{}))}function xs(t){let e={};for(let s of t??[]){let n=s.metadata?.experiment;e[s.feature.name.toLowerCase().replace(/ /g,"_")]={id:s.feature.id,enabled:s.enabled,value:s.feature_state_value,...s.variant?{variant:s.variant}:{},...s.reason?{reason:s.reason}:{},...n?{experiment:{id:n.id,name:n.name,inExperiment:!!n.in_experiment}}:{}}}return e}async function Ge(t,e){let s=e.api.endsWith("/")?e.api:`${e.api}/`,n=e.fetch??((l,c)=>fetch(l,c)),a={"X-Environment-Key":e.environmentKey,...e.headers??{}},o;if(!t)o=await n(`${s}flags/`,{headers:a,cache:"no-cache"});else{let l=z({},t).identity??{},c=Object.entries(l.traits??{}).map(([d,p])=>({trait_key:d,trait_value:p?.value,transient:!0}));c.length===0&&t.identifier?o=await n(`${s}identities/?identifier=${encodeURIComponent(t.identifier)}`,{headers:a,cache:"no-cache"}):o=await n(`${s}identities/`,{method:"POST",headers:{...a,"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify({identifier:l.identifier,...l.transient?{transient:!0}:{},traits:c}),cache:"no-cache"})}if(!o.ok)throw new Error(`Flagsmith answered ${o.status}`);let i=await o.json();return xs(Array.isArray(i)?i:i.flags)}var We=t=>t?.value===void 0||t.value===""?null:t.value;function ue(t,e){return!t||!e?t===e:t.enabled===e.enabled&&We(t)===We(e)}function qe(t,e){let s=[...new Set([...Object.keys(t),...Object.keys(e)])].sort(),n={differ:[],same:[]};for(let a of s){let o={key:a,a:t[a],b:e[a]};(ue(o.a,o.b)?n.same:n.differ).push(o)}return n}var ge=(t,e)=>`${t}|${e??""}`;function Je(t){let e=t.graceMs??1500,s=[];for(let n of Object.keys(t.flags).sort()){let a=t.flags[n];if(!a.experiment)continue;let o=t.exposures[ge(n,t.identity)],i=Math.max(t.reads[n]??0,t.since??0),l;a.experiment.inExperiment?o?l=o.status==="sent"?"recorded":o.status==="held"?"held":o.status==="off"?"events-off":"missing":t.eventsEnabled?n in t.reads?t.previewing?l="previewing":a.enabled?t.now-i<e?l="waiting":l="missing":l="disabled":l="not-read":l="events-off":l="not-enrolled",s.push({key:n,id:a.experiment.id,name:a.experiment.name,inExperiment:a.experiment.inExperiment,enabled:a.enabled,value:a.value,state:l,...o?{exposure:o}:{}})}return s}var he="TOOLBAR_OVERRIDE",_s="identity_overrides",ys=/^experiment-\d+-rollout$/;function me(t){if(!t)return{code:"",params:{}};let[e="",...s]=t.split(";").map(a=>a.trim()),n={};for(let a of s){let o=a.indexOf("=");o>0&&(n[a.slice(0,o).trim()]=a.slice(o+1).trim())}return{code:e.toUpperCase(),params:n}}function ws(t){if(!t)return"";let e=Number(t);return Number.isFinite(e)?`${Math.round(e*10)/10}%`:`${t}%`}function R(t){let{code:e,params:s}=me(t);switch(e){case"STATIC":return{kind:"static",label:"No targeting",detail:"Nothing targets this flag for this user, so they get the environment's value. In a split test, this is the control value."};case"DEFAULT":return{kind:"default",label:"No rule matched",detail:"This flag has targeting rules, but none matched this user, so they get the environment's value."};case"TARGETING_MATCH":{let n=s.segment;return n===_s?{kind:"identity",label:"Set for this user",detail:"An identity override in Flagsmith sets this flag for this exact user."}:n&&ys.test(n)?{kind:"experiment",label:"Experiment: control group",detail:"This user is in a running experiment, in its control group, so they see the original version."}:{kind:"segment",label:n?`Segment: ${n}`:"Segment match",detail:n?`This user is in the "${n}" segment, and that segment overrides the flag.`:"A segment override matched this user."}}case"SPLIT":{let n=ws(s.weight);return{kind:"split",label:n?`Split test: ${n} bucket`:"Split test",detail:n?`A percentage split put this user in a ${n} bucket. The bucket comes from their identity, so it stays the same on every visit.`:"A percentage split put this user in this bucket."}}case he:return{kind:"override",label:"Changed by you",detail:"You changed this in the toolbar. Only your browser sees it, and nothing changed in Flagsmith."};case"ERROR":return{kind:"error",label:"Evaluation error",detail:s.code?`Flagsmith could not evaluate this flag (${s.code}).`:"Flagsmith could not evaluate this flag."};case"":return{kind:"missing",label:"No reason sent",detail:"Flagsmith did not send a reason. Reasons need Flagsmith 2.295 or newer and @flagsmith/flagsmith 12.6 or newer."};default:return{kind:"other",label:t??"",detail:`Flagsmith reported: ${t}`}}}function ve(t){return t.toLowerCase().replace(/ /g,"_")}function Y(t,e){let s=Object.keys(e);if(s.length===0)return t;let n={...t??{}};for(let a of s){let o=e[a],i={...n[a]??{enabled:!1,value:null},reason:he};o.enabled!==void 0&&(i.enabled=o.enabled),o.value!==void 0&&(i.value=o.value,delete i.variant),n[a]=i}return n}function Xe(t,e,s){return{...t,[e]:{...t[e],...s}}}function be(t,e){let{[e]:s,...n}=t;return n}function Ye(t,e){return[...new Set([...Object.keys(t??{}),...Object.keys(e??{})])].filter(n=>{let a=t?.[n],o=e?.[n];return a?.enabled!==o?.enabled||a?.value!==o?.value})}function Ze(t,e){let s=t.trim();if(s==="")return null;if(typeof e=="number"){let n=Number(s);return Number.isFinite(n)?n:t}if(typeof e=="boolean"){if(s==="true")return!0;if(s==="false")return!1}return t}function O(t){return t==null||t===""?"No value":String(t)}function Qe(t,e){let s=t,n=s.flags??null,a={},o=null,i=!1;Object.defineProperty(s,"flags",{configurable:!0,enumerable:!0,get:()=>(i||(o=Y(n,a)??null,i=!0),o),set:u=>{n=u,i=!1,e.onServerFlags(u??{})}});let l=new Map,c=u=>{let v=String(u),h=l.get(v);return h===void 0&&(h=ve(v),l.size<5e3&&l.set(v,h)),h},d={},p=new Set,g=(u,v)=>{let h=s[u];typeof h=="function"&&(Object.prototype.hasOwnProperty.call(s,u)||p.add(u),d[u]=h,s[u]=v(h))},m=()=>s.getContext?.()?.identity?.identifier??s.identity??null,f=()=>s.eventsEnabled===!0;g("hasFeature",u=>(v,...h)=>(e.onRead(c(v)),u.call(s,v,...h))),g("getValue",u=>(v,...h)=>(e.onRead(c(v)),u.call(s,v,...h))),g("getExperimentFlag",u=>v=>(e.onRead(c(v)),u.call(s,v))),g("trackEvent",u=>(v,h)=>{let x=e.holdBack(),b=x?"held":f()?"sent":"off";if(e.onEvent({kind:"event",name:String(v),value:h?.value,identifier:h?.identifier??m(),status:b}),!x)return u.call(s,v,h)}),g("trackExposureEvent",u=>(v,h)=>{let x=e.holdBack(),b=h?.identifier??m(),y=x?"held":f()?b?"sent":"no-identity":"off";if(e.onEvent({kind:"exposure",name:String(v),key:ve(String(v)),value:h?.value,identifier:b,status:y}),!x)return u.call(s,v,h)});for(let u of["identify","logout","setContext"])g(u,v=>(...h)=>{let x=!e.isOwnContextChange?.(),b=v.apply(s,h);if(x&&e.onAppContextChange){let y=()=>e.onAppContextChange?.();Promise.resolve(b).then(y,y)}return b});return{serverFlags:()=>n??{},setOverrides(u){a=u,i=!1},notifyApp(u){try{s.onChange?.(n,{isFromServer:!1,flagsChanged:u,traitsChanged:null},s.loadingState)}catch(v){console.error("[flagsmith-toolbar] onChange threw",v)}s._trigger?.()},restore(){Object.defineProperty(s,"flags",{configurable:!0,enumerable:!0,writable:!0,value:n});for(let[u,v]of Object.entries(d))p.has(u)?delete s[u]:s[u]=v}}}function xe(t){return t.hash.startsWith("#/")?`${t.pathname}${t.hash}`:t.pathname}function et(t){if(typeof window>"u"||!window.history)return()=>{};let e=window.history,s=!1,n=()=>{s||t()},a=[];for(let o of["pushState","replaceState"]){let i=e[o];if(typeof i!="function")continue;let l=Object.prototype.hasOwnProperty.call(e,o),c=function(...d){let p=i.apply(this,d);return n(),p};e[o]=c,a.push(()=>{e[o]===c&&(l?e[o]=i:delete e[o])})}return window.addEventListener("popstate",n),window.addEventListener("hashchange",n),()=>{s=!0;for(let o of a)o();window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}var tt="flagsmith-toolbar",_e=new RegExp(`(^|&)${tt}=([A-Za-z0-9_-]+)`);function ks(t){let e="";for(let s of new TextEncoder().encode(t))e+=String.fromCharCode(s);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Fs(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),s=e+"=".repeat((4-e.length%4)%4),n=atob(s);return new TextDecoder().decode(Uint8Array.from(n,a=>a.charCodeAt(0)))}var Ss=t=>t===null||["string","number","boolean"].includes(typeof t),Cs=t=>["string","number","boolean"].includes(typeof t);function ye(t){let e={};if(!t||typeof t!="object")return e;for(let[s,n]of Object.entries(t)){if(!n||typeof n!="object")continue;let{enabled:a,value:o}=n,i={};typeof a=="boolean"&&(i.enabled=a),o!==void 0&&Ss(o)&&(i.value=o),Object.keys(i).length&&(e[s]=i)}return e}function we(t){if(!t||typeof t!="object")return null;let{name:e,description:s,identifier:n,traits:a}=t;if(typeof e!="string"||!e)return null;let o={name:e};return typeof s=="string"&&(o.description=s),typeof n=="string"&&n&&(o.identifier=n),a&&typeof a=="object"&&(o.traits=Object.fromEntries(Object.entries(a).filter(i=>Cs(i[1])))),o}function Ts(t){return ks(JSON.stringify({v:1,o:t.overrides,p:t.persona??null}))}function Es(t){try{let e=JSON.parse(Fs(t));return!e||e.v!==1?null:{overrides:ye(e.o),persona:we(e.p)}}catch{return null}}function st(t,e){let s=new URL(t),n=s.hash.replace(/^#/,"").replace(_e,"").replace(/^&/,""),a=`${tt}=${Ts(e)}`;return s.hash=n?`${n}&${a}`:a,s.toString()}function nt(t){let e=new URL(t).hash.replace(/^#/,"").match(_e);return e?Es(e[2]):null}function rt(t){let e=new URL(t);return e.hash=e.hash.replace(/^#/,"").replace(_e,"").replace(/^&/,""),e.toString().replace(/#$/,"")}var ot=t=>t.replace(/\|/g,"\\|").replace(/\r?\n/g," ");function Os(t){if(t.persona){let e=Object.entries(t.persona.traits??{}).map(([s,n])=>`${s}=${n}`).join(", ");return`${t.persona.name}${e?` (${e})`:""} \u2014 previewed with the toolbar`}return t.identity?`identity \`${t.identity}\``:"anonymous visitor"}function at(t){let e=new Set(t.usedOnPage),s=Object.keys(t.overrides),a=Object.keys(t.flags).sort((o,i)=>Number(e.has(i))-Number(e.has(o))||o.localeCompare(i)).map(o=>{let i=t.flags[o],l=R(i.reason).label;if(t.overrides[o]){let c=t.serverFlags[o];l+=c?` (Flagsmith: ${c.enabled?"on":"off"}, ${O(c.value)})`:""}return`| \`${o}\` | ${i.enabled?"on":"off"} | ${ot(O(i.value))} | ${ot(l)} | ${e.has(o)?"yes":""} |`});return["### Flagsmith flag state","",`- **Page:** ${t.url}`,`- **Flagsmith:** ${t.apiUrl??"unknown"}${t.environmentKey?` \xB7 environment \`${t.environmentKey}\``:""}`,`- **User:** ${Os(t)}`,`- **Changed in the toolbar:** ${s.length?s.map(o=>`\`${o}\``).join(", "):"nothing"}`,`- **Captured:** ${t.takenAt.toISOString()}`,"","| Flag | State | Value | Why | Used on this page |","| --- | --- | --- | --- | --- |",...a,"","_Captured with Flagsmith Toolbar_"].join(`
2
+ `)}var Rs=["flags","viewas","compare","share","experiments"],Z=class{constructor(e){this.listeners=new Set;this.state=e}get(){return this.state}set(e){let s=typeof e=="function"?e(this.state):e;this.state={...this.state,...s};for(let n of this.listeners)n()}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}};function Ps(t){if(!t||typeof t!="object"||Array.isArray(t))return{};let e=t,s={};"overrides"in e&&(s.overrides=ye(e.overrides)),"persona"in e&&(s.persona=we(e.persona)),typeof e.welcomeDismissed=="boolean"&&(s.welcomeDismissed=e.welcomeDismissed),typeof e.open=="boolean"&&(s.open=e.open);let n=e.tab==="events"?"experiments":e.tab;return typeof n=="string"&&Rs.includes(n)&&(s.tab=n),s}function it(t){try{let e=window.localStorage.getItem(t);return e?Ps(JSON.parse(e)):{}}catch{return{}}}function lt(t,e){try{window.localStorage.setItem(t,JSON.stringify(e))}catch{}}var _,ct,Is,M,ke,re,dt,ee,ut,Se,Fe,$s,K=Symbol.for("pv"),oe={},ae=[],Ms=/^m(i|n|o|s|text|space)$/,Ce=Array.isArray,gt=ae.slice,V=Object.assign;function U(t){t&&t.parentNode&&t.remove()}function te(t,e,s,n,a){var o={type:t,props:e,key:s,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:K,__v:a||++ct,__i:-1,__u:0};return!a&&_.vnode&&_.vnode(o),o}function S(t){return t.children}function se(t,e){this.props=t,this.context=e,this.__g=0}function A(t,e){if(e==null)return t.__&&A(t.__,t.__i+1);for(var s;e<t.__k.length;e++)if((s=t.__k[e])&&s.__e)return s.__e;return typeof t.type!="function"||t.props.__P?null:A(t)}function As(t){var e,s=t.__v,n=s.__e,a=[],o=[],i=t.__P;i&&((e=V({constructor:K},s)).__v=s.__v+1,_.vnode&&_.vnode(e),Te(i,e,s,t.__n,i.namespaceURI,32&s.__u?[n]:null,a,n||A(s),32&s.__u,o),e.__v=s.__v,e.__.__k[e.__i]=e,_t(a,e,o),s.__=s.__e=null,e.__e!=n&&ht(e))}function ht(t){if((t=t.__)&&t.__c&&!t.props.__P)return t.__e=null,t.__k.some(function(e){return e&&(t.__e=e.__e)}),ht(t)}function pt(t){(8&t.__g||(t.__g|=8,M.push(t),re++))&&ke==_.debounceRendering||((ke=_.debounceRendering)||queueMicrotask)(mt)}function mt(){try{for(var t,e=1;M.length;)M.length>e&&M.sort(dt),t=M.shift(),e=M.length,8&t.__g&&As(t)}finally{(re=M.length)&&(ke||queueMicrotask)(mt)}}function vt(t,e,s,n,a,o,i,l,c,d,p){var g,m,f,u,v,h,x=n.__k||ae,b=e.length;for(c=Ls(s,e,x,c,b),g=0;g<b;g++)(f=s.__k[g])!=null&&(m=~f.__i&&x[f.__i]||oe,f.__i=g,h=Te(t,f,m,a,o,i,l,c,d,p),u=f.__e,(m.ref!=f.ref||8&m.__u)&&(m.ref&&Ee(m.ref,null,f,m),f.ref&&p.push(f.ref,f.__c||u,f)),v=v||u,4&f.__u?(c=bt(f,c,t,!m.__v),m.__e&&(m.__e=null)):typeof f.type=="function"&&h!==void 0?c=h:u&&(c=u.nextSibling),f.__u&=-21);return s.__e=v,c}function Ls(t,e,s,n,a){var o,i,l,c,d,p,g,m,f,u=s.length,v=u,h=0,x=0,b=t.__k=Array(a);for(o=0;o<a;o++)(i=e[o])!=null&&typeof i!="boolean"&&typeof i!="function"?(typeof i!="object"||i.constructor===String?i=b[o]=te(null,i):Ce(i)?i=b[o]=te(S,{children:i}):i.constructor===K&&i.__b?i=b[o]=te(i.type,i.props,i.key,i.ref,i.__v):b[o]=i,c=o+h,i.__=t,i.__b=t.__b+1,l=null,~(d=i.__i=js(i,s,c,v))&&(v--,(l=s[d])&&(l.__u|=2)),l&&l.__v?(i.__u|=16,d==c-1?h--:d==c+1?h++:d!=c&&(d>c?h--:h++,x=1)):(~d||(a>u?h--:a<u&&h++),typeof i.type!="function"&&(i.__u|=4))):b[o]=null;if(x){for(p=[],g=[],o=0;o<a;o++)if((i=b[o])&&16&i.__u){for(h=0,m=p.length;h<m;)p[f=h+m>>1]<i.__i?h=f+1:m=f;p[h]=i.__i,g[o]=h+1}for(h=p.length;o--;)g[o]&&(g[o]==h?h--:b[o].__u|=4)}if(v)for(o=0;o<u;o++)!(l=s[o])||2&l.__u||(l.__e==n&&(n=A(l)),Oe(l,l));return n}function bt(t,e,s,n){var a,o,i,l;if(typeof t.type=="function"){if(t.props.__P)return e;if(a=t.__k)for(o=0;o<a.length;o++)a[o]&&(a[o].__=t,e=bt(a[o],e,s,!1));return e}for(e&&!e.parentNode&&(e=A(t))&&!e.parentNode&&(e=null),i=t.__e,l=e;l&&l.nodeType==8;)l=l.nextSibling;for(i!=l&&(!n&&s.moveBefore&&i.parentNode?s.moveBefore(i,e):s.insertBefore(i,e||null)),e=i;(e=e&&e.nextSibling)&&e.nodeType==8&&!e.data.startsWith("$s"););return e}function js(t,e,s,n){var a,o=t.key,i=t.type,l=e[s],c=l&&!(2&l.__u);if(l===null&&o==null||c&&o==l.key&&i==l.type)return s;if(n>(c?1:0)){for(a=s-1;a>=0;a--)if((l=e[a])&&!(2&l.__u)&&o==l.key&&i==l.type)return a;for(a=s+1;a<e.length;a++)if((l=e[a])&&!(2&l.__u)&&o==l.key&&i==l.type)return a}return-1}function ft(t,e,s){s==null&&(s=""),e[0]=="-"?t.setProperty(e,s):t[e]=s}function Q(t,e,s,n,a){var o,i;if(e=="style")if(typeof s=="string")t.style.cssText=s;else{if(typeof n=="string"&&(t.style.cssText=n=""),n)for(e in n)s&&e in s||ft(t.style,e);if(s)for(e in s)n&&s[e]==n[e]||ft(t.style,e,s[e])}else if(e[0]=="o"&&e[1]=="n")typeof s!="function"&&(s=null),typeof n!="function"&&(n=null),(t.__e||(t.__e={}))[e]=s,s&&n||(i=Fe[e]||(Fe[e]=Ns(e)),(t.__a||(t.__a={}))[e]=Se,o=e!=(e=e.replace(ut,"$1")),(e=e.slice(2))[0]<"a"&&(e=e.toLowerCase()),s?t.addEventListener(e,i,o):t.removeEventListener(e,i,o));else{if(a=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{return void(t[e]=s??"")}catch{}if(typeof s=="function")return;s==null||s===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&s==1?"":s)}}function Ns(t){return function(e){var s=this.__e;if(s){if(s=s[t],e[ee]==null)e[ee]=Se++;else if(e[ee]<this.__a[t])return;return s(_.event?_.event(e):e)}}}function Te(t,e,s,n,a,o,i,l,c,d){var p,g,m,f,u,v,h,x,b,y,w,ce,Ve,X,j,De,$,N,I=e.type;if(e.constructor!==K)return null;128&s.__u&&(c=32&s.__u,p=s.__c.__z)&&(e.__u|=c,g=o=[],p.nodeType==8?l=ne(p,o):o.push(p),l=o[0]||l),(p=_.__b)&&p(e);e:if(typeof I=="function"){m=i.length;try{if(x=e.props,b=(p=I.prototype)&&p.render,y=(p=I.contextType)&&n[p.__c],w=p?y?y.props.value:p.__:n,(f=s.__c)?(e.__c=f,2&f.__g&&(f.__g|=1)):(b?e.__c=f=new I(x,w):(e.__c=f=new se(x,w),f.constructor=I,f.render=Vs),y&&y.sub(f),f.state||(f.state={}),f.__n=n,f.__g|=8,f.__h=[],f.__k=[]),b&&(f.__s||(f.__s=f.state),I.getDerivedStateFromProps&&(f.__s==f.state&&(f.__s=V({},f.__s)),V(f.__s,I.getDerivedStateFromProps(x,f.__s)))),u=f.props,v=f.state,f.__v=e,s.__c){if(x!==u&&b&&!I.getDerivedStateFromProps&&f.componentWillReceiveProps&&f.componentWillReceiveProps(x,w),e.__v==s.__v&&!(8&f.__g)||!(4&f.__g)&&f.shouldComponentUpdate&&f.shouldComponentUpdate(x,f.__s,w)===!1){e.__v!=s.__v&&(f.props=x,f.state=f.__s,f.__g&=-9),e.__e=s.__e,e.__k=s.__k,e.__k.some(function(E){E&&(E.__=e)}),ae.push.apply(f.__h,f.__k),f.__k=[],f.__h.length&&i.push(f),l=A(s);break e}f.componentWillUpdate&&f.componentWillUpdate(x,f.__s,w),b&&f.componentDidUpdate&&f.__h.push(function(){f.componentDidUpdate(u,v,h)})}else b&&!I.getDerivedStateFromProps&&f.componentWillMount&&f.componentWillMount(),b&&f.componentDidMount&&f.__h.push(f.componentDidMount);f.context=w,f.props=x,f.__P=t,f.__g&=-5,ce=_.__r,Ve=b?25:0;do f.__g&=-9,ce&&ce(e),p=f.render(f.props,f.state=f.__s,f.context);while(8&f.__g&&++Ve<25);b&&(ae.push.apply(f.__h,f.__k),f.__k=[]),f.state=f.__s,f.getChildContext&&(n=V({},n,f.getChildContext())),b&&s.__c&&f.getSnapshotBeforeUpdate&&(h=f.getSnapshotBeforeUpdate(u,v)),X=p&&p.type===S&&p.key==null?p.props.children:p,x.__P&&(p=l,a=(t=x.__P).namespaceURI,c=o=null,s.props&&s.props.__P!=t&&(s.__k.some(function(E){E&&Oe(E,E)}),s.__k=null),l=s.__k?A(s,0):null),l=vt(t,Ce(X)?X:[X],e,s,n,a,o,i,l,c,d),x.__P&&(e.__e=null,l=p),e.__u&=-161,g&&g.some(U),f.__h.length&&i.push(f),1&f.__g&&(f.__g&=-4)}catch(E){if(i.length=m,e.__v=null,c||o)if(E&&E.then){if(e.__u|=128|c,o){for(~($=o.indexOf(l||void 0))||($=o.length);(N=o[$-1])&&N.nodeType==8;)$--;for(;$<o.length;$++)if(N=o[$])if(o[$]=null,j){if(N==De)break}else{if(N.nodeType!=8)break;N.data.startsWith("$s")&&(De=ne(j=N))}}if(!j){for(;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;j=l}(p=ne(j=e.__c.__z||(e.__c.__z=j)))?(e.__e=j,l=p):e.__e=l,l=l&&l.nextSibling}else o&&o.some(U);else e.__e=s.__e;e.__k||(e.__k=s.__k||[]),E&&E.then||xt(e),_.__e(E,e,s)}}else l=e.__e=Us(s.__e,e,s,n,a,o,i,c,d,t);return(p=_.diffed)&&p(e),l}function ne(t,e){if(t&&t.nodeType==8&&t.data.startsWith("$s"))for(var s=1;t=t.nextSibling;){if(t.nodeType==8){if(t.data.startsWith("$s"))s++;else if(t.data.startsWith("/$s")&&!--s)return t}e&&e.push(t)}}function xt(t){t&&(t.__c&&(t.__c.__g|=4),t.__k&&t.__k.some(xt))}function _t(t,e,s){for(var n=0;n<s.length;)Ee(s[n++],s[n++],s[n++]);_.__c&&_.__c(e,t),t.some(function(a){try{t=a.__h,a.__h=[],t.some(function(o){o.call(a)})}catch(o){_.__e(o,a.__v)}})}function Us(t,e,s,n,a,o,i,l,c,d){var p,g,m,f,u,v,h,x,b=s.props||oe,y=e.props,w=e.type;if(w=="svg"?a="http://www.w3.org/2000/svg":w=="math"?a="http://www.w3.org/1998/Math/MathML":a||(a="http://www.w3.org/1999/xhtml"),o){for(p=0;p<o.length;p++)if((u=o[p])&&(w?u.localName==w:u.nodeType==3)){t=u,o[p]=null;break}}if(!t){if(x=d.ownerDocument||document,!w)return x.createTextNode(y);t=x.createElementNS(a,w,y.is?y:d),l&&(_.__m&&_.__m(e,o),l=!1),o=null}if(w){if(d=w=="template"&&t.content||t,o=w=="textarea"&&y.defaultValue!=null?null:o&&gt.call(d.childNodes),!l&&o)for(b={},p=0;p<t.attributes.length;p++)b[(u=t.attributes[p]).name]=u.value;for(p in b)u=b[p],p=="dangerouslySetInnerHTML"?m=u:p=="children"||p in y||p=="value"&&"defaultValue"in y||p=="checked"&&"defaultChecked"in y||Q(t,p,null,u,a);for(p in y)u=y[p],p=="children"?f=u:p=="dangerouslySetInnerHTML"?g=u:p=="value"?v=u:p=="checked"?h=u:l&&typeof u!="function"||b[p]===u||Q(t,p,u,b[p],a);g?(l||m&&(g.__html==m.__html||g.__html==t.innerHTML)||(t.innerHTML=g.__html),e.__k=[]):(m&&(t.textContent=""),(w=="foreignObject"||a=="http://www.w3.org/1998/Math/MathML"&&Ms.test(w))&&(a="http://www.w3.org/1999/xhtml"),vt(d,Ce(f)?f:[f],e,s,n,a,o,i,o?o[0]:s.__k&&A(s,0),l,c),o&&o.some(U)),l&&w!="textarea"||(p="value",w=="progress"&&v==null?t.removeAttribute(p):v==null||v===t[p]&&(w!="progress"||v)||Q(t,p,v,b[p],a),p="checked",h!=null&&h!=t[p]&&Q(t,p,h,b[p],a))}else b===y||l&&t.data==y||(t.data=y);return t}function Ee(t,e,s,n){try{typeof t=="function"?e?e.__x=t(e)||1:n&&(n=n.__c||n.__e)&&(e=n.__x)&&(n.__x=null,typeof e=="function"?e():t(null)):t.current=e}catch(a){_.__e(a,s)}}function Oe(t,e,s){var n,a,o,i;if(_.unmount&&_.unmount(t),!(n=t.ref)||n.current&&n.current!=t.__e||Ee(n,null,e,t),n=t.__c){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(l){_.__e(l,e)}n.__P=n.__n=null}if(n=t.__k)for(i=0;i<n.length;i++)n[i]&&Oe(n[i],e,typeof t.type!="function"||s&&!t.props.__P);!s&&(n=t.__c)&&(n=n.__z)&&(a=ne(n,o=[]))&&(n==t.__e&&o.some(U),U(a),U(n)),s||U(t.__e),t.__e=t.__c=t.__=null}function Vs(t,e,s){return this.constructor(t,s)}function Re(t,e){var s,n,a,o;_.__&&_.__(t,e),e.nodeType==9&&(e=e.documentElement),n=(s=t&&32&t.__u)?null:e.__k,e.__k=te(S,{children:[t]}),a=[],o=[],Te(e,e.__k,n||oe,oe,e.namespaceURI,n?null:e.firstChild?gt.call(e.childNodes):null,a,n?n.__e:e.firstChild,s,o),_t(a,e.__k,o),e.__k.props.children=null}_={__e:function(t,e,s,n){for(var a,o,i;e=e.__;)if((a=e.__c)&&!(1&a.__g)){a.__g|=4;try{if((i=(o=a.constructor)&&o.getDerivedStateFromError)&&a.setState(o.getDerivedStateFromError(t)),a.componentDidCatch&&(a.componentDidCatch(t,n||{}),i=1),i&&8&a.__g)return void(a.__g|=2)}catch(l){t=l}}throw re=0,t}},ct=0,Is=function(t){return t!=null&&t.constructor===K},se.prototype.setState=function(t,e){var s=this.__s;s&&s!=this.state||(s=this.__s=V({},this.state)),typeof t=="function"&&(t=t(V({},s),this.props)),t&&(V(s,t),this.__v&&(e&&this.__k.push(e),pt(this)))},se.prototype.forceUpdate=function(t){this.__v&&(this.__g|=4,t&&this.__h.push(t),pt(this))},se.prototype.render=S,M=[],re=0,dt=function(t,e){return t.__v.__b-e.__v.__b},ee=Symbol(),ut=/(PointerCapture)$|Capture$/i,Se=0,Fe={},$s=0;var W,F,Pe,yt,Ie=Object.is,ie=0,Rt=[],$e=[],k=_,wt=k.__b,kt=k.__r,Ft=k.diffed,St=k.__c,Ct=k.unmount,Tt=k.__;function Ae(t,e){k.__h&&k.__h(F,t,ie||e),ie=0;var s=F.__H||(F.__H={__:[],__h:[]});return t>=s.__.length&&s.__.push({}),s.__[t]}function C(t){return ie=1,Ds(It,t)}function Ds(t,e,s){var n=Ae(W++,2);if(n.t=t,!n.__c&&(n.__=[s?s(e):It(void 0,e),function(o){var i=(n.__N||n.__)[0],l=n.t(i,o);Ie(i,l)||(n.__N=[l,n.__[1]],n.__c.setState({}))}],n.__c=F,!F.__f)){F.__f=!0;var a=F.shouldComponentUpdate;F.shouldComponentUpdate=function(o,i,l){var c=this.__H;if(!c)return!0;var d=!1,p=this.props!=o;if(c.__.some(function(m){m.__N&&(d=!0,Ie(m.__[0],m.__N[0])||(p=!0))}),a){var g=a.call(this,o,i,l);return d?g||p:g}return!d||p}}return n.__}function P(t,e){var s=Ae(W++,3);!k.__s&&Pt(s.__H,e)&&(s.__P=!0,s.__=t,s.u=e,F.__H.__h.push(s))}function D(t){return ie=5,Hs(function(){return{current:t}},[])}function Hs(t,e){var s=Ae(W++,7);return Pt(s.__H,e)&&(s.__=t(),s.__H=e),s.__}function zs(){var t;do{for(;t=$e.shift();)try{B(t)}catch(s){k.__e(s,{__:(t=t.__P)&&t.__v})}for(;t=Rt.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(B),e.__h.some(Me),e.__h=[]}catch(s){e.__h=[],k.__e(s,t.__v)}}}while($e.length)}k.__b=function(t){F=null,wt&&wt(t)},k.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Tt&&Tt(t,e)},k.__r=function(t){kt&&kt(t),W=0;var e=(F=t.__c).__H;e&&(Pe==F?F.__h=[]:(e.__h.some(B),e.__h.some(Me),W=0),e.__h=[],e.__.some(function(s){s.__N&&(s.__=s.__N),s.u=s.__N=void 0})),Pe=F},k.diffed=function(t){Ft&&Ft(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&Ot(Rt.push(e)),e.__H.__.some(function(s){s.u&&(s.__H=s.u)})),Pe=F=null},k.__c=function(t,e){e.some(function(s){try{s.__h.some(B),s.__h=s.__h.filter(function(n){return!n.__||Me(n)})}catch(n){s.__h=[function(){throw n}]}}),St&&St(t,e)},k.unmount=function(t){Ct&&Ct(t);var e,s,n=t.__c;n&&n.__H&&(n.__H.__.some(function(a){try{if(a.__P&&a.__c){if(s===void 0){for(s=t.__;s&&(!s.__c||!s.__c.__P);)s=s.__;s=s&&s.__c}a.__P=s,Ot($e.push(a))}else B(a)}catch(o){e=o}}),n.__H=void 0,e&&k.__e(e,n.__v))};var Et=typeof requestAnimationFrame=="function";function Ks(t){var e,s=function(){clearTimeout(n),Et&&cancelAnimationFrame(e),setTimeout(t)},n=setTimeout(s,35);Et&&(e=requestAnimationFrame(s))}function Ot(t){t!=1&&yt==k.requestAnimationFrame||((yt=k.requestAnimationFrame)||Ks)(zs)}function B(t){var e=F,s=t.__c;typeof s=="function"&&(t.__c=void 0,s()),F=e}function Me(t){var e=F;t.__c=t.__(),F=e}function Pt(t,e){return!t||t.length!=e.length||e.some(function(s,n){return!Ie(s,t[n])})}function It(t,e){return typeof e=="function"?e(t):e}var Bs=Symbol.for("pv"),Ws=0;function r(t,e,s,n,a,o){e||(e={});var i,l,c=e;if("ref"in c&&typeof t!="function")for(l in c={},e)l=="ref"?i=e[l]:c[l]=e[l];var d={type:t,props:c,key:s,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:Bs,__v:--Ws,__i:-1,__u:0};return(a||o)&&(d.__source=a,d.__self=o),_.vnode&&_.vnode(d),d}function T({children:t}){return r("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:t})}var Le=()=>r(T,{children:[r("path",{d:"M4 22V4"}),r("path",{d:"M4 4h12l-1.5 4L16 12H4"})]}),le=()=>r(T,{children:[r("path",{d:"M18 6 6 18"}),r("path",{d:"m6 6 12 12"})]}),$t=()=>r(T,{children:[r("path",{d:"M15 3h6v6"}),r("path",{d:"M10 14 21 3"}),r("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]}),Mt=()=>r(T,{children:[r("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),r("path",{d:"M3 3v5h5"})]}),At=()=>r(T,{children:[r("circle",{cx:"12",cy:"8",r:"4"}),r("path",{d:"M4 21a8 8 0 0 1 16 0"})]}),Lt=()=>r(T,{children:[r("path",{d:"M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7"}),r("path",{d:"M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7"})]}),jt=()=>r(T,{children:[r("rect",{x:"8",y:"2",width:"8",height:"4",rx:"1"}),r("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"})]}),Nt=()=>r(T,{children:[r("path",{d:"M21 12a9 9 0 0 1-15.4 6.4L3 16"}),r("path",{d:"M3 21v-5h5"}),r("path",{d:"M3 12a9 9 0 0 1 15.4-6.4L21 8"}),r("path",{d:"M21 3v5h-5"})]}),G=()=>r(T,{children:r("path",{d:"m5 12 5 5L20 7"})}),H=()=>r(T,{children:[r("path",{d:"M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z"}),r("path",{d:"M12 9v4"}),r("path",{d:"M12 17h.01"})]}),q=()=>r(T,{children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("path",{d:"M12 16v-4"}),r("path",{d:"M12 8h.01"})]}),Ut=()=>r(T,{children:[r("path",{d:"M9 3h6"}),r("path",{d:"M10 3v6.5L4.5 19a1.5 1.5 0 0 0 1.3 2h12.4a1.5 1.5 0 0 0 1.3-2L14 9.5V3"}),r("path",{d:"M7.5 15h9"})]}),Vt=()=>r(T,{children:[r("path",{d:"M8 3 4 7l4 4"}),r("path",{d:"M4 7h16"}),r("path",{d:"m16 21 4-4-4-4"}),r("path",{d:"M20 17H4"})]});function Dt(t,e){return e==="page"?"This page":e==="anonymous"?"Anonymous":t.subjectLabel(e).split("\xB7")[0].trim()}function Kt({controller:t,state:e}){let s=t.compareSubjects(),{compareA:n,compareB:a,compareStatus:o}=e,i=D(!1);P(()=>{let g=t.store.get(),m=g.compareA==="page"||g.compareB==="page",f=!i.current;i.current=!0,(m||f&&g.compareStatus!=="done")&&t.compare(g.compareA,g.compareB)},[e.serverFlags,e.overrides]);let l=e.compareResult?qe(e.compareResult.a,e.compareResult.b):null,c=l?l.differ.length+l.same.length:0,d=Dt(t,n),p=Dt(t,a);return r("div",{class:"fst-stack",children:[r("div",{class:"fst-card fst-compare-pick",children:[r(Ht,{id:"fst-compare-a",label:"User A",value:n,subjects:s,onChange:g=>{t.pickCompare("a",g)}}),r("button",{class:"fst-icon-btn fst-swap","aria-label":"Swap users A and B",title:"Swap",onClick:()=>{t.swapCompare()},children:r(Vt,{})}),r(Ht,{id:"fst-compare-b",label:"User B",value:a,subjects:s,onChange:g=>{t.pickCompare("b",g)}})]}),o==="loading"&&r("p",{class:"fst-loading",children:[r("span",{class:"fst-spinner","aria-hidden":"true"})," Asking Flagsmith about both users\u2026"]}),o==="error"&&r("p",{class:"fst-error",children:e.compareError}),l&&o!=="error"&&r(S,{children:[r("p",{class:"fst-compare-summary",role:"status",children:l.differ.length===0?r(S,{children:[r("strong",{children:d})," and ",r("strong",{children:p})," see the same ",c," flags."]}):r(S,{children:[r("strong",{children:[l.differ.length," of ",c," flags"]})," ","differ between ",d," and ",p,"."]})}),l.differ.length>0&&r("ul",{class:"fst-list",children:l.differ.map(g=>r(Gs,{row:g,labelA:d,labelB:p},g.key))}),l.same.length>0&&r("details",{class:"fst-same",children:[r("summary",{children:["Same for both (",l.same.length,")"]}),r("div",{class:"fst-chips",children:l.same.map(g=>r("code",{class:"fst-chip",children:g.key}))})]})]}),r("p",{class:"fst-note",children:"Flagsmith evaluates each user live, with its real segments, splits and experiments. Users without an identity are transient, so nothing is saved and your page doesn't change."})]})}function Ht({id:t,label:e,value:s,subjects:n,onChange:a}){return r("div",{class:"fst-picker",children:[r("label",{class:"fst-label",for:t,children:e}),r("select",{id:t,class:"fst-input fst-select",value:s,onChange:o=>a(o.currentTarget.value),children:n.map(o=>r("option",{value:o.id,children:o.label}))})]})}function Gs({row:t,labelA:e,labelB:s}){return r("li",{class:"fst-flag fst-compare-row",children:[r("div",{class:"fst-compare-key",children:r("code",{children:t.key})}),r(zt,{label:e,flag:t.a}),r(zt,{label:s,flag:t.b})]})}function zt({label:t,flag:e}){if(!e)return r("div",{class:"fst-side",children:[r("span",{class:"fst-side-label",children:t}),r("span",{class:"fst-muted",children:"Not sent for this user"})]});let s=R(e.reason);return r("div",{class:"fst-side",children:[r("span",{class:"fst-side-label",title:t,children:t}),r("span",{class:`fst-state${e.enabled?" is-on":""}`,children:e.enabled?"On":"Off"}),r("span",{class:"fst-side-value",title:O(e.value),children:O(e.value)}),r("span",{class:`fst-reason fst-reason--${s.kind}`,title:s.detail,children:s.label})]})}var Bt=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});function Wt({controller:t,state:e}){let s=t.experiments(),n=t.currentIdentity();return r("div",{class:"fst-stack",children:[t.isPreviewing()&&r("div",{class:"fst-callout",children:[r(q,{}),r("span",{children:"You're previewing, so the toolbar holds events back. Test visits never count in your real experiment results."})]}),r("div",{class:"fst-section-title",children:"Experiments on this page"}),s.length===0?r("div",{class:"fst-card fst-muted",children:n?"None of the flags for this user are in a running experiment.":"Flagsmith only puts identified users into experiments, and nobody is identified yet. Use View as, or sign in to your app, to see them here."}):r("ul",{class:"fst-list",children:s.map(a=>r(Xs,{row:a,previewing:t.isPreviewing()},a.key))}),r("div",{class:"fst-section-title",children:["Events",e.events.length?` (${e.events.length})`:""]}),r(Zs,{events:e.events})]})}var qs={recorded:"good",held:"neutral",previewing:"neutral",waiting:"neutral",missing:"bad","events-off":"bad","not-read":"neutral","not-enrolled":"neutral",disabled:"neutral"};function Js(t,e){let s=t.exposure?Bt(t.exposure.at):"";switch(t.state){case"recorded":return`Exposure recorded at ${s}, so this visit counts.`;case"held":return e?`Exposure held back at ${s} because you're previewing, so this visit isn't counted.`:`Exposure held back at ${s}, while you were previewing. Reload the page to record a real one.`;case"previewing":return"You're previewing, so any exposure is held back and this visit isn't counted.";case"waiting":return"Waiting for the page to record the exposure\u2026";case"missing":return"No exposure recorded. The page shows this variant but never records that the user saw it, so they won't be counted. Read the flag with getExperimentFlag, or useExperiment in React.";case"events-off":return"Exposures can't be recorded, because Flagsmith was started without enableEvents.";case"not-read":return"This page doesn't use this flag.";case"not-enrolled":return"Flagsmith didn't put this user in the experiment, so they get the control value and aren't counted.";case"disabled":return"The flag is off for this user, so there's nothing to expose."}}function Xs({row:t,previewing:e}){let s=qs[t.state];return r("li",{class:`fst-exp fst-exp--${s}`,children:[r("div",{class:"fst-exp-head",children:[r(Ut,{}),r("strong",{children:t.name})]}),r("div",{class:"fst-exp-meta",children:[r("code",{children:t.key}),t.inExperiment?r("span",{children:["in the experiment, sees ",r("strong",{children:O(t.value)})]}):r("span",{children:["not enrolled, sees ",O(t.value)]})]}),r("p",{class:"fst-exp-status",children:[s==="good"?r(G,{}):s==="bad"?r(H,{}):r(q,{}),r("span",{children:Js(t,e)})]}),t.state==="missing"&&r("pre",{class:"fst-pre",children:`flagsmith.getExperimentFlag('${t.key}')`})]})}var Ys={sent:"",held:" \xB7 held back: preview",off:" \xB7 not sent: enableEvents is off","no-identity":" \xB7 not sent: no user identified"};function Zs({events:t}){return t.length===0?r("div",{class:"fst-empty",children:[r("p",{children:r("strong",{children:"No events yet"})}),r("p",{children:["Events appear here as your app sends them: exposures from ",r("code",{children:"getExperimentFlag"})," and"," ",r("code",{children:"trackExposureEvent"}),", and conversions from ",r("code",{children:"trackEvent"}),"."]})]}):r("ul",{class:"fst-events",children:t.map(e=>r("li",{class:`fst-event${e.status==="sent"?"":" is-unsent"}`,children:[r("span",{class:`fst-chip fst-chip--${e.kind}`,children:e.kind==="exposure"?"Exposure":"Event"}),r("code",{children:e.name}),e.value!==void 0&&e.value!==null&&r("span",{class:"fst-muted",children:["= ",String(e.value)]}),r("span",{class:"fst-event-meta",children:[Bt(e.at)," \xB7 ",e.identifier??"no identity",Ys[e.status]]})]},e.id))})}var Gt={onoff:"On/off",number:"Number",json:"JSON",text:"Text",variant:"Variant"},Qs=/^-?\d+(\.\d+)?$/;function qt(t){if(typeof t.variant=="string"&&t.variant!=="")return"variant";let{value:e}=t;if(e==null||e==="")return"onoff";if(typeof e=="number")return Number.isFinite(e)?"number":"text";if(typeof e!="string")return"text";let s=e.trim();if(Qs.test(s))return"number";if(s.startsWith("{")||s.startsWith("["))try{let n=JSON.parse(s);if(n!==null&&typeof n=="object")return"json"}catch{}return"text"}function en(t,e,s){let n=s.trim().toLowerCase();return!n||t.toLowerCase().includes(n)||String(e?.value??"").toLowerCase().includes(n)}function Jt(t){let e=Object.keys(t.flags).filter(s=>en(s,t.flags[s],t.search)).sort();return t.filter==="page"?je([{id:"all",title:null,keys:e.filter(s=>s in t.reads)}]):t.filter==="changed"?je([{id:"all",title:null,keys:e.filter(s=>s in t.overrides)}]):je([{id:"page",title:"On this page",keys:e.filter(s=>s in t.reads)},{id:"other",title:"Other flags",keys:e.filter(s=>!(s in t.reads))}])}var je=t=>t.filter(e=>e.keys.length>0);function Xt(t){let[e,s]=C(t.get());return P(()=>(s(t.get()),t.subscribe(()=>s(t.get()))),[t]),e}async function J(t){try{return await navigator.clipboard.writeText(t),!0}catch{}try{let e=document.createElement("textarea");e.value=t,e.style.cssText="position:fixed;opacity:0;pointer-events:none;",document.body.appendChild(e),e.select();let s=document.execCommand("copy");return e.remove(),s}catch{return!1}}function Yt({controller:t,state:e,flags:s}){let n=Object.keys(s),a=n.filter(c=>c in e.reads).length,o=Object.keys(e.overrides).length,i=Jt({flags:s,reads:e.reads,overrides:e.overrides,filter:e.filter,search:e.search}),l=[["all","All",n.length],["page","On this page",a],["changed","Changed",o]];return r("div",{class:"fst-stack",children:[!e.welcomeDismissed&&r(tn,{controller:t}),r(sn,{controller:t,state:e}),r("input",{class:"fst-input fst-search",type:"search",placeholder:"Search flags or values","aria-label":"Search flags",value:e.search,onInput:c=>t.setSearch(c.currentTarget.value)}),r("div",{class:"fst-segmented",role:"group","aria-label":"Filter flags",children:l.map(([c,d,p])=>r("button",{class:`fst-segment${e.filter===c?" is-active":""}`,"aria-pressed":e.filter===c,onClick:()=>t.setFilter(c),children:[d,r("span",{class:"fst-segment-count",children:p})]}))}),n.length===0?r("div",{class:"fst-empty",children:[r("p",{children:r("strong",{children:"Waiting for flags from Flagsmith\u2026"})}),r("p",{children:"They appear here as soon as the SDK loads them."})]}):i.length===0?r("div",{class:"fst-empty",children:"No flags match."}):i.map(c=>r("div",{class:"fst-group",children:[c.title&&r("p",{class:"fst-section-title fst-group-title",children:[c.title,r("span",{class:"fst-group-count",children:c.keys.length})]}),r("ul",{class:"fst-list","aria-label":c.title??"Flags",children:c.keys.map(d=>r(nn,{controller:t,flagKey:d,flag:s[d],server:e.serverFlags[d],changed:d in e.overrides,fresh:d in e.changedInFlagsmith,used:d in e.reads,pages:e.seenOn[d]??[],expanded:e.expanded===d},d))})]},c.id)),o>0&&r("button",{class:"fst-link-btn",onClick:()=>t.resetAll(),children:["Reset ",o===1?"your change":`all ${o} changes`]})]})}function tn({controller:t}){return r("div",{class:"fst-welcome",children:[r("strong",{class:"fst-welcome-title",children:"See what Flagsmith is doing on this page"}),r("ol",{children:[r("li",{children:[r("strong",{children:"Why:"})," open any flag to see why it has its value."]}),r("li",{children:[r("strong",{children:"Try the other side:"})," flip a flag. Only you see the change."]}),r("li",{children:[r("strong",{children:"View as and Compare:"})," see the page as another user, or compare two users side by side."]})]}),r("p",{class:"fst-welcome-note",children:"The badge at the top checks your Flagsmith setup for common mistakes."}),r("button",{class:"fst-btn fst-btn--primary",onClick:()=>t.dismissWelcome(),children:"Got it"})]})}function sn({controller:t,state:e}){let s=t.flagsmith.identity,n=e.persona?.name??(s?`identity ${s}`:"an anonymous visitor");return r("div",{class:"fst-viewing",children:[r(At,{}),r("span",{children:["Flags for ",r("strong",{children:n})]}),e.personaStatus==="loading"&&r("span",{class:"fst-spinner","aria-label":"Loading"}),r("button",{class:"fst-link-btn",onClick:()=>t.setTab("viewas"),children:"Change"})]})}function nn({controller:t,flagKey:e,flag:s,server:n,changed:a,fresh:o,used:i,pages:l,expanded:c}){let d=R(s.reason),p=qt(n??s);return r("li",{class:`fst-flag${a?" is-changed":""}${o?" is-fresh":""}`,children:[r("div",{class:"fst-flag-main",children:[r("button",{class:"fst-flag-summary","aria-expanded":c,onClick:()=>t.toggleExpanded(e),children:[r("span",{class:"fst-flag-name",children:[i&&r("span",{class:"fst-used",title:"Used on this page"}),r("code",{children:e}),o&&r("span",{class:"fst-fresh",children:"Changed in Flagsmith"}),r("span",{class:"fst-type",children:Gt[p]})]}),r("span",{class:"fst-flag-meta",children:[r("span",{class:`fst-reason fst-reason--${d.kind}`,title:d.detail,children:d.label}),r("span",{class:"fst-flag-value",children:O(s.value)})]})]}),r(an,{checked:s.enabled,label:`${e}: turn ${s.enabled?"off":"on"} just for you`,onChange:g=>t.setEnabled(e,g)})]}),c&&r(rn,{controller:t,flagKey:e,flag:s,server:n,changed:a,pages:l})]})}function rn({controller:t,flagKey:e,flag:s,server:n,changed:a,pages:o}){let[i,l]=C(!1),c=R(s.reason),d=R(n?.reason),p=t.dashboardLink(e);return r("div",{class:"fst-details",children:[r("p",{children:[r("strong",{children:"Why: "}),c.detail]}),a&&n&&r("p",{class:"fst-muted",children:["Flagsmith says: ",r("strong",{children:n.enabled?"on":"off"}),", ",O(n.value)," (",d.label.toLowerCase(),")"]}),n?.reason&&r("p",{class:"fst-raw",title:"The reason exactly as Flagsmith sent it",children:r("code",{children:n.reason})}),r("p",{class:"fst-muted fst-pages",children:o.length?r(S,{children:["Read on:"," ",o.map((g,m)=>r("span",{children:[m>0&&", ",r("code",{children:g})]},g))]}):"Not read on any page yet"}),n?.experiment&&r("p",{class:"fst-muted",children:["Experiment ",r("strong",{children:n.experiment.name}),":"," ",n.experiment.inExperiment?"this user is in it.":"this user isn't enrolled."," ",r("button",{class:"fst-link-btn",onClick:()=>t.setTab("experiments"),children:"See exposures"})]}),r(on,{controller:t,flagKey:e,flag:s}),r("div",{class:"fst-actions",children:[a&&r("button",{class:"fst-btn",onClick:()=>t.resetFlag(e),children:[r(Mt,{})," Reset to Flagsmith"]}),p&&r("a",{class:"fst-btn",href:p,target:"_blank",rel:"noreferrer",children:["Open in Flagsmith ",r($t,{})]}),r("button",{class:"fst-btn",onClick:async()=>{l(await J(e)),setTimeout(()=>l(!1),1500)},children:i?"Copied":"Copy key"})]})]})}function on({controller:t,flagKey:e,flag:s}){let n=s.value===null||s.value===void 0?"":String(s.value),[a,o]=C(n),i=D(n);return P(()=>{i.current!==n&&(i.current=n,o(n))},[n]),r("form",{class:"fst-value",onSubmit:l=>{l.preventDefault(),t.setValue(e,Ze(a,s.value))},children:[r("label",{class:"fst-label",for:`fst-value-${e}`,children:"Value, just for you"}),r("div",{class:"fst-value-row",children:[r("input",{id:`fst-value-${e}`,class:"fst-input",value:a,placeholder:"No value",onInput:l=>o(l.currentTarget.value)}),r("button",{class:"fst-btn fst-btn--primary",type:"submit",disabled:a===n,children:"Apply"})]})]})}function an({checked:t,label:e,onChange:s}){return r("button",{role:"switch","aria-checked":t,"aria-label":e,title:e,class:`fst-switch${t?" is-on":""}`,onClick:()=>s(!t),children:r("span",{class:"fst-switch-thumb"})})}function Zt({controller:t,issues:e,open:s}){let n=e.filter(i=>i.level!=="tip"),a=n.some(i=>i.level==="problem"),o=n.length===0?"ok":a?"problem":"warning";return r("button",{class:`fst-setup-chip fst-setup-chip--${o}`,"aria-expanded":s,"aria-label":n.length?`Setup check: ${n.length} to fix`:"Setup check: no problems found",title:"Check this page's Flagsmith setup",onClick:()=>t.toggleSetup(),children:[n.length?r(H,{}):r(G,{}),r("span",{children:n.length?`${n.length} to fix`:"Setup OK"})]})}var ln={problem:H,warning:H,tip:q};function Qt({controller:t,issues:e}){return r("section",{class:"fst-setup","aria-label":"Setup check",children:[r("div",{class:"fst-setup-head",children:[r("strong",{children:"Setup check"}),r("button",{class:"fst-icon-btn","aria-label":"Close setup check",onClick:()=>t.toggleSetup(),children:r(le,{})})]}),e.filter(s=>s.level!=="tip").length===0&&r("p",{class:"fst-setup-ok",children:[r(G,{})," No problems found with how this page uses Flagsmith."]}),r("ul",{class:"fst-issues",children:e.map(s=>{let n=ln[s.level];return r("li",{class:`fst-issue fst-issue--${s.level}`,children:[r(n,{}),r("div",{children:[r("strong",{children:s.title}),r("p",{children:s.detail}),s.fix&&r("pre",{class:"fst-pre",children:s.fix})]})]},s.id)})})]})}function es({controller:t,state:e}){let[s,n]=C(""),[a,o]=C(""),[i,l]=C(""),[c,d]=C(""),p=Object.keys(e.overrides).length,g=[e.persona?`viewing as ${e.persona.name}`:"",p?`${p} changed flag${p===1?"":"s"}`:""].filter(Boolean).join(" and ")||"no changes yet, so it opens the page as normal";return r("div",{class:"fst-stack",children:[r("section",{class:"fst-card",children:[r("div",{class:"fst-card-title",children:[r(Lt,{})," Share this preview"]}),r("p",{children:["Copy a link that opens this page with the same user and flag changes (",g,"). Anyone who opens it with the toolbar enabled sees exactly what you see."]}),r("button",{class:"fst-btn fst-btn--primary",onClick:async()=>{let m=t.previewUrl();n(m),o(await J(m)?"Link copied":"Copy the link below")},children:"Copy preview link"}),a&&r("span",{class:"fst-status",children:a}),s&&r("p",{children:r("input",{class:"fst-input fst-mono",readOnly:!0,value:s,"aria-label":"Preview link",onFocus:m=>m.currentTarget.select()})})]}),r("section",{class:"fst-card",children:[r("div",{class:"fst-card-title",children:[r(jt,{})," Report a bug"]}),r("p",{children:"Copy every flag on this page, its value and why it has it, as a Markdown table for a GitHub issue or Jira ticket."}),r("button",{class:"fst-btn fst-btn--primary",onClick:async()=>{let m=t.bugReport();l(m),d(await J(m)?"Copied as Markdown":"Copy the text below")},children:"Copy bug report"}),c&&r("span",{class:"fst-status",children:c}),i&&r("pre",{class:"fst-pre",children:i})]})]})}function ts({controller:t,state:e}){let s=t.options.personas??[],n=t.flagsmith.identity,a=e.personaStatus==="loading";return r("div",{class:"fst-stack",children:[r("div",{class:"fst-card",children:[r("div",{class:"fst-muted",children:"Viewing the page as"}),r("div",{class:"fst-current-name",children:e.persona?.name??(n?`Identity ${n}`:"Yourself (anonymous visitor)")}),a&&r("p",{class:"fst-muted",children:"Asking Flagsmith for this user's flags\u2026"}),e.personaError&&r("p",{class:"fst-error",children:e.personaError}),e.persona&&r("p",{children:r("button",{class:"fst-btn",disabled:a,onClick:()=>{t.backToMe()},children:"Back to my view"})})]}),s.length>0&&r("div",{class:"fst-section-title",children:"Ready-made users"}),s.length>0&&r("ul",{class:"fst-personas",children:s.map(o=>r(pn,{controller:t,persona:o,active:e.persona?.name===o.name,disabled:a}))}),r("div",{class:"fst-section-title",children:"Any user"}),r(fn,{controller:t,disabled:a}),r("p",{class:"fst-note",children:"Flagsmith works out each user's flags live, with its real segments and splits. Users without an identity are transient, so Flagsmith saves nothing."})]})}function pn({controller:t,persona:e,active:s,disabled:n}){let a=Object.entries(e.traits??{});return r("li",{class:`fst-persona${s?" is-active":""}`,children:[r("div",{children:[r("div",{class:"fst-persona-name",children:e.name}),e.description&&r("div",{class:"fst-muted",children:e.description}),(e.identifier||a.length>0)&&r("div",{class:"fst-chips",children:[e.identifier&&r("span",{class:"fst-chip fst-chip--identity",children:["identity: ",e.identifier]}),a.map(([o,i])=>r("span",{class:"fst-chip",children:[o,": ",String(i)]}))]})]}),r("button",{class:`fst-btn${s?"":" fst-btn--primary"}`,disabled:s||n,onClick:()=>{t.viewAs(e)},children:s?"Viewing":"View as"})]})}function fn({controller:t,disabled:e}){let[s,n]=C(""),[a,o]=C(`country=IN
3
+ plan=pro`);return r("form",{class:"fst-card fst-form",onSubmit:i=>{i.preventDefault();let l=Ke(a),c=s.trim(),d=Object.entries(l).map(([p,g])=>`${p}=${g}`).join(", ");t.viewAs({name:c||(d?`Custom user (${d})`:"Custom user"),...c?{identifier:c}:{},traits:l})},children:[r("div",{children:[r("label",{class:"fst-label",for:"fst-identifier",children:"Identity (optional, uses that user's overrides)"}),r("input",{id:"fst-identifier",class:"fst-input",placeholder:"e.g. asha-beta-tester",value:s,onInput:i=>n(i.currentTarget.value)})]}),r("div",{children:[r("label",{class:"fst-label",for:"fst-traits",children:"Traits, one per line as key=value"}),r("textarea",{id:"fst-traits",class:"fst-input fst-mono",rows:3,value:a,onInput:i=>o(i.currentTarget.value)})]}),r("div",{children:r("button",{class:"fst-btn fst-btn--primary",type:"submit",disabled:e,children:"View as this user"})})]})}var cn=t=>t.length>10?`${t.slice(0,6)}\u2026`:t,ss=900,dn="424px";function un(t,e){let{layout:s,position:n}=t.options;P(()=>{let a=document.documentElement;if(a.dataset.flagsmithToolbar=e?"open":"closed",s!=="push"||!e)return;let o=n==="left"?"padding-left":"padding-right",i=a.style.getPropertyValue(o),l=()=>i?a.style.setProperty(o,i):a.style.removeProperty(o),c=()=>window.innerWidth>=ss?a.style.setProperty(o,dn):l();return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c),l()}},[e,s,n]),P(()=>()=>{delete document.documentElement.dataset.flagsmithToolbar},[])}function ns({controller:t}){let e=Xt(t.store),s=D(e.open),n=e.open&&!s.current;s.current=e.open;let a=Object.keys(e.overrides).length,o=!!e.persona||a>0;un(t,e.open);let i=t.options.layout==="push"&&e.open&&window.innerWidth>=ss;return r("div",{class:`fst${t.options.position==="left"?" fst--left":""}${i?" fst--pushed":""}`,children:[o&&r(hn,{controller:t,state:e,changed:a}),e.open?r(vn,{controller:t,state:e,focusOnOpen:n}):r(gn,{controller:t,changed:a})]})}function gn({controller:t,changed:e}){return r("button",{class:"fst-launcher",onClick:()=>t.open(),title:`Flagsmith Toolbar (${pe(t.options.hotkey)})`,"aria-label":"Flags: open Flagsmith Toolbar",children:[r(Le,{}),r("span",{children:"Flags"}),e>0&&r("span",{class:"fst-badge","aria-label":`${e} changed`,children:e})]})}function hn({controller:t,state:e,changed:s}){let n=[];return e.persona&&n.push(`Viewing as ${e.persona.name}`),s&&n.push(`${s} flag${s===1?"":"s"} changed`),r("div",{class:"fst-banner",role:"status",children:[r("span",{class:"fst-banner-tag",children:e.sharedPreview?"Shared preview":"Preview"}),r("span",{class:"fst-banner-text",children:n.join(" \xB7 ")}),r("span",{class:"fst-banner-muted",children:"Only you see this"}),r("button",{class:"fst-banner-btn",onClick:()=>{t.exitPreview()},children:"Exit preview"})]})}var mn={idle:"",loading:"Getting the latest flags from Flagsmith\u2026",updated:"Updated: the highlighted flags changed in Flagsmith.",unchanged:"Up to date: nothing changed in Flagsmith.",error:"Couldn't reach Flagsmith. Try again in a moment."};function vn({controller:t,state:e,focusOnOpen:s}){let n=D(null);P(()=>{s&&n.current?.focus({preventScroll:!0})},[]);let a=t.connection(),o=t.effectiveFlags(),i=Object.keys(o).length,l=t.setupIssues(),c=t.experiments().some(p=>p.state==="missing"||p.state==="events-off"),d=[["flags",i?`Flags (${i})`:"Flags",!1],["viewas","View as",!1],["compare","Compare",!1],["share","Share",!1],["experiments","Experiments",c]];return r("section",{ref:n,class:"fst-panel",role:"dialog","aria-label":"Flagsmith Toolbar",tabIndex:-1,onKeyDown:p=>{p.key==="Escape"&&t.close()},onPointerDown:p=>{p.target.closest("input, textarea, select, [contenteditable]")||n.current?.focus({preventScroll:!0})},children:[r("header",{class:"fst-header",children:[r("div",{class:"fst-title",children:[r(Le,{}),r("span",{children:"Flagsmith Toolbar"})]}),r("div",{class:"fst-header-actions",children:[i>0&&r(Zt,{controller:t,issues:l,open:e.setupOpen}),t.flagsmith.getFlags&&r("button",{class:`fst-icon-btn${e.refreshStatus==="loading"?" is-spinning":""}`,"aria-label":"Get the latest flags from Flagsmith",title:"Get the latest flags from Flagsmith",disabled:e.refreshStatus==="loading",onClick:()=>{t.refresh()},children:r(Nt,{})}),r("button",{class:"fst-icon-btn","aria-label":"Close toolbar",title:`Close (${pe(t.options.hotkey)})`,onClick:()=>t.close(),children:r(le,{})})]})]}),r("div",{class:"fst-connection",title:a.apiUrl??"Not connected yet",children:[r("span",{class:`fst-dot${i?" fst-dot--ok":""}`}),r("span",{children:[a.selfHosted?"Self-hosted Flagsmith":"Flagsmith",a.host?` \xB7 ${a.host}`:""]}),a.environmentKey&&r("code",{class:"fst-env",title:`Environment key ${a.environmentKey}`,children:cn(a.environmentKey)})]}),e.refreshStatus!=="idle"&&r("p",{class:`fst-refresh fst-refresh--${e.refreshStatus}`,role:"status",children:mn[e.refreshStatus]}),r("nav",{class:"fst-tabs",role:"tablist","aria-label":"Toolbar sections",children:d.map(([p,g,m])=>r("button",{role:"tab","aria-selected":e.tab===p,class:`fst-tab${e.tab===p?" is-active":""}`,onClick:()=>t.setTab(p),children:[g,m&&r("span",{class:"fst-tab-dot","aria-label":"needs attention"})]}))}),r("div",{class:"fst-body",children:[e.setupOpen&&r(Qt,{controller:t,issues:l}),e.tab==="flags"&&r(Yt,{controller:t,state:e,flags:o}),e.tab==="viewas"&&r(ts,{controller:t,state:e}),e.tab==="compare"&&r(Kt,{controller:t,state:e}),e.tab==="share"&&r(es,{controller:t,state:e}),e.tab==="experiments"&&r(Wt,{controller:t,state:e})]}),r("footer",{class:"fst-footer",children:[r("span",{children:[pe(t.options.hotkey).split("+").map((p,g)=>r(S,{children:[g>0&&"+",r("kbd",{children:p})]}))," ","opens and closes"]}),r("a",{href:"https://github.com/YashSoni998265/flagsmith-toolbar",target:"_blank",rel:"noreferrer",children:"flagsmith-toolbar"})]})]})}var Ne=`
4
+ :host { all: initial; }
5
+
6
+ .fst {
7
+ --fst-bg: #ffffff;
8
+ --fst-surface: #f7f6fb;
9
+ --fst-hover: #f0eef8;
10
+ --fst-border: #e6e3f0;
11
+ --fst-text: #1a1822;
12
+ --fst-muted: #6b6780;
13
+ --fst-accent: #6837fc;
14
+ --fst-accent-ink: #ffffff;
15
+ --fst-accent-soft: #efe9ff;
16
+ --fst-green: #077348;
17
+ --fst-green-soft: #e2f5ec;
18
+ --fst-amber: #9a5b00;
19
+ --fst-amber-soft: #fff2dc;
20
+ --fst-blue: #1b64c9;
21
+ --fst-blue-soft: #e6f0ff;
22
+ --fst-pink: #b0287b;
23
+ --fst-pink-soft: #fbe6f3;
24
+ --fst-red: #b0262b;
25
+ --fst-red-soft: #fde8e8;
26
+ --fst-shadow: 0 24px 60px rgba(24, 16, 52, 0.18), 0 2px 10px rgba(24, 16, 52, 0.08);
27
+ font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
28
+ font-size: 13px;
29
+ line-height: 1.45;
30
+ color: var(--fst-text);
31
+ -webkit-font-smoothing: antialiased;
32
+ }
33
+
34
+ @media (prefers-color-scheme: dark) {
35
+ .fst {
36
+ --fst-bg: #17161e;
37
+ --fst-surface: #1f1e28;
38
+ --fst-hover: #262532;
39
+ --fst-border: #302e3d;
40
+ --fst-text: #f2f1f7;
41
+ --fst-muted: #a19eb5;
42
+ --fst-accent: #9b7dff;
43
+ --fst-accent-ink: #120f1c;
44
+ --fst-accent-soft: #2a2342;
45
+ --fst-green: #43d19c;
46
+ --fst-green-soft: #12291f;
47
+ --fst-amber: #f3b660;
48
+ --fst-amber-soft: #2e2413;
49
+ --fst-blue: #74adff;
50
+ --fst-blue-soft: #15233a;
51
+ --fst-pink: #f58bcb;
52
+ --fst-pink-soft: #33182a;
53
+ --fst-red: #ff8084;
54
+ --fst-red-soft: #331a1c;
55
+ --fst-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
56
+ }
57
+ }
58
+
59
+ *, *::before, *::after { box-sizing: border-box; }
60
+ button, input, textarea { font: inherit; color: inherit; margin: 0; }
61
+ button { cursor: pointer; }
62
+ code, kbd, pre, .fst-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
63
+ a { color: var(--fst-accent); }
64
+ :focus-visible { outline: 2px solid var(--fst-accent); outline-offset: 2px; }
65
+
66
+ /* Launcher ---------------------------------------------------------------- */
67
+ .fst-launcher {
68
+ position: fixed; bottom: 20px; right: 20px;
69
+ display: inline-flex; align-items: center; gap: 8px;
70
+ padding: 10px 14px 10px 12px; border: 0; border-radius: 999px;
71
+ background: var(--fst-accent); color: var(--fst-accent-ink);
72
+ font-weight: 600; font-size: 13px; box-shadow: var(--fst-shadow);
73
+ transition: transform 120ms ease;
74
+ }
75
+ .fst--left .fst-launcher { right: auto; left: 20px; }
76
+ .fst-launcher:hover { transform: translateY(-1px); }
77
+ .fst-launcher svg { width: 16px; height: 16px; }
78
+ .fst-badge {
79
+ min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
80
+ display: inline-flex; align-items: center; justify-content: center;
81
+ background: #ffffff; color: #6837fc; font-size: 11px; font-weight: 700;
82
+ }
83
+
84
+ /* Preview banner ------------------------------------------------------------ */
85
+ .fst-banner {
86
+ position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
87
+ display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px);
88
+ padding: 6px 6px 6px 8px; border-radius: 999px;
89
+ background: #1a1822; color: #ffffff; font-size: 12.5px;
90
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); white-space: nowrap;
91
+ }
92
+ /* In push mode the page is narrower, so centre the banner on the page, not the window. */
93
+ .fst--pushed .fst-banner { left: calc((100vw - 424px) / 2); }
94
+ .fst--pushed.fst--left .fst-banner { left: calc(424px + (100vw - 424px) / 2); }
95
+ .fst-banner-tag {
96
+ padding: 2px 8px; border-radius: 999px; background: #6837fc; color: #fff;
97
+ font-weight: 700; font-size: 11px; letter-spacing: 0.02em; text-transform: uppercase;
98
+ }
99
+ .fst-banner-text { overflow: hidden; text-overflow: ellipsis; }
100
+ .fst-banner-muted { color: #b9b4cc; }
101
+ .fst-banner-btn {
102
+ border: 0; border-radius: 999px; padding: 5px 10px;
103
+ background: #ffffff; color: #1a1822; font-weight: 600; font-size: 12px;
104
+ }
105
+
106
+ /* Panel --------------------------------------------------------------------- */
107
+ .fst-panel {
108
+ position: fixed; top: 12px; right: 12px; bottom: 12px;
109
+ width: 400px; max-width: calc(100vw - 24px);
110
+ display: flex; flex-direction: column;
111
+ background: var(--fst-bg); border: 1px solid var(--fst-border); border-radius: 16px;
112
+ box-shadow: var(--fst-shadow); overflow: hidden;
113
+ }
114
+ .fst--left .fst-panel { right: auto; left: 12px; }
115
+ .fst-panel:focus { outline: none; }
116
+ .fst-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 6px 16px; }
117
+ .fst-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
118
+ .fst-title svg { width: 18px; height: 18px; color: var(--fst-accent); }
119
+ .fst-icon-btn {
120
+ display: inline-flex; align-items: center; justify-content: center;
121
+ width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--fst-muted);
122
+ }
123
+ .fst-icon-btn:hover { background: var(--fst-hover); color: var(--fst-text); }
124
+ .fst-icon-btn:disabled { cursor: default; }
125
+ .fst-icon-btn svg { width: 16px; height: 16px; }
126
+ .fst-icon-btn.is-spinning svg { animation: fst-spin 800ms linear infinite; }
127
+ .fst-header-actions { display: flex; align-items: center; gap: 2px; }
128
+ .fst-setup-chip {
129
+ display: inline-flex; align-items: center; gap: 4px; margin-right: 4px; padding: 3px 8px;
130
+ border: 0; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
131
+ }
132
+ .fst-setup-chip svg { width: 12px; height: 12px; }
133
+ .fst-setup-chip--ok { background: var(--fst-green-soft); color: var(--fst-green); }
134
+ .fst-setup-chip--warning { background: var(--fst-amber-soft); color: var(--fst-amber); }
135
+ .fst-setup-chip--problem { background: var(--fst-red-soft); color: var(--fst-red); }
136
+ .fst-refresh { margin: 0; padding: 6px 16px; font-size: 12px; font-weight: 600; }
137
+ .fst-refresh--loading { color: var(--fst-muted); }
138
+ .fst-refresh--updated { background: var(--fst-blue-soft); color: var(--fst-blue); }
139
+ .fst-refresh--unchanged { background: var(--fst-green-soft); color: var(--fst-green); }
140
+ .fst-refresh--error { background: var(--fst-red-soft); color: var(--fst-red); }
141
+ .fst-connection {
142
+ display: flex; align-items: center; gap: 8px; padding: 0 16px 10px;
143
+ color: var(--fst-muted); font-size: 12px; min-width: 0;
144
+ }
145
+ .fst-connection > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
146
+ .fst-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fst-muted); flex: none; }
147
+ .fst-dot--ok { background: var(--fst-green); box-shadow: 0 0 0 3px var(--fst-green-soft); }
148
+ .fst-env { margin-left: auto; padding: 1px 6px; border-radius: 6px; background: var(--fst-surface); color: var(--fst-muted); flex: none; }
149
+ .fst-tabs {
150
+ display: flex; gap: 0; padding: 0 8px; border-bottom: 1px solid var(--fst-border);
151
+ overflow-x: auto; scrollbar-width: none;
152
+ }
153
+ .fst-tabs::-webkit-scrollbar { display: none; }
154
+ .fst-tab {
155
+ position: relative; flex: none; padding: 9px 7px 10px; border: 0; background: transparent;
156
+ color: var(--fst-muted); font-weight: 600; font-size: 12.5px; white-space: nowrap;
157
+ }
158
+ .fst-tab-dot {
159
+ display: inline-block; width: 6px; height: 6px; margin-left: 4px; border-radius: 50%;
160
+ background: var(--fst-amber); vertical-align: middle;
161
+ }
162
+ .fst-tab:hover { color: var(--fst-text); }
163
+ .fst-tab.is-active { color: var(--fst-accent); }
164
+ .fst-tab.is-active::after {
165
+ content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px;
166
+ border-radius: 2px; background: var(--fst-accent);
167
+ }
168
+ .fst-body { flex: 1; overflow-y: auto; padding: 12px; }
169
+ .fst-footer {
170
+ display: flex; justify-content: space-between; gap: 8px; padding: 8px 14px;
171
+ border-top: 1px solid var(--fst-border); color: var(--fst-muted); font-size: 11.5px;
172
+ }
173
+ .fst-footer a { color: var(--fst-muted); }
174
+ kbd {
175
+ display: inline-block; padding: 0 5px; border: 1px solid var(--fst-border); border-bottom-width: 2px;
176
+ border-radius: 5px; background: var(--fst-surface); font-size: 11px;
177
+ }
178
+
179
+ /* Shared pieces ------------------------------------------------------------- */
180
+ .fst-stack { display: flex; flex-direction: column; gap: 10px; }
181
+ .fst-muted { color: var(--fst-muted); }
182
+ .fst-note { margin: 0; color: var(--fst-muted); font-size: 12px; }
183
+ .fst-error { margin: 0; color: var(--fst-red); }
184
+ .fst-section-title { margin: 4px 2px 0; color: var(--fst-muted); font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
185
+ .fst-card { padding: 12px; border: 1px solid var(--fst-border); border-radius: 12px; background: var(--fst-bg); }
186
+ .fst-card p { margin: 6px 0 10px; color: var(--fst-muted); }
187
+ .fst-card-title { display: flex; align-items: center; gap: 6px; font-weight: 700; }
188
+ .fst-card-title svg { width: 15px; height: 15px; color: var(--fst-accent); }
189
+ .fst-btn {
190
+ display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
191
+ border: 1px solid var(--fst-border); border-radius: 8px; background: var(--fst-bg);
192
+ font-weight: 600; font-size: 12.5px; text-decoration: none; color: var(--fst-text);
193
+ }
194
+ .fst-btn:hover { background: var(--fst-hover); }
195
+ .fst-btn:disabled { opacity: 0.55; cursor: default; }
196
+ .fst-btn svg { width: 13px; height: 13px; }
197
+ .fst-btn--primary { border-color: var(--fst-accent); background: var(--fst-accent); color: var(--fst-accent-ink); }
198
+ .fst-btn--primary:hover { background: var(--fst-accent); filter: brightness(1.08); }
199
+ .fst-link-btn { padding: 0; border: 0; background: none; color: var(--fst-accent); font-weight: 600; font-size: 12.5px; }
200
+ .fst-link-btn:hover { text-decoration: underline; }
201
+ .fst-status { margin-left: 8px; color: var(--fst-green); font-weight: 600; font-size: 12px; }
202
+ .fst-input {
203
+ width: 100%; padding: 7px 10px; border: 1px solid var(--fst-border); border-radius: 8px;
204
+ background: var(--fst-bg); font-size: 12.5px;
205
+ }
206
+ .fst-input:focus { outline: none; border-color: var(--fst-accent); box-shadow: 0 0 0 3px var(--fst-accent-soft); }
207
+ textarea.fst-input { resize: vertical; min-height: 64px; }
208
+ .fst-label { display: block; margin-bottom: 4px; color: var(--fst-muted); font-size: 12px; font-weight: 600; }
209
+ .fst-pre {
210
+ max-height: 220px; margin: 10px 0 0; padding: 10px; overflow: auto; border-radius: 8px;
211
+ background: var(--fst-surface); white-space: pre-wrap; word-break: break-word; font-size: 11.5px;
212
+ }
213
+ .fst-empty { padding: 18px 8px; color: var(--fst-muted); text-align: center; }
214
+ .fst-empty p { margin: 0 0 6px; }
215
+ .fst-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
216
+ .fst-chip {
217
+ display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px;
218
+ background: var(--fst-surface); color: var(--fst-muted); font-size: 11.5px; font-weight: 600;
219
+ }
220
+ .fst-chip--identity { background: var(--fst-pink-soft); color: var(--fst-pink); }
221
+ .fst-chip--exposure { background: var(--fst-blue-soft); color: var(--fst-blue); }
222
+ .fst-chip--event { background: var(--fst-green-soft); color: var(--fst-green); }
223
+ .fst-spinner {
224
+ width: 12px; height: 12px; border-radius: 50%; flex: none;
225
+ border: 2px solid var(--fst-accent-soft); border-top-color: var(--fst-accent);
226
+ animation: fst-spin 700ms linear infinite;
227
+ }
228
+ @keyframes fst-spin { to { transform: rotate(360deg); } }
229
+
230
+ /* Welcome and "viewing as" ------------------------------------------------- */
231
+ .fst-welcome { padding: 12px; border-radius: 12px; background: var(--fst-accent-soft); }
232
+ .fst-welcome-title { display: block; margin-bottom: 6px; }
233
+ .fst-welcome ol { margin: 0 0 8px; padding-left: 18px; }
234
+ .fst-welcome li { margin: 3px 0; }
235
+ .fst-welcome-note { margin: 0 0 10px; color: var(--fst-muted); font-size: 12px; }
236
+ .fst-viewing {
237
+ display: flex; align-items: center; gap: 8px; padding: 8px 10px;
238
+ border-radius: 10px; background: var(--fst-surface); font-size: 12.5px;
239
+ }
240
+ .fst-viewing svg { width: 14px; height: 14px; color: var(--fst-muted); flex: none; }
241
+ .fst-viewing > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
242
+
243
+ /* Flags list ---------------------------------------------------------------- */
244
+ .fst-search { padding-left: 10px; }
245
+ .fst-segmented { display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: var(--fst-surface); }
246
+ .fst-segment {
247
+ flex: 1; padding: 5px 6px; border: 0; border-radius: 8px; background: transparent;
248
+ color: var(--fst-muted); font-weight: 600; font-size: 12px; white-space: nowrap;
249
+ }
250
+ .fst-segment.is-active { background: var(--fst-bg); color: var(--fst-text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
251
+ .fst-segment-count { margin-left: 4px; color: var(--fst-muted); font-weight: 500; }
252
+ .fst-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
253
+ .fst-flag { border: 1px solid var(--fst-border); border-radius: 12px; background: var(--fst-bg); transition: border-color 120ms ease; }
254
+ .fst-flag:hover { border-color: color-mix(in srgb, var(--fst-accent) 35%, var(--fst-border)); }
255
+ .fst-flag.is-changed { border-color: var(--fst-amber); box-shadow: inset 3px 0 0 var(--fst-amber); }
256
+ .fst-flag.is-fresh { border-color: var(--fst-blue); animation: fst-flash 1.2s ease-out 2; }
257
+ @keyframes fst-flash { 0% { background: var(--fst-blue-soft); } 100% { background: var(--fst-bg); } }
258
+ .fst-fresh {
259
+ flex: none; padding: 0 6px; border-radius: 999px; background: var(--fst-blue-soft); color: var(--fst-blue);
260
+ font-size: 10.5px; font-weight: 700; font-family: inherit;
261
+ }
262
+ .fst-flag-main { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 12px; }
263
+ .fst-flag-summary {
264
+ flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 0;
265
+ border: 0; background: none; text-align: left;
266
+ }
267
+ .fst-flag-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 600; }
268
+ .fst-flag-name code { min-width: 0; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
269
+ .fst-used { width: 6px; height: 6px; border-radius: 50%; background: var(--fst-accent); flex: none; }
270
+ .fst-type {
271
+ flex: none; margin-left: auto; padding: 0 5px; border: 1px solid var(--fst-border); border-radius: 5px;
272
+ color: var(--fst-muted); font-size: 10.5px; font-weight: 600; line-height: 16px;
273
+ }
274
+ .fst-group { display: flex; flex-direction: column; gap: 6px; }
275
+ .fst-group-title { display: flex; align-items: center; gap: 6px; margin: 2px 2px 0; }
276
+ .fst-group-count { color: var(--fst-muted); font-weight: 500; letter-spacing: 0; }
277
+ .fst-pages code { padding: 0 4px; border-radius: 4px; background: var(--fst-surface); }
278
+ .fst-flag-meta { display: flex; align-items: center; gap: 6px; min-width: 0; }
279
+ .fst-flag-value { color: var(--fst-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
280
+ .fst-reason {
281
+ flex: none; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
282
+ padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600;
283
+ background: var(--fst-surface); color: var(--fst-muted);
284
+ }
285
+ .fst-reason--segment { background: var(--fst-blue-soft); color: var(--fst-blue); }
286
+ .fst-reason--identity { background: var(--fst-pink-soft); color: var(--fst-pink); }
287
+ .fst-reason--split { background: var(--fst-green-soft); color: var(--fst-green); }
288
+ .fst-reason--experiment { background: var(--fst-accent-soft); color: var(--fst-accent); }
289
+ .fst-reason--override { background: var(--fst-amber-soft); color: var(--fst-amber); }
290
+ .fst-reason--error { background: var(--fst-red-soft); color: var(--fst-red); }
291
+ .fst-details { padding: 0 12px 12px; border-top: 1px dashed var(--fst-border); }
292
+ .fst-details p { margin: 10px 0 0; }
293
+ .fst-raw code { padding: 1px 6px; border-radius: 6px; background: var(--fst-surface); color: var(--fst-muted); }
294
+ .fst-value { margin-top: 12px; }
295
+ .fst-value-row { display: flex; gap: 6px; }
296
+ .fst-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
297
+
298
+ /* Switch -------------------------------------------------------------------- */
299
+ .fst-switch {
300
+ position: relative; flex: none; width: 34px; height: 20px; padding: 0; border: 0; border-radius: 999px;
301
+ background: var(--fst-border); transition: background 120ms ease;
302
+ }
303
+ .fst-switch.is-on { background: var(--fst-green); }
304
+ .fst-switch-thumb {
305
+ position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
306
+ background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 120ms ease;
307
+ }
308
+ .fst-switch.is-on .fst-switch-thumb { transform: translateX(14px); }
309
+
310
+ /* View as -------------------------------------------------------------------- */
311
+ .fst-current-name { margin-top: 4px; font-size: 15px; font-weight: 700; }
312
+ .fst-personas { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
313
+ .fst-persona {
314
+ display: flex; align-items: center; justify-content: space-between; gap: 10px;
315
+ padding: 10px 12px; border: 1px solid var(--fst-border); border-radius: 12px;
316
+ }
317
+ .fst-persona.is-active { border-color: var(--fst-accent); background: var(--fst-accent-soft); }
318
+ .fst-persona > div { min-width: 0; }
319
+ .fst-persona > .fst-btn { flex: none; white-space: nowrap; }
320
+ .fst-persona-name { font-weight: 700; }
321
+ .fst-form { display: flex; flex-direction: column; gap: 8px; }
322
+
323
+ /* Events -------------------------------------------------------------------- */
324
+ .fst-events { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
325
+ .fst-event {
326
+ display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
327
+ padding: 8px 10px; border: 1px solid var(--fst-border); border-radius: 10px;
328
+ }
329
+ .fst-event-meta { width: 100%; color: var(--fst-muted); font-size: 11.5px; }
330
+
331
+ .fst-event.is-unsent { border-style: dashed; }
332
+
333
+ /* Setup check ------------------------------------------------------------------- */
334
+ .fst-setup { margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--fst-border); border-radius: 12px; background: var(--fst-surface); }
335
+ .fst-setup-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
336
+ .fst-setup-ok { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; color: var(--fst-green); font-weight: 600; }
337
+ .fst-setup-ok svg { width: 14px; height: 14px; }
338
+ .fst-issues { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
339
+ .fst-issue { display: flex; gap: 8px; align-items: flex-start; }
340
+ .fst-issue > svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }
341
+ .fst-issue p { margin: 2px 0 0; color: var(--fst-muted); }
342
+ .fst-issue .fst-pre { margin-top: 6px; }
343
+ .fst-issue--problem > svg { color: var(--fst-red); }
344
+ .fst-issue--warning > svg { color: var(--fst-amber); }
345
+ .fst-issue--tip > svg { color: var(--fst-muted); }
346
+
347
+ /* Compare ----------------------------------------------------------------------- */
348
+ .fst-compare-pick { display: flex; align-items: flex-end; gap: 6px; }
349
+ .fst-picker { flex: 1; min-width: 0; }
350
+ .fst-select { appearance: auto; padding: 6px 8px; text-overflow: ellipsis; }
351
+ .fst-swap { flex: none; margin-bottom: 2px; }
352
+ .fst-loading { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--fst-muted); }
353
+ .fst-compare-summary { margin: 2px 2px 0; }
354
+ .fst-compare-row { padding: 8px 12px 10px; }
355
+ .fst-compare-key { margin-bottom: 6px; font-weight: 600; }
356
+ .fst-compare-key code { font-size: 12.5px; }
357
+ .fst-side { display: grid; grid-template-columns: 92px 30px minmax(0, 1fr); align-items: center; gap: 4px 6px; padding: 3px 0; }
358
+ .fst-side .fst-reason { grid-column: 2 / 4; justify-self: start; max-width: 100%; }
359
+ .fst-side-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fst-muted); font-size: 12px; font-weight: 600; }
360
+ .fst-side-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
361
+ .fst-state { padding: 0 5px; border-radius: 6px; background: var(--fst-surface); color: var(--fst-muted); font-size: 11px; font-weight: 700; text-align: center; }
362
+ .fst-state.is-on { background: var(--fst-green-soft); color: var(--fst-green); }
363
+ .fst-same summary { cursor: pointer; color: var(--fst-muted); font-weight: 600; font-size: 12.5px; }
364
+
365
+ /* Experiments --------------------------------------------------------------------- */
366
+ .fst-callout {
367
+ display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 10px;
368
+ background: var(--fst-blue-soft); color: var(--fst-blue); font-size: 12.5px;
369
+ }
370
+ .fst-callout svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
371
+ .fst-exp { padding: 10px 12px; border: 1px solid var(--fst-border); border-radius: 12px; }
372
+ .fst-exp--good { border-color: color-mix(in srgb, var(--fst-green) 45%, var(--fst-border)); }
373
+ .fst-exp--bad { border-color: var(--fst-amber); box-shadow: inset 3px 0 0 var(--fst-amber); }
374
+ .fst-exp-head { display: flex; align-items: center; gap: 6px; }
375
+ .fst-exp-head svg { width: 15px; height: 15px; color: var(--fst-accent); }
376
+ .fst-exp-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; color: var(--fst-muted); }
377
+ .fst-exp-status { display: flex; gap: 6px; align-items: flex-start; margin: 8px 0 0; }
378
+ .fst-exp-status svg { width: 14px; height: 14px; flex: none; margin-top: 2px; }
379
+ .fst-exp--good .fst-exp-status svg { color: var(--fst-green); }
380
+ .fst-exp--bad .fst-exp-status svg { color: var(--fst-amber); }
381
+ .fst-exp--neutral .fst-exp-status svg { color: var(--fst-muted); }
382
+
383
+ /* Small screens ----------------------------------------------------------------- */
384
+ @media (max-width: 560px) {
385
+ .fst-panel, .fst--left .fst-panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: 80vh; }
386
+ .fst-banner { top: 8px; bottom: auto; }
387
+ .fst-banner-muted { display: none; }
388
+ .fst-flag-value { max-width: 110px; }
389
+ }
390
+ `;function rs(t){let e=document.createElement("div");e.setAttribute("data-flagsmith-toolbar",""),e.style.cssText="position:fixed;top:0;left:0;width:0;height:0;z-index:2147483000;";let s=e.attachShadow({mode:"open"});bn(s);let n=document.createElement("div");return s.append(n),document.body.appendChild(e),Re(r(ns,{controller:t}),n),{unmount(){Re(null,n),e.remove()}}}function bn(t){try{if("adoptedStyleSheets"in t&&"replaceSync"in CSSStyleSheet.prototype){let s=new CSSStyleSheet;s.replaceSync(Ne),t.adoptedStyleSheets=[s];return}}catch{}let e=document.createElement("style");e.textContent=Ne,t.append(e)}var _n=50,yn=6e3;function wn(t){let e=t.toLowerCase().split("+").map(n=>n.trim()).filter(Boolean);return{key:e.pop()??"",shift:e.includes("shift"),alt:e.includes("alt")||e.includes("option"),ctrl:e.includes("ctrl")||e.includes("control"),meta:e.includes("meta")||e.includes("cmd")}}function pe(t){return t.split("+").map(e=>e.trim()).map(e=>e.length===1?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1)).join("+")}var Ue=t=>t instanceof Error?t.message:String(t),fe=class{constructor(e,s={}){this.flagsmith=e;this.appContext=null;this.pendingReads={};this.lastSaved="";this.eventId=0;this.cleanups=[];this.destroyed=!1;this.lastFlagsFor=null;this.flagsSince=0;this.ownContextChanges=0;this.clockTimer=null;this.highlightTimer=null;this.statusTimer=null;this.compareRun=0;this.options={hotkey:"shift+f",position:"right",storageKey:"flagsmith-toolbar",layout:"overlay",...s};let n=it(this.options.storageKey),a=nt(window.location.href);a&&window.history.replaceState(window.history.state,"",rt(window.location.href)),this.store=new Z({open:a?!0:s.open??n.open??!1,tab:n.tab??"flags",filter:"all",search:"",expanded:null,serverFlags:{},page:xe(window.location),reads:{},seenOn:{},overrides:a?a.overrides:n.overrides??{},persona:a?a.persona:n.persona??null,personaStatus:"idle",personaError:null,events:[],exposures:{},welcomeDismissed:n.welcomeDismissed??!1,sharedPreview:!!a,setupOpen:!1,changedInFlagsmith:{},refreshStatus:"idle",compareA:"page",compareB:s.personas?.length?"persona:0":"anonymous",compareStatus:"idle",compareError:null,compareResult:null,clock:Date.now()}),this.instrumentation=Qe(e,{onServerFlags:o=>this.receiveServerFlags(o),onRead:o=>this.recordRead(o),onEvent:o=>this.recordEvent(o),holdBack:()=>this.isPreviewing(),onAppContextChange:()=>this.onAppContextChange(),isOwnContextChange:()=>this.ownContextChanges>0}),this.instrumentation.setOverrides(this.store.get().overrides),this.lastFlagsFor=this.currentIdentity(),this.flagsSince=Date.now(),this.store.set({serverFlags:{...this.instrumentation.serverFlags()}}),this.cleanups.push(this.store.subscribe(()=>this.saveIfChanged())),this.cleanups.push(et(()=>this.onNavigate()))}start(){let e=()=>{if(this.destroyed)return;let n=rs(this);this.cleanups.push(n.unmount)};document.body?e():document.addEventListener("DOMContentLoaded",e,{once:!0}),this.cleanups.push(this.listenForHotkey());let s=this.store.get().persona;s&&this.whenInitialised().then(n=>{n&&!this.destroyed&&this.applyPersona(s)})}open(){this.store.set({open:!0})}close(){this.store.set({open:!1})}toggle(){this.store.set(e=>({open:!e.open}))}setTab(e){this.store.set({tab:e})}setFilter(e){this.store.set({filter:e})}setSearch(e){this.store.set({search:e})}toggleExpanded(e){this.store.set(s=>({expanded:s.expanded===e?null:e}))}dismissWelcome(){this.store.set({welcomeDismissed:!0})}toggleSetup(){this.store.set(e=>({setupOpen:!e.setupOpen}))}isPreviewing(){let{persona:e,overrides:s}=this.store.get();return!!e||Object.keys(s).length>0}currentIdentity(){return this.flagsmith.getContext?.()?.identity?.identifier??this.flagsmith.identity??null}async refresh(){if(!this.flagsmith.getFlags)return;let e=this.store.get().serverFlags,s=this.lastFlagsFor;this.store.set({refreshStatus:"loading"});try{if(await this.flagsmith.getFlags(),this.destroyed)return;let n=this.store.get().serverFlags,a=s===this.lastFlagsFor&&Object.keys(e).length>0?Object.keys({...e,...n}).filter(o=>!ue(e[o],n[o])):[];if(a.length){let o=Date.now();this.store.set({changedInFlagsmith:Object.fromEntries(a.map(i=>[i,o]))}),this.highlightTimer&&clearTimeout(this.highlightTimer),this.highlightTimer=setTimeout(()=>this.store.set({changedInFlagsmith:{}}),yn)}this.flashStatus(a.length?"updated":"unchanged")}catch(n){this.recoverFromFailedFetch(n),this.flashStatus("error")}}recoverFromFailedFetch(e){let s=this.flagsmith;s.loadingState?.isFetching&&(s.isLoading=!1,s.loadingState={...s.loadingState,isFetching:!1,isLoading:!1,error:e},s._triggerLoadingState?.())}effectiveFlags(){let{serverFlags:e,overrides:s}=this.store.get();return Y(e,s)??{}}usedOnPage(){return Object.keys(this.store.get().reads)}setEnabled(e,s){this.changeFlag(e,{enabled:s})}setValue(e,s){this.changeFlag(e,{value:s})}resetFlag(e){this.updateOverrides(be(this.store.get().overrides,e))}resetAll(){this.updateOverrides({})}async exitPreview(){this.store.get().persona&&await this.backToMe(),this.resetAll(),this.store.set({sharedPreview:!1})}changeFlag(e,s){let{overrides:n,serverFlags:a}=this.store.get(),o={...n[e],...s},i=a[e],l=i!==void 0&&(o.enabled===void 0||o.enabled===i.enabled)&&(o.value===void 0||o.value===i.value);this.updateOverrides(l?be(n,e):Xe(n,e,s))}updateOverrides(e){let s=this.effectiveFlags();this.instrumentation.setOverrides(e),this.store.set({overrides:e}),this.instrumentation.notifyApp(Ye(s,this.effectiveFlags()))}async viewAs(e){await this.applyPersona(e)}async backToMe(){let e=this.appContext;this.store.set({personaStatus:"loading",personaError:null});try{e&&await this.setOwnContext(e),this.appContext=null,this.store.set({persona:null,personaStatus:"idle"})}catch(s){this.store.set({personaStatus:"error",personaError:`Flagsmith could not switch back to your view: ${Ue(s)}`})}}async applyPersona(e){this.appContext||(this.appContext=Be(this.flagsmith.getContext())),this.store.set({persona:e,personaStatus:"loading",personaError:null});try{await this.setOwnContext(z(this.appContext,e)),this.store.set({personaStatus:"idle"})}catch(s){this.store.set({personaStatus:"error",personaError:`Flagsmith could not evaluate this user: ${Ue(s)}`})}}setOwnContext(e){this.ownContextChanges++;try{return this.flagsmith.setContext(e)}finally{this.ownContextChanges--}}onAppContextChange(){let{persona:e}=this.store.get();if(!e){this.appContext=null;return}this.currentIdentity()!==(z({},e).identity?.identifier??null)&&(this.appContext=null,this.store.set({persona:null,personaStatus:"idle",personaError:null}))}previewUrl(){let{overrides:e,persona:s}=this.store.get();return st(window.location.href,{overrides:e,persona:s})}bugReport(){let{serverFlags:e,overrides:s,persona:n}=this.store.get(),a=this.connection();return at({url:window.location.href,apiUrl:a.apiUrl,environmentKey:a.environmentKey,persona:n,identity:this.flagsmith.identity??null,flags:this.effectiveFlags(),serverFlags:e,overrides:s,usedOnPage:this.usedOnPage(),takenAt:new Date})}compareSubjects(){let e=this.options.personas??[];return[{id:"page",label:this.subjectLabel("page")},{id:"anonymous",label:this.subjectLabel("anonymous")},...e.map((s,n)=>({id:`persona:${n}`,label:this.subjectLabel(`persona:${n}`)}))]}subjectLabel(e){if(e==="page"){let{persona:s}=this.store.get(),n=s?s.name.split("\xB7")[0].trim():this.flagsmith.identity;return n?`This page \xB7 ${n}`:"This page"}return e==="anonymous"?"Anonymous visitor":this.personaFor(e)?.name??"Unknown user"}pickCompare(e,s){let{compareA:n,compareB:a}=this.store.get();return e==="a"?this.compare(s,a):this.compare(n,s)}swapCompare(){let{compareA:e,compareB:s}=this.store.get();return this.compare(s,e)}async compare(e,s){let n=++this.compareRun;this.store.set({compareA:e,compareB:s,compareStatus:"loading",compareError:null});try{let[a,o]=await Promise.all([this.flagsFor(e),this.flagsFor(s)]);if(n!==this.compareRun||this.destroyed)return;this.store.set({compareStatus:"done",compareResult:{a,b:o,at:Date.now()}})}catch(a){if(n!==this.compareRun||this.destroyed)return;this.store.set({compareStatus:"error",compareError:`Flagsmith could not evaluate these users: ${Ue(a)}`})}}personaFor(e){let s=Number(e.split(":")[1]);return e.startsWith("persona:")?this.options.personas?.[s]:void 0}async flagsFor(e){if(e==="page")return this.effectiveFlags();let{apiUrl:s,environmentKey:n}=this.connection();if(!s||!n)throw new Error("the SDK has not connected to Flagsmith yet");let a=e==="anonymous"?null:this.personaFor(e);if(a===void 0)throw new Error("that user no longer exists");return Ge(a,{api:s,environmentKey:n,headers:this.flagsmith.headers??null})}experiments(){let{serverFlags:e,reads:s,exposures:n,clock:a}=this.store.get();return Je({flags:e,reads:s,exposures:n,identity:this.lastFlagsFor,eventsEnabled:this.flagsmith.eventsEnabled===!0,previewing:this.isPreviewing(),now:Math.max(a,Date.now()),since:this.flagsSince})}setupIssues(){let{serverFlags:e,reads:s,seenOn:n,events:a}=this.store.get();return ze({serverFlags:e,reads:s,seenOn:n,environmentKey:this.connection().environmentKey,loadingState:this.flagsmith.loadingState,identity:this.currentIdentity(),events:a,experiments:this.experiments()})}connection(){let e=this.flagsmith.api??null,s=null,n=!1;if(e)try{let o=new URL(e);s=o.host,n=!/(^|\.)flagsmith\.com$/i.test(o.hostname)}catch{}let a=this.flagsmith.getContext?.()?.environment?.apiKey??null;return{apiUrl:e,host:s,selfHosted:n,environmentKey:a}}dashboardLink(e){let{dashboardUrl:s,projectId:n}=this.options,a=this.store.get().serverFlags[e]?.id,o=this.connection().environmentKey;return!s||n===void 0||n===""||!a||!o?null:`${s.replace(/\/$/,"")}/project/${n}/environment/${o}/features?feature=${a}`}destroy(){this.destroyed=!0;for(let e of this.cleanups.splice(0))e();for(let e of[this.clockTimer,this.highlightTimer,this.statusTimer])e&&clearTimeout(e);this.instrumentation.restore()}receiveServerFlags(e){let s=this.currentIdentity();s!==this.lastFlagsFor&&(this.lastFlagsFor=s,this.flagsSince=Date.now()),this.store.set({serverFlags:{...e}}),this.tickLater()}recordEvent(e){let s={...e,id:++this.eventId,at:Date.now()};this.store.set(n=>({events:[s,...n.events].slice(0,_n),exposures:s.kind==="exposure"&&s.key?{...n.exposures,[ge(s.key,s.identifier)]:s}:n.exposures}))}flashStatus(e){this.store.set({refreshStatus:e}),this.statusTimer&&clearTimeout(this.statusTimer),this.statusTimer=setTimeout(()=>this.store.set({refreshStatus:"idle"}),2500)}tickLater(){this.clockTimer&&clearTimeout(this.clockTimer),this.clockTimer=setTimeout(()=>{this.destroyed||this.store.set({clock:Date.now()})},1600)}recordRead(e){if(e in this.store.get().reads||e in this.pendingReads)return;let s=Object.keys(this.pendingReads).length===0;this.pendingReads[e]=Date.now(),s&&queueMicrotask(()=>this.flushReads())}flushReads(){let e=this.pendingReads,s=Object.keys(e);this.destroyed||s.length===0||(this.pendingReads={},this.store.set(n=>{let a={...n.seenOn};for(let o of s){let i=a[o]??[];i.includes(n.page)||(a[o]=[...i,n.page])}return{reads:{...n.reads,...e},seenOn:a}}),this.tickLater())}onNavigate(){if(this.destroyed)return;let e=xe(window.location);e!==this.store.get().page&&(this.flushReads(),this.store.set({page:e,reads:{}}))}saveIfChanged(){let{overrides:e,persona:s,welcomeDismissed:n,open:a,tab:o}=this.store.get(),i=JSON.stringify({overrides:e,persona:s,welcomeDismissed:n,open:a,tab:o});i!==this.lastSaved&&(this.lastSaved=i,lt(this.options.storageKey,{overrides:e,persona:s,welcomeDismissed:n,open:a,tab:o}))}whenInitialised(e=2e4){return new Promise(s=>{let n=Date.now(),a=()=>{this.flagsmith.initialised?s(!0):this.destroyed||Date.now()-n>e?s(!1):setTimeout(a,100)};a()})}listenForHotkey(){let e=wn(this.options.hotkey),s=n=>{if(n.repeat)return;let a=n.composedPath()[0];if(a?.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(a?.tagName??""))return;(n.key.toLowerCase()===e.key||n.code.toLowerCase()===`key${e.key}`)&&n.shiftKey===e.shift&&n.altKey===e.alt&&n.ctrlKey===e.ctrl&&n.metaKey===e.meta&&(n.preventDefault(),this.toggle())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)}};var L=null;function os(t,e={}){if(!(typeof window>"u"||typeof document>"u")&&e.enabled!==!1){L?.destroy(),L=null;try{let s=new fe(t,e);s.start(),L=s}catch(s){console.error("[flagsmith-toolbar] could not start",s)}}}function as(){L?.open()}function is(){L?.close()}function ls(){L?.toggle()}function ps(){L?.destroy(),L=null}var kn={init:os,show:as,hide:is,toggle:ls,destroy:ps},Fn=kn;return hs(Sn);})();
391
+ //# sourceMappingURL=index.global.js.map