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 @@
1
+ {"version":3,"sources":["../src/checks.ts","../src/personas.ts","../src/compare.ts","../src/experiments.ts","../src/reasons.ts","../src/overrides.ts","../src/instrument.ts","../src/pages.ts","../src/preview-link.ts","../src/snapshot.ts","../src/store.ts","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/src/constants.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/src/options.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/src/create-element.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/src/component.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/src/diff/props.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/src/create-context.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/src/util.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/src/diff/children.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/src/diff/index.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/src/render.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/src/create-portal.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/src/diff/catch-error.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/hooks/src/index.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/jsx-runtime/src/utils.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/src/constants.js","../../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/jsx-runtime/src/index.js","../src/ui/icons.tsx","../src/ui/CompareTab.tsx","../src/ui/ExperimentsTab.tsx","../src/flag-list.ts","../src/ui/hooks.ts","../src/ui/FlagsTab.tsx","../src/ui/SetupCheck.tsx","../src/ui/ShareTab.tsx","../src/ui/ViewAsTab.tsx","../src/ui/App.tsx","../src/ui/styles.ts","../src/ui/mount.tsx","../src/controller.ts","../src/index.ts"],"sourcesContent":["import type { ExperimentRow } from './experiments';\nimport type { FlagMap, LoadingStateLike, ToolbarEvent } from './types';\n\n/**\n * problem: something is broken or unsafe.\n * warning: something works differently from what you probably expect.\n * tip: worth knowing, but nothing to fix.\n */\nexport type IssueLevel = 'problem' | 'warning' | 'tip';\n\nexport interface SetupIssue {\n id: string;\n level: IssueLevel;\n title: string;\n detail: string;\n /** A short code fix, when there is one. */\n fix?: string;\n}\n\nexport interface CheckInput {\n serverFlags: FlagMap;\n /** Flags read on the current page. */\n reads: Record<string, number>;\n /** For each flag read this session, the pages it was read on. */\n seenOn?: Record<string, string[]>;\n environmentKey: string | null;\n loadingState: LoadingStateLike | null | undefined;\n identity: string | null;\n events: ToolbarEvent[];\n experiments: ExperimentRow[];\n}\n\n/** Edit distance between two strings, for \"did you mean\" suggestions. */\nexport function levenshtein(a: string, b: string): number {\n if (a === b) return 0;\n let previous = Array.from({ length: b.length + 1 }, (_, i) => i);\n for (let i = 1; i <= a.length; i++) {\n const current = [i];\n for (let j = 1; j <= b.length; j++) {\n current[j] = Math.min(previous[j]! + 1, current[j - 1]! + 1, previous[j - 1]! + (a[i - 1] === b[j - 1] ? 0 : 1));\n }\n previous = current;\n }\n return previous[b.length]!;\n}\n\n/** The existing flag a mistyped key most likely meant, if one is close enough. */\nexport function closestKey(key: string, candidates: string[]): string | null {\n const limit = Math.max(2, Math.floor(key.length / 4));\n let best: string | null = null;\n let bestDistance = Infinity;\n for (const candidate of candidates) {\n const distance = levenshtein(key, candidate);\n if (distance < bestDistance) {\n best = candidate;\n bestDistance = distance;\n }\n }\n return bestDistance <= limit ? best : null;\n}\n\nconst list = (keys: string[]) => keys.map((key) => `\"${key}\"`).join(', ');\n\n/** Checks the page's Flagsmith setup for common mistakes. Problems come first. */\nexport function runSetupChecks(input: CheckInput): SetupIssue[] {\n const issues: SetupIssue[] = [];\n const source = input.loadingState?.source;\n const fromServer = source === 'SERVER';\n const flagKeys = Object.keys(input.serverFlags);\n\n if (input.environmentKey?.startsWith('ser.')) {\n issues.push({\n id: 'server-key',\n level: 'problem',\n title: 'A server-side key is in the browser',\n detail:\n '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 });\n }\n\n if (fromServer && flagKeys.length > 0) {\n // Every flag read this session counts, not only this page's: a typo on a page you\n // visited a minute ago is still a typo.\n const unknown = [...new Set([...Object.keys(input.seenOn ?? {}), ...Object.keys(input.reads)])]\n .filter((key) => !(key in input.serverFlags))\n .sort();\n for (const key of unknown) {\n const guess = closestKey(key, flagKeys);\n const pages = input.seenOn?.[key] ?? [];\n const where = pages.length ? ` (on ${pages.slice(0, 3).join(', ')}${pages.length > 3 ? ', …' : ''})` : '';\n issues.push({\n id: `unknown-flag:${key}`,\n level: 'problem',\n title: `This app reads \"${key}\"${where}, which isn't in Flagsmith`,\n detail: guess\n ? `There's no flag called \"${key}\", so it's always off. Did you mean \"${guess}\"?`\n : `There's no flag called \"${key}\" in this environment, so it's always off. Create it in Flagsmith, or remove it from the code.`,\n });\n }\n }\n\n const error = input.loadingState?.error;\n if (!input.loadingState?.isFetching && (error || source === 'CACHE' || source === 'DEFAULT_FLAGS')) {\n const from = source === 'CACHE' ? 'your browser cache' : 'the default flags in your code';\n issues.push({\n id: 'not-from-server',\n level: 'warning',\n title: \"These flags didn't come from Flagsmith\",\n detail: `The page is using flags from ${from}${error ? ` because Flagsmith couldn't be reached (${error instanceof Error ? error.message : String(error)})` : ''}.`,\n });\n }\n\n if (fromServer && flagKeys.length > 0 && flagKeys.every((key) => !input.serverFlags[key]!.reason)) {\n issues.push({\n id: 'no-reasons',\n level: 'warning',\n title: \"Flagsmith didn't say why flags have their values\",\n detail: 'Reasons need Flagsmith 2.295 or newer and @flagsmith/flagsmith 12.6 or newer. Everything else in the toolbar still works.',\n fix: 'npm install @flagsmith/flagsmith@latest',\n });\n }\n\n const dropped = [...new Set(input.events.filter((event) => event.status === 'off').map((event) => event.name))];\n const uncounted = input.experiments.filter((row) => row.state === 'events-off').map((row) => row.key);\n if (dropped.length > 0 || uncounted.length > 0) {\n issues.push({\n id: 'events-off',\n level: 'warning',\n title: dropped.length ? 'Events are tracked, but never sent' : 'This user is in an experiment that can\\'t count them',\n detail: `${dropped.length ? `The page tracked ${list(dropped)}, but` : `This user is in the experiment behind ${list(uncounted)}, but`} Flagsmith was started without enableEvents, so Experimentation never sees ${dropped.length ? 'them' : 'their exposures or conversions'}.`,\n fix: 'flagsmith.init({ environmentID, enableEvents: true })',\n });\n }\n\n // Flagsmith counts an exposure under the variant's key. A variant without a key arrives\n // with no variant at all, so Flagsmith can't tell which version the user saw.\n for (const key of flagKeys) {\n const flag = input.serverFlags[key]!;\n if (flag.experiment?.inExperiment && flag.reason?.toUpperCase().startsWith('SPLIT') && !flag.variant) {\n issues.push({\n id: `variant-without-key:${key}`,\n level: 'problem',\n title: `\"${key}\"'s variant has no key, so its results can't be counted`,\n detail: `This user sees \"${String(flag.value)}\" in \"${flag.experiment.name}\", but that variant has no key in Flagsmith, so their exposure arrives without a variant. Give every variant of \"${key}\" a key in Flagsmith.`,\n });\n }\n }\n\n for (const row of input.experiments.filter((experiment) => experiment.state === 'missing')) {\n issues.push({\n id: `exposure-missing:${row.key}`,\n level: 'warning',\n title: `\"${row.key}\" is in an experiment, but no exposure was recorded`,\n detail: `This user sees \"${String(row.value)}\" from \"${row.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.`,\n fix: `flagsmith.getExperimentFlag('${row.key}')`,\n });\n }\n\n if (!input.identity) {\n issues.push({\n id: 'anonymous',\n level: 'tip',\n title: 'No user is identified',\n 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.\",\n });\n }\n\n const order: Record<IssueLevel, number> = { problem: 0, warning: 1, tip: 2 };\n return issues.sort((a, b) => order[a.level] - order[b.level]);\n}\n","import type { EvaluationContextLike, IdentityContext, Persona, TraitValue } from './types';\n\nexport function slugify(text: string): string {\n return (\n text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 40) || 'user'\n );\n}\n\n/**\n * The evaluation context that makes Flagsmith evaluate flags for a persona.\n *\n * A persona with an `identifier` is a real identity, so its identity overrides\n * apply. Any traits are sent as transient, so they are never saved. A persona\n * without one becomes a transient identity: Flagsmith evaluates it live and\n * stores nothing.\n */\nexport function personaContext(base: EvaluationContextLike, persona: Persona): EvaluationContextLike {\n const traits = Object.fromEntries(\n Object.entries(persona.traits ?? {}).map(([key, value]) => [key, { value, transient: true }]),\n );\n const identity: IdentityContext = persona.identifier\n ? { identifier: persona.identifier, traits }\n : { identifier: `toolbar-preview-${slugify(persona.name)}`, transient: true, traits };\n return { ...base, identity };\n}\n\n/**\n * Parses traits typed one per line as key=value. Numbers and true/false keep\n * their type, so Flagsmith's numeric and boolean segment rules match.\n */\nexport function parseTraits(text: string): Record<string, TraitValue> {\n const traits: Record<string, TraitValue> = {};\n for (const line of text.split(/\\r?\\n/)) {\n const separator = line.indexOf('=');\n if (separator <= 0) continue;\n const key = line.slice(0, separator).trim();\n const raw = line.slice(separator + 1).trim();\n if (!key) continue;\n if (raw === 'true' || raw === 'false') traits[key] = raw === 'true';\n else if (raw !== '' && Number.isFinite(Number(raw))) traits[key] = Number(raw);\n else traits[key] = raw;\n }\n return traits;\n}\n\n/** A deep copy of the app's own context, so it can be restored exactly. */\nexport function cloneContext(context: EvaluationContextLike): EvaluationContextLike {\n return JSON.parse(JSON.stringify(context ?? {}));\n}\n","import { personaContext } from './personas';\nimport type { FlagMap, FlagValue, Persona, ToolbarFlag } from './types';\n\n/** One flag in a Flagsmith flags or identities response. */\nexport interface FlagResponseItem {\n enabled: boolean;\n feature_state_value: FlagValue;\n variant?: string;\n reason?: string;\n feature: { id: number; name: string };\n metadata?: { experiment?: { id: number; name: string; in_experiment: boolean } } | null;\n}\n\n/** Turns a Flagsmith response into the same shape the JS SDK keeps in `flagsmith.flags`. */\nexport function toFlagMap(items: FlagResponseItem[] | null | undefined): FlagMap {\n const flags: FlagMap = {};\n for (const item of items ?? []) {\n const experiment = item.metadata?.experiment;\n flags[item.feature.name.toLowerCase().replace(/ /g, '_')] = {\n id: item.feature.id,\n enabled: item.enabled,\n value: item.feature_state_value,\n ...(item.variant ? { variant: item.variant } : {}),\n ...(item.reason ? { reason: item.reason } : {}),\n ...(experiment ? { experiment: { id: experiment.id, name: experiment.name, inExperiment: Boolean(experiment.in_experiment) } } : {}),\n };\n }\n return flags;\n}\n\nexport interface FetchFlagsOptions {\n /** The SDK's API URL, e.g. \"https://flagsmith.example.com/api/v1/\". */\n api: string;\n environmentKey: string;\n /** Extra headers the app passes to the SDK, if any. */\n headers?: Record<string, string> | null;\n fetch?: (url: string, init?: RequestInit) => Promise<Response>;\n}\n\n/**\n * Asks Flagsmith for one user's flags without touching the app's own SDK.\n *\n * `null` means an anonymous visitor (environment flags). A persona is sent the\n * same way \"View as\" sends it: a real identity when it has an identifier, a\n * transient one otherwise, and its traits are always transient. So Flagsmith\n * stores nothing new.\n */\nexport async function fetchFlagsFor(persona: Persona | null, options: FetchFlagsOptions): Promise<FlagMap> {\n const api = options.api.endsWith('/') ? options.api : `${options.api}/`;\n const doFetch = options.fetch ?? ((url: string, init?: RequestInit) => fetch(url, init));\n const headers: Record<string, string> = { 'X-Environment-Key': options.environmentKey, ...(options.headers ?? {}) };\n\n let response: Response;\n if (!persona) {\n response = await doFetch(`${api}flags/`, { headers, cache: 'no-cache' });\n } else {\n const identity = personaContext({}, persona).identity ?? {};\n const traits = Object.entries(identity.traits ?? {}).map(([trait_key, trait]) => ({\n trait_key,\n trait_value: trait?.value,\n transient: true,\n }));\n if (traits.length === 0 && persona.identifier) {\n response = await doFetch(`${api}identities/?identifier=${encodeURIComponent(persona.identifier)}`, { headers, cache: 'no-cache' });\n } else {\n response = await doFetch(`${api}identities/`, {\n method: 'POST',\n headers: { ...headers, 'Content-Type': 'application/json; charset=utf-8' },\n body: JSON.stringify({ identifier: identity.identifier, ...(identity.transient ? { transient: true } : {}), traits }),\n cache: 'no-cache',\n });\n }\n }\n if (!response.ok) throw new Error(`Flagsmith answered ${response.status}`);\n const data = (await response.json()) as FlagResponseItem[] | { flags?: FlagResponseItem[] };\n return toFlagMap(Array.isArray(data) ? data : data.flags);\n}\n\nexport interface CompareRow {\n key: string;\n a: ToolbarFlag | undefined;\n b: ToolbarFlag | undefined;\n}\n\nexport interface Comparison {\n /** Flags where the two users see a different state or value. */\n differ: CompareRow[];\n /** Flags both users see the same way, even if for different reasons. */\n same: CompareRow[];\n}\n\nconst valueOf = (flag: ToolbarFlag | undefined) => (flag?.value === undefined || flag.value === '' ? null : flag.value);\n\nexport function flagsMatch(a: ToolbarFlag | undefined, b: ToolbarFlag | undefined): boolean {\n if (!a || !b) return a === b;\n return a.enabled === b.enabled && valueOf(a) === valueOf(b);\n}\n\n/** Compares what two users get from Flagsmith, flag by flag. */\nexport function compareFlags(a: FlagMap, b: FlagMap): Comparison {\n const keys = [...new Set([...Object.keys(a), ...Object.keys(b)])].sort();\n const comparison: Comparison = { differ: [], same: [] };\n for (const key of keys) {\n const row = { key, a: a[key], b: b[key] };\n (flagsMatch(row.a, row.b) ? comparison.same : comparison.differ).push(row);\n }\n return comparison;\n}\n","import type { FlagMap, FlagValue, ToolbarEvent } from './types';\n\n/**\n * Where a user stands in an experiment, as far as this page is concerned.\n *\n * - recorded: the page recorded an exposure, so this visit counts.\n * - held: the page tried to record one, but the toolbar held it back because you are previewing.\n * - waiting: the page just read the flag; give its code a moment to record the exposure.\n * - missing: the page shows a variant but never records the exposure, so the user is never counted.\n * - previewing: you are previewing, so any exposure would be held back and this visit isn't counted.\n * - events-off: the SDK was started without enableEvents, so nothing can be recorded.\n * - not-read: this page doesn't use the flag.\n * - not-enrolled: Flagsmith didn't put this user in the experiment.\n * - disabled: the flag is off for this user, so there is nothing to expose.\n */\nexport type ExposureState =\n | 'recorded'\n | 'held'\n | 'previewing'\n | 'waiting'\n | 'missing'\n | 'events-off'\n | 'not-read'\n | 'not-enrolled'\n | 'disabled';\n\nexport interface ExperimentRow {\n key: string;\n id: number;\n name: string;\n inExperiment: boolean;\n enabled: boolean;\n value: FlagValue;\n state: ExposureState;\n /** The exposure the page recorded for this user, if any. */\n exposure?: ToolbarEvent;\n}\n\nexport interface ExperimentInput {\n /** Flags exactly as Flagsmith sent them for the current user. */\n flags: FlagMap;\n reads: Record<string, number>;\n /** The latest exposure per flag and user, keyed by exposureKey(). */\n exposures: Record<string, ToolbarEvent>;\n /** The identity these flags were evaluated for. */\n identity: string | null;\n eventsEnabled: boolean;\n /** You are viewing as someone else or have changed a flag, so exposures are held back. */\n previewing?: boolean;\n now: number;\n /** When Flagsmith's flags for this identity arrived; the grace period never starts before it. */\n since?: number;\n /** How long to wait after a read before calling an exposure missing. */\n graceMs?: number;\n}\n\nexport const EXPOSURE_GRACE_MS = 1500;\n\nexport const exposureKey = (flagKey: string, identity: string | null | undefined) => `${flagKey}|${identity ?? ''}`;\n\n/** The experiments behind the flags on this page, and whether each exposure was recorded. */\nexport function experimentRows(input: ExperimentInput): ExperimentRow[] {\n const grace = input.graceMs ?? EXPOSURE_GRACE_MS;\n const rows: ExperimentRow[] = [];\n for (const key of Object.keys(input.flags).sort()) {\n const flag = input.flags[key]!;\n if (!flag.experiment) continue;\n const exposure = input.exposures[exposureKey(key, input.identity)];\n const readAt = Math.max(input.reads[key] ?? 0, input.since ?? 0);\n let state: ExposureState;\n if (!flag.experiment.inExperiment) state = 'not-enrolled';\n else if (exposure) state = exposure.status === 'sent' ? 'recorded' : exposure.status === 'held' ? 'held' : exposure.status === 'off' ? 'events-off' : 'missing';\n // Checked before \"not read\": React's useExperiment reads through getAllFlags and skips\n // getExperimentFlag entirely when events are off, so the read is never seen.\n else if (!input.eventsEnabled) state = 'events-off';\n else if (!(key in input.reads)) state = 'not-read';\n else if (input.previewing) state = 'previewing';\n else if (!flag.enabled) state = 'disabled';\n else if (input.now - readAt < grace) state = 'waiting';\n else state = 'missing';\n rows.push({\n key,\n id: flag.experiment.id,\n name: flag.experiment.name,\n inExperiment: flag.experiment.inExperiment,\n enabled: flag.enabled,\n value: flag.value,\n state,\n ...(exposure ? { exposure } : {}),\n });\n }\n return rows;\n}\n","/** Reason the toolbar gives a flag that you changed in the panel. */\nexport const OVERRIDE_REASON = 'TOOLBAR_OVERRIDE';\n\n/** Flagsmith's name for the segment that holds identity overrides. */\nconst IDENTITY_OVERRIDES_SEGMENT = 'identity_overrides';\n/** Flagsmith Experimentation enrols users through a hidden segment named like \"experiment-1-rollout\". */\nconst EXPERIMENT_SEGMENT = /^experiment-\\d+-rollout$/;\n\nexport type ReasonKind =\n | 'static'\n | 'default'\n | 'segment'\n | 'identity'\n | 'split'\n | 'experiment'\n | 'override'\n | 'error'\n | 'missing'\n | 'other';\n\nexport interface Explanation {\n kind: ReasonKind;\n /** A few words for a badge, e.g. \"Segment: Pro members\". */\n label: string;\n /** One plain sentence for the details view. */\n detail: string;\n}\n\n/**\n * Splits a Flagsmith reason such as \"TARGETING_MATCH; segment=Pro members\"\n * into its code and parameters.\n */\nexport function parseReason(raw: string | null | undefined): { code: string; params: Record<string, string> } {\n if (!raw) return { code: '', params: {} };\n const [code = '', ...parts] = raw.split(';').map((part) => part.trim());\n const params: Record<string, string> = {};\n for (const part of parts) {\n const separator = part.indexOf('=');\n if (separator > 0) params[part.slice(0, separator).trim()] = part.slice(separator + 1).trim();\n }\n return { code: code.toUpperCase(), params };\n}\n\n/** Turns \"50.0\" into \"50%\". */\nexport function formatWeight(weight: string | undefined): string {\n if (!weight) return '';\n const value = Number(weight);\n if (!Number.isFinite(value)) return `${weight}%`;\n return `${Math.round(value * 10) / 10}%`;\n}\n\n/** Explains, in plain words, why a flag has its value. */\nexport function explainReason(raw: string | null | undefined): Explanation {\n const { code, params } = parseReason(raw);\n switch (code) {\n case 'STATIC':\n return {\n kind: 'static',\n label: 'No targeting',\n detail:\n \"Nothing targets this flag for this user, so they get the environment's value. In a split test, this is the control value.\",\n };\n case 'DEFAULT':\n return {\n kind: 'default',\n label: 'No rule matched',\n detail: \"This flag has targeting rules, but none matched this user, so they get the environment's value.\",\n };\n case 'TARGETING_MATCH': {\n const segment = params.segment;\n if (segment === IDENTITY_OVERRIDES_SEGMENT) {\n return {\n kind: 'identity',\n label: 'Set for this user',\n detail: 'An identity override in Flagsmith sets this flag for this exact user.',\n };\n }\n if (segment && EXPERIMENT_SEGMENT.test(segment)) {\n return {\n kind: 'experiment',\n label: 'Experiment: control group',\n detail: \"This user is in a running experiment, in its control group, so they see the original version.\",\n };\n }\n return {\n kind: 'segment',\n label: segment ? `Segment: ${segment}` : 'Segment match',\n detail: segment\n ? `This user is in the \"${segment}\" segment, and that segment overrides the flag.`\n : 'A segment override matched this user.',\n };\n }\n case 'SPLIT': {\n const weight = formatWeight(params.weight);\n return {\n kind: 'split',\n label: weight ? `Split test: ${weight} bucket` : 'Split test',\n detail: weight\n ? `A percentage split put this user in a ${weight} bucket. The bucket comes from their identity, so it stays the same on every visit.`\n : 'A percentage split put this user in this bucket.',\n };\n }\n case OVERRIDE_REASON:\n return {\n kind: 'override',\n label: 'Changed by you',\n detail: 'You changed this in the toolbar. Only your browser sees it, and nothing changed in Flagsmith.',\n };\n case 'ERROR':\n return {\n kind: 'error',\n label: 'Evaluation error',\n detail: params.code\n ? `Flagsmith could not evaluate this flag (${params.code}).`\n : 'Flagsmith could not evaluate this flag.',\n };\n case '':\n return {\n kind: 'missing',\n label: 'No reason sent',\n detail: 'Flagsmith did not send a reason. Reasons need Flagsmith 2.295 or newer and @flagsmith/flagsmith 12.6 or newer.',\n };\n default:\n return { kind: 'other', label: raw ?? '', detail: `Flagsmith reported: ${raw}` };\n }\n}\n","import { OVERRIDE_REASON } from './reasons';\nimport type { FlagMap, FlagOverride, FlagValue, Overrides } from './types';\n\n/** Flagsmith stores flag keys lower-case with underscores for spaces. */\nexport function normalizeKey(key: string): string {\n return key.toLowerCase().replace(/ /g, '_');\n}\n\n/** Returns the flags the app should see: the real flags with your changes on top. */\nexport function applyOverrides(flags: FlagMap | null | undefined, overrides: Overrides): FlagMap | null | undefined {\n const keys = Object.keys(overrides);\n if (keys.length === 0) return flags;\n const result: FlagMap = { ...(flags ?? {}) };\n for (const key of keys) {\n const override = overrides[key]!;\n const next = { ...(result[key] ?? { enabled: false, value: null }), reason: OVERRIDE_REASON };\n if (override.enabled !== undefined) next.enabled = override.enabled;\n if (override.value !== undefined) {\n next.value = override.value;\n // A changed value no longer belongs to the variant the user was bucketed into.\n delete next.variant;\n }\n result[key] = next;\n }\n return result;\n}\n\nexport function withOverride(overrides: Overrides, key: string, patch: FlagOverride): Overrides {\n return { ...overrides, [key]: { ...overrides[key], ...patch } };\n}\n\nexport function withoutOverride(overrides: Overrides, key: string): Overrides {\n const { [key]: _removed, ...rest } = overrides;\n return rest;\n}\n\n/** Keys whose on/off state or value differ between two sets of flags. */\nexport function changedKeys(before: FlagMap | null | undefined, after: FlagMap | null | undefined): string[] {\n const keys = new Set([...Object.keys(before ?? {}), ...Object.keys(after ?? {})]);\n return [...keys].filter((key) => {\n const a = before?.[key];\n const b = after?.[key];\n return a?.enabled !== b?.enabled || a?.value !== b?.value;\n });\n}\n\n/** Parses text typed into a value box, keeping the type of the current value where it can. */\nexport function parseValueInput(text: string, current: FlagValue): FlagValue {\n const trimmed = text.trim();\n if (trimmed === '') return null;\n if (typeof current === 'number') {\n const number = Number(trimmed);\n return Number.isFinite(number) ? number : text;\n }\n if (typeof current === 'boolean') {\n if (trimmed === 'true') return true;\n if (trimmed === 'false') return false;\n }\n return text;\n}\n\n/** How a value is shown in the panel. */\nexport function formatValue(value: FlagValue | undefined): string {\n if (value === null || value === undefined || value === '') return 'No value';\n return String(value);\n}\n","import { applyOverrides, normalizeKey } from './overrides';\nimport type { EventStatus, FlagMap, FlagsmithLike, Overrides, ToolbarEvent } from './types';\n\nexport interface InstrumentHooks {\n /** Flagsmith delivered new flags (initial load, identity change, refresh, polling). */\n onServerFlags(flags: FlagMap): void;\n /** The app read a flag through hasFeature, getValue or getExperimentFlag. */\n onRead(key: string): void;\n /** The app tracked an Experimentation event or exposure. */\n onEvent(event: Omit<ToolbarEvent, 'id' | 'at'>): void;\n /**\n * True while you are previewing (viewing as someone else, or with a changed flag).\n * Events are then held back instead of sent, so test visits never count in real results.\n */\n holdBack(): boolean;\n /**\n * The app switched users itself (identify, logout or setContext), rather than the\n * toolbar. Called once Flagsmith has answered for the new user.\n */\n onAppContextChange?(): void;\n /** True while the toolbar itself is changing the context, so its own calls aren't mistaken for the app's. */\n isOwnContextChange?(): boolean;\n}\n\nexport interface Instrumentation {\n serverFlags(): FlagMap;\n setOverrides(overrides: Overrides): void;\n /** Tells the app's listeners (React hooks, onChange) that flags changed. */\n notifyApp(changed: string[]): void;\n restore(): void;\n}\n\ntype AnyFn = (...args: any[]) => any;\ntype TrackOptions = { identifier?: string | null; value?: unknown } & Record<string, unknown>;\n\n/**\n * Connects the toolbar to a Flagsmith SDK instance without changing the app's code.\n *\n * The SDK keeps its flags in `instance.flags`, and hasFeature, getValue and\n * getAllFlags all read from it. Replacing that field with a getter lets the\n * toolbar layer your changes on top, while Flagsmith keeps writing the real\n * flags through the setter.\n *\n * The event methods are wrapped too. getExperimentFlag records its exposure\n * through trackExposureEvent, so every exposure passes through one place.\n */\nexport function instrument(flagsmith: FlagsmithLike, hooks: InstrumentHooks): Instrumentation {\n const sdk = flagsmith as FlagsmithLike & Record<string, any>;\n let serverFlags: FlagMap | null = (sdk.flags as FlagMap | null | undefined) ?? null;\n let overrides: Overrides = {};\n // The app may read flags hundreds of times per render, so the merged flags are\n // built once and reused until Flagsmith's flags or your changes change.\n let merged: FlagMap | null = null;\n let mergedIsCurrent = false;\n\n Object.defineProperty(sdk, 'flags', {\n configurable: true,\n enumerable: true,\n get: () => {\n if (!mergedIsCurrent) {\n merged = applyOverrides(serverFlags, overrides) ?? null;\n mergedIsCurrent = true;\n }\n return merged;\n },\n set: (value: FlagMap | null) => {\n serverFlags = value;\n mergedIsCurrent = false;\n hooks.onServerFlags(value ?? {});\n },\n });\n\n const keys = new Map<string, string>();\n const keyOf = (key: unknown) => {\n const raw = String(key);\n let normalized = keys.get(raw);\n if (normalized === undefined) {\n normalized = normalizeKey(raw);\n if (keys.size < 5000) keys.set(raw, normalized);\n }\n return normalized;\n };\n\n const originals: Record<string, AnyFn> = {};\n /** Methods that came from the SDK's prototype, so restoring means removing our copy. */\n const inherited = new Set<string>();\n const wrap = (name: string, make: (original: AnyFn) => AnyFn) => {\n const original = sdk[name];\n if (typeof original !== 'function') return;\n if (!Object.prototype.hasOwnProperty.call(sdk, name)) inherited.add(name);\n originals[name] = original;\n sdk[name] = make(original);\n };\n const identity = (): string | null => sdk.getContext?.()?.identity?.identifier ?? sdk.identity ?? null;\n const eventsOn = () => sdk.eventsEnabled === true;\n\n wrap('hasFeature', (original) => (key: string, ...rest: unknown[]) => {\n hooks.onRead(keyOf(key));\n return original.call(sdk, key, ...rest);\n });\n wrap('getValue', (original) => (key: string, ...rest: unknown[]) => {\n hooks.onRead(keyOf(key));\n return original.call(sdk, key, ...rest);\n });\n wrap('getExperimentFlag', (original) => (key: string) => {\n hooks.onRead(keyOf(key));\n return original.call(sdk, key);\n });\n wrap('trackEvent', (original) => (event: string, opts?: TrackOptions) => {\n const held = hooks.holdBack();\n const status: EventStatus = held ? 'held' : eventsOn() ? 'sent' : 'off';\n hooks.onEvent({ kind: 'event', name: String(event), value: opts?.value, identifier: opts?.identifier ?? identity(), status });\n if (held) return undefined;\n return original.call(sdk, event, opts);\n });\n wrap('trackExposureEvent', (original) => (featureName: string, opts?: TrackOptions) => {\n const held = hooks.holdBack();\n const who = opts?.identifier ?? identity();\n const status: EventStatus = held ? 'held' : !eventsOn() ? 'off' : !who ? 'no-identity' : 'sent';\n hooks.onEvent({\n kind: 'exposure',\n name: String(featureName),\n key: normalizeKey(String(featureName)),\n value: opts?.value,\n identifier: who,\n status,\n });\n if (held) return undefined;\n return original.call(sdk, featureName, opts);\n });\n\n // Notice when the app itself switches users, for example after a login, while a preview is on.\n for (const name of ['identify', 'logout', 'setContext']) {\n wrap(name, (original) => (...args: unknown[]) => {\n const fromApp = !hooks.isOwnContextChange?.();\n const result = original.apply(sdk, args);\n if (fromApp && hooks.onAppContextChange) {\n const notify = () => hooks.onAppContextChange?.();\n Promise.resolve(result).then(notify, notify);\n }\n return result;\n });\n }\n\n return {\n serverFlags: () => serverFlags ?? {},\n setOverrides(next) {\n overrides = next;\n mergedIsCurrent = false;\n },\n notifyApp(changed) {\n try {\n sdk.onChange?.(serverFlags, { isFromServer: false, flagsChanged: changed, traitsChanged: null }, sdk.loadingState);\n } catch (error) {\n console.error('[flagsmith-toolbar] onChange threw', error);\n }\n sdk._trigger?.();\n },\n restore() {\n Object.defineProperty(sdk, 'flags', { configurable: true, enumerable: true, writable: true, value: serverFlags });\n for (const [name, original] of Object.entries(originals)) {\n if (inherited.has(name)) delete sdk[name];\n else sdk[name] = original;\n }\n },\n };\n}\n","/**\n * Page awareness for single-page apps.\n *\n * A single-page app changes pages without a reload, so \"the flags on this page\" has to\n * start over whenever the app moves to another page. The toolbar notices that by\n * wrapping history.pushState and history.replaceState (which every router calls) and by\n * listening for popstate (back and forward) and hashchange.\n */\n\n/** The page the app is showing: its path, plus the hash when a hash router uses it (\"#/settings\"). */\nexport function pageKey(location: { pathname: string; hash: string }): string {\n return location.hash.startsWith('#/') ? `${location.pathname}${location.hash}` : location.pathname;\n}\n\ntype HistoryMethod = 'pushState' | 'replaceState';\n\n/**\n * Calls onNavigate after anything that may have changed the page. The caller compares\n * page keys, since replaceState and hashchange often leave the page as it was.\n * Returns a function that stops watching and puts history back as it was.\n */\nexport function watchNavigation(onNavigate: () => void): () => void {\n if (typeof window === 'undefined' || !window.history) return () => {};\n const history = window.history as History & Partial<Record<HistoryMethod, unknown>>;\n let stopped = false;\n const notify = () => {\n if (!stopped) onNavigate();\n };\n\n const restores: Array<() => void> = [];\n for (const name of ['pushState', 'replaceState'] as const) {\n const original = history[name];\n if (typeof original !== 'function') continue;\n const own = Object.prototype.hasOwnProperty.call(history, name);\n const wrapper = function (this: History, ...args: Parameters<History[HistoryMethod]>) {\n const result = (original as History[HistoryMethod]).apply(this, args);\n notify();\n return result;\n };\n history[name] = wrapper;\n restores.push(() => {\n // Something else (an analytics script, another tool) may have wrapped history after\n // us. Leave its wrapper in place then; ours stays in its chain but does nothing.\n if (history[name] !== wrapper) return;\n if (own) history[name] = original;\n else delete history[name];\n });\n }\n window.addEventListener('popstate', notify);\n window.addEventListener('hashchange', notify);\n\n return () => {\n stopped = true;\n for (const restore of restores) restore();\n window.removeEventListener('popstate', notify);\n window.removeEventListener('hashchange', notify);\n };\n}\n","import type { FlagValue, Overrides, Persona, TraitValue } from './types';\n\n/** The URL hash parameter that carries a shared preview. */\nexport const PREVIEW_PARAM = 'flagsmith-toolbar';\n\nexport interface PreviewState {\n overrides: Overrides;\n persona: Persona | null;\n}\n\nconst PREVIEW_PATTERN = new RegExp(`(^|&)${PREVIEW_PARAM}=([A-Za-z0-9_-]+)`);\n\nfunction toBase64Url(text: string): string {\n let binary = '';\n for (const byte of new TextEncoder().encode(text)) binary += String.fromCharCode(byte);\n return btoa(binary).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n}\n\nfunction fromBase64Url(encoded: string): string {\n const base64 = encoded.replace(/-/g, '+').replace(/_/g, '/');\n const padded = base64 + '='.repeat((4 - (base64.length % 4)) % 4);\n const binary = atob(padded);\n return new TextDecoder().decode(Uint8Array.from(binary, (char) => char.charCodeAt(0)));\n}\n\nconst isFlagValue = (value: unknown): value is FlagValue =>\n value === null || ['string', 'number', 'boolean'].includes(typeof value);\nconst isTraitValue = (value: unknown): value is TraitValue => ['string', 'number', 'boolean'].includes(typeof value);\n\n/** Keeps only well-formed changes from untrusted input (a link or saved state). */\nexport function sanitizeOverrides(input: unknown): Overrides {\n const overrides: Overrides = {};\n if (!input || typeof input !== 'object') return overrides;\n for (const [key, raw] of Object.entries(input as Record<string, unknown>)) {\n if (!raw || typeof raw !== 'object') continue;\n const { enabled, value } = raw as Record<string, unknown>;\n const override: Overrides[string] = {};\n if (typeof enabled === 'boolean') override.enabled = enabled;\n if (value !== undefined && isFlagValue(value)) override.value = value;\n if (Object.keys(override).length) overrides[key] = override;\n }\n return overrides;\n}\n\n/** Keeps only a well-formed persona from untrusted input. */\nexport function sanitizePersona(input: unknown): Persona | null {\n if (!input || typeof input !== 'object') return null;\n const { name, description, identifier, traits } = input as Record<string, unknown>;\n if (typeof name !== 'string' || !name) return null;\n const persona: Persona = { name };\n if (typeof description === 'string') persona.description = description;\n if (typeof identifier === 'string' && identifier) persona.identifier = identifier;\n if (traits && typeof traits === 'object') {\n persona.traits = Object.fromEntries(\n Object.entries(traits as Record<string, unknown>).filter((entry): entry is [string, TraitValue] =>\n isTraitValue(entry[1]),\n ),\n );\n }\n return persona;\n}\n\nexport function encodePreview(state: PreviewState): string {\n return toBase64Url(JSON.stringify({ v: 1, o: state.overrides, p: state.persona ?? null }));\n}\n\nexport function decodePreview(payload: string): PreviewState | null {\n try {\n const data = JSON.parse(fromBase64Url(payload));\n if (!data || data.v !== 1) return null;\n return { overrides: sanitizeOverrides(data.o), persona: sanitizePersona(data.p) };\n } catch {\n return null;\n }\n}\n\n/** Adds the preview to the URL hash, keeping any hash the app already uses. */\nexport function buildPreviewUrl(href: string, state: PreviewState): string {\n const url = new URL(href);\n const existing = url.hash.replace(/^#/, '').replace(PREVIEW_PATTERN, '').replace(/^&/, '');\n const preview = `${PREVIEW_PARAM}=${encodePreview(state)}`;\n url.hash = existing ? `${existing}&${preview}` : preview;\n return url.toString();\n}\n\nexport function readPreviewFromUrl(href: string): PreviewState | null {\n const match = new URL(href).hash.replace(/^#/, '').match(PREVIEW_PATTERN);\n return match ? decodePreview(match[2]!) : null;\n}\n\n/** Removes the preview from the URL hash once it has been read. */\nexport function stripPreviewFromUrl(href: string): string {\n const url = new URL(href);\n url.hash = url.hash.replace(/^#/, '').replace(PREVIEW_PATTERN, '').replace(/^&/, '');\n return url.toString().replace(/#$/, '');\n}\n","import { formatValue } from './overrides';\nimport { explainReason } from './reasons';\nimport type { FlagMap, Overrides, Persona } from './types';\n\nexport interface SnapshotInput {\n url: string;\n apiUrl?: string | null;\n environmentKey?: string | null;\n persona: Persona | null;\n identity?: string | null;\n /** The flags the app sees right now, your changes included. */\n flags: FlagMap;\n /** The flags as Flagsmith sent them. */\n serverFlags: FlagMap;\n overrides: Overrides;\n usedOnPage: string[];\n takenAt: Date;\n}\n\nconst cell = (text: string) => text.replace(/\\|/g, '\\\\|').replace(/\\r?\\n/g, ' ');\n\nfunction describeUser(input: SnapshotInput): string {\n if (input.persona) {\n const traits = Object.entries(input.persona.traits ?? {})\n .map(([key, value]) => `${key}=${value}`)\n .join(', ');\n return `${input.persona.name}${traits ? ` (${traits})` : ''} — previewed with the toolbar`;\n }\n return input.identity ? `identity \\`${input.identity}\\`` : 'anonymous visitor';\n}\n\n/** The page's flag state as Markdown, ready to paste into a GitHub issue or Jira ticket. */\nexport function buildBugReport(input: SnapshotInput): string {\n const used = new Set(input.usedOnPage);\n const changed = Object.keys(input.overrides);\n const keys = Object.keys(input.flags).sort((a, b) => Number(used.has(b)) - Number(used.has(a)) || a.localeCompare(b));\n\n const rows = keys.map((key) => {\n const flag = input.flags[key]!;\n let why = explainReason(flag.reason).label;\n if (input.overrides[key]) {\n const real = input.serverFlags[key];\n why += real ? ` (Flagsmith: ${real.enabled ? 'on' : 'off'}, ${formatValue(real.value)})` : '';\n }\n return `| \\`${key}\\` | ${flag.enabled ? 'on' : 'off'} | ${cell(formatValue(flag.value))} | ${cell(why)} | ${used.has(key) ? 'yes' : ''} |`;\n });\n\n return [\n '### Flagsmith flag state',\n '',\n `- **Page:** ${input.url}`,\n `- **Flagsmith:** ${input.apiUrl ?? 'unknown'}${input.environmentKey ? ` · environment \\`${input.environmentKey}\\`` : ''}`,\n `- **User:** ${describeUser(input)}`,\n `- **Changed in the toolbar:** ${changed.length ? changed.map((key) => `\\`${key}\\``).join(', ') : 'nothing'}`,\n `- **Captured:** ${input.takenAt.toISOString()}`,\n '',\n '| Flag | State | Value | Why | Used on this page |',\n '| --- | --- | --- | --- | --- |',\n ...rows,\n '',\n '_Captured with Flagsmith Toolbar_',\n ].join('\\n');\n}\n","import { sanitizeOverrides, sanitizePersona } from './preview-link';\nimport type { FlagMap, Overrides, Persona, ToolbarEvent } from './types';\n\nexport type Tab = 'flags' | 'viewas' | 'compare' | 'share' | 'experiments';\nexport type FlagFilter = 'all' | 'page' | 'changed';\n\nconst TABS: Tab[] = ['flags', 'viewas', 'compare', 'share', 'experiments'];\n\n/** Who the Compare tab compares: \"page\" (what you see now), \"anonymous\", or \"persona:<index>\". */\nexport type CompareSubject = string;\n\nexport interface CompareResult {\n a: FlagMap;\n b: FlagMap;\n at: number;\n}\n\nexport interface ToolbarState {\n open: boolean;\n tab: Tab;\n filter: FlagFilter;\n search: string;\n expanded: string | null;\n /** Flags exactly as Flagsmith sent them, before your changes. */\n serverFlags: FlagMap;\n /** The page the app is showing, as pageKey() names it. */\n page: string;\n /** Flag keys read on the current page, with the time of the first read there. Starts over on every page change. */\n reads: Record<string, number>;\n /** For each flag, the pages it was read on this session, in the order they were seen. Not saved. */\n seenOn: Record<string, string[]>;\n overrides: Overrides;\n persona: Persona | null;\n personaStatus: 'idle' | 'loading' | 'error';\n personaError: string | null;\n events: ToolbarEvent[];\n /** The latest exposure per flag and user, keyed by exposureKey(). */\n exposures: Record<string, ToolbarEvent>;\n welcomeDismissed: boolean;\n /** The page was opened from a shared preview link. */\n sharedPreview: boolean;\n /** The setup check list is open. */\n setupOpen: boolean;\n /** Flags whose value changed in Flagsmith on the last refresh, with the time it was noticed. */\n changedInFlagsmith: Record<string, number>;\n refreshStatus: 'idle' | 'loading' | 'updated' | 'unchanged' | 'error';\n compareA: CompareSubject;\n compareB: CompareSubject;\n compareStatus: 'idle' | 'loading' | 'done' | 'error';\n compareError: string | null;\n compareResult: CompareResult | null;\n /** Bumped by a timer so time-based checks (like a missing exposure) update on screen. */\n clock: number;\n}\n\ntype Listener = () => void;\n\n/** A minimal observable store for the toolbar's state. */\nexport class Store<T extends object> {\n private state: T;\n private readonly listeners = new Set<Listener>();\n\n constructor(initial: T) {\n this.state = initial;\n }\n\n get(): T {\n return this.state;\n }\n\n set(patch: Partial<T> | ((state: T) => Partial<T>)): void {\n const next = typeof patch === 'function' ? patch(this.state) : patch;\n this.state = { ...this.state, ...next };\n for (const listener of this.listeners) listener();\n }\n\n subscribe(listener: Listener): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n}\n\n/** The parts of the state that survive a page reload. */\nexport interface SavedState {\n overrides?: Overrides;\n persona?: Persona | null;\n welcomeDismissed?: boolean;\n open?: boolean;\n tab?: Tab;\n}\n\n/**\n * Turns whatever is in storage into valid saved state. Storage can hold anything\n * (an old version, a hand edit, another app's data), and the toolbar must never\n * break the page because of it.\n */\nexport function sanitizeSaved(raw: unknown): SavedState {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return {};\n const input = raw as Record<string, unknown>;\n const saved: SavedState = {};\n if ('overrides' in input) saved.overrides = sanitizeOverrides(input.overrides);\n if ('persona' in input) saved.persona = sanitizePersona(input.persona);\n if (typeof input.welcomeDismissed === 'boolean') saved.welcomeDismissed = input.welcomeDismissed;\n if (typeof input.open === 'boolean') saved.open = input.open;\n // Version 0.1 called the experiments tab \"events\".\n const tab = input.tab === 'events' ? 'experiments' : input.tab;\n if (typeof tab === 'string' && TABS.includes(tab as Tab)) saved.tab = tab as Tab;\n return saved;\n}\n\nexport function loadSaved(key: string): SavedState {\n try {\n const raw = window.localStorage.getItem(key);\n return raw ? sanitizeSaved(JSON.parse(raw)) : {};\n } catch {\n return {};\n }\n}\n\nexport function save(key: string, value: SavedState): void {\n try {\n window.localStorage.setItem(key, JSON.stringify(value));\n } catch {\n // Storage can be full or blocked (private mode). The toolbar still works without it.\n }\n}\n","// Vnode._flags\n/** Normal hydration that attaches to a DOM tree but does not diff it. */\nexport const MODE_HYDRATE = 1 << 5;\n/** Signifies this VNode suspended on the previous render */\nexport const MODE_SUSPENDED = 1 << 7;\n/** Indicates that this node needs to be inserted while patching children */\nexport const INSERT_VNODE = 1 << 2;\n/** Indicates a VNode has been matched with another VNode in the diff */\nexport const MATCHED = 1 << 1;\n/** The vnode's ref was detached while its subtree was parked by Suspense */\nexport const REF_DETACHED = 1 << 3;\n\n// component._bits\n/** Component is processing an exception */\nexport const COMPONENT_PROCESSING_EXCEPTION = 1 << 0;\n/** Component has a pending error */\nexport const COMPONENT_PENDING_ERROR = 1 << 1;\n/** Component should force update (skip shouldComponentUpdate) */\nexport const COMPONENT_FORCE = 1 << 2;\n/** Component is queued for update */\nexport const COMPONENT_DIRTY = 1 << 3;\n\n/** Reset all mode flags */\nexport const RESET_MODE = ~(MODE_HYDRATE | MODE_SUSPENDED);\n\nexport const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\nexport const XHTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\nexport const MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';\n\nexport const NULL = null;\nexport const UNDEFINED = undefined;\nexport const VNODE_MARKER = Symbol.for('pv');\nexport const EMPTY_OBJ = /** @type {any} */ ({});\nexport const EMPTY_ARR = [];\n\nexport const MATHML_TOKEN_ELEMENTS = /^m(i|n|o|s|text|space)$/;\n\n/** Matched new vnode eligible for the longest increasing subsequence. */\nexport const LIS_CANDIDATE = 1 << 4;\n","import { _catchError } from './diff/catch-error';\n\n/**\n * The `option` object can potentially contain callback functions\n * that are called during various stages of our renderer. This is the\n * foundation on which all our addons like `preact/debug`, `preact/compat`,\n * and `preact/hooks` are based on. See the `Options` type in `internal.d.ts`\n * for a full list of available option hooks (most editors/IDEs allow you to\n * ctrl+click or cmd+click on mac the type definition below).\n * @type {import('./internal').Options}\n */\nconst options = {\n\t_catchError\n};\n\nexport default options;\n","import { assign, slice } from './util';\nimport options from './options';\nimport { NULL, UNDEFINED, VNODE_MARKER } from './constants';\n\nlet vnodeId = 0;\n\n/**\n * Create an virtual node (used for JSX)\n * @param {import('./internal').VNode[\"type\"]} type The node name or Component constructor for this\n * virtual node\n * @param {object | null | undefined} [props] The properties of the virtual node\n * @param {Array<import('.').ComponentChildren>} [children] The children of the\n * virtual node\n * @returns {import('./internal').VNode}\n */\nexport function createElement(type, props, children) {\n\tlet normalizedProps = {},\n\t\tkey,\n\t\tref,\n\t\ti,\n\t\tlength = arguments.length;\n\tfor (i in props) {\n\t\tif (i == 'key') key = props[i];\n\t\telse if (i == 'ref' && typeof type != 'function') ref = props[i];\n\t\telse normalizedProps[i] = props[i];\n\t}\n\n\tif (length > 2) {\n\t\tnormalizedProps.children = length > 3 ? slice.call(arguments, 2) : children;\n\t}\n\n\treturn createVNode(type, normalizedProps, key, ref, NULL);\n}\n\n/**\n * Clones the given VNode, optionally adding attributes/props and replacing its\n * children.\n * @param {import('./internal').VNode} vnode The virtual DOM element to clone\n * @param {object} props Attributes/props to add when cloning\n * @param {Array<import('./internal').ComponentChildren>} children Any additional arguments will be used\n * as replacement children.\n * @returns {import('./internal').VNode}\n */\nexport function cloneElement(vnode, props, children) {\n\tlet normalizedProps = assign({}, vnode.props),\n\t\tkey,\n\t\tref,\n\t\ti,\n\t\tlength = arguments.length;\n\n\tfor (i in props) {\n\t\tif (i == 'key') key = props[i];\n\t\telse if (i == 'ref' && typeof vnode.type != 'function') ref = props[i];\n\t\telse normalizedProps[i] = props[i];\n\t}\n\n\tif (length > 2) {\n\t\tnormalizedProps.children = length > 3 ? slice.call(arguments, 2) : children;\n\t}\n\n\treturn createVNode(\n\t\tvnode.type,\n\t\tnormalizedProps,\n\t\tkey !== UNDEFINED ? key : vnode.key,\n\t\tref !== UNDEFINED ? ref : vnode.ref,\n\t\tNULL\n\t);\n}\n\n/**\n * Create a VNode (used internally by Preact)\n * @param {import('./internal').VNode[\"type\"]} type The node name or Component\n * Constructor for this virtual node\n * @param {object | string | number | null} props The properties of this virtual node.\n * If this virtual node represents a text node, this is the text of the node (string or number).\n * @param {string | number | null} key The key for this virtual node, used when\n * diffing it against its children\n * @param {import('./internal').VNode[\"ref\"]} ref The ref property that will\n * receive a reference to its created child\n * @returns {import('./internal').VNode}\n */\nexport function createVNode(type, props, key, ref, original) {\n\t// V8 seems to be better at detecting type shapes if the object is allocated from the same call site\n\t// Do not inline into createElement and coerceToVNode!\n\t/** @type {import('./internal').VNode} */\n\tconst vnode = {\n\t\ttype,\n\t\tprops,\n\t\tkey,\n\t\tref,\n\t\t_children: NULL,\n\t\t_parent: NULL,\n\t\t_depth: 0,\n\t\t_dom: NULL,\n\t\t_component: NULL,\n\t\tconstructor: VNODE_MARKER,\n\t\t_original: original || ++vnodeId,\n\t\t_index: -1,\n\t\t_flags: 0\n\t};\n\n\t// Only invoke the vnode hook if this was *not* a direct copy:\n\tif (!original && options.vnode) options.vnode(vnode);\n\n\treturn vnode;\n}\n\nexport function createRef() {\n\treturn { current: NULL };\n}\n\nexport function Fragment(props) {\n\treturn props.children;\n}\n\n/**\n * Check if a the argument is a valid Preact VNode.\n * @param {*} vnode\n * @returns {vnode is VNode}\n */\nexport const isValidElement = vnode =>\n\tvnode != NULL && vnode.constructor === VNODE_MARKER;\n","import {\n\tCOMPONENT_DIRTY,\n\tCOMPONENT_FORCE,\n\tMODE_HYDRATE,\n\tNULL,\n\tVNODE_MARKER\n} from './constants';\nimport { Fragment } from './create-element';\nimport { commitRoot, diff } from './diff/index';\nimport options from './options';\nimport { assign } from './util';\n\n/**\n * Base Component class. Provides `setState()` and `forceUpdate()`, which\n * trigger rendering\n * @param {object} props The initial component props\n * @param {object} context The initial context from parent components'\n * getChildContext\n */\nexport function BaseComponent(props, context) {\n\tthis.props = props;\n\tthis.context = context;\n\tthis._bits = 0;\n}\n\n/**\n * Update component state and schedule a re-render.\n * @this {import('./internal').Component}\n * @param {object | ((s: object, p: object) => object)} update A hash of state\n * properties to update with new values or a function that given the current\n * state and props returns a new partial state\n * @param {() => void} [callback] A function to be called once component state is\n * updated\n */\nBaseComponent.prototype.setState = function (update, callback) {\n\t// only clone state when copying to nextState the first time.\n\tlet s = this._nextState;\n\tif (!s || s == this.state) {\n\t\ts = this._nextState = assign({}, this.state);\n\t}\n\n\tif (typeof update == 'function') {\n\t\t// Some libraries like `immer` mark the current state as readonly,\n\t\t// preventing us from mutating it, so we need to clone it. See #2716\n\t\tupdate = update(assign({}, s), this.props);\n\t}\n\n\tif (update) {\n\t\tassign(s, update);\n\t} else {\n\t\treturn;\n\t}\n\n\tif (this._vnode) {\n\t\tif (callback) {\n\t\t\tthis._stateCallbacks.push(callback);\n\t\t}\n\t\tenqueueRender(this);\n\t}\n};\n\n/**\n * Immediately perform a synchronous re-render of the component\n * @this {import('./internal').Component}\n * @param {() => void} [callback] A function to be called after component is\n * re-rendered\n */\nBaseComponent.prototype.forceUpdate = function (callback) {\n\tif (this._vnode) {\n\t\t// Set render mode so that we can differentiate where the render request\n\t\t// is coming from. We need this because forceUpdate should never call\n\t\t// shouldComponentUpdate\n\t\tthis._bits |= COMPONENT_FORCE;\n\t\tif (callback) this._renderCallbacks.push(callback);\n\t\tenqueueRender(this);\n\t}\n};\n\n/**\n * Accepts `props` and `state`, and returns a new Virtual DOM tree to build.\n * Virtual DOM is generally constructed via [JSX](https://jasonformat.com/wtf-is-jsx).\n * @param {object} props Props (eg: JSX attributes) received from parent\n * element/component\n * @param {object} state The component's current state\n * @param {object} context Context object, as returned by the nearest\n * ancestor's `getChildContext()`\n * @returns {ComponentChildren | void}\n */\nBaseComponent.prototype.render = Fragment;\n\n/**\n * @param {import('./internal').VNode} vnode\n * @param {number | null} [childIndex]\n */\nexport function getDomSibling(vnode, childIndex) {\n\tif (childIndex == NULL) {\n\t\t// Use childIndex==null as a signal to resume the search from the vnode's sibling\n\t\treturn vnode._parent && getDomSibling(vnode._parent, vnode._index + 1);\n\t}\n\n\tlet sibling;\n\tfor (; childIndex < vnode._children.length; childIndex++) {\n\t\tsibling = vnode._children[childIndex];\n\n\t\tif (sibling && sibling._dom) {\n\t\t\t// Since updateParentDomPointers keeps _dom pointer correct,\n\t\t\t// we can rely on _dom to tell us if this subtree contains a\n\t\t\t// rendered DOM node, and what the first rendered DOM node is\n\t\t\treturn sibling._dom;\n\t\t}\n\t}\n\n\t// If we get here, we have not found a DOM node in this vnode's children.\n\t// We must resume from this vnode's sibling (in it's parent _children array)\n\t// Only climb up and search the parent if we aren't searching through a DOM\n\t// VNode (meaning we reached the DOM parent of the original vnode that began\n\t// the search). New roots (_parentDom) are a DOM boundary too.\n\treturn typeof vnode.type == 'function' && !vnode.props._parentDom\n\t\t? getDomSibling(vnode)\n\t\t: NULL;\n}\n\n/**\n * Trigger in-place re-rendering of a component.\n * @param {import('./internal').Component} component The component to rerender\n */\nfunction renderComponent(component) {\n\tconst oldVNode = component._vnode,\n\t\toldDom = oldVNode._dom,\n\t\tcommitQueue = [],\n\t\trefQueue = [];\n\n\tconst parentDom = component._parentDom;\n\tif (parentDom) {\n\t\tconst newVNode = assign({ constructor: VNODE_MARKER }, oldVNode);\n\t\tnewVNode._original = oldVNode._original + 1;\n\t\tif (options.vnode) options.vnode(newVNode);\n\n\t\tdiff(\n\t\t\tparentDom,\n\t\t\tnewVNode,\n\t\t\toldVNode,\n\t\t\tcomponent._globalContext,\n\t\t\tparentDom.namespaceURI,\n\t\t\toldVNode._flags & MODE_HYDRATE ? [oldDom] : NULL,\n\t\t\tcommitQueue,\n\t\t\toldDom || getDomSibling(oldVNode),\n\t\t\toldVNode._flags & MODE_HYDRATE,\n\t\t\trefQueue\n\t\t);\n\n\t\tnewVNode._original = oldVNode._original;\n\t\tnewVNode._parent._children[newVNode._index] = newVNode;\n\t\tcommitRoot(commitQueue, newVNode, refQueue);\n\t\toldVNode._parent = oldVNode._dom = NULL;\n\n\t\tif (newVNode._dom != oldDom) {\n\t\t\tupdateParentDomPointers(newVNode);\n\t\t}\n\t}\n}\n\n/**\n * @param {import('./internal').VNode} vnode\n */\nfunction updateParentDomPointers(vnode) {\n\t// Stop at root boundaries (_parentDom)\n\tif ((vnode = vnode._parent) && vnode._component && !vnode.props._parentDom) {\n\t\t// _dom starts nulled, so re-assigning a null child._dom is a no-op and\n\t\t// the first truthy _dom stops the walk.\n\t\tvnode._dom = NULL;\n\t\tvnode._children.some(child => child && (vnode._dom = child._dom));\n\n\t\treturn updateParentDomPointers(vnode);\n\t}\n}\n\n/**\n * The render queue\n * @type {Array<import('./internal').Component>}\n */\nconst rerenderQueue = [];\n\n/*\n * The value of `Component.debounce` must asynchronously invoke the passed in callback. It is\n * important that contributors to Preact can consistently reason about what calls to `setState`, etc.\n * do, and when their effects will be applied. See the links below for some further reading on designing\n * asynchronous APIs.\n * * [Designing APIs for Asynchrony](https://blog.izs.me/2013/08/designing-apis-for-asynchrony)\n * * [Callbacks synchronous and asynchronous](https://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/)\n */\n\nlet prevDebounce,\n\trerenderCount = 0;\n\nexport function resetRenderCount() {\n\trerenderCount = 0;\n}\n\n/**\n * Enqueue a rerender of a component\n * @param {import('./internal').Component} c The component to rerender\n */\nexport function enqueueRender(c) {\n\tif (\n\t\t(!(c._bits & COMPONENT_DIRTY) &&\n\t\t\t((c._bits |= COMPONENT_DIRTY),\n\t\t\trerenderQueue.push(c),\n\t\t\t!rerenderCount++)) ||\n\t\tprevDebounce != options.debounceRendering\n\t) {\n\t\tprevDebounce = options.debounceRendering;\n\t\t(prevDebounce || queueMicrotask)(process);\n\t}\n}\n\n/**\n * @param {import('./internal').Component} a\n * @param {import('./internal').Component} b\n */\nconst depthSort = (a, b) => a._vnode._depth - b._vnode._depth;\n\n/** Flush the render queue by rerendering all queued components */\nfunction process() {\n\ttry {\n\t\tlet c,\n\t\t\tl = 1;\n\n\t\t// Don't update `renderCount` yet. Keep its value non-zero to prevent unnecessary\n\t\t// process() calls from getting scheduled while `queue` is still being consumed.\n\t\twhile (rerenderQueue.length) {\n\t\t\t// Keep the rerender queue sorted by (depth, insertion order). The queue\n\t\t\t// will initially be sorted on the first iteration only if it has more than 1 item.\n\t\t\t//\n\t\t\t// New items can be added to the queue e.g. when rerendering a provider, so we want to\n\t\t\t// keep the order from top to bottom with those new items so we can handle them in a\n\t\t\t// single pass\n\t\t\tif (rerenderQueue.length > l) {\n\t\t\t\trerenderQueue.sort(depthSort);\n\t\t\t}\n\n\t\t\tc = rerenderQueue.shift();\n\t\t\tl = rerenderQueue.length;\n\n\t\t\tif (c._bits & COMPONENT_DIRTY) {\n\t\t\t\trenderComponent(c);\n\t\t\t}\n\t\t}\n\t} finally {\n\t\tif ((rerenderCount = rerenderQueue.length)) {\n\t\t\t(prevDebounce || queueMicrotask)(process);\n\t\t}\n\t}\n}\n","import { NULL, SVG_NAMESPACE } from '../constants';\nimport options from '../options';\n\n// Per-instance unique key for the event clock stamp. Each Preact copy on the\n// page gets its own Symbol so that stamps on shared event objects can never\n// collide across instances.\nlet EVENT_DISPATCHED = Symbol();\n\nfunction setStyle(style, key, value) {\n\tif (value == NULL) value = '';\n\tif (key[0] == '-') {\n\t\tstyle.setProperty(key, value);\n\t} else {\n\t\tstyle[key] = value;\n\t}\n}\n\nconst CAPTURE_REGEX = /(PointerCapture)$|Capture$/i;\n\n// A logical clock to solve issues like https://github.com/preactjs/preact/issues/3927.\n// When the DOM performs an event it leaves micro-ticks in between bubbling up which means that\n// an event can trigger on a newly reated DOM-node while the event bubbles up.\n//\n// Originally inspired by Vue\n// (https://github.com/vuejs/core/blob/caeb8a68811a1b0f79/packages/runtime-dom/src/modules/events.ts#L90-L101),\n// but modified to use a logical clock instead of Date.now() in case event handlers get attached\n// and events get dispatched during the same millisecond.\n//\n// The clock is incremented after each new event dispatch. This allows 1 000 000 new events\n// per second for over 280 years before the value reaches Number.MAX_SAFE_INTEGER (2**53 - 1).\nlet eventClock = 0;\n\n/**\n * Set a property value on a DOM node\n * @param {import('../internal').PreactElement} dom The DOM node to modify\n * @param {string} name The name of the property to set\n * @param {*} value The value to set the property to\n * @param {*} oldValue The old value the property had\n * @param {string} namespace Whether or not this DOM node is an SVG node or not\n */\nexport function setProperty(dom, name, value, oldValue, namespace) {\n\tlet useCapture;\n\n\tif (name == 'style') {\n\t\tif (typeof value == 'string') {\n\t\t\tdom.style.cssText = value;\n\t\t} else {\n\t\t\tif (typeof oldValue == 'string') {\n\t\t\t\tdom.style.cssText = oldValue = '';\n\t\t\t}\n\n\t\t\tif (oldValue) {\n\t\t\t\tfor (name in oldValue) {\n\t\t\t\t\tif (!(value && name in value)) {\n\t\t\t\t\t\tsetStyle(dom.style, name);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (value) {\n\t\t\t\tfor (name in value) {\n\t\t\t\t\tif (!oldValue || value[name] != oldValue[name]) {\n\t\t\t\t\t\tsetStyle(dom.style, name, value[name]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// Benchmark for comparison: https://esbench.com/bench/574c954bdb965b9a00965ac6\n\telse if (name[0] == 'o' && name[1] == 'n') {\n\t\tif (typeof value != 'function') value = NULL;\n\t\tif (typeof oldValue != 'function') oldValue = NULL;\n\n\t\t// Handlers are keyed by prop name and every prop name gets its own proxy,\n\t\t// so swapping one (e.g. an inline arrow function on every render) is a\n\t\t// single store. The event name is only derived to attach or remove it.\n\t\t(dom._listeners || (dom._listeners = {}))[name] = value;\n\n\t\tif (!value || !oldValue) {\n\t\t\tconst proxy =\n\t\t\t\teventProxies[name] || (eventProxies[name] = createEventProxy(name));\n\t\t\t// The attach time belongs to the listener, not to the handler: one\n\t\t\t// function can back several listeners that were attached at different\n\t\t\t// times.\n\t\t\t(dom._attached || (dom._attached = {}))[name] = eventClock;\n\t\t\tuseCapture = name != (name = name.replace(CAPTURE_REGEX, '$1'));\n\n\t\t\t// Infer correct casing for DOM built-in events: `onClick` -> `click`.\n\t\t\t// Only names starting with an uppercase letter are lowercased, so\n\t\t\t// camelCase custom events keep their casing: `onionChange` -> `ionChange`.\n\t\t\tname = name.slice(2);\n\t\t\tif (name[0] < 'a') name = name.toLowerCase();\n\n\t\t\tif (value) {\n\t\t\t\tdom.addEventListener(name, proxy, useCapture);\n\t\t\t} else {\n\t\t\t\tdom.removeEventListener(name, proxy, useCapture);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif (namespace == SVG_NAMESPACE) {\n\t\t\t// Normalize incorrect prop usage for SVG:\n\t\t\t// - xlink:href / xlinkHref --> href (xlink:href was removed from SVG and isn't needed)\n\t\t\t// - className --> class\n\t\t\tname = name.replace(/xlink(H|:h)/, 'h').replace(/sName$/, 's');\n\t\t} else if (\n\t\t\tname != 'width' &&\n\t\t\tname != 'height' &&\n\t\t\tname != 'href' &&\n\t\t\tname != 'list' &&\n\t\t\tname != 'form' &&\n\t\t\t// Default value in browsers is `-1` and an empty string is\n\t\t\t// cast to `0` instead\n\t\t\tname != 'tabIndex' &&\n\t\t\tname != 'download' &&\n\t\t\tname != 'rowSpan' &&\n\t\t\tname != 'colSpan' &&\n\t\t\tname != 'role' &&\n\t\t\tname != 'popover' &&\n\t\t\tname in dom\n\t\t) {\n\t\t\ttry {\n\t\t\t\tdom[name] = value == NULL ? '' : value;\n\t\t\t\treturn;\n\t\t\t} catch (e) {}\n\t\t}\n\n\t\t// aria- and data- attributes have no boolean representation.\n\t\t// A `false` value is different from the attribute not being\n\t\t// present, so we can't remove it. For non-boolean aria\n\t\t// attributes we could treat false as a removal, but the\n\t\t// amount of exceptions would cost too many bytes. On top of\n\t\t// that other frameworks generally stringify `false`.\n\n\t\t// Never serialize functions as attribute values.\n\t\tif (typeof value == 'function') return;\n\t\tif (value != NULL && (value !== false || name[4] == '-')) {\n\t\t\tdom.setAttribute(name, name == 'popover' && value == true ? '' : value);\n\t\t} else {\n\t\t\tdom.removeAttribute(name);\n\t\t}\n\t}\n}\n\n/**\n * Create an event proxy function.\n * @param {string} name The prop name the handler is stored under.\n * @private\n */\nfunction createEventProxy(name) {\n\t/**\n\t * Proxy an event to hooked event handlers\n\t * @param {import('../internal').PreactEvent} e The event object from the browser\n\t * @private\n\t */\n\treturn function (e) {\n\t\tlet eventHandler = this._listeners;\n\t\tif (eventHandler) {\n\t\t\teventHandler = eventHandler[name];\n\t\t\tif (e[EVENT_DISPATCHED] == NULL) {\n\t\t\t\te[EVENT_DISPATCHED] = eventClock++;\n\n\t\t\t\t// When `e[EVENT_DISPATCHED]` is smaller than the time when the targeted event\n\t\t\t\t// listener was attached we know we have bubbled up to an element that was added\n\t\t\t\t// during patching the DOM.\n\t\t\t} else if (e[EVENT_DISPATCHED] < this._attached[name]) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn eventHandler(options.event ? options.event(e) : e);\n\t\t}\n\t};\n}\n\n/** @type {Record<string, (e: Event) => any>} */\nconst eventProxies = {};\n","import { enqueueRender } from './component';\nimport { COMPONENT_FORCE } from './constants';\n\nexport let i = 0;\n\nexport function createContext(defaultValue) {\n\tfunction Context(props) {\n\t\tif (!this.getChildContext) {\n\t\t\t/** @type {Set<import('./internal').Component> | null} */\n\t\t\tlet subs = new Set();\n\t\t\tlet ctx = {};\n\t\t\tctx[Context._id] = this;\n\n\t\t\tthis.getChildContext = () => ctx;\n\n\t\t\tthis.shouldComponentUpdate = function (_props) {\n\t\t\t\t// @ts-expect-error even\n\t\t\t\tif (this.props.value != _props.value) {\n\t\t\t\t\tsubs.forEach(c => {\n\t\t\t\t\t\tc._bits |= COMPONENT_FORCE;\n\t\t\t\t\t\tenqueueRender(c);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.sub = c => {\n\t\t\t\tsubs.add(c);\n\t\t\t\tlet old = c.componentWillUnmount;\n\t\t\t\tc.componentWillUnmount = () => {\n\t\t\t\t\tsubs.delete(c);\n\t\t\t\t\tif (old) old.call(c);\n\t\t\t\t};\n\t\t\t};\n\t\t}\n\n\t\treturn props.children;\n\t}\n\n\tContext._id = '__cC' + i++;\n\tContext._defaultValue = defaultValue;\n\n\t/** @type {import('./internal').FunctionComponent} */\n\tContext.Consumer = (props, contextValue) => {\n\t\treturn props.children(contextValue);\n\t};\n\n\tContext.Provider = Context.Consumer.contextType = Context;\n\n\treturn Context;\n}\n","import { EMPTY_ARR } from './constants';\n\nexport const isArray = Array.isArray;\nexport const slice = EMPTY_ARR.slice;\nexport const assign = Object.assign;\n\n/**\n * Remove a child node from its parent if attached.\n * @param {import('./internal').PreactElement | null} node The node to remove\n */\nexport function removeNode(node) {\n\tif (node && node.parentNode) node.remove();\n}\n","import { diff, unmount, applyRef } from './index';\nimport { createVNode, Fragment } from '../create-element';\nimport {\n\tEMPTY_OBJ,\n\tEMPTY_ARR,\n\tINSERT_VNODE,\n\tMATCHED,\n\tLIS_CANDIDATE,\n\tREF_DETACHED,\n\tUNDEFINED,\n\tVNODE_MARKER,\n\tNULL\n} from '../constants';\nimport { isArray } from '../util';\nimport { getDomSibling } from '../component';\n\n/**\n * @typedef {import('../internal').ComponentChildren} ComponentChildren\n * @typedef {import('../internal').Component} Component\n * @typedef {import('../internal').PreactElement} PreactElement\n * @typedef {import('../internal').VNode} VNode\n */\n\n/**\n * Diff the children of a virtual node\n * @param {PreactElement} parentDom The DOM element whose children are being\n * diffed\n * @param {ComponentChildren[]} renderResult\n * @param {VNode} newParentVNode The new virtual node whose children should be\n * diff'ed against oldParentVNode\n * @param {VNode} oldParentVNode The old virtual node whose children should be\n * diff'ed against newParentVNode\n * @param {object} globalContext The current context object - modified by\n * getChildContext\n * @param {string} namespace Current namespace of the DOM node (HTML, SVG, or MathML)\n * @param {Array<PreactElement>} excessDomChildren\n * @param {Array<Component>} commitQueue List of components which have callbacks\n * to invoke in commitRoot\n * @param {PreactElement} oldDom The current attached DOM element any new dom\n * elements should be placed around. Likely `null` on first render (except when\n * hydrating). Can be a sibling DOM element when diffing Fragments that have\n * siblings. In most cases, it starts out as `oldChildren[0]._dom`.\n * @param {boolean} isHydrating Whether or not we are in hydration\n * @param {any[]} refQueue an array of elements needed to invoke refs\n * @returns {PreactElement} The next sibling DOM element to insert new elements\n */\nexport function diffChildren(\n\tparentDom,\n\trenderResult,\n\tnewParentVNode,\n\toldParentVNode,\n\tglobalContext,\n\tnamespace,\n\texcessDomChildren,\n\tcommitQueue,\n\toldDom,\n\tisHydrating,\n\trefQueue\n) {\n\tlet i,\n\t\t/** @type {VNode} */\n\t\toldVNode,\n\t\t/** @type {VNode} */\n\t\tchildVNode,\n\t\t/** @type {PreactElement} */\n\t\tnewDom,\n\t\t/** @type {PreactElement} */\n\t\tfirstChildDom;\n\n\t// This is a compression of oldParentVNode != EMPTY_OBJ && oldParentVNode._children || EMPTY_ARR\n\t// as EMPTY_OBJ._children should be `undefined`. Callers always pass at\n\t// least EMPTY_OBJ, so a null check isn't needed.\n\t/** @type {VNode[]} */\n\tlet oldChildren = oldParentVNode._children || EMPTY_ARR;\n\n\tlet newChildrenLength = renderResult.length;\n\n\toldDom = constructNewChildrenArray(\n\t\tnewParentVNode,\n\t\trenderResult,\n\t\toldChildren,\n\t\toldDom,\n\t\tnewChildrenLength\n\t);\n\n\tfor (i = 0; i < newChildrenLength; i++) {\n\t\tchildVNode = newParentVNode._children[i];\n\t\tif (childVNode == NULL) continue;\n\n\t\t// At this point, constructNewChildrenArray has assigned _index to be the\n\t\t// matchingIndex for this VNode's oldVNode (or -1 if there is no oldVNode).\n\t\t// ~_index guards the -1 case: a negative array index is a named property\n\t\t// access which V8 can't serve from the fast elements path.\n\t\toldVNode =\n\t\t\t(~childVNode._index && oldChildren[childVNode._index]) || EMPTY_OBJ;\n\n\t\t// Update childVNode._index to its final index\n\t\tchildVNode._index = i;\n\n\t\t// Morph the old element into the new one, but don't append it to the dom yet\n\t\tlet result = diff(\n\t\t\tparentDom,\n\t\t\tchildVNode,\n\t\t\toldVNode,\n\t\t\tglobalContext,\n\t\t\tnamespace,\n\t\t\texcessDomChildren,\n\t\t\tcommitQueue,\n\t\t\toldDom,\n\t\t\tisHydrating,\n\t\t\trefQueue\n\t\t);\n\n\t\t// Adjust DOM nodes\n\t\tnewDom = childVNode._dom;\n\t\t// A ref detached while its subtree was parked by Suspense is attached\n\t\t// again on reveal.\n\t\tif (oldVNode.ref != childVNode.ref || oldVNode._flags & REF_DETACHED) {\n\t\t\tif (oldVNode.ref) applyRef(oldVNode.ref, NULL, childVNode, oldVNode);\n\t\t\tif (childVNode.ref) {\n\t\t\t\trefQueue.push(\n\t\t\t\t\tchildVNode.ref,\n\t\t\t\t\tchildVNode._component || newDom,\n\t\t\t\t\tchildVNode\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tfirstChildDom = firstChildDom || newDom;\n\n\t\tif (childVNode._flags & INSERT_VNODE) {\n\t\t\toldDom = insert(childVNode, oldDom, parentDom, !oldVNode._original);\n\n\t\t\t// When a matched VNode is physically moved via INSERT_VNODE, its old\n\t\t\t// _dom pointer becomes a stale positional reference. Clear it so that\n\t\t\t// getDomSibling (called from nested diffs) won't return this stale\n\t\t\t// reference and mis-place subsequent DOM nodes. See #5065.\n\t\t\tif (oldVNode._dom) {\n\t\t\t\toldVNode._dom = NULL;\n\t\t\t}\n\t\t} else if (typeof childVNode.type == 'function' && result !== UNDEFINED) {\n\t\t\toldDom = result;\n\t\t} else if (newDom) {\n\t\t\toldDom = newDom.nextSibling;\n\t\t}\n\n\t\t// Clear placement and LIS flags; MATCHED only belongs to old vnodes.\n\t\tchildVNode._flags &= ~(INSERT_VNODE | LIS_CANDIDATE);\n\t}\n\n\tnewParentVNode._dom = firstChildDom;\n\n\treturn oldDom;\n}\n\n/**\n * @param {VNode} newParentVNode\n * @param {ComponentChildren[]} renderResult\n * @param {VNode[]} oldChildren\n */\nfunction constructNewChildrenArray(\n\tnewParentVNode,\n\trenderResult,\n\toldChildren,\n\toldDom,\n\tnewChildrenLength\n) {\n\t/** @type {number} */\n\tlet i;\n\t/** @type {VNode} */\n\tlet childVNode;\n\t/** @type {VNode} */\n\tlet oldVNode;\n\n\tlet oldChildrenLength = oldChildren.length,\n\t\tremainingOldChildren = oldChildrenLength;\n\n\tlet skew = 0;\n\n\t/** Whether any matched child was found far from its skewed index, i.e. a\n\t * real reorder happened and we need to compute the minimal set of moves. */\n\tlet moved = 0;\n\n\t// Hoisted: every normalization branch below writes through this array, so\n\t// reading `_children` off the vnode each time is a wasted property load.\n\t/** @type {VNode[]} */\n\tlet newChildren = (newParentVNode._children = Array(newChildrenLength));\n\tfor (i = 0; i < newChildrenLength; i++) {\n\t\t// @ts-expect-error We are reusing the childVNode variable to hold both the\n\t\t// pre and post normalized childVNode\n\t\tchildVNode = renderResult[i];\n\n\t\tif (\n\t\t\tchildVNode == NULL ||\n\t\t\ttypeof childVNode == 'boolean' ||\n\t\t\ttypeof childVNode == 'function'\n\t\t) {\n\t\t\tnewChildren[i] = NULL;\n\t\t\tcontinue;\n\t\t}\n\t\t// If this newVNode is being reused (e.g. <div>{reuse}{reuse}</div>) in the same diff,\n\t\t// or we are rendering a component (e.g. setState) copy the oldVNodes so it can have\n\t\t// it's own DOM & etc. pointers\n\t\t// Anything that isn't an object at this point is a string, number or\n\t\t// bigint (null, booleans and functions are handled above), String\n\t\t// objects are the lone object type rendered as text.\n\t\telse if (\n\t\t\ttypeof childVNode != 'object' ||\n\t\t\tchildVNode.constructor === String\n\t\t) {\n\t\t\tchildVNode = newChildren[i] = createVNode(NULL, childVNode);\n\t\t} else if (isArray(childVNode)) {\n\t\t\tchildVNode = newChildren[i] = createVNode(Fragment, {\n\t\t\t\tchildren: childVNode\n\t\t\t});\n\t\t} else if (childVNode.constructor === VNODE_MARKER && childVNode._depth) {\n\t\t\t// VNode is already in use, clone it. This can happen in the following\n\t\t\t// scenario:\n\t\t\t// const reuse = <div />\n\t\t\t// <div>{reuse}<span />{reuse}</div>\n\t\t\tchildVNode = newChildren[i] = createVNode(\n\t\t\t\tchildVNode.type,\n\t\t\t\tchildVNode.props,\n\t\t\t\tchildVNode.key,\n\t\t\t\tchildVNode.ref,\n\t\t\t\tchildVNode._original\n\t\t\t);\n\t\t} else {\n\t\t\tnewChildren[i] = childVNode;\n\t\t}\n\n\t\tconst skewedIndex = i + skew;\n\t\tchildVNode._parent = newParentVNode;\n\t\tchildVNode._depth = newParentVNode._depth + 1;\n\n\t\t// Temporarily store the matchingIndex on the _index property so we can pull\n\t\t// out the oldVNode in diffChildren. We'll override this to the VNode's\n\t\t// final index after using this property to get the oldVNode\n\t\tconst matchingIndex = (childVNode._index = findMatchingIndex(\n\t\t\tchildVNode,\n\t\t\toldChildren,\n\t\t\tskewedIndex,\n\t\t\tremainingOldChildren\n\t\t));\n\n\t\toldVNode = NULL;\n\t\t// ~matchingIndex is only falsy for -1, i.e. when no match was found\n\t\tif (~matchingIndex) {\n\t\t\toldVNode = oldChildren[matchingIndex];\n\t\t\tremainingOldChildren--;\n\t\t\tif (oldVNode) {\n\t\t\t\toldVNode._flags |= MATCHED;\n\t\t\t}\n\t\t}\n\n\t\t// Here, we define isMounting for the purposes of the skew diffing\n\t\t// algorithm. Nodes that are unsuspending are considered mounting and we detect\n\t\t// this by checking if oldVNode._original == null\n\t\tif (!oldVNode || !oldVNode._original) {\n\t\t\tif (!~matchingIndex) {\n\t\t\t\t// When the array of children is growing we need to decrease the skew\n\t\t\t\t// as we are adding a new element to the array.\n\t\t\t\t// Example:\n\t\t\t\t// [1, 2, 3] --> [0, 1, 2, 3]\n\t\t\t\t// oldChildren newChildren\n\t\t\t\t//\n\t\t\t\t// The new element is at index 0, so our skew is 0,\n\t\t\t\t// we need to decrease the skew as we are adding a new element.\n\t\t\t\t// The decrease will cause us to compare the element at position 1\n\t\t\t\t// with value 1 with the element at position 0 with value 0.\n\t\t\t\t//\n\t\t\t\t// A linear concept is applied when the array is shrinking,\n\t\t\t\t// if the length is unchanged we can assume that no skew\n\t\t\t\t// changes are needed.\n\t\t\t\tif (newChildrenLength > oldChildrenLength) {\n\t\t\t\t\tskew--;\n\t\t\t\t} else if (newChildrenLength < oldChildrenLength) {\n\t\t\t\t\tskew++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If we are mounting a DOM VNode, mark it for insertion\n\t\t\tif (typeof childVNode.type != 'function') {\n\t\t\t\tchildVNode._flags |= INSERT_VNODE;\n\t\t\t}\n\t\t} else {\n\t\t\t// Keep LIS eligibility separate from MATCHED on old vnodes: if a child\n\t\t\t// throws, uncleared new-vnode flags must not prevent the next match.\n\t\t\tchildVNode._flags |= LIS_CANDIDATE;\n\n\t\t\t// Center the next search for shifts. Only matches farther than one\n\t\t\t// position away require the minimal-move pass.\n\t\t\tif (matchingIndex == skewedIndex - 1) {\n\t\t\t\tskew--;\n\t\t\t} else if (matchingIndex == skewedIndex + 1) {\n\t\t\t\tskew++;\n\t\t\t} else if (matchingIndex != skewedIndex) {\n\t\t\t\tif (matchingIndex > skewedIndex) {\n\t\t\t\t\tskew--;\n\t\t\t\t} else {\n\t\t\t\t\tskew++;\n\t\t\t\t}\n\n\t\t\t\tmoved = 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (moved) {\n\t\t// Children were reordered: mark the minimal set of matched (LIS_CANDIDATE flag)\n\t\t// children for insertion by finding the longest increasing subsequence of\n\t\t// old indices (patience sorting). Children on the subsequence stay in\n\t\t// place, all others get INSERT_VNODE. `_index` still holds the\n\t\t// matchingIndex here.\n\t\t/** @type {number[]} tails[x] is the smallest old index ending an increasing subsequence of length x+1 */\n\t\tlet tails = [];\n\t\t/** @type {number[]} length of the longest increasing subsequence ending at child i */\n\t\tlet lisLengths = [];\n\t\tfor (i = 0; i < newChildrenLength; i++) {\n\t\t\tchildVNode = newChildren[i];\n\t\t\tif (childVNode && childVNode._flags & LIS_CANDIDATE) {\n\t\t\t\t// Binary search for the insertion point, keeping the pass at\n\t\t\t\t// O(n log n) even for pathological reorders.\n\t\t\t\tskew = 0;\n\t\t\t\tlet hi = tails.length;\n\t\t\t\twhile (skew < hi) {\n\t\t\t\t\tconst mid = (skew + hi) >> 1;\n\t\t\t\t\tif (tails[mid] < childVNode._index) {\n\t\t\t\t\t\tskew = mid + 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\thi = mid;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttails[skew] = childVNode._index;\n\t\t\t\tlisLengths[i] = skew + 1;\n\t\t\t}\n\t\t}\n\n\t\t// `skew` is dead after the main loop; reuse it as the remaining\n\t\t// subsequence length while walking backwards. Likewise `i` is left at\n\t\t// newChildrenLength by the loop above.\n\t\tskew = tails.length;\n\t\twhile (i--) {\n\t\t\tif (lisLengths[i]) {\n\t\t\t\tif (lisLengths[i] == skew) {\n\t\t\t\t\tskew--;\n\t\t\t\t} else {\n\t\t\t\t\tnewChildren[i]._flags |= INSERT_VNODE;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Remove remaining oldChildren if there are any. Loop forwards so that as we\n\t// unmount DOM from the beginning of the oldChildren, we can adjust oldDom to\n\t// point to the next child, which needs to be the first DOM node that won't be\n\t// unmounted. Keep this a plain loop: an arrow function here would capture\n\t// `oldDom`, forcing V8 to context-allocate it on every call to this function.\n\tif (remainingOldChildren) {\n\t\tfor (i = 0; i < oldChildrenLength; i++) {\n\t\t\toldVNode = oldChildren[i];\n\t\t\tif (oldVNode && !(oldVNode._flags & MATCHED)) {\n\t\t\t\tif (oldVNode._dom == oldDom) {\n\t\t\t\t\toldDom = getDomSibling(oldVNode);\n\t\t\t\t}\n\n\t\t\t\tunmount(oldVNode, oldVNode);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn oldDom;\n}\n\n/**\n * @param {VNode} parentVNode\n * @param {PreactElement} oldDom\n * @param {PreactElement} parentDom\n * @param {boolean} isMounting\n * @returns {PreactElement}\n */\nfunction insert(parentVNode, oldDom, parentDom, isMounting) {\n\t// Note: VNodes in nested suspended trees may be missing _children.\n\tif (typeof parentVNode.type == 'function') {\n\t\t// Root children live in another container, they never move with the\n\t\t// host tree and contribute nothing to the host insertion cursor.\n\t\tif (parentVNode.props._parentDom) return oldDom;\n\t\tlet children = parentVNode._children;\n\t\tif (children) {\n\t\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\t\tif (children[i]) {\n\t\t\t\t\t// If we enter this code path on sCU bailout, where we copy\n\t\t\t\t\t// oldVNode._children to newVNode._children, we need to update the old\n\t\t\t\t\t// children's _parent pointer to point to the newVNode (parentVNode\n\t\t\t\t\t// here).\n\t\t\t\t\tchildren[i]._parent = parentVNode;\n\t\t\t\t\toldDom = insert(children[i], oldDom, parentDom, false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn oldDom;\n\t} else {\n\t\t// A cursor a parked Suspense subtree detached can't be a reference node:\n\t\t// retry from the vnode tree, then give up and append.\n\t\tif (oldDom && !oldDom.parentNode) {\n\t\t\toldDom = getDomSibling(parentVNode);\n\t\t\tif (oldDom && !oldDom.parentNode) oldDom = NULL;\n\t\t}\n\n\t\t// Comments (e.g. server `$s` markers) are never ours: a node right after\n\t\t// them is already in place.\n\t\tlet dom = parentVNode._dom;\n\t\tlet next = oldDom;\n\t\twhile (next && next.nodeType == 8) next = next.nextSibling;\n\n\t\tif (dom != next) {\n\t\t\t// Containers that aren't DOM nodes may not implement moveBefore()\n\t\t\tif (!isMounting && parentDom.moveBefore && dom.parentNode) {\n\t\t\t\t// @ts-expect-error This isn't added to TypeScript lib.d.ts yet\n\t\t\t\tparentDom.moveBefore(dom, oldDom);\n\t\t\t} else {\n\t\t\t\tparentDom.insertBefore(dom, oldDom || NULL);\n\t\t\t}\n\t\t}\n\t\toldDom = dom;\n\t}\n\n\twhile (\n\t\t(oldDom = oldDom && oldDom.nextSibling) &&\n\t\toldDom.nodeType == 8 &&\n\t\t!oldDom.data.startsWith('$s')\n\t);\n\n\treturn oldDom;\n}\n\n/**\n * Flatten and loop through the children of a virtual node\n * @param {ComponentChildren} children The unflattened children of a virtual\n * node\n * @returns {VNode[]}\n */\nexport function toChildArray(children, out) {\n\tout = out || [];\n\tif (children != NULL && typeof children != 'boolean') {\n\t\tif (isArray(children)) {\n\t\t\tchildren.some(child => {\n\t\t\t\ttoChildArray(child, out);\n\t\t\t});\n\t\t} else {\n\t\t\tout.push(children);\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n * @param {VNode} childVNode\n * @param {VNode[]} oldChildren\n * @param {number} skewedIndex\n * @param {number} remainingOldChildren\n * @returns {number}\n */\nfunction findMatchingIndex(\n\tchildVNode,\n\toldChildren,\n\tskewedIndex,\n\tremainingOldChildren\n) {\n\tconst key = childVNode.key;\n\tconst type = childVNode.type;\n\tlet oldVNode = oldChildren[skewedIndex];\n\tconst matched = oldVNode && !(oldVNode._flags & MATCHED);\n\n\t// We only need to perform a search if there are more children\n\t// (remainingOldChildren) to search. However, if the oldVNode we just looked\n\t// at skewedIndex was not already used in this diff, then there must be at\n\t// least 1 other (so greater than 1) remainingOldChildren to attempt to match\n\t// against. So the following condition checks that ensuring\n\t// remainingOldChildren > 1 if the oldVNode is not already used/matched. Else\n\t// if the oldVNode was null or matched, then there could needs to be at least\n\t// 1 (aka `remainingOldChildren > 0`) children to find and compare against.\n\t//\n\t// If there is an unkeyed functional VNode, that isn't a built-in like our Fragment,\n\t// we should not search as we risk re-using state of an unrelated VNode. (reverted for now)\n\tlet shouldSearch =\n\t\t// (typeof type != 'function' || type === Fragment || key) &&\n\t\t// The ternary keeps this a Smi comparison; `> matched` would compare\n\t\t// number to boolean which V8 can't serve from the fast path.\n\t\tremainingOldChildren > (matched ? 1 : 0);\n\n\tif (\n\t\t(oldVNode === NULL && key == NULL) ||\n\t\t(matched && key == oldVNode.key && type == oldVNode.type)\n\t) {\n\t\treturn skewedIndex;\n\t} else if (shouldSearch) {\n\t\tlet x;\n\t\tfor (x = skewedIndex - 1; x >= 0; x--) {\n\t\t\toldVNode = oldChildren[x];\n\t\t\tif (\n\t\t\t\toldVNode &&\n\t\t\t\t!(oldVNode._flags & MATCHED) &&\n\t\t\t\tkey == oldVNode.key &&\n\t\t\t\ttype == oldVNode.type\n\t\t\t)\n\t\t\t\treturn x;\n\t\t}\n\t\tfor (x = skewedIndex + 1; x < oldChildren.length; x++) {\n\t\t\toldVNode = oldChildren[x];\n\t\t\tif (\n\t\t\t\toldVNode &&\n\t\t\t\t!(oldVNode._flags & MATCHED) &&\n\t\t\t\tkey == oldVNode.key &&\n\t\t\t\ttype == oldVNode.type\n\t\t\t)\n\t\t\t\treturn x;\n\t\t}\n\t}\n\n\treturn -1;\n}\n","import { BaseComponent, getDomSibling } from '../component';\nimport {\n\tCOMPONENT_DIRTY,\n\tCOMPONENT_FORCE,\n\tCOMPONENT_PENDING_ERROR,\n\tCOMPONENT_PROCESSING_EXCEPTION,\n\tEMPTY_ARR,\n\tEMPTY_OBJ,\n\tMATHML_TOKEN_ELEMENTS,\n\tMATH_NAMESPACE,\n\tMODE_HYDRATE,\n\tMODE_SUSPENDED,\n\tNULL,\n\tRESET_MODE,\n\tSVG_NAMESPACE,\n\tUNDEFINED,\n\tVNODE_MARKER,\n\tXHTML_NAMESPACE\n} from '../constants';\nimport { Fragment } from '../create-element';\nimport options from '../options';\nimport { assign, isArray, removeNode, slice } from '../util';\nimport { diffChildren } from './children';\nimport { setProperty } from './props';\n\n/**\n * @typedef {import('../internal').ComponentType} ComponentType\n * @typedef {import('../internal').ComponentChildren} ComponentChildren\n * @typedef {import('../internal').Component} Component\n * @typedef {import('../internal').PreactElement} PreactElement\n * @typedef {import('../internal').VNode} VNode\n */\n\n/**\n * @template {any} T\n * @typedef {import('../internal').Ref<T>} Ref<T>\n */\n\n/**\n * Diff two virtual nodes and apply proper changes to the DOM\n * @param {PreactElement} parentDom The parent of the DOM element\n * @param {VNode} newVNode The new virtual node\n * @param {VNode} oldVNode The old virtual node\n * @param {object} globalContext The current context object. Modified by\n * getChildContext\n * @param {string} namespace Current namespace of the DOM node (HTML, SVG, or MathML)\n * @param {Array<PreactElement>} excessDomChildren\n * @param {Array<Component>} commitQueue List of components which have callbacks\n * to invoke in commitRoot\n * @param {PreactElement} oldDom The current attached DOM element any new dom\n * elements should be placed around. Likely `null` on first render (except when\n * hydrating). Can be a sibling DOM element when diffing Fragments that have\n * siblings. In most cases, it starts out as `oldChildren[0]._dom`.\n * @param {boolean} isHydrating Whether or not we are in hydration\n * @param {any[]} refQueue an array of elements needed to invoke refs\n */\nexport function diff(\n\tparentDom,\n\tnewVNode,\n\toldVNode,\n\tglobalContext,\n\tnamespace,\n\texcessDomChildren,\n\tcommitQueue,\n\toldDom,\n\tisHydrating,\n\trefQueue\n) {\n\t/** @type {any} */\n\tlet tmp,\n\t\tresumed,\n\t\tnewType = newVNode.type;\n\n\t// Only diff VNodes created by Preact.\n\tif (newVNode.constructor !== VNODE_MARKER) return NULL;\n\n\t// If the previous diff bailed out, resume creating/hydrating into the DOM\n\t// that was kept while suspended (server-rendered, or already in the\n\t// container we rendered into). `tmp` holds the stored excess node until the\n\t// options._diff call below.\n\tif (\n\t\toldVNode._flags & MODE_SUSPENDED &&\n\t\t// @ts-expect-error This is MODE_HYDRATE or 0\n\t\t((isHydrating = oldVNode._flags & MODE_HYDRATE),\n\t\t(tmp = oldVNode._component._excess))\n\t) {\n\t\tnewVNode._flags |= isHydrating;\n\t\tresumed = excessDomChildren = [];\n\t\tif (tmp.nodeType == 8) {\n\t\t\t// Re-scan DOM from stored start marker for streamed hydration.\n\t\t\toldDom = rangeEnd(tmp, excessDomChildren);\n\t\t} else {\n\t\t\texcessDomChildren.push(tmp);\n\t\t}\n\t\toldDom = excessDomChildren[0] || oldDom;\n\t}\n\n\tif ((tmp = options._diff)) tmp(newVNode);\n\n\touter: if (typeof newType == 'function') {\n\t\tlet oldCommitQueueLength = commitQueue.length;\n\t\ttry {\n\t\t\tlet c,\n\t\t\t\toldProps,\n\t\t\t\toldState,\n\t\t\t\tsnapshot,\n\t\t\t\tnewProps = newVNode.props;\n\t\t\tconst isClassComponent = (tmp = newType.prototype) && tmp.render;\n\n\t\t\t// Necessary for createContext api. Setting this property will pass\n\t\t\t// the context value as `this.context` just for this component.\n\t\t\ttmp = newType.contextType;\n\t\t\tconst provider = tmp && globalContext[tmp._id];\n\t\t\tconst componentContext = tmp\n\t\t\t\t? provider\n\t\t\t\t\t? provider.props.value\n\t\t\t\t\t: tmp._defaultValue\n\t\t\t\t: globalContext;\n\n\t\t\t// Get component and set it to `c`\n\t\t\tif ((c = oldVNode._component)) {\n\t\t\t\tnewVNode._component = c;\n\t\t\t\tif (c._bits & COMPONENT_PENDING_ERROR) {\n\t\t\t\t\tc._bits |= COMPONENT_PROCESSING_EXCEPTION;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Instantiate the new component\n\t\t\t\tif (isClassComponent) {\n\t\t\t\t\t// @ts-expect-error Trust me, Component implements the interface we want\n\t\t\t\t\tnewVNode._component = c = new newType(newProps, componentContext); // eslint-disable-line new-cap\n\t\t\t\t} else {\n\t\t\t\t\t// @ts-expect-error Trust me, Component implements the interface we want\n\t\t\t\t\tnewVNode._component = c = new BaseComponent(\n\t\t\t\t\t\tnewProps,\n\t\t\t\t\t\tcomponentContext\n\t\t\t\t\t);\n\n\t\t\t\t\tc.constructor = newType;\n\t\t\t\t\tc.render = doRender;\n\t\t\t\t}\n\t\t\t\tif (provider) provider.sub(c);\n\n\t\t\t\tif (!c.state) c.state = {};\n\t\t\t\tc._globalContext = globalContext;\n\t\t\t\tc._bits |= COMPONENT_DIRTY;\n\t\t\t\tc._renderCallbacks = [];\n\t\t\t\tc._stateCallbacks = [];\n\t\t\t}\n\n\t\t\tif (isClassComponent) {\n\t\t\t\tif (!c._nextState) c._nextState = c.state;\n\n\t\t\t\t// Invoke getDerivedStateFromProps\n\t\t\t\tif (newType.getDerivedStateFromProps) {\n\t\t\t\t\tif (c._nextState == c.state) {\n\t\t\t\t\t\tc._nextState = assign({}, c._nextState);\n\t\t\t\t\t}\n\n\t\t\t\t\tassign(\n\t\t\t\t\t\tc._nextState,\n\t\t\t\t\t\tnewType.getDerivedStateFromProps(newProps, c._nextState)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\toldProps = c.props;\n\t\t\toldState = c.state;\n\t\t\tc._vnode = newVNode;\n\n\t\t\t// Invoke pre-render lifecycle methods\n\t\t\tif (!oldVNode._component) {\n\t\t\t\tif (\n\t\t\t\t\tisClassComponent &&\n\t\t\t\t\t!newType.getDerivedStateFromProps &&\n\t\t\t\t\tc.componentWillMount\n\t\t\t\t) {\n\t\t\t\t\tc.componentWillMount();\n\t\t\t\t}\n\n\t\t\t\tif (isClassComponent && c.componentDidMount) {\n\t\t\t\t\tc._renderCallbacks.push(c.componentDidMount);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tnewProps !== oldProps &&\n\t\t\t\t\tisClassComponent &&\n\t\t\t\t\t!newType.getDerivedStateFromProps &&\n\t\t\t\t\tc.componentWillReceiveProps\n\t\t\t\t) {\n\t\t\t\t\tc.componentWillReceiveProps(newProps, componentContext);\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t(newVNode._original == oldVNode._original &&\n\t\t\t\t\t\t!(c._bits & COMPONENT_DIRTY)) ||\n\t\t\t\t\t(!(c._bits & COMPONENT_FORCE) &&\n\t\t\t\t\t\tc.shouldComponentUpdate &&\n\t\t\t\t\t\tc.shouldComponentUpdate(\n\t\t\t\t\t\t\tnewProps,\n\t\t\t\t\t\t\tc._nextState,\n\t\t\t\t\t\t\tcomponentContext\n\t\t\t\t\t\t) === false)\n\t\t\t\t) {\n\t\t\t\t\t// More info about this here: https://gist.github.com/JoviDeCroock/bec5f2ce93544d2e6070ef8e0036e4e8\n\t\t\t\t\tif (newVNode._original != oldVNode._original) {\n\t\t\t\t\t\t// When we are dealing with a bail because of sCU we have to update\n\t\t\t\t\t\t// the props, state and dirty-state.\n\t\t\t\t\t\t// when we are dealing with strict-equality we don't as the child could still\n\t\t\t\t\t\t// be dirtied see #3883\n\t\t\t\t\t\tc.props = newProps;\n\t\t\t\t\t\tc.state = c._nextState;\n\t\t\t\t\t\tc._bits &= ~COMPONENT_DIRTY;\n\t\t\t\t\t}\n\n\t\t\t\t\tnewVNode._dom = oldVNode._dom;\n\t\t\t\t\tnewVNode._children = oldVNode._children;\n\t\t\t\t\tnewVNode._children.some(vnode => {\n\t\t\t\t\t\tif (vnode) vnode._parent = newVNode;\n\t\t\t\t\t});\n\n\t\t\t\t\tEMPTY_ARR.push.apply(c._renderCallbacks, c._stateCallbacks);\n\t\t\t\t\tc._stateCallbacks = [];\n\n\t\t\t\t\tif (c._renderCallbacks.length) {\n\t\t\t\t\t\tcommitQueue.push(c);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Skip over the retained subtree without traversing it; the\n\t\t\t\t\t// `result` branch in diffChildren picks this up as the next\n\t\t\t\t\t// oldDom.\n\t\t\t\t\toldDom = getDomSibling(oldVNode);\n\n\t\t\t\t\tbreak outer;\n\t\t\t\t}\n\n\t\t\t\tif (c.componentWillUpdate) {\n\t\t\t\t\tc.componentWillUpdate(newProps, c._nextState, componentContext);\n\t\t\t\t}\n\n\t\t\t\tif (isClassComponent && c.componentDidUpdate) {\n\t\t\t\t\tc._renderCallbacks.push(() => {\n\t\t\t\t\t\tc.componentDidUpdate(oldProps, oldState, snapshot);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tc.context = componentContext;\n\t\t\tc.props = newProps;\n\t\t\tc._parentDom = parentDom;\n\t\t\tc._bits &= ~COMPONENT_FORCE;\n\n\t\t\t// Function components re-render until they stop calling setState\n\t\t\t// during render (see #2553), class components render exactly once.\n\t\t\tlet renderHook = options._render,\n\t\t\t\tcount = isClassComponent ? 25 : 0;\n\t\t\tdo {\n\t\t\t\tc._bits &= ~COMPONENT_DIRTY;\n\t\t\t\tif (renderHook) renderHook(newVNode);\n\t\t\t\ttmp = c.render(c.props, (c.state = c._nextState), c.context);\n\t\t\t} while (c._bits & COMPONENT_DIRTY && ++count < 25);\n\n\t\t\tif (isClassComponent) {\n\t\t\t\tEMPTY_ARR.push.apply(c._renderCallbacks, c._stateCallbacks);\n\t\t\t\tc._stateCallbacks = [];\n\t\t\t}\n\n\t\t\t// Handle setState called in render, see #2553\n\t\t\tc.state = c._nextState;\n\n\t\t\tif (c.getChildContext) {\n\t\t\t\tglobalContext = assign({}, globalContext, c.getChildContext());\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tisClassComponent &&\n\t\t\t\toldVNode._component &&\n\t\t\t\tc.getSnapshotBeforeUpdate\n\t\t\t) {\n\t\t\t\tsnapshot = c.getSnapshotBeforeUpdate(oldProps, oldState);\n\t\t\t}\n\n\t\t\tconst renderResult =\n\t\t\t\ttmp && tmp.type === Fragment && tmp.key == NULL\n\t\t\t\t\t? tmp.props.children\n\t\t\t\t\t: tmp;\n\n\t\t\t// A vnode carrying a `_parentDom` prop, considered a new root,\n\t\t\t// continues rendering into that container. The subtree must stay\n\t\t\t// invisible to the host tree's DOM bookkeeping: the portal vnode\n\t\t\t// keeps a `null` `_dom` and the host insertion cursor (`oldDom`)\n\t\t\t// passes through unchanged.\n\t\t\t// `tmp` (the raw render result, already unwrapped into renderResult)\n\t\t\t// doubles as the saved host insertion cursor while we render into\n\t\t\t// the portal's container.\n\t\t\tif (newProps._parentDom) {\n\t\t\t\ttmp = oldDom;\n\t\t\t\tparentDom = newProps._parentDom;\n\t\t\t\t// If we portal into a math or svg element we need\n\t\t\t\t// to swap the namespace (chart libraries often do this).\n\t\t\t\t// The document follows the container too (e.g. iframes) as\n\t\t\t\t// diffElementNodes derives it from its parentDom.\n\t\t\t\tnamespace = parentDom.namespaceURI;\n\t\t\t\t// Portals are never server-rendered: hydration must not claim the\n\t\t\t\t// host parent's excess nodes for the container's children.\n\t\t\t\tisHydrating = excessDomChildren = NULL;\n\n\t\t\t\t// Changing the container remounts the children into the new one\n\t\t\t\tif (oldVNode.props && oldVNode.props._parentDom != parentDom) {\n\t\t\t\t\t/** @type {VNode[]} */ (oldVNode._children).some(child => {\n\t\t\t\t\t\tif (child) unmount(child, child);\n\t\t\t\t\t});\n\t\t\t\t\toldVNode._children = NULL;\n\t\t\t\t}\n\n\t\t\t\toldDom = oldVNode._children ? getDomSibling(oldVNode, 0) : NULL;\n\t\t\t}\n\n\t\t\toldDom = diffChildren(\n\t\t\t\tparentDom,\n\t\t\t\tisArray(renderResult) ? renderResult : [renderResult],\n\t\t\t\tnewVNode,\n\t\t\t\toldVNode,\n\t\t\t\tglobalContext,\n\t\t\t\tnamespace,\n\t\t\t\texcessDomChildren,\n\t\t\t\tcommitQueue,\n\t\t\t\toldDom,\n\t\t\t\tisHydrating,\n\t\t\t\trefQueue\n\t\t\t);\n\n\t\t\t// When we exit a portal we\n\t\t\t// change up the oldDom\n\t\t\tif (newProps._parentDom) {\n\t\t\t\tnewVNode._dom = NULL;\n\t\t\t\toldDom = tmp;\n\t\t\t}\n\n\t\t\t// Keep `_excess` so unmount can remove the range markers.\n\t\t\tnewVNode._flags &= RESET_MODE;\n\n\t\t\t// Remove the kept DOM this resumed render didn't claim\n\t\t\tif (resumed) resumed.some(removeNode);\n\n\t\t\tif (c._renderCallbacks.length) {\n\t\t\t\tcommitQueue.push(c);\n\t\t\t}\n\n\t\t\t// Only clear when this render was the retry; PENDING_ERROR set by a\n\t\t\t// descendant during this render must survive until then.\n\t\t\tif (c._bits & COMPONENT_PROCESSING_EXCEPTION) {\n\t\t\t\tc._bits &= ~(COMPONENT_PROCESSING_EXCEPTION | COMPONENT_PENDING_ERROR);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\t// We remove any componentDidMount, ...\n\t\t\t// that have been invalidated by us\n\t\t\t// intercepting the error.\n\t\t\tcommitQueue.length = oldCommitQueueLength;\n\t\t\tnewVNode._original = NULL;\n\t\t\t// if hydrating or creating initial tree, bailout preserves DOM:\n\t\t\tif (isHydrating || excessDomChildren) {\n\t\t\t\tif (e && e.then) {\n\t\t\t\t\tlet startMarker, end;\n\n\t\t\t\t\t// isHydrating is MODE_HYDRATE or falsy\n\t\t\t\t\tnewVNode._flags |= MODE_SUSPENDED | isHydrating;\n\n\t\t\t\t\tif (excessDomChildren) {\n\t\t\t\t\t\tlet i = excessDomChildren.indexOf(oldDom || UNDEFINED),\n\t\t\t\t\t\t\tchild;\n\t\t\t\t\t\tif (!~i) i = excessDomChildren.length;\n\n\t\t\t\t\t\t// The cursor skips comments: step back to this component's markers.\n\t\t\t\t\t\twhile ((child = excessDomChildren[i - 1]) && child.nodeType == 8) {\n\t\t\t\t\t\t\ti--;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Keep what this component would have claimed: its whole\n\t\t\t\t\t\t// streamed range (all of it when unclosed), or else the first\n\t\t\t\t\t\t// node that isn't a comment.\n\t\t\t\t\t\tfor (; i < excessDomChildren.length; i++) {\n\t\t\t\t\t\t\tif ((child = excessDomChildren[i])) {\n\t\t\t\t\t\t\t\texcessDomChildren[i] = NULL;\n\t\t\t\t\t\t\t\tif (startMarker) {\n\t\t\t\t\t\t\t\t\tif (child == end) break;\n\t\t\t\t\t\t\t\t} else if (child.nodeType != 8) {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t} else if (child.data.startsWith('$s')) {\n\t\t\t\t\t\t\t\t\tend = rangeEnd((startMarker = child));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!startMarker) {\n\t\t\t\t\t\twhile (oldDom && oldDom.nodeType == 8 && oldDom.nextSibling) {\n\t\t\t\t\t\t\toldDom = oldDom.nextSibling;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstartMarker = oldDom;\n\t\t\t\t\t}\n\t\t\t\t\t// Preserve the original range when re-suspending.\n\t\t\t\t\tstartMarker =\n\t\t\t\t\t\tnewVNode._component._excess ||\n\t\t\t\t\t\t(newVNode._component._excess = startMarker);\n\t\t\t\t\t// Insert before the range; continue diffing after it.\n\t\t\t\t\tif ((tmp = rangeEnd(startMarker))) {\n\t\t\t\t\t\tnewVNode._dom = startMarker;\n\t\t\t\t\t\toldDom = tmp;\n\t\t\t\t\t} else newVNode._dom = oldDom;\n\t\t\t\t\toldDom = oldDom && oldDom.nextSibling;\n\t\t\t\t} else if (excessDomChildren) {\n\t\t\t\t\texcessDomChildren.some(removeNode);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnewVNode._dom = oldVNode._dom;\n\t\t\t}\n\n\t\t\tif (!newVNode._children) {\n\t\t\t\tnewVNode._children = oldVNode._children || [];\n\t\t\t}\n\n\t\t\tif (!(e && e.then)) markAsForce(newVNode);\n\t\t\toptions._catchError(e, newVNode, oldVNode);\n\t\t}\n\t} else {\n\t\toldDom = newVNode._dom = diffElementNodes(\n\t\t\toldVNode._dom,\n\t\t\tnewVNode,\n\t\t\toldVNode,\n\t\t\tglobalContext,\n\t\t\tnamespace,\n\t\t\texcessDomChildren,\n\t\t\tcommitQueue,\n\t\t\tisHydrating,\n\t\t\trefQueue,\n\t\t\tparentDom\n\t\t);\n\t}\n\n\tif ((tmp = options.diffed)) tmp(newVNode);\n\n\treturn oldDom;\n}\n\n/**\n * Find the closing marker of a streamed range.\n * @param {PreactElement} start A `$s` marker opening a range\n * @param {PreactElement[]} [nodes] Collects the nodes inside the range\n * @returns {PreactElement} The closing marker, or undefined when `start` doesn't\n * open a range or the range is unclosed\n */\nfunction rangeEnd(start, nodes) {\n\tif (start && start.nodeType == 8 && start.data.startsWith('$s')) {\n\t\tfor (let depth = 1; (start = start.nextSibling); ) {\n\t\t\tif (start.nodeType == 8) {\n\t\t\t\tif (start.data.startsWith('$s')) depth++;\n\t\t\t\telse if (start.data.startsWith('/$s') && !--depth) return start;\n\t\t\t}\n\t\t\tif (nodes) nodes.push(start);\n\t\t}\n\t}\n}\n\nfunction markAsForce(vnode) {\n\tif (vnode) {\n\t\tif (vnode._component) vnode._component._bits |= COMPONENT_FORCE;\n\t\tif (vnode._children) vnode._children.some(markAsForce);\n\t}\n}\n\n/**\n * @param {Array<Component>} commitQueue List of components\n * which have callbacks to invoke in commitRoot\n * @param {VNode} root\n */\nexport function commitRoot(commitQueue, root, refQueue) {\n\tfor (let i = 0; i < refQueue.length; ) {\n\t\tapplyRef(refQueue[i++], refQueue[i++], refQueue[i++]);\n\t}\n\n\tif (options._commit) options._commit(root, commitQueue);\n\n\tcommitQueue.some(c => {\n\t\ttry {\n\t\t\t// @ts-expect-error Reuse the commitQueue variable here so the type changes\n\t\t\tcommitQueue = c._renderCallbacks;\n\t\t\tc._renderCallbacks = [];\n\t\t\tcommitQueue.some(cb => {\n\t\t\t\t// @ts-expect-error See above comment on commitQueue\n\t\t\t\tcb.call(c);\n\t\t\t});\n\t\t} catch (e) {\n\t\t\toptions._catchError(e, c._vnode);\n\t\t}\n\t});\n}\n\n/**\n * Diff two virtual nodes representing DOM element\n * @param {PreactElement} dom The DOM element representing the virtual nodes\n * being diffed\n * @param {VNode} newVNode The new virtual node\n * @param {VNode} oldVNode The old virtual node\n * @param {object} globalContext The current context object\n * @param {string} namespace Current namespace of the DOM node (HTML, SVG, or MathML)\n * @param {Array<PreactElement>} excessDomChildren\n * @param {Array<Component>} commitQueue List of components which have callbacks\n * to invoke in commitRoot\n * @param {boolean} isHydrating Whether or not we are in hydration\n * @param {any[]} refQueue an array of elements needed to invoke refs\n * @param {PreactElement} parentDom The parent this element will be inserted\n * into; new nodes are created from its ownerDocument (e.g. iframes), or from\n * the global document for containers that don't have one\n * @returns {PreactElement}\n */\nfunction diffElementNodes(\n\tdom,\n\tnewVNode,\n\toldVNode,\n\tglobalContext,\n\tnamespace,\n\texcessDomChildren,\n\tcommitQueue,\n\tisHydrating,\n\trefQueue,\n\tparentDom\n) {\n\tlet oldProps = oldVNode.props || EMPTY_OBJ;\n\tconst newProps = newVNode.props;\n\tconst nodeType = /** @type {string} */ (newVNode.type);\n\t/** @type {any} */\n\tlet i;\n\t/** @type {{ __html?: string }} */\n\tlet newHtml;\n\t/** @type {{ __html?: string }} */\n\tlet oldHtml;\n\t/** @type {ComponentChildren} */\n\tlet newChildren;\n\tlet value;\n\tlet inputValue;\n\tlet checked;\n\n\t// Tracks entering and exiting namespaces when descending through the tree.\n\tif (nodeType == 'svg') namespace = SVG_NAMESPACE;\n\telse if (nodeType == 'math') namespace = MATH_NAMESPACE;\n\telse if (!namespace) namespace = XHTML_NAMESPACE;\n\n\tif (excessDomChildren) {\n\t\tfor (i = 0; i < excessDomChildren.length; i++) {\n\t\t\tvalue = excessDomChildren[i];\n\n\t\t\t// if newVNode matches an element in excessDomChildren or the `dom`\n\t\t\t// argument matches an element in excessDomChildren, remove it from\n\t\t\t// excessDomChildren so it isn't later removed in diffChildren.\n\t\t\t// `localName` is only present on elements, so it doubles as the\n\t\t\t// element check for the non-text branch.\n\t\t\tif (\n\t\t\t\tvalue &&\n\t\t\t\t(nodeType ? value.localName == nodeType : value.nodeType == 3)\n\t\t\t) {\n\t\t\t\tdom = value;\n\t\t\t\texcessDomChildren[i] = NULL;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!dom) {\n\t\tconst doc = parentDom.ownerDocument || document;\n\t\tif (!nodeType) {\n\t\t\treturn doc.createTextNode(newProps);\n\t\t}\n\n\t\t// Without `is`, the parent doubles as the creation options so its\n\t\t// `customElementRegistry` (scoped registries on shadow roots/elements) is\n\t\t// inherited. The spec throws when `is` and a registry are both passed.\n\t\tdom = doc.createElementNS(\n\t\t\tnamespace,\n\t\t\tnodeType,\n\t\t\tnewProps.is ? newProps : parentDom\n\t\t);\n\n\t\t// we are creating a new node, so we can assume this is a new subtree (in\n\t\t// case we are hydrating), this deopts the hydrate\n\t\tif (isHydrating) {\n\t\t\tif (options._hydrationMismatch)\n\t\t\t\toptions._hydrationMismatch(newVNode, excessDomChildren);\n\t\t\tisHydrating = false;\n\t\t}\n\t\t// we created a new parent, so none of the previously attached children can be reused:\n\t\texcessDomChildren = NULL;\n\t}\n\n\tif (!nodeType) {\n\t\t// During hydration, we still have to split merged text from SSR'd HTML.\n\t\tif (oldProps !== newProps && (!isHydrating || dom.data != newProps)) {\n\t\t\tdom.data = newProps;\n\t\t}\n\t} else {\n\t\t// A <template> holds its children in a separate document-fragment, both\n\t\t// when reading existing DOM and when inserting new nodes. `parentDom` is\n\t\t// unused from here on, so we reuse it as the container for our children.\n\t\t// @ts-expect-error\n\t\tparentDom = (nodeType == 'template' && dom.content) || dom;\n\n\t\t// If excessDomChildren was not null, repopulate it with the current element's children:\n\t\texcessDomChildren =\n\t\t\tnodeType == 'textarea' && newProps.defaultValue != NULL\n\t\t\t\t? NULL\n\t\t\t\t: excessDomChildren && slice.call(parentDom.childNodes);\n\n\t\t// If we are in a situation where we are not hydrating but are using\n\t\t// existing DOM (e.g. replaceNode) we should read the existing DOM\n\t\t// attributes to diff them\n\t\tif (!isHydrating && excessDomChildren) {\n\t\t\t// Keep this a plain loop: an arrow function here would capture\n\t\t\t// `oldProps`, forcing V8 to context-allocate it and slowing down the\n\t\t\t// hot `for (i in oldProps)` loop below for every element we diff.\n\t\t\toldProps = {};\n\t\t\tfor (i = 0; i < dom.attributes.length; i++) {\n\t\t\t\tvalue = dom.attributes[i];\n\t\t\t\toldProps[value.name] = value.value;\n\t\t\t}\n\t\t}\n\n\t\tfor (i in oldProps) {\n\t\t\tvalue = oldProps[i];\n\t\t\tif (i == 'dangerouslySetInnerHTML') {\n\t\t\t\toldHtml = value;\n\t\t\t} else if (\n\t\t\t\ti != 'children' &&\n\t\t\t\t!(i in newProps) &&\n\t\t\t\t!(i == 'value' && 'defaultValue' in newProps) &&\n\t\t\t\t!(i == 'checked' && 'defaultChecked' in newProps)\n\t\t\t) {\n\t\t\t\tsetProperty(dom, i, NULL, value, namespace);\n\t\t\t}\n\t\t}\n\n\t\t// During hydration, props are not diffed at all (including dangerouslySetInnerHTML)\n\t\t// @TODO we should warn in debug mode when props don't match here.\n\t\tfor (i in newProps) {\n\t\t\tvalue = newProps[i];\n\t\t\tif (i == 'children') {\n\t\t\t\tnewChildren = value;\n\t\t\t} else if (i == 'dangerouslySetInnerHTML') {\n\t\t\t\tnewHtml = value;\n\t\t\t} else if (i == 'value') {\n\t\t\t\tinputValue = value;\n\t\t\t} else if (i == 'checked') {\n\t\t\t\tchecked = value;\n\t\t\t} else if (\n\t\t\t\t(!isHydrating || typeof value == 'function') &&\n\t\t\t\toldProps[i] !== value\n\t\t\t) {\n\t\t\t\tsetProperty(dom, i, value, oldProps[i], namespace);\n\t\t\t}\n\t\t}\n\n\t\t// If the new vnode didn't have dangerouslySetInnerHTML, diff its children\n\t\tif (newHtml) {\n\t\t\t// Avoid re-applying the same '__html' if it did not changed between re-render\n\t\t\tif (\n\t\t\t\t!isHydrating &&\n\t\t\t\t(!oldHtml ||\n\t\t\t\t\t(newHtml.__html != oldHtml.__html && newHtml.__html != dom.innerHTML))\n\t\t\t) {\n\t\t\t\tdom.innerHTML = newHtml.__html;\n\t\t\t}\n\n\t\t\tnewVNode._children = [];\n\t\t} else {\n\t\t\tif (oldHtml) dom.textContent = '';\n\n\t\t\tif (\n\t\t\t\tnodeType == 'foreignObject' ||\n\t\t\t\t(namespace == MATH_NAMESPACE && MATHML_TOKEN_ELEMENTS.test(nodeType))\n\t\t\t) {\n\t\t\t\tnamespace = XHTML_NAMESPACE;\n\t\t\t}\n\n\t\t\tdiffChildren(\n\t\t\t\tparentDom,\n\t\t\t\tisArray(newChildren) ? newChildren : [newChildren],\n\t\t\t\tnewVNode,\n\t\t\t\toldVNode,\n\t\t\t\tglobalContext,\n\t\t\t\tnamespace,\n\t\t\t\texcessDomChildren,\n\t\t\t\tcommitQueue,\n\t\t\t\texcessDomChildren\n\t\t\t\t\t? excessDomChildren[0]\n\t\t\t\t\t: oldVNode._children && getDomSibling(oldVNode, 0),\n\t\t\t\tisHydrating,\n\t\t\t\trefQueue\n\t\t\t);\n\n\t\t\t// Remove children that are not part of any vnode.\n\t\t\tif (excessDomChildren) excessDomChildren.some(removeNode);\n\t\t}\n\n\t\t// As above, don't diff props during hydration\n\t\tif (!isHydrating || nodeType == 'textarea') {\n\t\t\ti = 'value';\n\t\t\tif (nodeType == 'progress' && inputValue == NULL) {\n\t\t\t\tdom.removeAttribute(i);\n\t\t\t} else if (\n\t\t\t\tinputValue != UNDEFINED &&\n\t\t\t\t// #2756 For the <progress>-element the initial value is 0,\n\t\t\t\t// despite the attribute not being present. When the attribute\n\t\t\t\t// is missing the progress bar is treated as indeterminate.\n\t\t\t\t// To fix that we'll always update it when it is 0 for progress elements\n\t\t\t\t(inputValue !== dom[i] || (nodeType == 'progress' && !inputValue))\n\t\t\t) {\n\t\t\t\tsetProperty(dom, i, inputValue, oldProps[i], namespace);\n\t\t\t}\n\n\t\t\ti = 'checked';\n\t\t\tif (checked != UNDEFINED && checked != dom[i]) {\n\t\t\t\tsetProperty(dom, i, checked, oldProps[i], namespace);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn dom;\n}\n\n/**\n * Invoke or update a ref, depending on whether it is a function or object ref.\n * @param {Ref<any>} ref\n * @param {any} value The element or component to attach, or `null` to detach\n * @param {VNode} vnode\n * @param {any} [owner] The vnode the ref is detached from\n */\nexport function applyRef(ref, value, vnode, owner) {\n\ttry {\n\t\tif (typeof ref == 'function') {\n\t\t\t// Store the cleanup on the element or component rather than on the\n\t\t\t// ref function, which can be shared between several of them. The\n\t\t\t// slot is cleared on detach, so detaching twice is a no-op.\n\t\t\tif (value) value._refCleanup = ref(value) || 1;\n\t\t\telse if (\n\t\t\t\towner &&\n\t\t\t\t(owner = owner._component || owner._dom) &&\n\t\t\t\t(value = owner._refCleanup)\n\t\t\t) {\n\t\t\t\towner._refCleanup = NULL;\n\t\t\t\tif (typeof value == 'function') value();\n\t\t\t\telse ref(NULL);\n\t\t\t}\n\t\t} else ref.current = value;\n\t} catch (e) {\n\t\toptions._catchError(e, vnode);\n\t}\n}\n\n/**\n * Unmount a virtual node from the tree and apply DOM changes\n * @param {VNode} vnode The virtual node to unmount\n * @param {VNode} parentVNode The parent of the VNode that initiated the unmount\n * @param {boolean} [skipRemove] Flag that indicates that a parent node of the\n * current element is already detached from the DOM.\n */\nexport function unmount(vnode, parentVNode, skipRemove) {\n\tlet r, end, nodes;\n\tif (options.unmount) options.unmount(vnode);\n\n\tif ((r = vnode.ref) && (!r.current || r.current == vnode._dom)) {\n\t\tapplyRef(r, NULL, parentVNode, vnode);\n\t}\n\n\tif ((r = vnode._component)) {\n\t\tif (r.componentWillUnmount) {\n\t\t\ttry {\n\t\t\t\tr.componentWillUnmount();\n\t\t\t} catch (e) {\n\t\t\t\toptions._catchError(e, parentVNode);\n\t\t\t}\n\t\t}\n\n\t\tr._parentDom = r._globalContext = NULL;\n\t}\n\n\tif ((r = vnode._children)) {\n\t\tfor (let i = 0; i < r.length; i++) {\n\t\t\tif (r[i]) {\n\t\t\t\tunmount(\n\t\t\t\t\tr[i],\n\t\t\t\t\tparentVNode,\n\t\t\t\t\t// A portal's children live in another container, so a removed\n\t\t\t\t\t// host ancestor doesn't detach them; always remove them.\n\t\t\t\t\ttypeof vnode.type == 'function'\n\t\t\t\t\t\t? skipRemove && !vnode.props._parentDom\n\t\t\t\t\t\t: true\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t// A component that suspended while hydrating owns its range's markers,\n\t// and its content too while still pending.\n\tif (\n\t\t!skipRemove &&\n\t\t(r = vnode._component) &&\n\t\t(r = r._excess) &&\n\t\t(end = rangeEnd(r, (nodes = [])))\n\t) {\n\t\tif (r == vnode._dom) nodes.some(removeNode);\n\t\tremoveNode(end);\n\t\tremoveNode(r);\n\t}\n\n\tif (!skipRemove) removeNode(vnode._dom);\n\n\tvnode._dom = vnode._component = vnode._parent = NULL;\n}\n\n/** The `.render()` method for a PFC backing instance. */\nfunction doRender(props, state, context) {\n\treturn this.constructor(props, context);\n}\n","import { EMPTY_OBJ, MODE_HYDRATE, NULL } from './constants';\nimport { commitRoot, diff } from './diff/index';\nimport { createVNode, Fragment } from './create-element';\nimport options from './options';\nimport { slice } from './util';\n\n/**\n * Render a Preact virtual node into a DOM element\n * @param {import('./internal').ComponentChild} vnode The virtual node to render\n * @param {import('./internal').PreactElement} parentDom The DOM element to render into\n */\nexport function render(vnode, parentDom) {\n\tif (options._root) options._root(vnode, parentDom);\n\n\t// https://github.com/preactjs/preact/issues/3794\n\t// https://github.com/preactjs/preact/issues/5118\n\tif (parentDom.nodeType == 9) {\n\t\tparentDom = parentDom.documentElement;\n\t}\n\n\t// @ts-expect-error\n\tlet isHydrating = vnode && vnode._flags & MODE_HYDRATE;\n\n\t// To be able to support calling `render()` multiple times on the same\n\t// DOM node, we need to obtain a reference to the previous tree. We do\n\t// this by assigning a new `_children` property to DOM nodes which points\n\t// to the last rendered tree. By default this property is not present, which\n\t// means that we are mounting a new tree for the first time.\n\tlet oldVNode = isHydrating ? NULL : parentDom._children;\n\n\tparentDom._children = createVNode(Fragment, { children: [vnode] });\n\n\t// List of effects that need to be called after diffing.\n\tlet commitQueue = [],\n\t\trefQueue = [];\n\n\tdiff(\n\t\tparentDom,\n\t\t// Determine the new vnode tree and store it on the DOM element on\n\t\t// our custom `_children` property.\n\t\tparentDom._children,\n\t\toldVNode || EMPTY_OBJ,\n\t\tEMPTY_OBJ,\n\t\tparentDom.namespaceURI,\n\t\toldVNode\n\t\t\t? NULL\n\t\t\t: parentDom.firstChild\n\t\t\t\t? slice.call(parentDom.childNodes)\n\t\t\t\t: NULL,\n\t\tcommitQueue,\n\t\toldVNode ? oldVNode._dom : parentDom.firstChild,\n\t\t// @ts-expect-error we are doing a bit-wise operation so it's either 0 or true\n\t\tisHydrating,\n\t\trefQueue\n\t);\n\n\t// Flush all queued effects\n\tcommitRoot(commitQueue, parentDom._children, refQueue);\n\n\t// The live children are tracked on _children after diffing.\n\tparentDom._children.props.children = NULL;\n}\n\n/**\n * Update an existing DOM element with data from a Preact virtual node\n * @param {import('./internal').ComponentChild} vnode The virtual node to render\n * @param {import('./internal').PreactElement} parentDom The DOM element to update\n */\nexport function hydrate(vnode, parentDom) {\n\t// Only objects can carry the flag. Primitives (null, strings, numbers,\n\t// booleans) render into the existing DOM the same way hydrating would.\n\tif (vnode && typeof vnode == 'object') {\n\t\t// @ts-expect-error\n\t\tvnode._flags |= MODE_HYDRATE;\n\t}\n\trender(vnode, parentDom);\n}\n","import { createVNode } from './create-element';\n\n/**\n * Portal component. A unique type is used instead of Fragment so that a\n * portal returned directly from a component isn't collapsed into the\n * component's children array by the Fragment unwrapping in `diff()`.\n * @param {object} props\n */\nfunction Portal(props) {\n\treturn props.children;\n}\n\n/**\n * Create a `Portal` to continue rendering the vnode tree at a different DOM node\n * @param {import('./internal').ComponentChildren} vnode The vnode to render\n * @param {import('./internal').PreactElement} container The DOM node to continue rendering in to\n */\nexport function createPortal(vnode, container) {\n\treturn createVNode(Portal, { _parentDom: container, children: vnode });\n}\n","import { resetRenderCount } from '../component';\nimport {\n\tCOMPONENT_DIRTY,\n\tCOMPONENT_PENDING_ERROR,\n\tCOMPONENT_PROCESSING_EXCEPTION,\n\tCOMPONENT_FORCE\n} from '../constants';\n\n/**\n * Find the closest error boundary to a thrown error and call it\n * @param {object} error The thrown value\n * @param {import('../internal').VNode} vnode The vnode that threw the error that was caught (except\n * for unmounting when this parameter is the highest parent that was being\n * unmounted)\n * @param {import('../internal').VNode} [oldVNode]\n * @param {import('../internal').ErrorInfo} [errorInfo]\n */\nexport function _catchError(error, vnode, oldVNode, errorInfo) {\n\t/** @type {import('../internal').Component} */\n\tlet component,\n\t\t/** @type {import('../internal').ComponentType} */\n\t\tctor,\n\t\t/** @type {number} */\n\t\thandled;\n\n\tfor (; (vnode = vnode._parent); ) {\n\t\tif (\n\t\t\t(component = vnode._component) &&\n\t\t\t!(component._bits & COMPONENT_PROCESSING_EXCEPTION)\n\t\t) {\n\t\t\tcomponent._bits |= COMPONENT_FORCE;\n\t\t\ttry {\n\t\t\t\tctor = component.constructor;\n\n\t\t\t\t// `handled` is reassigned before any read on every boundary\n\t\t\t\t// candidate, so nothing carries over to the next ancestor.\n\t\t\t\tif ((handled = ctor && ctor.getDerivedStateFromError)) {\n\t\t\t\t\tcomponent.setState(ctor.getDerivedStateFromError(error));\n\t\t\t\t}\n\n\t\t\t\tif (component.componentDidCatch) {\n\t\t\t\t\tcomponent.componentDidCatch(error, errorInfo || {});\n\t\t\t\t\thandled = 1;\n\t\t\t\t}\n\n\t\t\t\t// This is an error boundary. Mark it as having bailed out, and whether it was mid-hydration.\n\t\t\t\tif (handled && component._bits & COMPONENT_DIRTY) {\n\t\t\t\t\tcomponent._bits |= COMPONENT_PENDING_ERROR;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\terror = e;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Reset rerender count to 0, so that the next render will not be skipped\n\t// when we leverage prefresh\n\tresetRenderCount();\n\tthrow error;\n}\n","import { options as _options } from 'preact';\n\nconst ObjectIs = Object.is;\n\n/** @type {number} */\nlet currentIndex;\n\n/** @type {import('./internal').Component} */\nlet currentComponent;\n\n/** @type {import('./internal').Component} */\nlet previousComponent;\n\n/** @type {number} */\nlet currentHook = 0;\n\n/** @type {Array<import('./internal').Component>} */\nlet afterPaintEffects = [];\n\n/**\n * Passive (useEffect) hook states of unmounted components whose cleanup is\n * still pending. Deferred to the after-paint flush to match React, which runs\n * passive destroys after the commit has painted. Each state's `_passive` holds\n * the surviving component its errors should be routed to.\n * @type {Array<import('./internal').EffectHookState>}\n */\nlet unmountCleanups = [];\n\n// Cast to use internal Options type\nconst options = /** @type {import('./internal').Options} */ (_options);\n\nlet oldBeforeDiff = options._diff;\nlet oldBeforeRender = options._render;\nlet oldAfterDiff = options.diffed;\nlet oldCommit = options._commit;\nlet oldBeforeUnmount = options.unmount;\nlet oldRoot = options._root;\n\n// We take the minimum timeout for requestAnimationFrame to ensure that\n// the callback is invoked after the next frame. 35ms is based on a 30hz\n// refresh rate, which is the minimum rate for a smooth user experience.\nconst RAF_TIMEOUT = 35;\nlet prevRaf;\n\n/** @type {(vnode: import('./internal').VNode) => void} */\noptions._diff = vnode => {\n\tcurrentComponent = null;\n\tif (oldBeforeDiff) oldBeforeDiff(vnode);\n};\n\noptions._root = (vnode, parentDom) => {\n\tif (vnode && parentDom._children && parentDom._children._mask) {\n\t\tvnode._mask = parentDom._children._mask;\n\t}\n\n\tif (oldRoot) oldRoot(vnode, parentDom);\n};\n\n/** @type {(vnode: import('./internal').VNode) => void} */\noptions._render = vnode => {\n\tif (oldBeforeRender) oldBeforeRender(vnode);\n\n\tcurrentComponent = vnode._component;\n\tcurrentIndex = 0;\n\n\tconst hooks = currentComponent.__hooks;\n\tif (hooks) {\n\t\tif (previousComponent == currentComponent) {\n\t\t\tcurrentComponent._renderCallbacks = [];\n\t\t} else {\n\t\t\thooks._pendingEffects.some(invokeCleanup);\n\t\t\thooks._pendingEffects.some(invokeEffect);\n\t\t\tcurrentIndex = 0;\n\t\t}\n\t\thooks._pendingEffects = [];\n\n\t\t// Runs before every render, forced or not, so `shouldComponentUpdate`\n\t\t// never has to apply these itself.\n\t\thooks._list.some(hookItem => {\n\t\t\tif (hookItem._nextValue) {\n\t\t\t\thookItem._value = hookItem._nextValue;\n\t\t\t}\n\t\t\thookItem._pendingArgs = hookItem._nextValue = undefined;\n\t\t});\n\t}\n\tpreviousComponent = currentComponent;\n};\n\n/** @type {(vnode: import('./internal').VNode) => void} */\noptions.diffed = vnode => {\n\tif (oldAfterDiff) oldAfterDiff(vnode);\n\n\tconst c = vnode._component;\n\tif (c && c.__hooks) {\n\t\tif (c.__hooks._pendingEffects.length) afterPaint(afterPaintEffects.push(c));\n\t\t// `_pendingArgs` is cleared again by `options._render` before anything\n\t\t// can read it, so committing it here is enough.\n\t\tc.__hooks._list.some(hookItem => {\n\t\t\tif (hookItem._pendingArgs) hookItem._args = hookItem._pendingArgs;\n\t\t});\n\t}\n\tpreviousComponent = currentComponent = null;\n};\n\n// TODO: Improve typing of commitQueue parameter\n/** @type {(vnode: import('./internal').VNode, commitQueue: any) => void} */\noptions._commit = (vnode, commitQueue) => {\n\tcommitQueue.some(component => {\n\t\ttry {\n\t\t\tcomponent._renderCallbacks.some(invokeCleanup);\n\t\t\tcomponent._renderCallbacks = component._renderCallbacks.filter(cb =>\n\t\t\t\tcb._value ? invokeEffect(cb) : true\n\t\t\t);\n\t\t} catch (e) {\n\t\t\t// Only this component skips its remaining effects, commitRoot rethrows\n\t\t\t// the error to its boundary after the others ran.\n\t\t\tcomponent._renderCallbacks = [\n\t\t\t\t() => {\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t];\n\t\t}\n\t});\n\n\tif (oldCommit) oldCommit(vnode, commitQueue);\n};\n\n/** @type {(vnode: import('./internal').VNode) => void} */\noptions.unmount = vnode => {\n\tif (oldBeforeUnmount) oldBeforeUnmount(vnode);\n\n\tconst c = vnode._component;\n\tif (c && c.__hooks) {\n\t\tlet hasErrored, errorParent;\n\t\tc.__hooks._list.some(s => {\n\t\t\ttry {\n\t\t\t\t// Layout cleanups have to run before the new DOM is in place, so\n\t\t\t\t// they stay in the commit phase (see #1886). Passive cleanups run\n\t\t\t\t// after paint, before any new passive effect (see #4299), with\n\t\t\t\t// `_passive` repurposed to hold the error-routing component.\n\t\t\t\tif (s._passive && s._cleanup) {\n\t\t\t\t\tif (errorParent === undefined) {\n\t\t\t\t\t\terrorParent = vnode._parent;\n\t\t\t\t\t\twhile (\n\t\t\t\t\t\t\terrorParent &&\n\t\t\t\t\t\t\t!(errorParent._component && errorParent._component._parentDom)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\terrorParent = errorParent._parent;\n\t\t\t\t\t\t}\n\t\t\t\t\t\terrorParent = errorParent && errorParent._component;\n\t\t\t\t\t}\n\t\t\t\t\ts._passive = errorParent;\n\t\t\t\t\tafterPaint(unmountCleanups.push(s));\n\t\t\t\t} else {\n\t\t\t\t\tinvokeCleanup(s);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\thasErrored = e;\n\t\t\t}\n\t\t});\n\t\tc.__hooks = undefined;\n\t\tif (hasErrored) options._catchError(hasErrored, c._vnode);\n\t}\n};\n\n/**\n * Get a hook's state from the currentComponent\n * @param {number} index The index of the hook to get\n * @param {number} type The type of the hook to get\n * @returns {any}\n */\nfunction getHookState(index, type) {\n\tif (options._hook) {\n\t\toptions._hook(currentComponent, index, currentHook || type);\n\t}\n\tcurrentHook = 0;\n\n\t// Largely inspired by:\n\t// * https://github.com/michael-klein/funcy.js/blob/f6be73468e6ec46b0ff5aa3cc4c9baf72a29025a/src/hooks/core_hooks.mjs\n\t// * https://github.com/michael-klein/funcy.js/blob/650beaa58c43c33a74820a3c98b3c7079cf2e333/src/renderer.mjs\n\t// Other implementations to look at:\n\t// * https://codesandbox.io/s/mnox05qp8\n\tconst hooks =\n\t\tcurrentComponent.__hooks ||\n\t\t(currentComponent.__hooks = {\n\t\t\t_list: [],\n\t\t\t_pendingEffects: []\n\t\t});\n\n\tif (index >= hooks._list.length) {\n\t\thooks._list.push({});\n\t}\n\n\treturn hooks._list[index];\n}\n\n/**\n * @template {unknown} S\n * @param {import('./index').Dispatch<import('./index').StateUpdater<S>>} [initialState]\n * @returns {[S, (state: S) => void]}\n */\nexport function useState(initialState) {\n\tcurrentHook = 1;\n\treturn useReducer(invokeOrReturn, initialState);\n}\n\n/**\n * @template {unknown} S\n * @template {unknown} A\n * @param {import('./index').Reducer<S, A>} reducer\n * @param {import('./index').Dispatch<import('./index').StateUpdater<S>>} initialState\n * @param {(initialState: any) => void} [init]\n * @returns {[ S, (state: S) => void ]}\n */\nexport function useReducer(reducer, initialState, init) {\n\t/** @type {import('./internal').ReducerHookState} */\n\tconst hookState = getHookState(currentIndex++, 2);\n\thookState._reducer = reducer;\n\tif (!hookState._component) {\n\t\thookState._value = [\n\t\t\t!init ? invokeOrReturn(undefined, initialState) : init(initialState),\n\n\t\t\taction => {\n\t\t\t\tconst currentValue = (hookState._nextValue || hookState._value)[0];\n\t\t\t\tconst nextValue = hookState._reducer(currentValue, action);\n\n\t\t\t\tif (!ObjectIs(currentValue, nextValue)) {\n\t\t\t\t\thookState._nextValue = [nextValue, hookState._value[1]];\n\t\t\t\t\thookState._component.setState({});\n\t\t\t\t}\n\t\t\t}\n\t\t];\n\n\t\thookState._component = currentComponent;\n\n\t\tif (!currentComponent._hasScuFromHooks) {\n\t\t\tcurrentComponent._hasScuFromHooks = true;\n\t\t\tconst prevScu = currentComponent.shouldComponentUpdate;\n\n\t\t\t// This SCU has the purpose of bailing out after repeated updates\n\t\t\t// to stateful hooks. We store the next value in `_nextValue[0]` and\n\t\t\t// keep doing that for all state setters; if we have next states and\n\t\t\t// all next states within a component end up being equal to their\n\t\t\t// original state we are safe to bail out for this specific component.\n\t\t\tcurrentComponent.shouldComponentUpdate = function (p, s, c) {\n\t\t\t\tconst hooks = this.__hooks;\n\t\t\t\tif (!hooks) return true;\n\n\t\t\t\t// We check whether we have components with a nextValue set that\n\t\t\t\t// have values that aren't equal to one another this pushes\n\t\t\t\t// us to update further down the tree\n\t\t\t\tlet updatedHook = false;\n\t\t\t\tlet shouldUpdate = this.props != p;\n\t\t\t\thooks._list.some(hookItem => {\n\t\t\t\t\tif (hookItem._nextValue) {\n\t\t\t\t\t\tupdatedHook = true;\n\t\t\t\t\t\tif (!ObjectIs(hookItem._value[0], hookItem._nextValue[0])) {\n\t\t\t\t\t\t\tshouldUpdate = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tif (prevScu) {\n\t\t\t\t\tconst result = prevScu.call(this, p, s, c);\n\t\t\t\t\treturn updatedHook ? result || shouldUpdate : result;\n\t\t\t\t}\n\n\t\t\t\treturn !updatedHook || shouldUpdate;\n\t\t\t};\n\t\t}\n\t}\n\n\treturn hookState._value;\n}\n\n/**\n * @param {import('./internal').Effect} callback\n * @param {unknown[]} args\n * @returns {void}\n */\nexport function useEffect(callback, args) {\n\t/** @type {import('./internal').EffectHookState} */\n\tconst state = getHookState(currentIndex++, 3);\n\tif (!options._skipEffects && argsChanged(state._args, args)) {\n\t\tstate._passive = true;\n\t\tstate._value = callback;\n\t\tstate._pendingArgs = args;\n\n\t\tcurrentComponent.__hooks._pendingEffects.push(state);\n\t}\n}\n\n/**\n * @param {import('./internal').Effect} callback\n * @param {unknown[]} args\n * @returns {void}\n */\nexport function useLayoutEffect(callback, args) {\n\t/** @type {import('./internal').EffectHookState} */\n\tconst state = getHookState(currentIndex++, 4);\n\tif (!options._skipEffects && argsChanged(state._args, args)) {\n\t\tstate._passive = false;\n\t\tstate._value = callback;\n\t\tstate._pendingArgs = args;\n\n\t\tcurrentComponent._renderCallbacks.push(state);\n\t}\n}\n\n/** @type {(initialValue: unknown) => unknown} */\nexport function useRef(initialValue) {\n\tcurrentHook = 5;\n\treturn useMemo(() => ({ current: initialValue }), []);\n}\n\n/**\n * @param {object} ref\n * @param {() => object} createHandle\n * @param {unknown[]} args\n * @returns {void}\n */\nexport function useImperativeHandle(ref, createHandle, args) {\n\tcurrentHook = 6;\n\tuseLayoutEffect(\n\t\t() => {\n\t\t\tif (typeof ref == 'function') {\n\t\t\t\tconst result = ref(createHandle());\n\t\t\t\treturn () => {\n\t\t\t\t\tref(null);\n\t\t\t\t\tif (typeof result == 'function') result();\n\t\t\t\t};\n\t\t\t} else if (ref) {\n\t\t\t\tref.current = createHandle();\n\t\t\t\treturn () => (ref.current = null);\n\t\t\t}\n\t\t},\n\t\targs == null ? args : args.concat(ref)\n\t);\n}\n\n/**\n * @template {unknown} T\n * @param {() => T} factory\n * @param {unknown[]} args\n * @returns {T}\n */\nexport function useMemo(factory, args) {\n\t/** @type {import('./internal').MemoHookState<T>} */\n\tconst state = getHookState(currentIndex++, 7);\n\tif (argsChanged(state._args, args)) {\n\t\tstate._value = factory();\n\t\tstate._args = args;\n\t}\n\n\treturn state._value;\n}\n\n/**\n * @param {() => void} callback\n * @param {unknown[]} args\n * @returns {() => void}\n */\nexport function useCallback(callback, args) {\n\tcurrentHook = 8;\n\treturn useMemo(() => callback, args);\n}\n\n/**\n * @param {import('./internal').PreactContext} context\n */\nexport function useContext(context) {\n\tconst provider = currentComponent.context[context._id];\n\t// We could skip this call here, but than we'd not call\n\t// `options._hook`. We need to do that in order to make\n\t// the devtools aware of this hook.\n\t/** @type {import('./internal').ContextHookState} */\n\tconst state = getHookState(currentIndex++, 9);\n\t// The devtools needs access to the context object to\n\t// be able to pull of the default value when no provider\n\t// is present in the tree.\n\tstate._context = context;\n\tif (!provider) return context._defaultValue;\n\t// This is probably not safe to convert to \"!\"\n\tif (state._value == null) {\n\t\tstate._value = true;\n\t\tprovider.sub(currentComponent);\n\t}\n\treturn provider.props.value;\n}\n\n/**\n * Display a custom label for a custom hook for the devtools panel\n * @type {<T>(value: T, cb?: (value: T) => string | number) => void}\n */\nexport function useDebugValue(value, formatter) {\n\tif (options.useDebugValue) {\n\t\toptions.useDebugValue(\n\t\t\tformatter ? formatter(value) : /** @type {any}*/ (value)\n\t\t);\n\t}\n}\n\n/**\n * @param {(error: unknown, errorInfo: import('preact').ErrorInfo) => void} cb\n * @returns {[unknown, () => void]}\n */\nexport function useErrorBoundary(cb) {\n\t/** @type {import('./internal').ErrorBoundaryHookState} */\n\tconst state = getHookState(currentIndex++, 10);\n\tconst errState = useState();\n\tstate._value = cb;\n\tif (!currentComponent.componentDidCatch) {\n\t\tcurrentComponent.componentDidCatch = (err, errorInfo) => {\n\t\t\tif (state._value) state._value(err, errorInfo);\n\t\t\terrState[1](err);\n\t\t};\n\t}\n\treturn [errState[0], () => errState[1]()];\n}\n\n/** @type {() => string} */\nexport function useId() {\n\t/** @type {import('./internal').IdHookState} */\n\tconst state = getHookState(currentIndex++, 11);\n\tif (!state._value) {\n\t\t// Grab either the root node or the nearest async boundary node.\n\t\t/** @type {import('./internal').VNode} */\n\t\tlet root = currentComponent._vnode;\n\t\twhile (!root._mask && root._parent) {\n\t\t\troot = root._parent;\n\t\t}\n\n\t\tlet mask = root._mask || (root._mask = [0, 0]);\n\t\tstate._value = 'P' + mask[0] + '-' + mask[1]++;\n\t}\n\n\treturn state._value;\n}\n\n/**\n * After paint effects consumer.\n */\nfunction flushAfterPaintEffects() {\n\tlet component;\n\t// The loop picks up components unmounted by an effect we just invoked, which\n\t// don't necessarily schedule a flush of their own.\n\tdo {\n\t\t// Unmounted components' passive cleanups run before any new passive\n\t\t// effect, mirroring React running all destroys before any create.\n\t\twhile ((component = unmountCleanups.shift())) {\n\t\t\ttry {\n\t\t\t\tinvokeCleanup(component);\n\t\t\t} catch (e) {\n\t\t\t\tcomponent = /** @type {any} */ (component._passive);\n\t\t\t\toptions._catchError(e, { _parent: component && component._vnode });\n\t\t\t}\n\t\t}\n\n\t\twhile ((component = afterPaintEffects.shift())) {\n\t\t\tconst hooks = component.__hooks;\n\t\t\tif (!component._parentDom || !hooks) continue;\n\t\t\ttry {\n\t\t\t\thooks._pendingEffects.some(invokeCleanup);\n\t\t\t\thooks._pendingEffects.some(invokeEffect);\n\t\t\t\thooks._pendingEffects = [];\n\t\t\t} catch (e) {\n\t\t\t\thooks._pendingEffects = [];\n\t\t\t\toptions._catchError(e, component._vnode);\n\t\t\t}\n\t\t}\n\t} while (unmountCleanups.length);\n}\n\nlet HAS_RAF = typeof requestAnimationFrame == 'function';\n\n/**\n * Schedule a callback to be invoked after the browser has a chance to paint a new frame.\n * Do this by combining requestAnimationFrame (rAF) + setTimeout to invoke a callback after\n * the next browser frame.\n *\n * Also, schedule a timeout in parallel to the the rAF to ensure the callback is invoked\n * even if RAF doesn't fire (for example if the browser tab is not visible)\n *\n * @param {() => void} callback\n */\nfunction afterNextFrame(callback) {\n\tconst done = () => {\n\t\tclearTimeout(timeout);\n\t\tif (HAS_RAF) cancelAnimationFrame(raf);\n\t\tsetTimeout(callback);\n\t};\n\tconst timeout = setTimeout(done, RAF_TIMEOUT);\n\n\tlet raf;\n\tif (HAS_RAF) {\n\t\traf = requestAnimationFrame(done);\n\t}\n}\n\n// Note: if someone used options.debounceRendering = requestAnimationFrame,\n// then effects will ALWAYS run on the NEXT frame instead of the current one, incurring a ~16ms delay.\n// Perhaps this is not such a big deal.\n/**\n * Schedule afterPaintEffects flush after the browser paints\n * @param {number} newQueueLength\n * @returns {void}\n */\nfunction afterPaint(newQueueLength) {\n\tif (newQueueLength == 1 || prevRaf != options.requestAnimationFrame) {\n\t\tprevRaf = options.requestAnimationFrame;\n\t\t(prevRaf || afterNextFrame)(flushAfterPaintEffects);\n\t}\n}\n\n/**\n * @param {import('./internal').HookState} hook\n * @returns {void}\n */\nfunction invokeCleanup(hook) {\n\t// A hook cleanup can introduce a call to render which creates a new root, this will call options.vnode\n\t// and move the currentComponent away.\n\tconst comp = currentComponent;\n\tlet cleanup = hook._cleanup;\n\tif (typeof cleanup == 'function') {\n\t\thook._cleanup = undefined;\n\t\tcleanup();\n\t}\n\n\tcurrentComponent = comp;\n}\n\n/**\n * Invoke a Hook's effect\n * @param {import('./internal').EffectHookState} hook\n * @returns {void}\n */\nfunction invokeEffect(hook) {\n\t// A hook call can introduce a call to render which creates a new root, this will call options.vnode\n\t// and move the currentComponent away.\n\tconst comp = currentComponent;\n\thook._cleanup = hook._value();\n\tcurrentComponent = comp;\n}\n\n/**\n * @param {unknown[]} oldArgs\n * @param {unknown[]} newArgs\n * @returns {boolean}\n */\nfunction argsChanged(oldArgs, newArgs) {\n\treturn (\n\t\t!oldArgs ||\n\t\toldArgs.length != newArgs.length ||\n\t\tnewArgs.some((arg, index) => !ObjectIs(arg, oldArgs[index]))\n\t);\n}\n\n/**\n * @template Arg\n * @param {Arg} arg\n * @param {(arg: Arg) => any} f\n * @returns {any}\n */\nfunction invokeOrReturn(arg, f) {\n\treturn typeof f == 'function' ? f(arg) : f;\n}\n","const ENCODED_ENTITIES = /[\"&<]/;\n\n/** @param {string} str */\nexport function encodeEntities(str) {\n\t// Skip all work for strings with no entities needing encoding:\n\tif (!str.length || !ENCODED_ENTITIES.test(str)) return str;\n\n\tlet last = 0,\n\t\ti = 0,\n\t\tout = '',\n\t\tch = '';\n\n\t// Seek forward in str until the next entity char:\n\tfor (; i < str.length; i++) {\n\t\tswitch (str.charCodeAt(i)) {\n\t\t\tcase 34:\n\t\t\t\tch = '&quot;';\n\t\t\t\tbreak;\n\t\t\tcase 38:\n\t\t\t\tch = '&amp;';\n\t\t\t\tbreak;\n\t\t\tcase 60:\n\t\t\t\tch = '&lt;';\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tcontinue;\n\t\t}\n\t\t// Append skipped/buffered characters and the encoded entity:\n\t\tif (i != last) out += str.slice(last, i);\n\t\tout += ch;\n\t\t// Start the next seek/buffer after the entity's offset:\n\t\tlast = i + 1;\n\t}\n\tif (i != last) out += str.slice(last, i);\n\treturn out;\n}\n","// Vnode._flags\n/** Normal hydration that attaches to a DOM tree but does not diff it. */\nexport const MODE_HYDRATE = 1 << 5;\n/** Signifies this VNode suspended on the previous render */\nexport const MODE_SUSPENDED = 1 << 7;\n/** Indicates that this node needs to be inserted while patching children */\nexport const INSERT_VNODE = 1 << 2;\n/** Indicates a VNode has been matched with another VNode in the diff */\nexport const MATCHED = 1 << 1;\n/** The vnode's ref was detached while its subtree was parked by Suspense */\nexport const REF_DETACHED = 1 << 3;\n\n// component._bits\n/** Component is processing an exception */\nexport const COMPONENT_PROCESSING_EXCEPTION = 1 << 0;\n/** Component has a pending error */\nexport const COMPONENT_PENDING_ERROR = 1 << 1;\n/** Component should force update (skip shouldComponentUpdate) */\nexport const COMPONENT_FORCE = 1 << 2;\n/** Component is queued for update */\nexport const COMPONENT_DIRTY = 1 << 3;\n\n/** Reset all mode flags */\nexport const RESET_MODE = ~(MODE_HYDRATE | MODE_SUSPENDED);\n\nexport const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\nexport const XHTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\nexport const MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';\n\nexport const NULL = null;\nexport const UNDEFINED = undefined;\nexport const VNODE_MARKER = Symbol.for('pv');\nexport const EMPTY_OBJ = /** @type {any} */ ({});\nexport const EMPTY_ARR = [];\n\nexport const MATHML_TOKEN_ELEMENTS = /^m(i|n|o|s|text|space)$/;\n\n/** Matched new vnode eligible for the longest increasing subsequence. */\nexport const LIS_CANDIDATE = 1 << 4;\n","import { options, Fragment } from 'preact';\nimport { encodeEntities } from './utils';\nimport { VNODE_MARKER } from '../../src/constants';\n\nlet vnodeId = 0;\n\nconst isArray = Array.isArray;\n\n/**\n * @fileoverview\n * This file exports various methods that implement Babel's \"automatic\" JSX runtime API:\n * - jsx(type, props, key)\n * - jsxs(type, props, key)\n * - jsxDEV(type, props, key, __source, __self)\n *\n * The implementation of createVNode here is optimized for performance.\n * Benchmarks: https://esbench.com/bench/5f6b54a0b4632100a7dcd2b3\n */\n\n/**\n * JSX.Element factory used by Babel's {runtime:\"automatic\"} JSX transform\n * @param {import('../../src/internal').VNode['type']} type\n * @param {import('preact').VNode['props']} props\n * @param {import('preact').VNode['key']} [key]\n * @param {unknown} [isStaticChildren]\n * @param {unknown} [__source]\n * @param {unknown} [__self]\n */\nfunction createVNode(type, props, key, isStaticChildren, __source, __self) {\n\tif (!props) props = {};\n\t// We'll want to preserve `ref` in props to get rid of the need for\n\t// forwardRef components in the future, but that should happen via\n\t// a separate PR.\n\tlet normalizedProps = props,\n\t\tref,\n\t\ti;\n\n\tif ('ref' in normalizedProps && typeof type != 'function') {\n\t\tnormalizedProps = {};\n\t\tfor (i in props) {\n\t\t\tif (i == 'ref') {\n\t\t\t\tref = props[i];\n\t\t\t} else {\n\t\t\t\tnormalizedProps[i] = props[i];\n\t\t\t}\n\t\t}\n\t}\n\n\t/** @type {import('../../src/internal').VNode & { __source?: any; __self?: any }} */\n\tconst vnode = {\n\t\ttype,\n\t\tprops: normalizedProps,\n\t\tkey,\n\t\tref,\n\t\t_children: null,\n\t\t_parent: null,\n\t\t_depth: 0,\n\t\t_dom: null,\n\t\t_component: null,\n\t\tconstructor: VNODE_MARKER,\n\t\t_original: --vnodeId,\n\t\t_index: -1,\n\t\t_flags: 0\n\t};\n\n\tif (__source || __self) {\n\t\tvnode.__source = __source;\n\t\tvnode.__self = __self;\n\t}\n\n\tif (options.vnode) options.vnode(vnode);\n\treturn vnode;\n}\n\n/**\n * Create a template vnode. This function is not expected to be\n * used directly, but rather through a precompile JSX transform\n * @param {string[]} templates\n * @param {Array<string | null | import('preact').VNode>} exprs\n * @returns {import('preact').VNode}\n */\nfunction jsxTemplate(templates, ...exprs) {\n\tconst vnode = createVNode(Fragment, { tpl: templates, exprs });\n\t// Bypass render to string top level Fragment optimization\n\t// @ts-ignore\n\tvnode.key = vnode._vnode;\n\treturn vnode;\n}\n\nconst JS_TO_CSS = {};\nconst CSS_REGEX = /[A-Z]/g;\n\n/**\n * Unwrap potential signals.\n * @param {*} value\n * @returns {*}\n */\nfunction normalizeAttrValue(value) {\n\treturn value != null &&\n\t\ttypeof value == 'object' &&\n\t\ttypeof value.valueOf == 'function'\n\t\t? value.valueOf()\n\t\t: value;\n}\n\n/**\n * Serialize an HTML attribute to a string. This function is not\n * expected to be used directly, but rather through a precompile\n * JSX transform\n * @param {string} name The attribute name\n * @param {*} value The attribute value\n * @returns {string}\n */\nfunction jsxAttr(name, value) {\n\tif (options.attr) {\n\t\tconst result = options.attr(name, value);\n\t\tif (typeof result == 'string') return result;\n\t}\n\n\tvalue = normalizeAttrValue(value);\n\n\tif (name == 'ref' || name == 'key') return '';\n\tif (name == 'style' && typeof value == 'object') {\n\t\tlet str = '';\n\t\tfor (let prop in value) {\n\t\t\tlet val = value[prop];\n\t\t\tif (val != null && val !== '') {\n\t\t\t\tconst name =\n\t\t\t\t\tprop[0] == '-'\n\t\t\t\t\t\t? prop\n\t\t\t\t\t\t: JS_TO_CSS[prop] ||\n\t\t\t\t\t\t\t(JS_TO_CSS[prop] = prop.replace(CSS_REGEX, '-$&').toLowerCase());\n\n\t\t\t\tstr = str + name + ':' + val + ';';\n\t\t\t}\n\t\t}\n\t\treturn name + '=\"' + encodeEntities(str) + '\"';\n\t}\n\n\tif (\n\t\tvalue == null ||\n\t\tvalue === false ||\n\t\ttypeof value == 'function' ||\n\t\ttypeof value == 'object'\n\t) {\n\t\treturn '';\n\t} else if (value === true) return name;\n\n\treturn name + '=\"' + encodeEntities('' + value) + '\"';\n}\n\n/**\n * Escape a dynamic child passed to `jsxTemplate`. This function\n * is not expected to be used directly, but rather through a\n * precompile JSX transform\n * @param {*} value\n * @returns {string | null | import('preact').VNode | Array<string | null | import('preact').VNode>}\n */\nfunction jsxEscape(value) {\n\tif (\n\t\tvalue == null ||\n\t\ttypeof value == 'boolean' ||\n\t\ttypeof value == 'function'\n\t) {\n\t\treturn null;\n\t}\n\n\tif (typeof value == 'object') {\n\t\t// Check for VNode\n\t\tif (value.constructor === VNODE_MARKER) return value;\n\n\t\tif (isArray(value)) {\n\t\t\tfor (let i = 0; i < value.length; i++) {\n\t\t\t\tvalue[i] = jsxEscape(value[i]);\n\t\t\t}\n\t\t\treturn value;\n\t\t}\n\t}\n\n\treturn encodeEntities('' + value);\n}\n\nexport {\n\tcreateVNode as jsx,\n\tcreateVNode as jsxs,\n\tcreateVNode as jsxDEV,\n\tFragment,\n\t// precompiled JSX transform\n\tjsxTemplate,\n\tjsxAttr,\n\tjsxEscape\n};\n","import type { ComponentChildren } from 'preact';\n\nfunction Icon({ children }: { children: ComponentChildren }) {\n return (\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">\n {children}\n </svg>\n );\n}\n\nexport const FlagIcon = () => (\n <Icon>\n <path d=\"M4 22V4\" />\n <path d=\"M4 4h12l-1.5 4L16 12H4\" />\n </Icon>\n);\n\nexport const CloseIcon = () => (\n <Icon>\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </Icon>\n);\n\nexport const ExternalIcon = () => (\n <Icon>\n <path d=\"M15 3h6v6\" />\n <path d=\"M10 14 21 3\" />\n <path d=\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\" />\n </Icon>\n);\n\nexport const ResetIcon = () => (\n <Icon>\n <path d=\"M3 12a9 9 0 1 0 3-6.7L3 8\" />\n <path d=\"M3 3v5h5\" />\n </Icon>\n);\n\nexport const UserIcon = () => (\n <Icon>\n <circle cx=\"12\" cy=\"8\" r=\"4\" />\n <path d=\"M4 21a8 8 0 0 1 16 0\" />\n </Icon>\n);\n\nexport const LinkIcon = () => (\n <Icon>\n <path d=\"M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7\" />\n <path d=\"M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7\" />\n </Icon>\n);\n\nexport const ClipboardIcon = () => (\n <Icon>\n <rect x=\"8\" y=\"2\" width=\"8\" height=\"4\" rx=\"1\" />\n <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\" />\n </Icon>\n);\n\nexport const RefreshIcon = () => (\n <Icon>\n <path d=\"M21 12a9 9 0 0 1-15.4 6.4L3 16\" />\n <path d=\"M3 21v-5h5\" />\n <path d=\"M3 12a9 9 0 0 1 15.4-6.4L21 8\" />\n <path d=\"M21 3v5h-5\" />\n </Icon>\n);\n\nexport const CheckIcon = () => (\n <Icon>\n <path d=\"m5 12 5 5L20 7\" />\n </Icon>\n);\n\nexport const AlertIcon = () => (\n <Icon>\n <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\" />\n <path d=\"M12 9v4\" />\n <path d=\"M12 17h.01\" />\n </Icon>\n);\n\nexport const InfoIcon = () => (\n <Icon>\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M12 16v-4\" />\n <path d=\"M12 8h.01\" />\n </Icon>\n);\n\nexport const FlaskIcon = () => (\n <Icon>\n <path d=\"M9 3h6\" />\n <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\" />\n <path d=\"M7.5 15h9\" />\n </Icon>\n);\n\nexport const CompareIcon = () => (\n <Icon>\n <path d=\"M8 3 4 7l4 4\" />\n <path d=\"M4 7h16\" />\n <path d=\"m16 21 4-4-4-4\" />\n <path d=\"M20 17H4\" />\n </Icon>\n);\n","import { useEffect, useRef } from 'preact/hooks';\nimport { compareFlags, type CompareRow } from '../compare';\nimport type { ToolbarController } from '../controller';\nimport { formatValue } from '../overrides';\nimport { explainReason } from '../reasons';\nimport type { CompareSubject, ToolbarState } from '../store';\nimport type { ToolbarFlag } from '../types';\nimport { CompareIcon } from './icons';\n\ninterface Props {\n controller: ToolbarController;\n state: ToolbarState;\n}\n\nfunction shortLabel(controller: ToolbarController, subject: CompareSubject): string {\n if (subject === 'page') return 'This page';\n if (subject === 'anonymous') return 'Anonymous';\n return controller.subjectLabel(subject).split('·')[0]!.trim();\n}\n\nexport function CompareTab({ controller, state }: Props) {\n const subjects = controller.compareSubjects();\n const { compareA: a, compareB: b, compareStatus: status } = state;\n const opened = useRef(false);\n\n // Compare when the tab opens, and again whenever \"This page\" changes (you flip a flag, view as\n // someone else, or Flagsmith's flags arrive). Effects run a frame late, so read the latest\n // picks from the store rather than from this render.\n useEffect(() => {\n const latest = controller.store.get();\n const usesPage = latest.compareA === 'page' || latest.compareB === 'page';\n const first = !opened.current;\n opened.current = true;\n if (usesPage || (first && latest.compareStatus !== 'done')) void controller.compare(latest.compareA, latest.compareB);\n }, [state.serverFlags, state.overrides]);\n\n const comparison = state.compareResult ? compareFlags(state.compareResult.a, state.compareResult.b) : null;\n const total = comparison ? comparison.differ.length + comparison.same.length : 0;\n const labelA = shortLabel(controller, a);\n const labelB = shortLabel(controller, b);\n\n return (\n <div class=\"fst-stack\">\n <div class=\"fst-card fst-compare-pick\">\n <Picker id=\"fst-compare-a\" label=\"User A\" value={a} subjects={subjects} onChange={(next) => void controller.pickCompare('a', next)} />\n <button class=\"fst-icon-btn fst-swap\" aria-label=\"Swap users A and B\" title=\"Swap\" onClick={() => void controller.swapCompare()}>\n <CompareIcon />\n </button>\n <Picker id=\"fst-compare-b\" label=\"User B\" value={b} subjects={subjects} onChange={(next) => void controller.pickCompare('b', next)} />\n </div>\n\n {status === 'loading' && (\n <p class=\"fst-loading\">\n <span class=\"fst-spinner\" aria-hidden=\"true\" /> Asking Flagsmith about both users…\n </p>\n )}\n {status === 'error' && <p class=\"fst-error\">{state.compareError}</p>}\n\n {comparison && status !== 'error' && (\n <>\n <p class=\"fst-compare-summary\" role=\"status\">\n {comparison.differ.length === 0 ? (\n <>\n <strong>{labelA}</strong> and <strong>{labelB}</strong> see the same {total} flags.\n </>\n ) : (\n <>\n <strong>\n {comparison.differ.length} of {total} flags\n </strong>{' '}\n differ between {labelA} and {labelB}.\n </>\n )}\n </p>\n {comparison.differ.length > 0 && (\n <ul class=\"fst-list\">\n {comparison.differ.map((row) => (\n <CompareItem key={row.key} row={row} labelA={labelA} labelB={labelB} />\n ))}\n </ul>\n )}\n {comparison.same.length > 0 && (\n <details class=\"fst-same\">\n <summary>Same for both ({comparison.same.length})</summary>\n <div class=\"fst-chips\">\n {comparison.same.map((row) => (\n <code class=\"fst-chip\">{row.key}</code>\n ))}\n </div>\n </details>\n )}\n </>\n )}\n\n <p class=\"fst-note\">\n Flagsmith evaluates each user live, with its real segments, splits and experiments. Users without an identity are\n transient, so nothing is saved and your page doesn't change.\n </p>\n </div>\n );\n}\n\nfunction Picker({\n id,\n label,\n value,\n subjects,\n onChange,\n}: {\n id: string;\n label: string;\n value: CompareSubject;\n subjects: Array<{ id: CompareSubject; label: string }>;\n onChange: (value: CompareSubject) => void;\n}) {\n return (\n <div class=\"fst-picker\">\n <label class=\"fst-label\" for={id}>\n {label}\n </label>\n <select id={id} class=\"fst-input fst-select\" value={value} onChange={(event) => onChange(event.currentTarget.value)}>\n {subjects.map((subject) => (\n <option value={subject.id}>{subject.label}</option>\n ))}\n </select>\n </div>\n );\n}\n\nfunction CompareItem({ row, labelA, labelB }: { row: CompareRow; labelA: string; labelB: string }) {\n return (\n <li class=\"fst-flag fst-compare-row\">\n <div class=\"fst-compare-key\">\n <code>{row.key}</code>\n </div>\n <Side label={labelA} flag={row.a} />\n <Side label={labelB} flag={row.b} />\n </li>\n );\n}\n\nfunction Side({ label, flag }: { label: string; flag: ToolbarFlag | undefined }) {\n if (!flag) {\n return (\n <div class=\"fst-side\">\n <span class=\"fst-side-label\">{label}</span>\n <span class=\"fst-muted\">Not sent for this user</span>\n </div>\n );\n }\n const why = explainReason(flag.reason);\n return (\n <div class=\"fst-side\">\n <span class=\"fst-side-label\" title={label}>\n {label}\n </span>\n <span class={`fst-state${flag.enabled ? ' is-on' : ''}`}>{flag.enabled ? 'On' : 'Off'}</span>\n <span class=\"fst-side-value\" title={formatValue(flag.value)}>\n {formatValue(flag.value)}\n </span>\n <span class={`fst-reason fst-reason--${why.kind}`} title={why.detail}>\n {why.label}\n </span>\n </div>\n );\n}\n","import type { ToolbarController } from '../controller';\nimport type { ExperimentRow } from '../experiments';\nimport { formatValue } from '../overrides';\nimport type { ToolbarState } from '../store';\nimport type { ToolbarEvent } from '../types';\nimport { AlertIcon, CheckIcon, FlaskIcon, InfoIcon } from './icons';\n\nconst time = (at: number) => new Date(at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' });\n\ninterface Props {\n controller: ToolbarController;\n state: ToolbarState;\n}\n\nexport function ExperimentsTab({ controller, state }: Props) {\n const rows = controller.experiments();\n const identity = controller.currentIdentity();\n return (\n <div class=\"fst-stack\">\n {controller.isPreviewing() && (\n <div class=\"fst-callout\">\n <InfoIcon />\n <span>\n You're previewing, so the toolbar holds events back. Test visits never count in your real experiment results.\n </span>\n </div>\n )}\n\n <div class=\"fst-section-title\">Experiments on this page</div>\n {rows.length === 0 ? (\n <div class=\"fst-card fst-muted\">\n {identity\n ? 'None of the flags for this user are in a running experiment.'\n : '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.'}\n </div>\n ) : (\n <ul class=\"fst-list\">\n {rows.map((row) => (\n <ExperimentCard key={row.key} row={row} previewing={controller.isPreviewing()} />\n ))}\n </ul>\n )}\n\n <div class=\"fst-section-title\">Events{state.events.length ? ` (${state.events.length})` : ''}</div>\n <EventList events={state.events} />\n </div>\n );\n}\n\nconst TONE: Record<ExperimentRow['state'], 'good' | 'bad' | 'neutral'> = {\n recorded: 'good',\n held: 'neutral',\n previewing: 'neutral',\n waiting: 'neutral',\n missing: 'bad',\n 'events-off': 'bad',\n 'not-read': 'neutral',\n 'not-enrolled': 'neutral',\n disabled: 'neutral',\n};\n\nfunction statusText(row: ExperimentRow, previewing: boolean): string {\n const at = row.exposure ? time(row.exposure.at) : '';\n switch (row.state) {\n case 'recorded':\n return `Exposure recorded at ${at}, so this visit counts.`;\n case 'held':\n return previewing\n ? `Exposure held back at ${at} because you're previewing, so this visit isn't counted.`\n : `Exposure held back at ${at}, while you were previewing. Reload the page to record a real one.`;\n case 'previewing':\n return \"You're previewing, so any exposure is held back and this visit isn't counted.\";\n case 'waiting':\n return 'Waiting for the page to record the exposure…';\n case 'missing':\n 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.\";\n case 'events-off':\n return \"Exposures can't be recorded, because Flagsmith was started without enableEvents.\";\n case 'not-read':\n return \"This page doesn't use this flag.\";\n case 'not-enrolled':\n return \"Flagsmith didn't put this user in the experiment, so they get the control value and aren't counted.\";\n case 'disabled':\n return \"The flag is off for this user, so there's nothing to expose.\";\n }\n}\n\nfunction ExperimentCard({ row, previewing }: { row: ExperimentRow; previewing: boolean }) {\n const tone = TONE[row.state];\n return (\n <li class={`fst-exp fst-exp--${tone}`}>\n <div class=\"fst-exp-head\">\n <FlaskIcon />\n <strong>{row.name}</strong>\n </div>\n <div class=\"fst-exp-meta\">\n <code>{row.key}</code>\n {row.inExperiment ? (\n <span>\n in the experiment, sees <strong>{formatValue(row.value)}</strong>\n </span>\n ) : (\n <span>not enrolled, sees {formatValue(row.value)}</span>\n )}\n </div>\n <p class=\"fst-exp-status\">\n {tone === 'good' ? <CheckIcon /> : tone === 'bad' ? <AlertIcon /> : <InfoIcon />}\n <span>{statusText(row, previewing)}</span>\n </p>\n {row.state === 'missing' && <pre class=\"fst-pre\">{`flagsmith.getExperimentFlag('${row.key}')`}</pre>}\n </li>\n );\n}\n\nconst STATUS_NOTE: Record<ToolbarEvent['status'], string> = {\n sent: '',\n held: ' · held back: preview',\n off: ' · not sent: enableEvents is off',\n 'no-identity': ' · not sent: no user identified',\n};\n\nfunction EventList({ events }: { events: ToolbarEvent[] }) {\n if (events.length === 0) {\n return (\n <div class=\"fst-empty\">\n <p>\n <strong>No events yet</strong>\n </p>\n <p>\n Events appear here as your app sends them: exposures from <code>getExperimentFlag</code> and{' '}\n <code>trackExposureEvent</code>, and conversions from <code>trackEvent</code>.\n </p>\n </div>\n );\n }\n return (\n <ul class=\"fst-events\">\n {events.map((event) => (\n <li class={`fst-event${event.status === 'sent' ? '' : ' is-unsent'}`} key={event.id}>\n <span class={`fst-chip fst-chip--${event.kind}`}>{event.kind === 'exposure' ? 'Exposure' : 'Event'}</span>\n <code>{event.name}</code>\n {event.value !== undefined && event.value !== null && <span class=\"fst-muted\">= {String(event.value)}</span>}\n <span class=\"fst-event-meta\">\n {time(event.at)} · {event.identifier ?? 'no identity'}\n {STATUS_NOTE[event.status]}\n </span>\n </li>\n ))}\n </ul>\n );\n}\n","import type { FlagMap, Overrides, ToolbarFlag } from './types';\n\n/** What kind of flag this is, judged from what Flagsmith sent. */\nexport type FlagType = 'onoff' | 'number' | 'json' | 'text' | 'variant';\n\nexport const FLAG_TYPE_LABELS: Record<FlagType, string> = {\n onoff: 'On/off',\n number: 'Number',\n json: 'JSON',\n text: 'Text',\n variant: 'Variant',\n};\n\nconst NUMERIC = /^-?\\d+(\\.\\d+)?$/;\n\n/**\n * - variant: a multivariate flag (Flagsmith says which variant this user got).\n * - onoff: no value, only on or off.\n * - number: a number, or a string that is one (\"25\").\n * - json: a string holding a JSON object or array.\n * - text: anything else. Boolean values are rare in Flagsmith and read as text (\"true\").\n */\nexport function flagType(flag: Pick<ToolbarFlag, 'value' | 'variant'>): FlagType {\n if (typeof flag.variant === 'string' && flag.variant !== '') return 'variant';\n const { value } = flag;\n if (value === null || value === undefined || value === '') return 'onoff';\n if (typeof value === 'number') return Number.isFinite(value) ? 'number' : 'text';\n if (typeof value !== 'string') return 'text';\n const trimmed = value.trim();\n if (NUMERIC.test(trimmed)) return 'number';\n if (trimmed.startsWith('{') || trimmed.startsWith('[')) {\n try {\n const parsed: unknown = JSON.parse(trimmed);\n if (parsed !== null && typeof parsed === 'object') return 'json';\n } catch {\n // Not JSON after all: plain text that starts with a bracket.\n }\n }\n return 'text';\n}\n\nexport interface FlagGroup {\n id: 'page' | 'other' | 'all';\n /** Shown above the group. Null when the list isn't split into groups. */\n title: string | null;\n keys: string[];\n}\n\nexport interface FlagListInput {\n flags: FlagMap;\n /** Flags read on the current page. */\n reads: Record<string, number>;\n overrides: Overrides;\n filter: 'all' | 'page' | 'changed';\n search: string;\n}\n\n/** Whether a flag matches the search box: by key or by value. */\nexport function matchesSearch(key: string, flag: ToolbarFlag | undefined, search: string): boolean {\n const query = search.trim().toLowerCase();\n return !query || key.toLowerCase().includes(query) || String(flag?.value ?? '').toLowerCase().includes(query);\n}\n\n/**\n * The flags to list, in groups. With the \"All\" filter, flags this page reads come first\n * and every other flag after them, each group sorted by key. The other filters show one\n * plain list. Empty groups are left out.\n */\nexport function flagGroups(input: FlagListInput): FlagGroup[] {\n const keys = Object.keys(input.flags)\n .filter((key) => matchesSearch(key, input.flags[key], input.search))\n .sort();\n if (input.filter === 'page') return nonEmpty([{ id: 'all', title: null, keys: keys.filter((key) => key in input.reads) }]);\n if (input.filter === 'changed') return nonEmpty([{ id: 'all', title: null, keys: keys.filter((key) => key in input.overrides) }]);\n return nonEmpty([\n { id: 'page', title: 'On this page', keys: keys.filter((key) => key in input.reads) },\n { id: 'other', title: 'Other flags', keys: keys.filter((key) => !(key in input.reads)) },\n ]);\n}\n\nconst nonEmpty = (groups: FlagGroup[]) => groups.filter((group) => group.keys.length > 0);\n","import { useEffect, useState } from 'preact/hooks';\nimport type { Store } from '../store';\n\n/** Re-renders the component whenever the store changes. */\nexport function useStore<T extends object>(store: Store<T>): T {\n const [state, setState] = useState(store.get());\n useEffect(() => {\n setState(store.get());\n return store.subscribe(() => setState(store.get()));\n }, [store]);\n return state;\n}\n\n/** Copies text, falling back to a hidden textarea where the Clipboard API is blocked. */\nexport async function copyText(text: string): Promise<boolean> {\n try {\n await navigator.clipboard.writeText(text);\n return true;\n } catch {\n // Fall through to the legacy approach.\n }\n try {\n const textarea = document.createElement('textarea');\n textarea.value = text;\n textarea.style.cssText = 'position:fixed;opacity:0;pointer-events:none;';\n document.body.appendChild(textarea);\n textarea.select();\n const copied = document.execCommand('copy');\n textarea.remove();\n return copied;\n } catch {\n return false;\n }\n}\n","import { useEffect, useRef, useState } from 'preact/hooks';\nimport type { ToolbarController } from '../controller';\nimport { FLAG_TYPE_LABELS, flagGroups, flagType } from '../flag-list';\nimport { formatValue, parseValueInput } from '../overrides';\nimport { explainReason } from '../reasons';\nimport type { FlagFilter, ToolbarState } from '../store';\nimport type { FlagMap, ToolbarFlag } from '../types';\nimport { copyText } from './hooks';\nimport { ExternalIcon, ResetIcon, UserIcon } from './icons';\n\ninterface Props {\n controller: ToolbarController;\n state: ToolbarState;\n flags: FlagMap;\n}\n\nexport function FlagsTab({ controller, state, flags }: Props) {\n const keys = Object.keys(flags);\n const usedCount = keys.filter((key) => key in state.reads).length;\n const changedCount = Object.keys(state.overrides).length;\n const groups = flagGroups({ flags, reads: state.reads, overrides: state.overrides, filter: state.filter, search: state.search });\n const filters: Array<[FlagFilter, string, number]> = [\n ['all', 'All', keys.length],\n ['page', 'On this page', usedCount],\n ['changed', 'Changed', changedCount],\n ];\n\n return (\n <div class=\"fst-stack\">\n {!state.welcomeDismissed && <Welcome controller={controller} />}\n <ViewingAs controller={controller} state={state} />\n <input\n class=\"fst-input fst-search\"\n type=\"search\"\n placeholder=\"Search flags or values\"\n aria-label=\"Search flags\"\n value={state.search}\n onInput={(event) => controller.setSearch(event.currentTarget.value)}\n />\n <div class=\"fst-segmented\" role=\"group\" aria-label=\"Filter flags\">\n {filters.map(([id, label, count]) => (\n <button class={`fst-segment${state.filter === id ? ' is-active' : ''}`} aria-pressed={state.filter === id} onClick={() => controller.setFilter(id)}>\n {label}\n <span class=\"fst-segment-count\">{count}</span>\n </button>\n ))}\n </div>\n {keys.length === 0 ? (\n <div class=\"fst-empty\">\n <p>\n <strong>Waiting for flags from Flagsmith…</strong>\n </p>\n <p>They appear here as soon as the SDK loads them.</p>\n </div>\n ) : groups.length === 0 ? (\n <div class=\"fst-empty\">No flags match.</div>\n ) : (\n groups.map((group) => (\n <div class=\"fst-group\" key={group.id}>\n {group.title && (\n <p class=\"fst-section-title fst-group-title\">\n {group.title}\n <span class=\"fst-group-count\">{group.keys.length}</span>\n </p>\n )}\n <ul class=\"fst-list\" aria-label={group.title ?? 'Flags'}>\n {group.keys.map((key) => (\n <FlagRow\n key={key}\n controller={controller}\n flagKey={key}\n flag={flags[key]!}\n server={state.serverFlags[key]}\n changed={key in state.overrides}\n fresh={key in state.changedInFlagsmith}\n used={key in state.reads}\n pages={state.seenOn[key] ?? []}\n expanded={state.expanded === key}\n />\n ))}\n </ul>\n </div>\n ))\n )}\n {changedCount > 0 && (\n <button class=\"fst-link-btn\" onClick={() => controller.resetAll()}>\n Reset {changedCount === 1 ? 'your change' : `all ${changedCount} changes`}\n </button>\n )}\n </div>\n );\n}\n\nfunction Welcome({ controller }: { controller: ToolbarController }) {\n return (\n <div class=\"fst-welcome\">\n <strong class=\"fst-welcome-title\">See what Flagsmith is doing on this page</strong>\n <ol>\n <li>\n <strong>Why:</strong> open any flag to see why it has its value.\n </li>\n <li>\n <strong>Try the other side:</strong> flip a flag. Only you see the change.\n </li>\n <li>\n <strong>View as and Compare:</strong> see the page as another user, or compare two users side by side.\n </li>\n </ol>\n <p class=\"fst-welcome-note\">The badge at the top checks your Flagsmith setup for common mistakes.</p>\n <button class=\"fst-btn fst-btn--primary\" onClick={() => controller.dismissWelcome()}>\n Got it\n </button>\n </div>\n );\n}\n\nfunction ViewingAs({ controller, state }: { controller: ToolbarController; state: ToolbarState }) {\n const identity = controller.flagsmith.identity;\n const who = state.persona?.name ?? (identity ? `identity ${identity}` : 'an anonymous visitor');\n return (\n <div class=\"fst-viewing\">\n <UserIcon />\n <span>\n Flags for <strong>{who}</strong>\n </span>\n {state.personaStatus === 'loading' && <span class=\"fst-spinner\" aria-label=\"Loading\" />}\n <button class=\"fst-link-btn\" onClick={() => controller.setTab('viewas')}>\n Change\n </button>\n </div>\n );\n}\n\ninterface RowProps {\n controller: ToolbarController;\n flagKey: string;\n flag: ToolbarFlag;\n server: ToolbarFlag | undefined;\n changed: boolean;\n /** The value just changed in Flagsmith (seen on a refresh). */\n fresh: boolean;\n used: boolean;\n /** The pages this flag was read on this session. */\n pages: string[];\n expanded: boolean;\n}\n\nfunction FlagRow({ controller, flagKey, flag, server, changed, fresh, used, pages, expanded }: RowProps) {\n const why = explainReason(flag.reason);\n // The kind of flag comes from Flagsmith's own value, so a change you made doesn't relabel it.\n const type = flagType(server ?? flag);\n return (\n <li class={`fst-flag${changed ? ' is-changed' : ''}${fresh ? ' is-fresh' : ''}`}>\n <div class=\"fst-flag-main\">\n <button class=\"fst-flag-summary\" aria-expanded={expanded} onClick={() => controller.toggleExpanded(flagKey)}>\n <span class=\"fst-flag-name\">\n {used && <span class=\"fst-used\" title=\"Used on this page\" />}\n <code>{flagKey}</code>\n {fresh && <span class=\"fst-fresh\">Changed in Flagsmith</span>}\n <span class=\"fst-type\">{FLAG_TYPE_LABELS[type]}</span>\n </span>\n <span class=\"fst-flag-meta\">\n <span class={`fst-reason fst-reason--${why.kind}`} title={why.detail}>\n {why.label}\n </span>\n <span class=\"fst-flag-value\">{formatValue(flag.value)}</span>\n </span>\n </button>\n <Switch checked={flag.enabled} label={`${flagKey}: turn ${flag.enabled ? 'off' : 'on'} just for you`} onChange={(enabled) => controller.setEnabled(flagKey, enabled)} />\n </div>\n {expanded && <FlagDetails controller={controller} flagKey={flagKey} flag={flag} server={server} changed={changed} pages={pages} />}\n </li>\n );\n}\n\nfunction FlagDetails({ controller, flagKey, flag, server, changed, pages }: Omit<RowProps, 'used' | 'expanded' | 'fresh'>) {\n const [copied, setCopied] = useState(false);\n const why = explainReason(flag.reason);\n const serverWhy = explainReason(server?.reason);\n const link = controller.dashboardLink(flagKey);\n return (\n <div class=\"fst-details\">\n <p>\n <strong>Why: </strong>\n {why.detail}\n </p>\n {changed && server && (\n <p class=\"fst-muted\">\n Flagsmith says: <strong>{server.enabled ? 'on' : 'off'}</strong>, {formatValue(server.value)} ({serverWhy.label.toLowerCase()})\n </p>\n )}\n {server?.reason && (\n <p class=\"fst-raw\" title=\"The reason exactly as Flagsmith sent it\">\n <code>{server.reason}</code>\n </p>\n )}\n <p class=\"fst-muted fst-pages\">\n {pages.length ? (\n <>\n Read on:{' '}\n {pages.map((page, index) => (\n <span key={page}>\n {index > 0 && ', '}\n <code>{page}</code>\n </span>\n ))}\n </>\n ) : (\n 'Not read on any page yet'\n )}\n </p>\n {server?.experiment && (\n <p class=\"fst-muted\">\n Experiment <strong>{server.experiment.name}</strong>:{' '}\n {server.experiment.inExperiment ? 'this user is in it.' : \"this user isn't enrolled.\"}{' '}\n <button class=\"fst-link-btn\" onClick={() => controller.setTab('experiments')}>\n See exposures\n </button>\n </p>\n )}\n <ValueEditor controller={controller} flagKey={flagKey} flag={flag} />\n <div class=\"fst-actions\">\n {changed && (\n <button class=\"fst-btn\" onClick={() => controller.resetFlag(flagKey)}>\n <ResetIcon /> Reset to Flagsmith\n </button>\n )}\n {link && (\n <a class=\"fst-btn\" href={link} target=\"_blank\" rel=\"noreferrer\">\n Open in Flagsmith <ExternalIcon />\n </a>\n )}\n <button\n class=\"fst-btn\"\n onClick={async () => {\n setCopied(await copyText(flagKey));\n setTimeout(() => setCopied(false), 1500);\n }}\n >\n {copied ? 'Copied' : 'Copy key'}\n </button>\n </div>\n </div>\n );\n}\n\nfunction ValueEditor({ controller, flagKey, flag }: { controller: ToolbarController; flagKey: string; flag: ToolbarFlag }) {\n const current = flag.value === null || flag.value === undefined ? '' : String(flag.value);\n const [draft, setDraft] = useState(current);\n const shown = useRef(current);\n // Follow the flag when its value really changes, but never wipe what you're typing:\n // effects run a frame late, so an unconditional reset here would undo fast typing.\n useEffect(() => {\n if (shown.current === current) return;\n shown.current = current;\n setDraft(current);\n }, [current]);\n return (\n <form\n class=\"fst-value\"\n onSubmit={(event) => {\n event.preventDefault();\n controller.setValue(flagKey, parseValueInput(draft, flag.value));\n }}\n >\n <label class=\"fst-label\" for={`fst-value-${flagKey}`}>\n Value, just for you\n </label>\n <div class=\"fst-value-row\">\n <input id={`fst-value-${flagKey}`} class=\"fst-input\" value={draft} placeholder=\"No value\" onInput={(event) => setDraft(event.currentTarget.value)} />\n <button class=\"fst-btn fst-btn--primary\" type=\"submit\" disabled={draft === current}>\n Apply\n </button>\n </div>\n </form>\n );\n}\n\nfunction Switch({ checked, label, onChange }: { checked: boolean; label: string; onChange: (value: boolean) => void }) {\n return (\n <button role=\"switch\" aria-checked={checked} aria-label={label} title={label} class={`fst-switch${checked ? ' is-on' : ''}`} onClick={() => onChange(!checked)}>\n <span class=\"fst-switch-thumb\" />\n </button>\n );\n}\n","import type { SetupIssue } from '../checks';\nimport type { ToolbarController } from '../controller';\nimport { AlertIcon, CheckIcon, CloseIcon, InfoIcon } from './icons';\n\n/** The small \"Setup OK\" / \"2 to fix\" button in the panel header. */\nexport function SetupChip({ controller, issues, open }: { controller: ToolbarController; issues: SetupIssue[]; open: boolean }) {\n const toFix = issues.filter((issue) => issue.level !== 'tip');\n const problem = toFix.some((issue) => issue.level === 'problem');\n const tone = toFix.length === 0 ? 'ok' : problem ? 'problem' : 'warning';\n return (\n <button\n class={`fst-setup-chip fst-setup-chip--${tone}`}\n aria-expanded={open}\n aria-label={toFix.length ? `Setup check: ${toFix.length} to fix` : 'Setup check: no problems found'}\n title=\"Check this page's Flagsmith setup\"\n onClick={() => controller.toggleSetup()}\n >\n {toFix.length ? <AlertIcon /> : <CheckIcon />}\n <span>{toFix.length ? `${toFix.length} to fix` : 'Setup OK'}</span>\n </button>\n );\n}\n\nconst ICON = { problem: AlertIcon, warning: AlertIcon, tip: InfoIcon };\n\n/** The list of setup findings, shown above the current tab. */\nexport function SetupList({ controller, issues }: { controller: ToolbarController; issues: SetupIssue[] }) {\n return (\n <section class=\"fst-setup\" aria-label=\"Setup check\">\n <div class=\"fst-setup-head\">\n <strong>Setup check</strong>\n <button class=\"fst-icon-btn\" aria-label=\"Close setup check\" onClick={() => controller.toggleSetup()}>\n <CloseIcon />\n </button>\n </div>\n {issues.filter((issue) => issue.level !== 'tip').length === 0 && (\n <p class=\"fst-setup-ok\">\n <CheckIcon /> No problems found with how this page uses Flagsmith.\n </p>\n )}\n <ul class=\"fst-issues\">\n {issues.map((issue) => {\n const Icon = ICON[issue.level];\n return (\n <li class={`fst-issue fst-issue--${issue.level}`} key={issue.id}>\n <Icon />\n <div>\n <strong>{issue.title}</strong>\n <p>{issue.detail}</p>\n {issue.fix && <pre class=\"fst-pre\">{issue.fix}</pre>}\n </div>\n </li>\n );\n })}\n </ul>\n </section>\n );\n}\n","import { useState } from 'preact/hooks';\nimport type { ToolbarController } from '../controller';\nimport type { ToolbarState } from '../store';\nimport { copyText } from './hooks';\nimport { ClipboardIcon, LinkIcon } from './icons';\n\ninterface Props {\n controller: ToolbarController;\n state: ToolbarState;\n}\n\nexport function ShareTab({ controller, state }: Props) {\n const [link, setLink] = useState('');\n const [linkStatus, setLinkStatus] = useState('');\n const [report, setReport] = useState('');\n const [reportStatus, setReportStatus] = useState('');\n const changed = Object.keys(state.overrides).length;\n const summary =\n [state.persona ? `viewing as ${state.persona.name}` : '', changed ? `${changed} changed flag${changed === 1 ? '' : 's'}` : '']\n .filter(Boolean)\n .join(' and ') || 'no changes yet, so it opens the page as normal';\n\n return (\n <div class=\"fst-stack\">\n <section class=\"fst-card\">\n <div class=\"fst-card-title\">\n <LinkIcon /> Share this preview\n </div>\n <p>\n Copy a link that opens this page with the same user and flag changes ({summary}). Anyone who opens it with the\n toolbar enabled sees exactly what you see.\n </p>\n <button\n class=\"fst-btn fst-btn--primary\"\n onClick={async () => {\n const url = controller.previewUrl();\n setLink(url);\n setLinkStatus((await copyText(url)) ? 'Link copied' : 'Copy the link below');\n }}\n >\n Copy preview link\n </button>\n {linkStatus && <span class=\"fst-status\">{linkStatus}</span>}\n {link && (\n <p>\n <input class=\"fst-input fst-mono\" readOnly value={link} aria-label=\"Preview link\" onFocus={(event) => event.currentTarget.select()} />\n </p>\n )}\n </section>\n\n <section class=\"fst-card\">\n <div class=\"fst-card-title\">\n <ClipboardIcon /> Report a bug\n </div>\n <p>Copy every flag on this page, its value and why it has it, as a Markdown table for a GitHub issue or Jira ticket.</p>\n <button\n class=\"fst-btn fst-btn--primary\"\n onClick={async () => {\n const markdown = controller.bugReport();\n setReport(markdown);\n setReportStatus((await copyText(markdown)) ? 'Copied as Markdown' : 'Copy the text below');\n }}\n >\n Copy bug report\n </button>\n {reportStatus && <span class=\"fst-status\">{reportStatus}</span>}\n {report && <pre class=\"fst-pre\">{report}</pre>}\n </section>\n </div>\n );\n}\n","import { useState } from 'preact/hooks';\nimport type { ToolbarController } from '../controller';\nimport { parseTraits } from '../personas';\nimport type { ToolbarState } from '../store';\nimport type { Persona } from '../types';\n\ninterface Props {\n controller: ToolbarController;\n state: ToolbarState;\n}\n\nexport function ViewAsTab({ controller, state }: Props) {\n const personas = controller.options.personas ?? [];\n const identity = controller.flagsmith.identity;\n const loading = state.personaStatus === 'loading';\n return (\n <div class=\"fst-stack\">\n <div class=\"fst-card\">\n <div class=\"fst-muted\">Viewing the page as</div>\n <div class=\"fst-current-name\">{state.persona?.name ?? (identity ? `Identity ${identity}` : 'Yourself (anonymous visitor)')}</div>\n {loading && <p class=\"fst-muted\">Asking Flagsmith for this user's flags…</p>}\n {state.personaError && <p class=\"fst-error\">{state.personaError}</p>}\n {state.persona && (\n <p>\n <button class=\"fst-btn\" disabled={loading} onClick={() => void controller.backToMe()}>\n Back to my view\n </button>\n </p>\n )}\n </div>\n\n {personas.length > 0 && <div class=\"fst-section-title\">Ready-made users</div>}\n {personas.length > 0 && (\n <ul class=\"fst-personas\">\n {personas.map((persona) => (\n <PersonaCard controller={controller} persona={persona} active={state.persona?.name === persona.name} disabled={loading} />\n ))}\n </ul>\n )}\n\n <div class=\"fst-section-title\">Any user</div>\n <CustomUser controller={controller} disabled={loading} />\n\n <p class=\"fst-note\">\n Flagsmith works out each user's flags live, with its real segments and splits. Users without an identity are\n transient, so Flagsmith saves nothing.\n </p>\n </div>\n );\n}\n\nfunction PersonaCard({ controller, persona, active, disabled }: { controller: ToolbarController; persona: Persona; active: boolean; disabled: boolean }) {\n const traits = Object.entries(persona.traits ?? {});\n return (\n <li class={`fst-persona${active ? ' is-active' : ''}`}>\n <div>\n <div class=\"fst-persona-name\">{persona.name}</div>\n {persona.description && <div class=\"fst-muted\">{persona.description}</div>}\n {(persona.identifier || traits.length > 0) && (\n <div class=\"fst-chips\">\n {persona.identifier && <span class=\"fst-chip fst-chip--identity\">identity: {persona.identifier}</span>}\n {traits.map(([key, value]) => (\n <span class=\"fst-chip\">\n {key}: {String(value)}\n </span>\n ))}\n </div>\n )}\n </div>\n <button class={`fst-btn${active ? '' : ' fst-btn--primary'}`} disabled={active || disabled} onClick={() => void controller.viewAs(persona)}>\n {active ? 'Viewing' : 'View as'}\n </button>\n </li>\n );\n}\n\nfunction CustomUser({ controller, disabled }: { controller: ToolbarController; disabled: boolean }) {\n const [identifier, setIdentifier] = useState('');\n const [traitsText, setTraitsText] = useState('country=IN\\nplan=pro');\n return (\n <form\n class=\"fst-card fst-form\"\n onSubmit={(event) => {\n event.preventDefault();\n const traits = parseTraits(traitsText);\n const id = identifier.trim();\n const summary = Object.entries(traits)\n .map(([key, value]) => `${key}=${value}`)\n .join(', ');\n void controller.viewAs({\n name: id || (summary ? `Custom user (${summary})` : 'Custom user'),\n ...(id ? { identifier: id } : {}),\n traits,\n });\n }}\n >\n <div>\n <label class=\"fst-label\" for=\"fst-identifier\">\n Identity (optional, uses that user's overrides)\n </label>\n <input id=\"fst-identifier\" class=\"fst-input\" placeholder=\"e.g. asha-beta-tester\" value={identifier} onInput={(event) => setIdentifier(event.currentTarget.value)} />\n </div>\n <div>\n <label class=\"fst-label\" for=\"fst-traits\">\n Traits, one per line as key=value\n </label>\n <textarea id=\"fst-traits\" class=\"fst-input fst-mono\" rows={3} value={traitsText} onInput={(event) => setTraitsText(event.currentTarget.value)} />\n </div>\n <div>\n <button class=\"fst-btn fst-btn--primary\" type=\"submit\" disabled={disabled}>\n View as this user\n </button>\n </div>\n </form>\n );\n}\n","import { useEffect, useRef } from 'preact/hooks';\nimport type { ToolbarController } from '../controller';\nimport { formatHotkey } from '../controller';\nimport type { Tab, ToolbarState } from '../store';\nimport { CompareTab } from './CompareTab';\nimport { ExperimentsTab } from './ExperimentsTab';\nimport { FlagsTab } from './FlagsTab';\nimport { useStore } from './hooks';\nimport { CloseIcon, FlagIcon, RefreshIcon } from './icons';\nimport { SetupChip, SetupList } from './SetupCheck';\nimport { ShareTab } from './ShareTab';\nimport { ViewAsTab } from './ViewAsTab';\n\ninterface Props {\n controller: ToolbarController;\n}\n\nconst shortKey = (key: string) => (key.length > 10 ? `${key.slice(0, 6)}…` : key);\n\n/** Below this width the panel floats over the page even in \"push\" mode. */\nconst PUSH_MIN_WIDTH = 900;\n/** Panel width plus its margin and a gap. */\nconst PANEL_SPACE = '424px';\n\n/**\n * Marks <html data-flagsmith-toolbar=\"open|closed\"> so apps can style around the\n * toolbar, and in \"push\" mode makes room for the open panel on wide screens.\n */\nfunction useHostLayout(controller: ToolbarController, open: boolean) {\n const { layout, position } = controller.options;\n useEffect(() => {\n const html = document.documentElement;\n html.dataset.flagsmithToolbar = open ? 'open' : 'closed';\n if (layout !== 'push' || !open) return;\n const property = position === 'left' ? 'padding-left' : 'padding-right';\n const previous = html.style.getPropertyValue(property);\n const restore = () => (previous ? html.style.setProperty(property, previous) : html.style.removeProperty(property));\n const apply = () => (window.innerWidth >= PUSH_MIN_WIDTH ? html.style.setProperty(property, PANEL_SPACE) : restore());\n apply();\n window.addEventListener('resize', apply);\n return () => {\n window.removeEventListener('resize', apply);\n restore();\n };\n }, [open, layout, position]);\n useEffect(() => () => void delete document.documentElement.dataset.flagsmithToolbar, []);\n}\n\nexport function App({ controller }: Props) {\n const state = useStore(controller.store);\n // Opened by you (not restored from last time): move focus into the panel, like a dialog.\n const wasOpen = useRef(state.open);\n const focusOnOpen = state.open && !wasOpen.current;\n wasOpen.current = state.open;\n const changed = Object.keys(state.overrides).length;\n const previewing = Boolean(state.persona) || changed > 0;\n useHostLayout(controller, state.open);\n const pushed = controller.options.layout === 'push' && state.open && window.innerWidth >= PUSH_MIN_WIDTH;\n return (\n <div class={`fst${controller.options.position === 'left' ? ' fst--left' : ''}${pushed ? ' fst--pushed' : ''}`}>\n {previewing && <Banner controller={controller} state={state} changed={changed} />}\n {state.open ? <Panel controller={controller} state={state} focusOnOpen={focusOnOpen} /> : <Launcher controller={controller} changed={changed} />}\n </div>\n );\n}\n\nfunction Launcher({ controller, changed }: Props & { changed: number }) {\n return (\n <button\n class=\"fst-launcher\"\n onClick={() => controller.open()}\n title={`Flagsmith Toolbar (${formatHotkey(controller.options.hotkey)})`}\n aria-label=\"Flags: open Flagsmith Toolbar\"\n >\n <FlagIcon />\n <span>Flags</span>\n {changed > 0 && (\n <span class=\"fst-badge\" aria-label={`${changed} changed`}>\n {changed}\n </span>\n )}\n </button>\n );\n}\n\nfunction Banner({ controller, state, changed }: Props & { state: ToolbarState; changed: number }) {\n const parts: string[] = [];\n if (state.persona) parts.push(`Viewing as ${state.persona.name}`);\n if (changed) parts.push(`${changed} flag${changed === 1 ? '' : 's'} changed`);\n return (\n <div class=\"fst-banner\" role=\"status\">\n <span class=\"fst-banner-tag\">{state.sharedPreview ? 'Shared preview' : 'Preview'}</span>\n <span class=\"fst-banner-text\">{parts.join(' · ')}</span>\n <span class=\"fst-banner-muted\">Only you see this</span>\n <button class=\"fst-banner-btn\" onClick={() => void controller.exitPreview()}>\n Exit preview\n </button>\n </div>\n );\n}\n\nconst REFRESH_TEXT: Record<ToolbarState['refreshStatus'], string> = {\n idle: '',\n loading: 'Getting the latest flags from Flagsmith…',\n updated: 'Updated: the highlighted flags changed in Flagsmith.',\n unchanged: 'Up to date: nothing changed in Flagsmith.',\n error: \"Couldn't reach Flagsmith. Try again in a moment.\",\n};\n\nfunction Panel({ controller, state, focusOnOpen }: Props & { state: ToolbarState; focusOnOpen: boolean }) {\n const panel = useRef<HTMLElement>(null);\n useEffect(() => {\n if (focusOnOpen) panel.current?.focus({ preventScroll: true });\n }, []);\n const connection = controller.connection();\n const flags = controller.effectiveFlags();\n const flagCount = Object.keys(flags).length;\n const issues = controller.setupIssues();\n const needsAttention = controller.experiments().some((row) => row.state === 'missing' || row.state === 'events-off');\n const tabs: Array<[Tab, string, boolean]> = [\n ['flags', flagCount ? `Flags (${flagCount})` : 'Flags', false],\n ['viewas', 'View as', false],\n ['compare', 'Compare', false],\n ['share', 'Share', false],\n ['experiments', 'Experiments', needsAttention],\n ];\n return (\n <section\n ref={panel}\n class=\"fst-panel\"\n role=\"dialog\"\n aria-label=\"Flagsmith Toolbar\"\n tabIndex={-1}\n onKeyDown={(event) => {\n if (event.key === 'Escape') controller.close();\n }}\n onPointerDown={(event) => {\n // Safari doesn't focus a button you click, so keys like Esc would go to the page.\n // Keep focus inside the panel unless you clicked something that takes it.\n const target = event.target as HTMLElement;\n if (!target.closest('input, textarea, select, [contenteditable]')) panel.current?.focus({ preventScroll: true });\n }}\n >\n <header class=\"fst-header\">\n <div class=\"fst-title\">\n <FlagIcon />\n <span>Flagsmith Toolbar</span>\n </div>\n <div class=\"fst-header-actions\">\n {flagCount > 0 && <SetupChip controller={controller} issues={issues} open={state.setupOpen} />}\n {controller.flagsmith.getFlags && (\n <button\n class={`fst-icon-btn${state.refreshStatus === 'loading' ? ' is-spinning' : ''}`}\n aria-label=\"Get the latest flags from Flagsmith\"\n title=\"Get the latest flags from Flagsmith\"\n disabled={state.refreshStatus === 'loading'}\n onClick={() => void controller.refresh()}\n >\n <RefreshIcon />\n </button>\n )}\n <button class=\"fst-icon-btn\" aria-label=\"Close toolbar\" title={`Close (${formatHotkey(controller.options.hotkey)})`} onClick={() => controller.close()}>\n <CloseIcon />\n </button>\n </div>\n </header>\n <div class=\"fst-connection\" title={connection.apiUrl ?? 'Not connected yet'}>\n <span class={`fst-dot${flagCount ? ' fst-dot--ok' : ''}`} />\n <span>\n {connection.selfHosted ? 'Self-hosted Flagsmith' : 'Flagsmith'}\n {connection.host ? ` · ${connection.host}` : ''}\n </span>\n {connection.environmentKey && (\n <code class=\"fst-env\" title={`Environment key ${connection.environmentKey}`}>\n {shortKey(connection.environmentKey)}\n </code>\n )}\n </div>\n {state.refreshStatus !== 'idle' && (\n <p class={`fst-refresh fst-refresh--${state.refreshStatus}`} role=\"status\">\n {REFRESH_TEXT[state.refreshStatus]}\n </p>\n )}\n <nav class=\"fst-tabs\" role=\"tablist\" aria-label=\"Toolbar sections\">\n {tabs.map(([id, label, attention]) => (\n <button role=\"tab\" aria-selected={state.tab === id} class={`fst-tab${state.tab === id ? ' is-active' : ''}`} onClick={() => controller.setTab(id)}>\n {label}\n {attention && <span class=\"fst-tab-dot\" aria-label=\"needs attention\" />}\n </button>\n ))}\n </nav>\n <div class=\"fst-body\">\n {state.setupOpen && <SetupList controller={controller} issues={issues} />}\n {state.tab === 'flags' && <FlagsTab controller={controller} state={state} flags={flags} />}\n {state.tab === 'viewas' && <ViewAsTab controller={controller} state={state} />}\n {state.tab === 'compare' && <CompareTab controller={controller} state={state} />}\n {state.tab === 'share' && <ShareTab controller={controller} state={state} />}\n {state.tab === 'experiments' && <ExperimentsTab controller={controller} state={state} />}\n </div>\n <footer class=\"fst-footer\">\n <span>\n {formatHotkey(controller.options.hotkey)\n .split('+')\n .map((key, index) => (\n <>\n {index > 0 && '+'}\n <kbd>{key}</kbd>\n </>\n ))}{' '}\n opens and closes\n </span>\n <a href=\"https://github.com/YashSoni998265/flagsmith-toolbar\" target=\"_blank\" rel=\"noreferrer\">\n flagsmith-toolbar\n </a>\n </footer>\n </section>\n );\n}\n","/** Styles for the toolbar. They live inside a Shadow DOM, so the host page can't affect them. */\nexport const css = /* css */ `\n:host { all: initial; }\n\n.fst {\n --fst-bg: #ffffff;\n --fst-surface: #f7f6fb;\n --fst-hover: #f0eef8;\n --fst-border: #e6e3f0;\n --fst-text: #1a1822;\n --fst-muted: #6b6780;\n --fst-accent: #6837fc;\n --fst-accent-ink: #ffffff;\n --fst-accent-soft: #efe9ff;\n --fst-green: #077348;\n --fst-green-soft: #e2f5ec;\n --fst-amber: #9a5b00;\n --fst-amber-soft: #fff2dc;\n --fst-blue: #1b64c9;\n --fst-blue-soft: #e6f0ff;\n --fst-pink: #b0287b;\n --fst-pink-soft: #fbe6f3;\n --fst-red: #b0262b;\n --fst-red-soft: #fde8e8;\n --fst-shadow: 0 24px 60px rgba(24, 16, 52, 0.18), 0 2px 10px rgba(24, 16, 52, 0.08);\n font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n font-size: 13px;\n line-height: 1.45;\n color: var(--fst-text);\n -webkit-font-smoothing: antialiased;\n}\n\n@media (prefers-color-scheme: dark) {\n .fst {\n --fst-bg: #17161e;\n --fst-surface: #1f1e28;\n --fst-hover: #262532;\n --fst-border: #302e3d;\n --fst-text: #f2f1f7;\n --fst-muted: #a19eb5;\n --fst-accent: #9b7dff;\n --fst-accent-ink: #120f1c;\n --fst-accent-soft: #2a2342;\n --fst-green: #43d19c;\n --fst-green-soft: #12291f;\n --fst-amber: #f3b660;\n --fst-amber-soft: #2e2413;\n --fst-blue: #74adff;\n --fst-blue-soft: #15233a;\n --fst-pink: #f58bcb;\n --fst-pink-soft: #33182a;\n --fst-red: #ff8084;\n --fst-red-soft: #331a1c;\n --fst-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);\n }\n}\n\n*, *::before, *::after { box-sizing: border-box; }\nbutton, input, textarea { font: inherit; color: inherit; margin: 0; }\nbutton { cursor: pointer; }\ncode, kbd, pre, .fst-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }\na { color: var(--fst-accent); }\n:focus-visible { outline: 2px solid var(--fst-accent); outline-offset: 2px; }\n\n/* Launcher ---------------------------------------------------------------- */\n.fst-launcher {\n position: fixed; bottom: 20px; right: 20px;\n display: inline-flex; align-items: center; gap: 8px;\n padding: 10px 14px 10px 12px; border: 0; border-radius: 999px;\n background: var(--fst-accent); color: var(--fst-accent-ink);\n font-weight: 600; font-size: 13px; box-shadow: var(--fst-shadow);\n transition: transform 120ms ease;\n}\n.fst--left .fst-launcher { right: auto; left: 20px; }\n.fst-launcher:hover { transform: translateY(-1px); }\n.fst-launcher svg { width: 16px; height: 16px; }\n.fst-badge {\n min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;\n display: inline-flex; align-items: center; justify-content: center;\n background: #ffffff; color: #6837fc; font-size: 11px; font-weight: 700;\n}\n\n/* Preview banner ------------------------------------------------------------ */\n.fst-banner {\n position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);\n display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px);\n padding: 6px 6px 6px 8px; border-radius: 999px;\n background: #1a1822; color: #ffffff; font-size: 12.5px;\n box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); white-space: nowrap;\n}\n/* In push mode the page is narrower, so centre the banner on the page, not the window. */\n.fst--pushed .fst-banner { left: calc((100vw - 424px) / 2); }\n.fst--pushed.fst--left .fst-banner { left: calc(424px + (100vw - 424px) / 2); }\n.fst-banner-tag {\n padding: 2px 8px; border-radius: 999px; background: #6837fc; color: #fff;\n font-weight: 700; font-size: 11px; letter-spacing: 0.02em; text-transform: uppercase;\n}\n.fst-banner-text { overflow: hidden; text-overflow: ellipsis; }\n.fst-banner-muted { color: #b9b4cc; }\n.fst-banner-btn {\n border: 0; border-radius: 999px; padding: 5px 10px;\n background: #ffffff; color: #1a1822; font-weight: 600; font-size: 12px;\n}\n\n/* Panel --------------------------------------------------------------------- */\n.fst-panel {\n position: fixed; top: 12px; right: 12px; bottom: 12px;\n width: 400px; max-width: calc(100vw - 24px);\n display: flex; flex-direction: column;\n background: var(--fst-bg); border: 1px solid var(--fst-border); border-radius: 16px;\n box-shadow: var(--fst-shadow); overflow: hidden;\n}\n.fst--left .fst-panel { right: auto; left: 12px; }\n.fst-panel:focus { outline: none; }\n.fst-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 6px 16px; }\n.fst-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }\n.fst-title svg { width: 18px; height: 18px; color: var(--fst-accent); }\n.fst-icon-btn {\n display: inline-flex; align-items: center; justify-content: center;\n width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--fst-muted);\n}\n.fst-icon-btn:hover { background: var(--fst-hover); color: var(--fst-text); }\n.fst-icon-btn:disabled { cursor: default; }\n.fst-icon-btn svg { width: 16px; height: 16px; }\n.fst-icon-btn.is-spinning svg { animation: fst-spin 800ms linear infinite; }\n.fst-header-actions { display: flex; align-items: center; gap: 2px; }\n.fst-setup-chip {\n display: inline-flex; align-items: center; gap: 4px; margin-right: 4px; padding: 3px 8px;\n border: 0; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap;\n}\n.fst-setup-chip svg { width: 12px; height: 12px; }\n.fst-setup-chip--ok { background: var(--fst-green-soft); color: var(--fst-green); }\n.fst-setup-chip--warning { background: var(--fst-amber-soft); color: var(--fst-amber); }\n.fst-setup-chip--problem { background: var(--fst-red-soft); color: var(--fst-red); }\n.fst-refresh { margin: 0; padding: 6px 16px; font-size: 12px; font-weight: 600; }\n.fst-refresh--loading { color: var(--fst-muted); }\n.fst-refresh--updated { background: var(--fst-blue-soft); color: var(--fst-blue); }\n.fst-refresh--unchanged { background: var(--fst-green-soft); color: var(--fst-green); }\n.fst-refresh--error { background: var(--fst-red-soft); color: var(--fst-red); }\n.fst-connection {\n display: flex; align-items: center; gap: 8px; padding: 0 16px 10px;\n color: var(--fst-muted); font-size: 12px; min-width: 0;\n}\n.fst-connection > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.fst-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fst-muted); flex: none; }\n.fst-dot--ok { background: var(--fst-green); box-shadow: 0 0 0 3px var(--fst-green-soft); }\n.fst-env { margin-left: auto; padding: 1px 6px; border-radius: 6px; background: var(--fst-surface); color: var(--fst-muted); flex: none; }\n.fst-tabs {\n display: flex; gap: 0; padding: 0 8px; border-bottom: 1px solid var(--fst-border);\n overflow-x: auto; scrollbar-width: none;\n}\n.fst-tabs::-webkit-scrollbar { display: none; }\n.fst-tab {\n position: relative; flex: none; padding: 9px 7px 10px; border: 0; background: transparent;\n color: var(--fst-muted); font-weight: 600; font-size: 12.5px; white-space: nowrap;\n}\n.fst-tab-dot {\n display: inline-block; width: 6px; height: 6px; margin-left: 4px; border-radius: 50%;\n background: var(--fst-amber); vertical-align: middle;\n}\n.fst-tab:hover { color: var(--fst-text); }\n.fst-tab.is-active { color: var(--fst-accent); }\n.fst-tab.is-active::after {\n content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px;\n border-radius: 2px; background: var(--fst-accent);\n}\n.fst-body { flex: 1; overflow-y: auto; padding: 12px; }\n.fst-footer {\n display: flex; justify-content: space-between; gap: 8px; padding: 8px 14px;\n border-top: 1px solid var(--fst-border); color: var(--fst-muted); font-size: 11.5px;\n}\n.fst-footer a { color: var(--fst-muted); }\nkbd {\n display: inline-block; padding: 0 5px; border: 1px solid var(--fst-border); border-bottom-width: 2px;\n border-radius: 5px; background: var(--fst-surface); font-size: 11px;\n}\n\n/* Shared pieces ------------------------------------------------------------- */\n.fst-stack { display: flex; flex-direction: column; gap: 10px; }\n.fst-muted { color: var(--fst-muted); }\n.fst-note { margin: 0; color: var(--fst-muted); font-size: 12px; }\n.fst-error { margin: 0; color: var(--fst-red); }\n.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; }\n.fst-card { padding: 12px; border: 1px solid var(--fst-border); border-radius: 12px; background: var(--fst-bg); }\n.fst-card p { margin: 6px 0 10px; color: var(--fst-muted); }\n.fst-card-title { display: flex; align-items: center; gap: 6px; font-weight: 700; }\n.fst-card-title svg { width: 15px; height: 15px; color: var(--fst-accent); }\n.fst-btn {\n display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;\n border: 1px solid var(--fst-border); border-radius: 8px; background: var(--fst-bg);\n font-weight: 600; font-size: 12.5px; text-decoration: none; color: var(--fst-text);\n}\n.fst-btn:hover { background: var(--fst-hover); }\n.fst-btn:disabled { opacity: 0.55; cursor: default; }\n.fst-btn svg { width: 13px; height: 13px; }\n.fst-btn--primary { border-color: var(--fst-accent); background: var(--fst-accent); color: var(--fst-accent-ink); }\n.fst-btn--primary:hover { background: var(--fst-accent); filter: brightness(1.08); }\n.fst-link-btn { padding: 0; border: 0; background: none; color: var(--fst-accent); font-weight: 600; font-size: 12.5px; }\n.fst-link-btn:hover { text-decoration: underline; }\n.fst-status { margin-left: 8px; color: var(--fst-green); font-weight: 600; font-size: 12px; }\n.fst-input {\n width: 100%; padding: 7px 10px; border: 1px solid var(--fst-border); border-radius: 8px;\n background: var(--fst-bg); font-size: 12.5px;\n}\n.fst-input:focus { outline: none; border-color: var(--fst-accent); box-shadow: 0 0 0 3px var(--fst-accent-soft); }\ntextarea.fst-input { resize: vertical; min-height: 64px; }\n.fst-label { display: block; margin-bottom: 4px; color: var(--fst-muted); font-size: 12px; font-weight: 600; }\n.fst-pre {\n max-height: 220px; margin: 10px 0 0; padding: 10px; overflow: auto; border-radius: 8px;\n background: var(--fst-surface); white-space: pre-wrap; word-break: break-word; font-size: 11.5px;\n}\n.fst-empty { padding: 18px 8px; color: var(--fst-muted); text-align: center; }\n.fst-empty p { margin: 0 0 6px; }\n.fst-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }\n.fst-chip {\n display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px;\n background: var(--fst-surface); color: var(--fst-muted); font-size: 11.5px; font-weight: 600;\n}\n.fst-chip--identity { background: var(--fst-pink-soft); color: var(--fst-pink); }\n.fst-chip--exposure { background: var(--fst-blue-soft); color: var(--fst-blue); }\n.fst-chip--event { background: var(--fst-green-soft); color: var(--fst-green); }\n.fst-spinner {\n width: 12px; height: 12px; border-radius: 50%; flex: none;\n border: 2px solid var(--fst-accent-soft); border-top-color: var(--fst-accent);\n animation: fst-spin 700ms linear infinite;\n}\n@keyframes fst-spin { to { transform: rotate(360deg); } }\n\n/* Welcome and \"viewing as\" ------------------------------------------------- */\n.fst-welcome { padding: 12px; border-radius: 12px; background: var(--fst-accent-soft); }\n.fst-welcome-title { display: block; margin-bottom: 6px; }\n.fst-welcome ol { margin: 0 0 8px; padding-left: 18px; }\n.fst-welcome li { margin: 3px 0; }\n.fst-welcome-note { margin: 0 0 10px; color: var(--fst-muted); font-size: 12px; }\n.fst-viewing {\n display: flex; align-items: center; gap: 8px; padding: 8px 10px;\n border-radius: 10px; background: var(--fst-surface); font-size: 12.5px;\n}\n.fst-viewing svg { width: 14px; height: 14px; color: var(--fst-muted); flex: none; }\n.fst-viewing > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n\n/* Flags list ---------------------------------------------------------------- */\n.fst-search { padding-left: 10px; }\n.fst-segmented { display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: var(--fst-surface); }\n.fst-segment {\n flex: 1; padding: 5px 6px; border: 0; border-radius: 8px; background: transparent;\n color: var(--fst-muted); font-weight: 600; font-size: 12px; white-space: nowrap;\n}\n.fst-segment.is-active { background: var(--fst-bg); color: var(--fst-text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }\n.fst-segment-count { margin-left: 4px; color: var(--fst-muted); font-weight: 500; }\n.fst-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }\n.fst-flag { border: 1px solid var(--fst-border); border-radius: 12px; background: var(--fst-bg); transition: border-color 120ms ease; }\n.fst-flag:hover { border-color: color-mix(in srgb, var(--fst-accent) 35%, var(--fst-border)); }\n.fst-flag.is-changed { border-color: var(--fst-amber); box-shadow: inset 3px 0 0 var(--fst-amber); }\n.fst-flag.is-fresh { border-color: var(--fst-blue); animation: fst-flash 1.2s ease-out 2; }\n@keyframes fst-flash { 0% { background: var(--fst-blue-soft); } 100% { background: var(--fst-bg); } }\n.fst-fresh {\n flex: none; padding: 0 6px; border-radius: 999px; background: var(--fst-blue-soft); color: var(--fst-blue);\n font-size: 10.5px; font-weight: 700; font-family: inherit;\n}\n.fst-flag-main { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 12px; }\n.fst-flag-summary {\n flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 0;\n border: 0; background: none; text-align: left;\n}\n.fst-flag-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 600; }\n.fst-flag-name code { min-width: 0; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.fst-used { width: 6px; height: 6px; border-radius: 50%; background: var(--fst-accent); flex: none; }\n.fst-type {\n flex: none; margin-left: auto; padding: 0 5px; border: 1px solid var(--fst-border); border-radius: 5px;\n color: var(--fst-muted); font-size: 10.5px; font-weight: 600; line-height: 16px;\n}\n.fst-group { display: flex; flex-direction: column; gap: 6px; }\n.fst-group-title { display: flex; align-items: center; gap: 6px; margin: 2px 2px 0; }\n.fst-group-count { color: var(--fst-muted); font-weight: 500; letter-spacing: 0; }\n.fst-pages code { padding: 0 4px; border-radius: 4px; background: var(--fst-surface); }\n.fst-flag-meta { display: flex; align-items: center; gap: 6px; min-width: 0; }\n.fst-flag-value { color: var(--fst-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }\n.fst-reason {\n flex: none; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;\n padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600;\n background: var(--fst-surface); color: var(--fst-muted);\n}\n.fst-reason--segment { background: var(--fst-blue-soft); color: var(--fst-blue); }\n.fst-reason--identity { background: var(--fst-pink-soft); color: var(--fst-pink); }\n.fst-reason--split { background: var(--fst-green-soft); color: var(--fst-green); }\n.fst-reason--experiment { background: var(--fst-accent-soft); color: var(--fst-accent); }\n.fst-reason--override { background: var(--fst-amber-soft); color: var(--fst-amber); }\n.fst-reason--error { background: var(--fst-red-soft); color: var(--fst-red); }\n.fst-details { padding: 0 12px 12px; border-top: 1px dashed var(--fst-border); }\n.fst-details p { margin: 10px 0 0; }\n.fst-raw code { padding: 1px 6px; border-radius: 6px; background: var(--fst-surface); color: var(--fst-muted); }\n.fst-value { margin-top: 12px; }\n.fst-value-row { display: flex; gap: 6px; }\n.fst-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }\n\n/* Switch -------------------------------------------------------------------- */\n.fst-switch {\n position: relative; flex: none; width: 34px; height: 20px; padding: 0; border: 0; border-radius: 999px;\n background: var(--fst-border); transition: background 120ms ease;\n}\n.fst-switch.is-on { background: var(--fst-green); }\n.fst-switch-thumb {\n position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;\n background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 120ms ease;\n}\n.fst-switch.is-on .fst-switch-thumb { transform: translateX(14px); }\n\n/* View as -------------------------------------------------------------------- */\n.fst-current-name { margin-top: 4px; font-size: 15px; font-weight: 700; }\n.fst-personas { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }\n.fst-persona {\n display: flex; align-items: center; justify-content: space-between; gap: 10px;\n padding: 10px 12px; border: 1px solid var(--fst-border); border-radius: 12px;\n}\n.fst-persona.is-active { border-color: var(--fst-accent); background: var(--fst-accent-soft); }\n.fst-persona > div { min-width: 0; }\n.fst-persona > .fst-btn { flex: none; white-space: nowrap; }\n.fst-persona-name { font-weight: 700; }\n.fst-form { display: flex; flex-direction: column; gap: 8px; }\n\n/* Events -------------------------------------------------------------------- */\n.fst-events { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }\n.fst-event {\n display: flex; flex-wrap: wrap; align-items: center; gap: 6px;\n padding: 8px 10px; border: 1px solid var(--fst-border); border-radius: 10px;\n}\n.fst-event-meta { width: 100%; color: var(--fst-muted); font-size: 11.5px; }\n\n.fst-event.is-unsent { border-style: dashed; }\n\n/* Setup check ------------------------------------------------------------------- */\n.fst-setup { margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--fst-border); border-radius: 12px; background: var(--fst-surface); }\n.fst-setup-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }\n.fst-setup-ok { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; color: var(--fst-green); font-weight: 600; }\n.fst-setup-ok svg { width: 14px; height: 14px; }\n.fst-issues { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }\n.fst-issue { display: flex; gap: 8px; align-items: flex-start; }\n.fst-issue > svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }\n.fst-issue p { margin: 2px 0 0; color: var(--fst-muted); }\n.fst-issue .fst-pre { margin-top: 6px; }\n.fst-issue--problem > svg { color: var(--fst-red); }\n.fst-issue--warning > svg { color: var(--fst-amber); }\n.fst-issue--tip > svg { color: var(--fst-muted); }\n\n/* Compare ----------------------------------------------------------------------- */\n.fst-compare-pick { display: flex; align-items: flex-end; gap: 6px; }\n.fst-picker { flex: 1; min-width: 0; }\n.fst-select { appearance: auto; padding: 6px 8px; text-overflow: ellipsis; }\n.fst-swap { flex: none; margin-bottom: 2px; }\n.fst-loading { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--fst-muted); }\n.fst-compare-summary { margin: 2px 2px 0; }\n.fst-compare-row { padding: 8px 12px 10px; }\n.fst-compare-key { margin-bottom: 6px; font-weight: 600; }\n.fst-compare-key code { font-size: 12.5px; }\n.fst-side { display: grid; grid-template-columns: 92px 30px minmax(0, 1fr); align-items: center; gap: 4px 6px; padding: 3px 0; }\n.fst-side .fst-reason { grid-column: 2 / 4; justify-self: start; max-width: 100%; }\n.fst-side-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fst-muted); font-size: 12px; font-weight: 600; }\n.fst-side-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.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; }\n.fst-state.is-on { background: var(--fst-green-soft); color: var(--fst-green); }\n.fst-same summary { cursor: pointer; color: var(--fst-muted); font-weight: 600; font-size: 12.5px; }\n\n/* Experiments --------------------------------------------------------------------- */\n.fst-callout {\n display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 10px;\n background: var(--fst-blue-soft); color: var(--fst-blue); font-size: 12.5px;\n}\n.fst-callout svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }\n.fst-exp { padding: 10px 12px; border: 1px solid var(--fst-border); border-radius: 12px; }\n.fst-exp--good { border-color: color-mix(in srgb, var(--fst-green) 45%, var(--fst-border)); }\n.fst-exp--bad { border-color: var(--fst-amber); box-shadow: inset 3px 0 0 var(--fst-amber); }\n.fst-exp-head { display: flex; align-items: center; gap: 6px; }\n.fst-exp-head svg { width: 15px; height: 15px; color: var(--fst-accent); }\n.fst-exp-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; color: var(--fst-muted); }\n.fst-exp-status { display: flex; gap: 6px; align-items: flex-start; margin: 8px 0 0; }\n.fst-exp-status svg { width: 14px; height: 14px; flex: none; margin-top: 2px; }\n.fst-exp--good .fst-exp-status svg { color: var(--fst-green); }\n.fst-exp--bad .fst-exp-status svg { color: var(--fst-amber); }\n.fst-exp--neutral .fst-exp-status svg { color: var(--fst-muted); }\n\n/* Small screens ----------------------------------------------------------------- */\n@media (max-width: 560px) {\n .fst-panel, .fst--left .fst-panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: 80vh; }\n .fst-banner { top: 8px; bottom: auto; }\n .fst-banner-muted { display: none; }\n .fst-flag-value { max-width: 110px; }\n}\n`;\n","import { render } from 'preact';\nimport type { ToolbarController } from '../controller';\nimport { App } from './App';\nimport { css } from './styles';\n\n/** Renders the toolbar into its own Shadow DOM, so page styles and toolbar styles never mix. */\nexport function mountUI(controller: ToolbarController): { unmount(): void } {\n const host = document.createElement('div');\n host.setAttribute('data-flagsmith-toolbar', '');\n host.style.cssText = 'position:fixed;top:0;left:0;width:0;height:0;z-index:2147483000;';\n const shadow = host.attachShadow({ mode: 'open' });\n addStyles(shadow);\n const root = document.createElement('div');\n shadow.append(root);\n document.body.appendChild(host);\n render(<App controller={controller} />, root);\n return {\n unmount() {\n render(null, root);\n host.remove();\n },\n };\n}\n\n/**\n * A constructed stylesheet isn't an inline <style>, so pages with a strict\n * Content-Security-Policy (style-src 'self') don't block it. Older browsers\n * get a <style> element instead.\n */\nfunction addStyles(shadow: ShadowRoot): void {\n try {\n if ('adoptedStyleSheets' in shadow && 'replaceSync' in CSSStyleSheet.prototype) {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(css);\n shadow.adoptedStyleSheets = [sheet];\n return;\n }\n } catch {\n // Fall back to a <style> element below.\n }\n const style = document.createElement('style');\n style.textContent = css;\n shadow.append(style);\n}\n","import { runSetupChecks, type SetupIssue } from './checks';\nimport { fetchFlagsFor, flagsMatch } from './compare';\nimport { EXPOSURE_GRACE_MS, experimentRows, exposureKey, type ExperimentRow } from './experiments';\nimport { instrument, type Instrumentation } from './instrument';\nimport { applyOverrides, changedKeys, withOverride, withoutOverride } from './overrides';\nimport { pageKey, watchNavigation } from './pages';\nimport { cloneContext, personaContext } from './personas';\nimport { buildPreviewUrl, readPreviewFromUrl, stripPreviewFromUrl } from './preview-link';\nimport { buildBugReport } from './snapshot';\nimport { loadSaved, save, Store, type CompareSubject, type FlagFilter, type Tab, type ToolbarState } from './store';\nimport type { EvaluationContextLike, FlagMap, FlagOverride, FlagValue, FlagsmithLike, Overrides, Persona, ToolbarEvent, ToolbarOptions } from './types';\nimport { mountUI } from './ui/mount';\n\nconst MAX_EVENTS = 50;\n/** How long a flag stays highlighted after it changed in Flagsmith. */\nconst CHANGED_HIGHLIGHT_MS = 6000;\n\nexport interface ConnectionInfo {\n apiUrl: string | null;\n host: string | null;\n selfHosted: boolean;\n environmentKey: string | null;\n}\n\nexport interface Hotkey {\n key: string;\n shift: boolean;\n alt: boolean;\n ctrl: boolean;\n meta: boolean;\n}\n\nexport function parseHotkey(spec: string): Hotkey {\n const parts = spec.toLowerCase().split('+').map((part) => part.trim()).filter(Boolean);\n const key = parts.pop() ?? '';\n return {\n key,\n shift: parts.includes('shift'),\n alt: parts.includes('alt') || parts.includes('option'),\n ctrl: parts.includes('ctrl') || parts.includes('control'),\n meta: parts.includes('meta') || parts.includes('cmd'),\n };\n}\n\nexport function formatHotkey(spec: string): string {\n return spec\n .split('+')\n .map((part) => part.trim())\n .map((part) => (part.length === 1 ? part.toUpperCase() : part.charAt(0).toUpperCase() + part.slice(1)))\n .join('+');\n}\n\nconst errorMessage = (error: unknown) => (error instanceof Error ? error.message : String(error));\n\nexport class ToolbarController {\n readonly store: Store<ToolbarState>;\n readonly options: ToolbarOptions & {\n hotkey: string;\n position: 'right' | 'left';\n storageKey: string;\n layout: 'overlay' | 'push';\n };\n private readonly instrumentation: Instrumentation;\n /** The app's own evaluation context, kept while previewing as someone else. */\n private appContext: EvaluationContextLike | null = null;\n private pendingReads: Record<string, number> = {};\n /** The last state written to storage, so unchanged state isn't written again. */\n private lastSaved = '';\n private eventId = 0;\n private readonly cleanups: Array<() => void> = [];\n private destroyed = false;\n /** The identity the current flags from Flagsmith were evaluated for. */\n private lastFlagsFor: string | null = null;\n /** When flags for that identity first arrived. */\n private flagsSince = 0;\n /** Counts the toolbar's own context changes, so they aren't mistaken for the app switching users. */\n private ownContextChanges = 0;\n private clockTimer: ReturnType<typeof setTimeout> | null = null;\n private highlightTimer: ReturnType<typeof setTimeout> | null = null;\n private statusTimer: ReturnType<typeof setTimeout> | null = null;\n private compareRun = 0;\n\n constructor(\n readonly flagsmith: FlagsmithLike,\n options: ToolbarOptions = {},\n ) {\n this.options = { hotkey: 'shift+f', position: 'right', storageKey: 'flagsmith-toolbar', layout: 'overlay', ...options };\n const saved = loadSaved(this.options.storageKey);\n\n // A shared preview link wins over what was saved, then leaves the URL clean.\n const shared = readPreviewFromUrl(window.location.href);\n if (shared) window.history.replaceState(window.history.state, '', stripPreviewFromUrl(window.location.href));\n\n this.store = new Store<ToolbarState>({\n open: shared ? true : (options.open ?? saved.open ?? false),\n tab: saved.tab ?? 'flags',\n filter: 'all',\n search: '',\n expanded: null,\n serverFlags: {},\n page: pageKey(window.location),\n reads: {},\n seenOn: {},\n overrides: shared ? shared.overrides : (saved.overrides ?? {}),\n persona: shared ? shared.persona : (saved.persona ?? null),\n personaStatus: 'idle',\n personaError: null,\n events: [],\n exposures: {},\n welcomeDismissed: saved.welcomeDismissed ?? false,\n sharedPreview: Boolean(shared),\n setupOpen: false,\n changedInFlagsmith: {},\n refreshStatus: 'idle',\n compareA: 'page',\n compareB: options.personas?.length ? 'persona:0' : 'anonymous',\n compareStatus: 'idle',\n compareError: null,\n compareResult: null,\n clock: Date.now(),\n });\n\n this.instrumentation = instrument(flagsmith, {\n onServerFlags: (flags) => this.receiveServerFlags(flags),\n onRead: (key) => this.recordRead(key),\n onEvent: (event) => this.recordEvent(event),\n holdBack: () => this.isPreviewing(),\n onAppContextChange: () => this.onAppContextChange(),\n isOwnContextChange: () => this.ownContextChanges > 0,\n });\n this.instrumentation.setOverrides(this.store.get().overrides);\n this.lastFlagsFor = this.currentIdentity();\n this.flagsSince = Date.now();\n this.store.set({ serverFlags: { ...this.instrumentation.serverFlags() } });\n this.cleanups.push(this.store.subscribe(() => this.saveIfChanged()));\n this.cleanups.push(watchNavigation(() => this.onNavigate()));\n }\n\n start(): void {\n const mount = () => {\n if (this.destroyed) return;\n const ui = mountUI(this);\n this.cleanups.push(ui.unmount);\n };\n if (document.body) mount();\n else document.addEventListener('DOMContentLoaded', mount, { once: true });\n this.cleanups.push(this.listenForHotkey());\n\n // A persona saved from last time (or from a shared link) is applied once the SDK is ready.\n const persona = this.store.get().persona;\n if (persona) {\n void this.whenInitialised().then((ready) => {\n if (ready && !this.destroyed) void this.applyPersona(persona);\n });\n }\n }\n\n // Panel ------------------------------------------------------------------\n\n open(): void {\n this.store.set({ open: true });\n }\n\n close(): void {\n this.store.set({ open: false });\n }\n\n toggle(): void {\n this.store.set((state) => ({ open: !state.open }));\n }\n\n setTab(tab: Tab): void {\n this.store.set({ tab });\n }\n\n setFilter(filter: FlagFilter): void {\n this.store.set({ filter });\n }\n\n setSearch(search: string): void {\n this.store.set({ search });\n }\n\n toggleExpanded(key: string): void {\n this.store.set((state) => ({ expanded: state.expanded === key ? null : key }));\n }\n\n dismissWelcome(): void {\n this.store.set({ welcomeDismissed: true });\n }\n\n toggleSetup(): void {\n this.store.set((state) => ({ setupOpen: !state.setupOpen }));\n }\n\n /** True while you are viewing as someone else or have changed a flag. Events are held back then. */\n isPreviewing(): boolean {\n const { persona, overrides } = this.store.get();\n return Boolean(persona) || Object.keys(overrides).length > 0;\n }\n\n /** The identity Flagsmith is evaluating flags for right now, or null for an anonymous visitor. */\n currentIdentity(): string | null {\n return this.flagsmith.getContext?.()?.identity?.identifier ?? this.flagsmith.identity ?? null;\n }\n\n /** Fetches the latest flags from Flagsmith, so a change made in the dashboard shows up without a reload. */\n async refresh(): Promise<void> {\n if (!this.flagsmith.getFlags) return;\n const before = this.store.get().serverFlags;\n const who = this.lastFlagsFor;\n this.store.set({ refreshStatus: 'loading' });\n try {\n await this.flagsmith.getFlags();\n if (this.destroyed) return;\n const after = this.store.get().serverFlags;\n // Only a refresh for the same user counts: a user switch in the meantime changes flags too.\n const changed =\n who === this.lastFlagsFor && Object.keys(before).length > 0\n ? Object.keys({ ...before, ...after }).filter((key) => !flagsMatch(before[key], after[key]))\n : [];\n if (changed.length) {\n const now = Date.now();\n this.store.set({ changedInFlagsmith: Object.fromEntries(changed.map((key) => [key, now])) });\n if (this.highlightTimer) clearTimeout(this.highlightTimer);\n this.highlightTimer = setTimeout(() => this.store.set({ changedInFlagsmith: {} }), CHANGED_HIGHLIGHT_MS);\n }\n this.flashStatus(changed.length ? 'updated' : 'unchanged');\n } catch (error) {\n this.recoverFromFailedFetch(error);\n this.flashStatus('error');\n }\n }\n\n /**\n * The SDK marks itself as fetching before a request and only clears that on success.\n * After a failed refresh, clear it the way a failed load would, so the app doesn't\n * think Flagsmith is still loading.\n */\n private recoverFromFailedFetch(error: unknown): void {\n const sdk = this.flagsmith as FlagsmithLike & { isLoading?: boolean; _triggerLoadingState?: (() => void) | null };\n if (!sdk.loadingState?.isFetching) return;\n sdk.isLoading = false;\n sdk.loadingState = { ...sdk.loadingState, isFetching: false, isLoading: false, error };\n sdk._triggerLoadingState?.();\n }\n\n // Flags ------------------------------------------------------------------\n\n /** The flags the app sees right now: Flagsmith's flags with your changes on top. */\n effectiveFlags(): FlagMap {\n const { serverFlags, overrides } = this.store.get();\n return applyOverrides(serverFlags, overrides) ?? {};\n }\n\n usedOnPage(): string[] {\n return Object.keys(this.store.get().reads);\n }\n\n setEnabled(key: string, enabled: boolean): void {\n this.changeFlag(key, { enabled });\n }\n\n setValue(key: string, value: FlagValue): void {\n this.changeFlag(key, { value });\n }\n\n resetFlag(key: string): void {\n this.updateOverrides(withoutOverride(this.store.get().overrides, key));\n }\n\n resetAll(): void {\n this.updateOverrides({});\n }\n\n /** Leaves preview mode: you see the page as yourself again and your changes are cleared. */\n async exitPreview(): Promise<void> {\n // Switch back to your own user first, while events are still held back, then drop your changes.\n if (this.store.get().persona) await this.backToMe();\n this.resetAll();\n this.store.set({ sharedPreview: false });\n }\n\n private changeFlag(key: string, patch: FlagOverride): void {\n const { overrides, serverFlags } = this.store.get();\n const next = { ...overrides[key], ...patch };\n const real = serverFlags[key];\n // Flipping a flag back to what Flagsmith says removes the change instead of keeping a no-op.\n const matchesFlagsmith =\n real !== undefined &&\n (next.enabled === undefined || next.enabled === real.enabled) &&\n (next.value === undefined || next.value === real.value);\n this.updateOverrides(matchesFlagsmith ? withoutOverride(overrides, key) : withOverride(overrides, key, patch));\n }\n\n private updateOverrides(next: Overrides): void {\n const before = this.effectiveFlags();\n this.instrumentation.setOverrides(next);\n this.store.set({ overrides: next });\n this.instrumentation.notifyApp(changedKeys(before, this.effectiveFlags()));\n }\n\n // View as ----------------------------------------------------------------\n\n async viewAs(persona: Persona): Promise<void> {\n await this.applyPersona(persona);\n }\n\n async backToMe(): Promise<void> {\n const context = this.appContext;\n // The persona stays set until Flagsmith has answered for your own user. The SDK switches\n // identity at once but keeps the persona's flags until then, so events stay held back.\n this.store.set({ personaStatus: 'loading', personaError: null });\n try {\n if (context) await this.setOwnContext(context);\n this.appContext = null;\n this.store.set({ persona: null, personaStatus: 'idle' });\n } catch (error) {\n this.store.set({ personaStatus: 'error', personaError: `Flagsmith could not switch back to your view: ${errorMessage(error)}` });\n }\n }\n\n private async applyPersona(persona: Persona): Promise<void> {\n if (!this.appContext) this.appContext = cloneContext(this.flagsmith.getContext());\n this.store.set({ persona, personaStatus: 'loading', personaError: null });\n try {\n await this.setOwnContext(personaContext(this.appContext, persona));\n this.store.set({ personaStatus: 'idle' });\n } catch (error) {\n this.store.set({ personaStatus: 'error', personaError: `Flagsmith could not evaluate this user: ${errorMessage(error)}` });\n }\n }\n\n private setOwnContext(context: EvaluationContextLike): Promise<void> {\n this.ownContextChanges++;\n try {\n return this.flagsmith.setContext(context);\n } finally {\n this.ownContextChanges--;\n }\n }\n\n /** The app switched users itself (say, after a login). If that ends a preview, the app's user wins. */\n private onAppContextChange(): void {\n const { persona } = this.store.get();\n if (!persona) {\n this.appContext = null;\n return;\n }\n // The app only touched the previewed user's traits: the preview is still on.\n if (this.currentIdentity() === (personaContext({}, persona).identity?.identifier ?? null)) return;\n this.appContext = null;\n this.store.set({ persona: null, personaStatus: 'idle', personaError: null });\n }\n\n // Share ------------------------------------------------------------------\n\n previewUrl(): string {\n const { overrides, persona } = this.store.get();\n return buildPreviewUrl(window.location.href, { overrides, persona });\n }\n\n bugReport(): string {\n const { serverFlags, overrides, persona } = this.store.get();\n const connection = this.connection();\n return buildBugReport({\n url: window.location.href,\n apiUrl: connection.apiUrl,\n environmentKey: connection.environmentKey,\n persona,\n identity: this.flagsmith.identity ?? null,\n flags: this.effectiveFlags(),\n serverFlags,\n overrides,\n usedOnPage: this.usedOnPage(),\n takenAt: new Date(),\n });\n }\n\n // Compare ----------------------------------------------------------------\n\n /** The users the Compare tab can pick from. */\n compareSubjects(): Array<{ id: CompareSubject; label: string }> {\n const personas = this.options.personas ?? [];\n return [\n { id: 'page', label: this.subjectLabel('page') },\n { id: 'anonymous', label: this.subjectLabel('anonymous') },\n ...personas.map((_, index) => ({ id: `persona:${index}`, label: this.subjectLabel(`persona:${index}`) })),\n ];\n }\n\n subjectLabel(subject: CompareSubject): string {\n if (subject === 'page') {\n const { persona } = this.store.get();\n const who = persona ? persona.name.split('·')[0]!.trim() : this.flagsmith.identity;\n return who ? `This page · ${who}` : 'This page';\n }\n if (subject === 'anonymous') return 'Anonymous visitor';\n return this.personaFor(subject)?.name ?? 'Unknown user';\n }\n\n /** Compares two users' flags. Each one is evaluated live by Flagsmith; nothing is saved. */\n /** Picks one side of the comparison. Reads the latest state, so quick changes in a row never use a stale pick. */\n pickCompare(side: 'a' | 'b', subject: CompareSubject): Promise<void> {\n const { compareA, compareB } = this.store.get();\n return side === 'a' ? this.compare(subject, compareB) : this.compare(compareA, subject);\n }\n\n swapCompare(): Promise<void> {\n const { compareA, compareB } = this.store.get();\n return this.compare(compareB, compareA);\n }\n\n async compare(a: CompareSubject, b: CompareSubject): Promise<void> {\n const run = ++this.compareRun;\n this.store.set({ compareA: a, compareB: b, compareStatus: 'loading', compareError: null });\n try {\n const [flagsA, flagsB] = await Promise.all([this.flagsFor(a), this.flagsFor(b)]);\n if (run !== this.compareRun || this.destroyed) return;\n this.store.set({ compareStatus: 'done', compareResult: { a: flagsA, b: flagsB, at: Date.now() } });\n } catch (error) {\n if (run !== this.compareRun || this.destroyed) return;\n this.store.set({ compareStatus: 'error', compareError: `Flagsmith could not evaluate these users: ${errorMessage(error)}` });\n }\n }\n\n private personaFor(subject: CompareSubject): Persona | undefined {\n const index = Number(subject.split(':')[1]);\n return subject.startsWith('persona:') ? this.options.personas?.[index] : undefined;\n }\n\n private async flagsFor(subject: CompareSubject): Promise<FlagMap> {\n if (subject === 'page') return this.effectiveFlags();\n const { apiUrl, environmentKey } = this.connection();\n if (!apiUrl || !environmentKey) throw new Error('the SDK has not connected to Flagsmith yet');\n const persona = subject === 'anonymous' ? null : this.personaFor(subject);\n if (persona === undefined) throw new Error('that user no longer exists');\n return fetchFlagsFor(persona, { api: apiUrl, environmentKey, headers: this.flagsmith.headers ?? null });\n }\n\n // Experiments and setup ------------------------------------------------------\n\n /** The experiments behind this page's flags, for the user Flagsmith is evaluating right now. */\n experiments(): ExperimentRow[] {\n const { serverFlags, reads, exposures, clock } = this.store.get();\n return experimentRows({\n flags: serverFlags,\n reads,\n exposures,\n // The user these flags belong to. Right after a switch the SDK already has the new\n // identity but still the old flags, and the two must not be mixed.\n identity: this.lastFlagsFor,\n eventsEnabled: this.flagsmith.eventsEnabled === true,\n previewing: this.isPreviewing(),\n now: Math.max(clock, Date.now()),\n since: this.flagsSince,\n });\n }\n\n /** Common setup mistakes on this page, and on the pages visited before it. */\n setupIssues(): SetupIssue[] {\n const { serverFlags, reads, seenOn, events } = this.store.get();\n return runSetupChecks({\n serverFlags,\n reads,\n seenOn,\n environmentKey: this.connection().environmentKey,\n loadingState: this.flagsmith.loadingState,\n identity: this.currentIdentity(),\n events,\n experiments: this.experiments(),\n });\n }\n\n connection(): ConnectionInfo {\n const apiUrl = this.flagsmith.api ?? null;\n let host: string | null = null;\n let selfHosted = false;\n if (apiUrl) {\n try {\n const url = new URL(apiUrl);\n host = url.host;\n selfHosted = !/(^|\\.)flagsmith\\.com$/i.test(url.hostname);\n } catch {\n // Not a valid URL; show what we have.\n }\n }\n const environmentKey = this.flagsmith.getContext?.()?.environment?.apiKey ?? null;\n return { apiUrl, host, selfHosted, environmentKey };\n }\n\n /** A link to the flag in the Flagsmith dashboard, when dashboardUrl and projectId are set. */\n dashboardLink(key: string): string | null {\n const { dashboardUrl, projectId } = this.options;\n const id = this.store.get().serverFlags[key]?.id;\n const environmentKey = this.connection().environmentKey;\n if (!dashboardUrl || projectId === undefined || projectId === '' || !id || !environmentKey) return null;\n return `${dashboardUrl.replace(/\\/$/, '')}/project/${projectId}/environment/${environmentKey}/features?feature=${id}`;\n }\n\n // Lifecycle --------------------------------------------------------------\n\n destroy(): void {\n this.destroyed = true;\n for (const cleanup of this.cleanups.splice(0)) cleanup();\n for (const timer of [this.clockTimer, this.highlightTimer, this.statusTimer]) if (timer) clearTimeout(timer);\n this.instrumentation.restore();\n }\n\n private receiveServerFlags(flags: FlagMap): void {\n // The SDK sets the new identity before it writes the flags, so this is who they're for.\n const who = this.currentIdentity();\n if (who !== this.lastFlagsFor) {\n this.lastFlagsFor = who;\n this.flagsSince = Date.now();\n }\n this.store.set({ serverFlags: { ...flags } });\n this.tickLater();\n }\n\n private recordEvent(event: Omit<ToolbarEvent, 'id' | 'at'>): void {\n const full: ToolbarEvent = { ...event, id: ++this.eventId, at: Date.now() };\n this.store.set((state) => ({\n events: [full, ...state.events].slice(0, MAX_EVENTS),\n exposures: full.kind === 'exposure' && full.key ? { ...state.exposures, [exposureKey(full.key, full.identifier)]: full } : state.exposures,\n }));\n }\n\n private flashStatus(status: ToolbarState['refreshStatus']): void {\n this.store.set({ refreshStatus: status });\n if (this.statusTimer) clearTimeout(this.statusTimer);\n this.statusTimer = setTimeout(() => this.store.set({ refreshStatus: 'idle' }), 2500);\n }\n\n /** Re-renders once the exposure grace period has passed, so a missing exposure shows up. */\n private tickLater(): void {\n if (this.clockTimer) clearTimeout(this.clockTimer);\n this.clockTimer = setTimeout(() => {\n if (!this.destroyed) this.store.set({ clock: Date.now() });\n }, EXPOSURE_GRACE_MS + 100);\n }\n\n private recordRead(key: string): void {\n if (key in this.store.get().reads || key in this.pendingReads) return;\n const first = Object.keys(this.pendingReads).length === 0;\n this.pendingReads[key] = Date.now();\n // Batched into one update per render: the app may read many flags in a single pass.\n if (first) queueMicrotask(() => this.flushReads());\n }\n\n /** Moves batched reads into the store, on the page they were read on. */\n private flushReads(): void {\n const pending = this.pendingReads;\n const keys = Object.keys(pending);\n if (this.destroyed || keys.length === 0) return;\n this.pendingReads = {};\n this.store.set((state) => {\n const seenOn = { ...state.seenOn };\n for (const key of keys) {\n const pages = seenOn[key] ?? [];\n if (!pages.includes(state.page)) seenOn[key] = [...pages, state.page];\n }\n return { reads: { ...state.reads, ...pending }, seenOn };\n });\n this.tickLater();\n }\n\n /** The app may have moved to another page. Reads start over there; where each flag was read is kept. */\n private onNavigate(): void {\n if (this.destroyed) return;\n const page = pageKey(window.location);\n if (page === this.store.get().page) return;\n // Reads batched just before the change belong to the page they happened on.\n this.flushReads();\n this.store.set({ page, reads: {} });\n }\n\n /** Saves right away (no debounce), so a change made just before a reload is never lost. */\n private saveIfChanged(): void {\n const { overrides, persona, welcomeDismissed, open, tab } = this.store.get();\n const snapshot = JSON.stringify({ overrides, persona, welcomeDismissed, open, tab });\n if (snapshot === this.lastSaved) return;\n this.lastSaved = snapshot;\n save(this.options.storageKey, { overrides, persona, welcomeDismissed, open, tab });\n }\n\n private whenInitialised(timeoutMs = 20000): Promise<boolean> {\n return new Promise((resolve) => {\n const started = Date.now();\n const check = () => {\n if (this.flagsmith.initialised) resolve(true);\n else if (this.destroyed || Date.now() - started > timeoutMs) resolve(false);\n else setTimeout(check, 100);\n };\n check();\n });\n }\n\n private listenForHotkey(): () => void {\n const hotkey = parseHotkey(this.options.hotkey);\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.repeat) return;\n const target = event.composedPath()[0] as HTMLElement | undefined;\n const editing = target?.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target?.tagName ?? '');\n if (editing) return;\n const keyMatches = event.key.toLowerCase() === hotkey.key || event.code.toLowerCase() === `key${hotkey.key}`;\n if (\n keyMatches &&\n event.shiftKey === hotkey.shift &&\n event.altKey === hotkey.alt &&\n event.ctrlKey === hotkey.ctrl &&\n event.metaKey === hotkey.meta\n ) {\n event.preventDefault();\n this.toggle();\n }\n };\n window.addEventListener('keydown', onKeyDown);\n return () => window.removeEventListener('keydown', onKeyDown);\n }\n}\n","/**\n * Flagsmith Toolbar: a developer toolbar for the Flagsmith JS SDK.\n *\n * import flagsmith from '@flagsmith/flagsmith';\n * import FlagsmithToolbar from 'flagsmith-toolbar';\n *\n * FlagsmithToolbar.init(flagsmith, { enabled: import.meta.env.DEV });\n * FlagsmithToolbar.show();\n * FlagsmithToolbar.hide();\n *\n * The API follows the design sketched in flagsmith-js-client issue #233.\n */\nimport { ToolbarController } from './controller';\nimport type { FlagsmithLike, ToolbarOptions } from './types';\n\nlet current: ToolbarController | null = null;\n\n/** Attaches the toolbar to a Flagsmith SDK instance. Call it before or after flagsmith.init(). */\nexport function init(flagsmith: FlagsmithLike, options: ToolbarOptions = {}): void {\n if (typeof window === 'undefined' || typeof document === 'undefined') return; // server-side rendering\n if (options.enabled === false) return;\n current?.destroy();\n current = null;\n try {\n const controller = new ToolbarController(flagsmith, options);\n controller.start();\n current = controller;\n } catch (error) {\n // A developer tool must never take the app down with it.\n console.error('[flagsmith-toolbar] could not start', error);\n }\n}\n\n/** Opens the toolbar panel. */\nexport function show(): void {\n current?.open();\n}\n\n/** Closes the toolbar panel. The launcher button stays. */\nexport function hide(): void {\n current?.close();\n}\n\nexport function toggle(): void {\n current?.toggle();\n}\n\n/** Removes the toolbar and puts the SDK back exactly as it was. */\nexport function destroy(): void {\n current?.destroy();\n current = null;\n}\n\nexport { explainReason, parseReason } from './reasons';\nexport type { Explanation, ReasonKind } from './reasons';\nexport type { FlagMap, FlagOverride, FlagValue, FlagsmithLike, Overrides, Persona, ToolbarFlag, ToolbarOptions, TraitValue } from './types';\n\nconst FlagsmithToolbar = { init, show, hide, toggle, destroy };\nexport default FlagsmithToolbar;\n"],"mappings":";AAiCO,SAAS,YAAYA,IAAW,GAAmB;AACxD,MAAIA,OAAM,EAAG,QAAO;AACpB,MAAI,WAAW,MAAM,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,CAACC,IAAGC,OAAMA,EAAC;AAC/D,WAASA,KAAI,GAAGA,MAAKF,GAAE,QAAQE,MAAK;AAClC,UAAMC,WAAU,CAACD,EAAC;AAClB,aAASE,KAAI,GAAGA,MAAK,EAAE,QAAQA,MAAK;AAClC,MAAAD,SAAQC,EAAC,IAAI,KAAK,IAAI,SAASA,EAAC,IAAK,GAAGD,SAAQC,KAAI,CAAC,IAAK,GAAG,SAASA,KAAI,CAAC,KAAMJ,GAAEE,KAAI,CAAC,MAAM,EAAEE,KAAI,CAAC,IAAI,IAAI,EAAE;AAAA,IACjH;AACA,eAAWD;AAAA,EACb;AACA,SAAO,SAAS,EAAE,MAAM;AAC1B;AAGO,SAAS,WAAW,KAAa,YAAqC;AAC3E,QAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,MAAM,IAAI,SAAS,CAAC,CAAC;AACpD,MAAI,OAAsB;AAC1B,MAAI,eAAe;AACnB,aAAW,aAAa,YAAY;AACl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AAO,OAAO,MAAM,KAAK,YAAY,MAAM,MAAM,OAAO,GAAG;AAC1G,UACE,cACA,MAAM,aAAa,OAAO,SAC1B,MAAM,WAAW,OAAO,OACxB,MAAM,YAAY,OAAO,QACzB,MAAM,YAAY,OAAO,MACzB;AACA,cAAM,eAAe;AACrB,aAAK,OAAO;AAAA,MACd;AAAA,IACF;AACA,WAAO,iBAAiB,WAAW,SAAS;AAC5C,WAAO,MAAM,OAAO,oBAAoB,WAAW,SAAS;AAAA,EAC9D;AACF;;;AC7lBA,IAAI,UAAoC;AAGjC,SAAS,KAAK,WAA0B,UAA0B,CAAC,GAAS;AACjF,MAAI,OAAO,WAAW,eAAe,OAAO,aAAa,YAAa;AACtE,MAAI,QAAQ,YAAY,MAAO;AAC/B,WAAS,QAAQ;AACjB,YAAU;AACV,MAAI;AACF,UAAM,aAAa,IAAI,kBAAkB,WAAW,OAAO;AAC3D,eAAW,MAAM;AACjB,cAAU;AAAA,EACZ,SAAS,OAAO;AAEd,YAAQ,MAAM,uCAAuC,KAAK;AAAA,EAC5D;AACF;AAGO,SAAS,OAAa;AAC3B,WAAS,KAAK;AAChB;AAGO,SAAS,OAAa;AAC3B,WAAS,MAAM;AACjB;AAEO,SAAS,SAAe;AAC7B,WAAS,OAAO;AAClB;AAGO,SAAS,UAAgB;AAC9B,WAAS,QAAQ;AACjB,YAAU;AACZ;AAMA,IAAM,mBAAmB,EAAE,MAAM,MAAM,MAAM,QAAQ,QAAQ;AAC7D,IAAO,gBAAQ;","names":["a","_","i","current","j","init","a","a","current","a","options","vnodeId","isValidElement","rerenderQueue","prevDebounce","rerenderCount","depthSort","EVENT_DISPATCHED","CAPTURE_REGEX","eventClock","eventProxies","i","VNODE_MARKER","Symbol","for","EMPTY_OBJ","EMPTY_ARR","MATHML_TOKEN_ELEMENTS","isArray","Array","slice","assign","Object","removeNode","node","parentNode","remove","createVNode","type","props","key","ref","original","vnode","__k","__","__b","__e","__c","constructor","VNODE_MARKER","__v","vnodeId","__i","__u","options","Fragment","props","children","BaseComponent","context","this","__g","getDomSibling","vnode","childIndex","__","__i","sibling","__k","length","__e","type","__P","renderComponent","component","newVNode","oldVNode","__v","oldDom","commitQueue","refQueue","parentDom","assign","constructor","VNODE_MARKER","options","diff","__n","namespaceURI","__u","commitRoot","updateParentDomPointers","__c","some","child","enqueueRender","c","rerenderQueue","push","rerenderCount","prevDebounce","debounceRendering","queueMicrotask","process","l","sort","depthSort","shift","diffChildren","renderResult","newParentVNode","oldParentVNode","globalContext","namespace","excessDomChildren","isHydrating","i","childVNode","newDom","firstChildDom","result","oldChildren","EMPTY_ARR","newChildrenLength","constructNewChildrenArray","EMPTY_OBJ","ref","applyRef","insert","nextSibling","skewedIndex","matchingIndex","tails","lisLengths","hi","mid","oldChildrenLength","remainingOldChildren","skew","moved","newChildren","Array","String","createVNode","isArray","__b","key","findMatchingIndex","unmount","parentVNode","isMounting","dom","next","parentNode","nodeType","moveBefore","insertBefore","data","startsWith","findMatchingIndex","childVNode","oldChildren","skewedIndex","remainingOldChildren","x","key","type","oldVNode","matched","__u","length","setStyle","style","value","setProperty","dom","name","oldValue","namespace","useCapture","proxy","cssText","__e","eventProxies","createEventProxy","__a","eventClock","replace","CAPTURE_REGEX","slice","toLowerCase","addEventListener","removeEventListener","e","removeAttribute","setAttribute","eventHandler","this","EVENT_DISPATCHED","options","event","diff","parentDom","newVNode","globalContext","excessDomChildren","commitQueue","oldDom","isHydrating","refQueue","tmp","resumed","oldCommitQueueLength","c","oldProps","oldState","snapshot","newProps","isClassComponent","provider","componentContext","renderHook","count","renderResult","startMarker","end","i","child","newType","constructor","VNODE_MARKER","__c","__z","nodeType","rangeEnd","push","__b","outer","props","prototype","render","contextType","__","__g","BaseComponent","doRender","sub","state","__n","__h","__k","__s","getDerivedStateFromProps","assign","__v","componentWillReceiveProps","shouldComponentUpdate","some","vnode","EMPTY_ARR","apply","getDomSibling","componentWillUpdate","componentDidUpdate","componentWillMount","componentDidMount","context","__P","__r","getChildContext","getSnapshotBeforeUpdate","Fragment","children","namespaceURI","unmount","diffChildren","isArray","removeNode","then","indexOf","undefined","data","startsWith","nextSibling","markAsForce","diffElementNodes","diffed","start","nodes","depth","commitRoot","root","applyRef","cb","call","newHtml","oldHtml","newChildren","inputValue","checked","doc","EMPTY_OBJ","localName","ownerDocument","document","createTextNode","createElementNS","is","__m","content","defaultValue","childNodes","attributes","__html","innerHTML","textContent","MATHML_TOKEN_ELEMENTS","test","ref","owner","__x","current","parentVNode","skipRemove","r","componentWillUnmount","documentElement","createVNode","firstChild","options","__e","error","vnode","oldVNode","errorInfo","component","ctor","handled","__","__c","__g","constructor","getDerivedStateFromError","setState","componentDidCatch","e","rerenderCount","vnodeId","isValidElement","VNODE_MARKER","BaseComponent","prototype","update","callback","s","this","__s","state","assign","props","__v","__k","push","enqueueRender","forceUpdate","__h","render","Fragment","rerenderQueue","depthSort","a","b","__b","EVENT_DISPATCHED","Symbol","CAPTURE_REGEX","eventClock","eventProxies","i","currentIndex","currentComponent","previousComponent","prevRaf","ObjectIs","Object","is","currentHook","afterPaintEffects","unmountCleanups","options","_options","oldBeforeDiff","__b","oldBeforeRender","__r","oldAfterDiff","diffed","oldCommit","__c","oldBeforeUnmount","unmount","oldRoot","__","getHookState","index","type","__h","hooks","__H","length","push","useState","initialState","useReducer","invokeOrReturn","reducer","init","hookState","_reducer","action","currentValue","__N","nextValue","setState","__f","prevScu","shouldComponentUpdate","p","s","c","this","updatedHook","shouldUpdate","props","some","hookItem","result","call","useEffect","callback","args","state","__s","argsChanged","__P","_pendingArgs","useRef","initialValue","currentHook","useMemo","current","useMemo","factory","args","state","getHookState","currentIndex","argsChanged","__H","__","flushAfterPaintEffects","component","unmountCleanups","shift","invokeCleanup","e","options","__e","__","__P","__v","afterPaintEffects","hooks","__H","__h","some","invokeEffect","length","__b","vnode","currentComponent","oldBeforeDiff","parentDom","__k","__m","oldRoot","__r","oldBeforeRender","currentIndex","__c","previousComponent","hookItem","__N","_pendingArgs","diffed","oldAfterDiff","c","afterPaint","push","commitQueue","filter","cb","oldCommit","unmount","oldBeforeUnmount","hasErrored","errorParent","s","HAS_RAF","requestAnimationFrame","afterNextFrame","callback","raf","done","clearTimeout","timeout","cancelAnimationFrame","setTimeout","newQueueLength","prevRaf","hook","comp","cleanup","argsChanged","oldArgs","newArgs","arg","index","ObjectIs","invokeOrReturn","f","VNODE_MARKER","Symbol","for","vnodeId","createVNode","type","props","key","isStaticChildren","__source","__self","ref","i","normalizedProps","vnode","__k","__","__b","__e","__c","constructor","VNODE_MARKER","__v","vnodeId","__i","__u","options","a","a","T","A","a","d","A","a","d","current","T","A","a","Icon","d","a","a","d","A","T","a","a","_","a"]}