@calmdown/pyxis 1.0.0-rc.2 → 1.0.0-rc.4
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.
- package/dist/core-dev.d.ts +606 -358
- package/dist/core-dev.js +1316 -875
- package/dist/core-dev.js.map +1 -1
- package/dist/core.d.ts +620 -322
- package/dist/core.js +2028 -1
- package/dist/core.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-dev-runtime.js +2 -4
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/package.json +2 -6
- package/dist/main.d.ts +0 -67
- package/dist/main.js +0 -29
package/dist/core-dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-dev.js","names":["getValue","setValue","notify","setValue","notify","notify","notify"],"sources":["../src/dev/ComponentRegistry.ts","../src/dev/StateRegistry.ts","../src/dev/PyxisHotReload.ts","../src/support/common.ts","../src/data/Lifecycle.ts","../src/data/Dependency.ts","../src/data/Scheduler.ts","../src/data/Effect.ts","../src/data/Atom.ts","../src/component/Text.ts","../src/Renderer.ts","../src/component/Fragment.ts","../src/data/Context.ts","../src/data/ListDelta.ts","../src/data/ProxyAtom.ts","../src/component/Iterator.ts","../src/component/Native.ts","../src/component/Show.ts","../src/data/Derivation.ts","../src/data/List.ts","../src/extension/RefExtension.ts","../src/support/text.ts","../src/Builder.ts","../src/Component.ts","../src/jsx.ts"],"sourcesContent":["import type { ComponentBlock } from \"~/Component\";\n\ndeclare global {\n\t// we expect this global to exist in ~all environments\n\tfunction queueMicrotask(callback: () => void): void;\n}\n\nexport interface HotComponentEntry {\n\tcomponent: ComponentBlock;\n\tdirty: boolean;\n\tlh?: HotComponentListener | null;\n\tlt?: HotComponentListener | null;\n}\n\nexport interface HotComponentListener {\n\treadonly fn: HotComponentListenerFn;\n\treadonly entry: HotComponentEntry;\n\tlp?: HotComponentListener | null;\n\tln?: HotComponentListener | null;\n}\n\nexport interface HotComponentListenerFn {\n\t(component: ComponentBlock): void;\n}\n\nexport class ComponentRegistry {\n\tprivate readonly components = new Map<string, HotComponentEntry>();\n\tprivate isPendingUpdate = false;\n\n\tpublic on(id: string, fn: HotComponentListenerFn): HotComponentListener {\n\t\tconst entry = this.components.get(id);\n\t\tif (!entry) {\n\t\t\tthrow new Error(`no component was registered under \"${id}\"`);\n\t\t}\n\n\t\tconst listener: HotComponentListener = { fn, entry };\n\t\tif (entry.lt) {\n\t\t\tentry.lt.ln = listener;\n\t\t\tlistener.lp = entry.lt;\n\t\t}\n\t\telse {\n\t\t\tentry.lh = listener;\n\t\t}\n\n\t\tentry.lt = listener;\n\t\tfn(entry.component);\n\n\t\treturn listener;\n\t}\n\n\tpublic off(listener: HotComponentListener) {\n\t\tconst { entry } = listener;\n\t\tif (listener.lp) {\n\t\t\tlistener.lp.ln = listener.ln;\n\t\t}\n\t\telse if (entry.lh === listener) {\n\t\t\tentry.lh = listener.ln;\n\t\t}\n\n\t\tif (listener.ln) {\n\t\t\tlistener.ln.lp = listener.lp;\n\t\t}\n\t\telse if (entry.lt === listener) {\n\t\t\tentry.lt = listener.lp;\n\t\t}\n\n\t\tlistener.lp = null;\n\t\tlistener.ln = null;\n\t}\n\n\tpublic subscribe(id: string, fn: HotComponentListenerFn) {\n\t\tconst listener = this.on(id, fn);\n\t\treturn () => this.off(listener);\n\t}\n\n\tpublic upsert(id: string, component: ComponentBlock) {\n\t\tconst entry = this.components.get(id);\n\t\tif (!entry) {\n\t\t\tthis.components.set(id, {\n\t\t\t\tcomponent,\n\t\t\t\tdirty: false,\n\t\t\t});\n\n\t\t\treturn;\n\t\t}\n\n\t\tentry.component = component;\n\t\tentry.dirty = true;\n\t\tif (!this.isPendingUpdate) {\n\t\t\tqueueMicrotask(this.update);\n\t\t\tthis.isPendingUpdate = true;\n\t\t}\n\t}\n\n\tprivate readonly update = () => {\n\t\tthis.isPendingUpdate = false;\n\t\tthis.components.forEach(entry => {\n\t\t\tif (!entry.dirty) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet current = entry.lh;\n\t\t\tlet next;\n\t\t\twhile (current) {\n\t\t\t\tnext = current.ln;\n\t\t\t\tcurrent.fn(entry.component);\n\t\t\t\tcurrent = next;\n\t\t\t}\n\n\t\t\tentry.dirty = false;\n\t\t});\n\t};\n}\n","type StateMap = { [K in string]?: unknown };\n\nexport class StateRegistry {\n\tprivate readonly state = new WeakMap<WeakKey, StateMap>();\n\n\tpublic preserve(handle: WeakKey | undefined, devId: string | undefined, value: any) {\n\t\tif (!handle || !devId) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet map = this.state.get(handle);\n\t\tif (!map) {\n\t\t\tthis.state.set(handle, map = {});\n\t\t}\n\n\t\tmap[devId] = value;\n\t}\n\n\tpublic restore<T = any>(handle: WeakKey | undefined, devId: string | undefined): T;\n\tpublic restore<T>(handle: WeakKey | undefined, devId: string | undefined, block: (value: any) => T): T | undefined;\n\tpublic restore(handle: WeakKey | undefined, devId: string | undefined, block?: (value: any) => any) {\n\t\tif (!handle || !devId) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst map = this.state.get(handle);\n\t\tif (!map || !Object.hasOwn(map, devId)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn block\n\t\t\t? block(map[devId])\n\t\t\t: map[devId];\n\t}\n}\n","import type { MountingGroup } from \"~/Renderer\";\n\nimport { ComponentRegistry } from \"./ComponentRegistry\";\nimport { StateRegistry } from \"./StateRegistry\";\n\nexport interface PyxisHotReload {\n\treadonly component: ComponentRegistry;\n\treadonly state: StateRegistry;\n}\n\ndeclare global {\n\tvar __PYXIS_HMR__: PyxisHotReload;\n\tvar __PYXIS_ROOT__: MountingGroup<any>;\n}\n\nglobalThis.__PYXIS_HMR__ = {\n\tcomponent: new ComponentRegistry(),\n\tstate: new StateRegistry(),\n};\n","import type { ArgsMax2, Callback } from \"./types\";\n\n/**\n * Invokes a Callback passing stored arguments and forwarding the return value.\n * @internal\n */\nexport function invoke<TArgs extends ArgsMax2, TReturn>(callback: Callback<TArgs, TReturn>): TReturn;\nexport function invoke(callback: Callback<ArgsMax2>) {\n\treturn callback.$fn(\n\t\tcallback.$a0,\n\t\tcallback.$a1,\n\t);\n}\n","import type { Callback, Nil } from \"~/support/types\";\n\nimport type { DependencyList } from \"./Dependency\";\nimport type { Scheduler } from \"./Scheduler\";\n\nexport interface Lifecycle extends DependencyList {\n\t/** whether this Lifecycle is currently mounted or not */\n\tmounted: boolean;\n\n\t/** @internal */\n\treadonly $scheduler: Scheduler;\n\n\t/**\n\t * tracks the life of this lifecycle, incremented each time it is resurrected - used for\n\t * detecting stale updates scheduled in a previous life\n\t * @internal\n\t */\n\t$life: number;\n\n\t/** @internal */\n\t$onMount?: Nil<Callback[]>;\n\n\t/** @internal */\n\t$onUnmount?: Nil<Callback[]>;\n}\n\nexport interface MountBlock {\n\t(): (() => void) | void;\n}\n\nexport interface UnmountBlock {\n\t(): void;\n}\n\n\n/**\n * Registers a callback to run just after the current Component has mounted.\n *\n * If a teardown callback is returned, it will be run just before the Component unmounts (equivalent\n * to adding a separate `unmounted` block).\n * @see {@link unmounted}\n */\nexport function mounted(block: MountBlock, lifecycle = getLifecycle()) {\n\tonMounted(lifecycle, {\n\t\t$fn: invokeMountedCallback,\n\t\t$a0: lifecycle,\n\t\t$a1: block,\n\t});\n}\n\n/** @internal */\nexport function onMounted(lifecycle: Lifecycle, callback: Callback) {\n\t(lifecycle.$onMount ??= []).push(callback);\n}\n\nfunction invokeMountedCallback(lifecycle: Lifecycle, block: MountBlock) {\n\tconst dispose = block();\n\tif (dispose) {\n\t\tonUnmounted(lifecycle, { $fn: dispose });\n\t}\n}\n\n\n/**\n * Registers a callback to run once the current Component is just about to unmount.\n * @see {@link mounted}\n */\nexport function unmounted(block: UnmountBlock, lifecycle = getLifecycle()) {\n\tonUnmounted(lifecycle, { $fn: block });\n}\n\n/** @internal */\nexport function onUnmounted(lifecycle: Lifecycle, callback: Callback) {\n\t(lifecycle.$onUnmount ??= []).push(callback);\n}\n\n\nlet $currentLifecycle: Lifecycle | null = null;\n\n/**\n * Gets the Lifecycle of the calling component.\n */\nexport function getLifecycle(): Lifecycle {\n\tif (__DEV__ && !$currentLifecycle) {\n\t\tthrow new Error(\"Cannot get current lifecycle. Are you creating an Atom outside of a Component?\");\n\t}\n\n\treturn $currentLifecycle!;\n}\n\n/** @internal */\nexport function setLifecycle(lifecycle: Lifecycle | null): Lifecycle | null {\n\tconst previous = $currentLifecycle;\n\t$currentLifecycle = lifecycle;\n\treturn previous;\n}\n\n/**\n * Runs a block of code with the provided Lifecycle. Calls to `getLifecycle` within the block will\n * return the specified object.\n * @see {@link getLifecycle}\n */\nexport function withLifecycle<TArgs extends [ arg?: any ], TReturn>(\n\tlifecycle: Lifecycle,\n\tblock: (...args: TArgs) => TReturn,\n\t...args: TArgs\n): TReturn;\n\nexport function withLifecycle(\n\tlifecycle: Lifecycle,\n\tblock: (arg: any) => any,\n\targ: any,\n) {\n\tconst previousLifecycle = $currentLifecycle;\n\t$currentLifecycle = lifecycle;\n\n\ttry {\n\t\treturn block(arg);\n\t}\n\tfinally {\n\t\t$currentLifecycle = previousLifecycle;\n\t}\n}\n","import type { ArgsMax2, Callback, Nil } from \"~/support/types\";\n\nimport type { Lifecycle } from \"./Lifecycle\";\n\n/**\n * A dependency callback of an Atom. The callback will be run whenever the relevant Atom changes.\n */\nexport interface Dependency<TArgs extends ArgsMax2 = ArgsMax2> extends Callback<TArgs> {\n\t/** @internal */\n\t$lifecycle?: Nil<Lifecycle>;\n\n\t/** @internal */\n\t$target?: Nil<DependencyList<TArgs>>;\n\n\t/**\n\t * Previous Dependency within an Atom's dependency list.\n\t * @internal\n\t */\n\t$ap?: Nil<Dependency<TArgs>>;\n\n\t/**\n\t * Next Dependency within an Atom's dependency list.\n\t * @internal\n\t */\n\t$an?: Nil<Dependency<TArgs>>;\n\n\t/**\n\t * Previous Dependency within a Lifecycle's dependency list.\n\t * @internal\n\t */\n\t$lp?: Nil<Dependency>;\n\n\t/**\n\t * Next Dependency within an Lifecycle's dependency list.\n\t * @internal\n\t */\n\t$ln?: Nil<Dependency>;\n}\n\nexport interface DependencyList<TArgs extends ArgsMax2 = ArgsMax2> {\n\t/**\n\t * The head of the dependencies linked list.\n\t * @internal\n\t */\n\t$dh?: Nil<Dependency<TArgs>>;\n\n\t/**\n\t * The tail of the dependencies linked list.\n\t * @internal\n\t */\n\t$dt?: Nil<Dependency<TArgs>>;\n}\n\nexport function bind(lifecycle: Lifecycle, target: DependencyList, block: () => void) {\n\tlink(lifecycle, target, { $fn: block });\n\tblock();\n}\n\n/**\n * Links a Dependency to an Atom and Lifecycle.\n * @internal\n */\nexport function link<TArgs extends ArgsMax2>(lifecycle: Lifecycle, target: DependencyList<TArgs>, dep: Dependency<TArgs>) {\n\t// link to target\n\tif (target.$dt) {\n\t\ttarget.$dt.$an = dep;\n\t\tdep.$ap = target.$dt;\n\t}\n\telse {\n\t\ttarget.$dh = dep;\n\t}\n\n\tdep.$target = target;\n\ttarget.$dt = dep;\n\n\t// link to lifecycle\n\tif (lifecycle.$dt) {\n\t\tlifecycle.$dt.$ln = dep as Dependency;\n\t\tdep.$lp = lifecycle.$dt;\n\t}\n\telse {\n\t\tlifecycle.$dh = dep as Dependency;\n\t}\n\n\tdep.$lifecycle = lifecycle;\n\tlifecycle.$dt = dep as Dependency;\n}\n\n/**\n * Unlinks a Dependency from the Atom and Lifecycle it has been linked to.\n * @internal\n */\nexport function unlink(dep: Dependency) {\n\tconst target = dep.$target;\n\tif (!target) {\n\t\treturn; // already unlinked?\n\t}\n\n\t// unlink from target\n\tif (dep.$ap) {\n\t\tdep.$ap.$an = dep.$an;\n\t}\n\telse if (target.$dh === dep) {\n\t\ttarget.$dh = dep.$an;\n\t}\n\n\tif (dep.$an) {\n\t\tdep.$an.$ap = dep.$ap;\n\t}\n\telse if (target.$dt === dep) {\n\t\ttarget.$dt = dep.$ap;\n\t}\n\n\tdep.$target = null;\n\tdep.$ap = null;\n\tdep.$an = null;\n\n\t// unlink from lifecycle\n\tconst lifecycle = dep.$lifecycle!;\n\tif (dep.$lp) {\n\t\tdep.$lp.$ln = dep.$ln;\n\t}\n\telse if (lifecycle.$dh === dep) {\n\t\tlifecycle.$dh = dep.$ln;\n\t}\n\n\tif (dep.$ln) {\n\t\tdep.$ln.$lp = dep.$lp;\n\t}\n\telse if (lifecycle.$dt === dep) {\n\t\tlifecycle.$dt = dep.$lp;\n\t}\n\n\tdep.$lifecycle = null;\n\tdep.$lp = null;\n\tdep.$ln = null;\n}\n\n/**\n * Unlinks all Dependencies managed by the given Lifecycle.\n * @internal\n */\nexport function unlinkAll(lifecycle: Lifecycle) {\n\tlet dep = lifecycle.$dh;\n\tlet atom;\n\tlet next;\n\n\twhile (dep) {\n\t\tatom = dep.$target!;\n\n\t\tif (dep.$ap) {\n\t\t\tdep.$ap.$an = dep.$an;\n\t\t}\n\t\telse if (atom.$dh === dep) {\n\t\t\tatom.$dh = dep.$an;\n\t\t}\n\n\t\tif (dep.$an) {\n\t\t\tdep.$an.$ap = dep.$ap;\n\t\t}\n\t\telse if (atom.$dt === dep) {\n\t\t\tatom.$dt = dep.$ap;\n\t\t}\n\n\t\tnext = dep.$ln;\n\t\tdep.$lifecycle = null;\n\t\tdep.$target = null;\n\t\tdep.$ap = null;\n\t\tdep.$an = null;\n\t\tdep.$lp = null;\n\t\tdep.$ln = null;\n\t\tdep = next;\n\t}\n\n\tlifecycle.$dh = null;\n\tlifecycle.$dt = null;\n}\n","import { invoke } from \"~/support/common\";\nimport type { ArgsMax2, Callback } from \"~/support/types\";\n\nimport { getLifecycle, type Lifecycle } from \"./Lifecycle\";\n\n/**\n * Manages a queue of scheduled updates.\n * @internal\n */\nexport interface Scheduler {\n\t/**\n\t * Schedules a new tick to execute, unless one is already pending or executing.\n\t */\n\treadonly $scheduleTick: () => void;\n\n\t/**\n\t * Array of pending update callbacks, cleared after each tick.\n\t */\n\treadonly $onTick: UpdateCallback[];\n\n\t/**\n\t * Array of pending end-of-update callbacks, cleared after each tick.\n\t */\n\treadonly $onTock: UpdateCallback[];\n\n\t/**\n\t * Increments with each scheduler tick. Used to deduplicate updates and detect dependency\n\t * cycles.\n\t */\n\t$epoch: number;\n}\n\n/**\n * An update callback that can be scheduled.\n * @see {@link Scheduler}\n * @internal\n */\nexport interface UpdateCallback<TArgs extends ArgsMax2 = ArgsMax2> extends Callback<TArgs> {\n\t/**\n\t * The Lifecycle responsible for this callback.\n\t */\n\t$lifecycle?: Lifecycle;\n\n\t/**\n\t * The life number of the Lifecycle when this callback was scheduled.\n\t */\n\t$life?: number;\n\n\t/**\n\t * Schedule epoch - tracked to prevent scheduling the same callback multiple times within\n\t * the same tick.\n\t */\n\t$se?: number;\n\n\t/**\n\t * Run epoch - only tracked in dev mode to detect dependency loops.\n\t */\n\t$re?: number;\n}\n\n/**\n * A function able to schedule a callback to be executed at a later time, e.g. `queueMicrotask`.\n * The function must guarantee that the callback will be eventually executed.\n */\nexport interface TickFn {\n\t(onTick: () => void): void;\n}\n\n/** @internal */\nexport function createScheduler(tick: TickFn) {\n\tlet isPending = false;\n\n\tconst ticks: UpdateCallback[] = [];\n\tconst tocks: UpdateCallback[] = [];\n\tconst scheduler: Scheduler = {\n\t\t$epoch: 1,\n\t\t$onTick: ticks,\n\t\t$onTock: tocks,\n\t\t$scheduleTick: () => {\n\t\t\tif (isPending) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tisPending = true;\n\t\t\ttick(update);\n\t\t},\n\t};\n\n\tconst update = () => {\n\t\ttry {\n\t\t\tlet index = 0;\n\t\t\tlet callback;\n\n\t\t\t// array lengths are re-read on each cycle, as they may increase when new updates get\n\t\t\t// added by the running code\n\n\t\t\t// run ticks\n\t\t\tfor (; index < ticks.length; index += 1) {\n\t\t\t\tcallback = ticks[index];\n\t\t\t\tif (callback.$life === callback.$lifecycle!.$life) {\n\t\t\t\t\tif (__DEV__) {\n\t\t\t\t\t\tcallback.$re = scheduler.$epoch;\n\t\t\t\t\t}\n\n\t\t\t\t\tinvoke(callback);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// run tocks\n\t\t\tfor (index = 0; index < tocks.length; index += 1) {\n\t\t\t\tcallback = tocks[index];\n\t\t\t\tif (callback.$life === callback.$lifecycle!.$life) {\n\t\t\t\t\tif (__DEV__) {\n\t\t\t\t\t\tcallback.$re = scheduler.$epoch;\n\t\t\t\t\t}\n\n\t\t\t\t\tinvoke(callback);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfinally {\n\t\t\tisPending = false;\n\t\t\tticks.length = 0;\n\t\t\ttocks.length = 0;\n\t\t\tscheduler.$epoch += 1;\n\t\t}\n\t};\n\n\treturn scheduler;\n}\n\nfunction schedule(lifecycle: Lifecycle, queue: UpdateCallback[], callback: UpdateCallback) {\n\tconst scheduler = lifecycle.$scheduler;\n\tif (callback.$se === scheduler.$epoch) {\n\t\tif (__DEV__ && callback.$re === scheduler.$epoch) {\n\t\t\t// if run epoch (::$re) matches, the callback already executed this tick and now is being\n\t\t\t// scheduled again in the same tick -> this is potentially an infinite loop, complain:\n\t\t\tthrow new Error(\"Refusing to re-schedule an update after it already executed, as it may cause an infinite loop. Are you mutating an Atom inside an effect that observes it?\");\n\t\t}\n\n\t\t// if schedule epoch (::$se) matches, the callback was already scheduled -> bail\n\t\treturn;\n\t}\n\n\tcallback.$lifecycle = lifecycle;\n\tcallback.$life = lifecycle.$life;\n\tcallback.$se = scheduler.$epoch;\n\tqueue.push(callback);\n\tscheduler.$scheduleTick();\n}\n\n/** @internal */\nexport function scheduleTick(lifecycle: Lifecycle, callback: UpdateCallback) {\n\tschedule(lifecycle, lifecycle.$scheduler.$onTick, callback);\n}\n\n/**\n * Runs a block of code on the next tick of the scheduler, synchronized with other updates. If a\n * tick is not currently pending, a new one is scheduled.\n */\nexport function tick(block: () => void, lifecycle = getLifecycle()) {\n\tschedule(lifecycle, lifecycle.$scheduler.$onTick, { $fn: block });\n}\n\n/** @internal */\nexport function scheduleTock(lifecycle: Lifecycle, callback: UpdateCallback) {\n\tschedule(lifecycle, lifecycle.$scheduler.$onTock, callback);\n}\n\n/**\n * Runs a block of code after the next tick of the scheduler, once all regular updates finished.\n * If a tick is not currently pending, a new one is scheduled.\n */\nexport function tock(block: () => void, lifecycle = getLifecycle()) {\n\tschedule(lifecycle, lifecycle.$scheduler.$onTock, { $fn: block });\n}\n","import type { Nil } from \"~/support/types\";\n\nimport { getLifecycle, onUnmounted, setLifecycle, type Lifecycle } from \"./Lifecycle\";\nimport { link, unlink, type Dependency, type DependencyList } from \"./Dependency\";\nimport { scheduleTick, type UpdateCallback } from \"./Scheduler\";\n\nexport interface EffectBlock {\n\t(): (() => void) | void;\n}\n\nexport interface Effect<T> {\n\t/** @internal */\n\treadonly $lifecycle: Lifecycle;\n\n\t/** @internal */\n\treadonly $life: number;\n\n\t/** @internal */\n\treadonly $block: () => T;\n\n\t/** @internal */\n\treadonly $react: (effect: this, epoch: number) => void;\n\n\t/**\n\t * Keeps track of the effect run cycle, incrementing on each effect run. Used to detect stale\n\t * dependencies and lazily unlink them.\n\t * @internal\n\t */\n\t$cycle: number;\n\n\t/** @internal */\n\t$deps?: WeakMap<DependencyList, EffectDependency>;\n\n\t/** @internal */\n\t$resolve?: UpdateCallback<[ effect: this ]>;\n\n\t/** @internal */\n\t$dispose?: Nil<() => void>;\n\n\t/** @internal */\n\t$tracksUnmount?: true;\n}\n\n/** @internal */\nexport type EffectDependency = Dependency<[ effect: Effect<any>, epoch: number ]>;\n\n/**\n * Creates an Effect - a block of logic executed each time any of the Atoms accessed within it\n * change. The block is first synchronously executed when the Effect is created.\n *\n * If a teardown callback is returned, it will be run before the next effect re-run, or on component\n * unmount.\n */\nexport function effect(block: EffectBlock, lifecycle = getLifecycle()) {\n\trunEffect({\n\t\t$lifecycle: lifecycle,\n\t\t$life: lifecycle.$life,\n\t\t$block: block,\n\t\t$react: scheduleEffect,\n\t\t$cycle: 0,\n\t});\n}\n\nfunction scheduleEffect(this: EffectDependency, effect: Effect<ReturnType<EffectBlock>>, cycle: number) {\n\t// lazy cleanup: when we get an update from a stale dependency, the reported epoch will be lower\n\t// than our current one (see the reportAccess function). We can unlink and skip the effect.\n\tif (effect.$cycle > cycle) {\n\t\tunlink(this);\n\t\treturn;\n\t}\n\n\t// we're already within a scheduler tick; the effect will therefore run synchronously despite\n\t// being \"scheduled\" - this also gives priority to already scheduled updates and prevents\n\t// potential infinite loops in case dependency cycles exist\n\tscheduleTick(effect.$lifecycle, effect.$resolve ??= {\n\t\t$fn: runEffect,\n\t\t$a0: effect,\n\t});\n}\n\nfunction runEffect(effect: Effect<ReturnType<EffectBlock>>) {\n\t// effect was scheduled in a previous life and is now stale\n\tif (effect.$life !== effect.$lifecycle.$life) {\n\t\treturn;\n\t}\n\n\teffect.$dispose?.();\n\teffect.$dispose = resolve(effect) as Nil<() => void>;\n\n\tif (!effect.$tracksUnmount && effect.$dispose) {\n\t\teffect.$tracksUnmount = true;\n\t\tonUnmounted(effect.$lifecycle, {\n\t\t\t$fn: teardownEffect,\n\t\t\t$a0: effect,\n\t\t});\n\t}\n}\n\nfunction teardownEffect(effect: Effect<ReturnType<EffectBlock>>) {\n\teffect.$dispose?.();\n\teffect.$dispose = null;\n}\n\nlet $currentEffect: Effect<any> | null = null;\n\n/**\n * Resolves an Effect: runs user logic tracking accessed Atoms and updating dependency links.\n * Returned value is forwarded.\n * @internal\n */\nexport function resolve<TEffect extends Effect<any>>(effect: TEffect): TEffect extends Effect<infer T> ? T : unknown {\n\teffect.$deps ??= new WeakMap();\n\teffect.$cycle += 1;\n\n\tconst previousEffect = $currentEffect;\n\tconst previousLifecycle = setLifecycle(effect.$lifecycle);\n\t$currentEffect = effect;\n\n\ttry {\n\t\treturn effect.$block();\n\t}\n\tfinally {\n\t\tsetLifecycle(previousLifecycle);\n\t\t$currentEffect = previousEffect;\n\t}\n}\n\n/**\n * Reports an Atom has been accessed. Does nothing if not within an Effect.\n * @internal\n */\nexport function reportAccess(atom: DependencyList) {\n\tif (!$currentEffect || $currentEffect.$life !== $currentEffect.$lifecycle.$life) {\n\t\treturn;\n\t}\n\n\tlet dep = $currentEffect.$deps!.get(atom);\n\tif (dep) {\n\t\t// refresh dependency to the current epoch\n\t\tdep.$a1 = $currentEffect.$cycle;\n\t\tif (!dep.$lifecycle) {\n\t\t\t// dep has become temporarily stale and got unlinked while still lingering in the\n\t\t\t// $deps WeakMap - that's okay, but must be re-linked now to work again\n\t\t\tlink($currentEffect.$lifecycle, atom, dep);\n\t\t}\n\t}\n\telse {\n\t\tlink($currentEffect.$lifecycle, atom, dep = {\n\t\t\t$fn: $currentEffect.$react,\n\t\t\t$a0: $currentEffect,\n\t\t\t$a1: $currentEffect.$cycle,\n\t\t});\n\n\t\t$currentEffect.$deps!.set(atom, dep);\n\t}\n}\n\n/**\n * Runs a block of code removed from any effects. Accessing atoms within this block will be ignored\n * by any effect that may otherwise be observing this code.\n */\nexport function noEffect<T>(block: () => T) {\n\tconst previousEffect = $currentEffect;\n\t$currentEffect = null;\n\n\ttry {\n\t\treturn block();\n\t}\n\tfinally {\n\t\t$currentEffect = previousEffect;\n\t}\n}\n\n/**\n * Asserts that the current code is not running within an effect block.\n * Only used in development; In production, this function should be removed by the bundler.\n */\nexport function __DEV__assertNotEffect() {\n\tif (\n\t\t$currentEffect &&\n\t\t$currentEffect.$lifecycle === getLifecycle() &&\n\t\t$currentEffect.$life === $currentEffect.$lifecycle.$life\n\t) {\n\t\tthrow new Error(\"Attempt to create an Atom inside an effect block.\");\n\t}\n}\n","import { invoke } from \"~/support/common\";\nimport type { Nil } from \"~/support/types\";\n\nimport { getLifecycle, type Lifecycle } from \"./Lifecycle\";\nimport { __DEV__assertNotEffect, reportAccess } from \"./Effect\";\nimport { scheduleTick, type UpdateCallback } from \"./Scheduler\";\nimport type { DependencyList } from \"./Dependency\";\n\n/**\n * Pyxis Atom type guard marker.\n */\n// @ts-expect-error this is a unique symbol at runtime\nexport const S_ATOM: unique symbol = __DEV__ ? Symbol.for(\"pyxis:atom\") : Symbol();\n\n\n/** Contract for Atoms where they need to be read. */\nexport interface ReadAtom<out T> extends DependencyList {\n\t/** Pyxis Atom type guard marker. */\n\treadonly [S_ATOM]: true;\n\n\t/**\n\t * Gets the value of this Atom. Only use this method when the target is guaranteed to be an\n\t * Atom, otherwise it is recommended to use the `read` or `peek` functions.\n\t *\n\t * This method does *not* report access, thus within effects it is analogous to `peek`.\n\t * @see {@link read}\n\t * @see {@link peek}\n\t */\n\tget: () => T;\n}\n\n/**\n * Holds any single value, managing reactions to its changes. Use the `read`, `write` functions to\n * access its value.\n * @see {@link read}\n * @see {@link write}\n */\nexport interface Atom<T = unknown> extends ReadAtom<T> {\n\t/**\n\t * Sets the value of this Atom. Does nothing if this Atom is readonly. Only use this method when\n\t * the target is guaranteed to be an Atom, otherwise it is recommended to use the `write` or\n\t * `update` functions.\n\t *\n\t * This method does *not* send out any change notifications to observers!\n\t * @returns Boolean indicating whether the value of this Atom changed.\n\t * @see {@link write}\n\t * @see {@link update}\n\t */\n\tset: (value: T) => boolean;\n\n\t/** @internal */\n\treadonly $lifecycle: Lifecycle;\n\n\t/** @internal */\n\treadonly $tracksValue?: boolean;\n\n\t/** @internal */\n\t$lastValue?: T;\n\n\t/** @internal */\n\t$force?: boolean;\n\n\t/**\n\t * The notify callback of this Atom.\n\t * @internal\n\t */\n\t$notify?: UpdateCallback<[ self: Atom<T> ]>;\n\n\t/**\n\t * The ID of this Atom, only present in development mode with transpiler.\n\t * @internal\n\t */\n\t$devId?: string;\n}\n\ninterface DirectAtom<T> extends Atom<any> {\n\t$value: T;\n}\n\n/**\n * Union of the given type or an Atom of that type. Use the `read`, `peek`, `write`, `update` or\n * `isAtom` functions to interact with such values.\n * @see {@link read}\n * @see {@link peek}\n * @see {@link write}\n * @see {@link update}\n * @see {@link isAtom}\n */\nexport type MaybeAtom<T> = Atom<T> | T;\n\n/**\n * Union of the given type or the ReadAtom contract of that type. Use the `read`, `peek` or `isAtom`\n * functions to interact with such values.\n * @see {@link read}\n * @see {@link peek}\n * @see {@link isAtom}\n */\nexport type MaybeReadAtom<T> = ReadAtom<T> | T;\n\n/**\n * Creates an empty Atom; i.e. value set to `undefined`.\n */\nexport function atomOf<T>(): Atom<T | undefined>;\n\n/**\n * Creates an Atom initialized to the provided value. If the provided value is already an Atom, it\n * is returned as-is.\n * @see {@link isAtom}\n */\nexport function atomOf<T>(initialValue: MaybeAtom<T>, lifecycle?: Lifecycle, devId?: string): Atom<T>;\n\nexport function atomOf<T>(initialValue?: MaybeAtom<T>, lifecycle = getLifecycle()) {\n\tif (__DEV__) {\n\t\t__DEV__assertNotEffect();\n\t}\n\n\tif (isAtom(initialValue)) {\n\t\treturn initialValue;\n\t}\n\n\tconst atom: DirectAtom<T> = {\n\t\t[S_ATOM]: true,\n\t\t$value: initialValue as T,\n\t\t$tracksValue: true,\n\t\t$lifecycle: lifecycle,\n\t\t$lastValue: initialValue,\n\t\tget: getValue,\n\t\tset: setValue,\n\t};\n\n\tif (__DEV__) {\n\t\tconst devId = arguments[2];\n\t\tatom.$devId = devId;\n\t\tglobalThis.__PYXIS_HMR__.state.restore(lifecycle, devId, value => {\n\t\t\tatom.$value = value;\n\t\t});\n\t}\n\n\treturn atom;\n}\n\nfunction getValue<T>(this: DirectAtom<T>) {\n\treturn this.$value;\n}\n\nfunction setValue<T>(this: DirectAtom<T>, value: T) {\n\tif (Object.is(this.$value, value)) {\n\t\treturn false;\n\t}\n\n\tthis.$value = value;\n\tif (__DEV__) {\n\t\tglobalThis.__PYXIS_HMR__.state.preserve(this.$lifecycle, this.$devId, value);\n\t}\n\n\treturn true;\n}\n\n/**\n * Atom type guard, checks if the provided input is an Atom.\n */\nexport function isAtom<T = unknown>(input: Nil<MaybeAtom<T>>): input is Atom<T>;\nexport function isAtom<T = unknown>(input: Nil<MaybeReadAtom<T>>): input is ReadAtom<T>;\nexport function isAtom<T = unknown>(input: unknown): input is Atom<T>;\nexport function isAtom(input: unknown): input is Atom<any> {\n\treturn (\n\t\tinput !== null &&\n\t\ttypeof input === \"object\" &&\n\t\t(input as { [S_ATOM]?: true })[S_ATOM] === true\n\t);\n}\n\n/**\n * Checks if the provided input is an Atom and reads its value. Non-atom inputs are returned as-is.\n * Reports read access when inside an effect.\n * @see {@link isAtom}\n * @see {@link write}\n * @see {@link peek}\n * @see {@link update}\n */\nexport function read<A>(input: A): A extends MaybeReadAtom<infer T> ? T : never;\nexport function read<T>(input: MaybeReadAtom<T>) {\n\tif (isAtom<T>(input)) {\n\t\treportAccess(input);\n\t\treturn input.get();\n\t}\n\n\treturn input;\n}\n\n/**\n * Checks if the provided input is an Atom and reads its value. Non-atom inputs are returned as-is.\n * Does NOT report read access when inside an effect.\n * @see {@link isAtom}\n * @see {@link read}\n * @see {@link write}\n * @see {@link update}\n */\nexport function peek<A>(input: A): A extends MaybeReadAtom<infer T> ? T : never;\nexport function peek<T>(input: MaybeReadAtom<T>): T {\n\tif (isAtom<T>(input)) {\n\t\treturn input.get();\n\t}\n\n\treturn input;\n}\n\n/**\n * Checks if the provided input is an Atom, writes its value and returns the new value.\n *\n * Non-atom inputs are never modified in any way. Instead the provided new value is discarded and\n * the input is returned as-is.\n * @see {@link isAtom}\n * @see {@link read}\n * @see {@link write}\n * @see {@link update}\n */\nexport function write<A>(\n\tinput: A,\n\tvalue: A extends Atom<infer T> ? T : never,\n\tforce?: boolean,\n): A extends MaybeAtom<infer T> ? T : never;\n\nexport function write<T>(input: MaybeAtom<T>, value: T, force = false): T {\n\tif (isAtom(input)) {\n\t\tif (input.set(value) || force) {\n\t\t\tinput.$force ||= force;\n\t\t\tscheduleTick(input.$lifecycle, input.$notify ??= {\n\t\t\t\t$fn: notify,\n\t\t\t\t$a0: input,\n\t\t\t});\n\t\t}\n\n\t\treturn input.get();\n\t}\n\n\treturn input;\n}\n\n/**\n * Checks if the provided input is an Atom, updates its value using the provided transform function\n * and returns the new value.\n *\n * Non-atom inputs are never modified in any way and the input is returned as-is.\n * @see {@link isAtom}\n * @see {@link read}\n * @see {@link peek}\n * @see {@link write}\n */\nexport function update<A>(\n\tinput: A,\n\ttransform: A extends Atom<infer T> ? (value: T) => T : never,\n\tforce?: boolean,\n): A extends MaybeAtom<infer T> ? T : never;\n\nexport function update<T>(input: MaybeAtom<T>, transform: (value: T) => T, force = false): T {\n\tif (isAtom(input)) {\n\t\tif (input.set(transform(input.get())) || force) {\n\t\t\tinput.$force ||= force;\n\t\t\tscheduleTick(input.$lifecycle, input.$notify ??= {\n\t\t\t\t$fn: notify,\n\t\t\t\t$a0: input,\n\t\t\t});\n\t\t}\n\n\t\treturn input.get();\n\t}\n\n\treturn input;\n}\n\n/**\n * Notifies the dependencies of an Atom.\n * @internal\n */\nexport function notify<T>(input: Atom<T>) {\n\t// optimization: when Atom changes multiple times within a single update and ends up with the\n\t// same value it started with, the notification can be skipped\n\tif (input.$tracksValue) {\n\t\tconst newValue = input.get();\n\t\tif (Object.is(input.$lastValue, newValue) && !input.$force) {\n\t\t\treturn;\n\t\t}\n\n\t\tinput.$lastValue = newValue;\n\t}\n\n\tinput.$force = false;\n\n\tlet current = input.$dh;\n\tlet next;\n\twhile (current) {\n\t\tnext = current.$an;\n\t\tinvoke(current);\n\t\tcurrent = next;\n\t}\n}\n","import { isAtom } from \"~/data/Atom\";\nimport { bind } from \"~/data/Dependency\";\nimport type { JsxText } from \"~/Component\";\nimport { insert, type HNode } from \"~/Renderer\";\n\nexport function Text<TNode>(\n\tjsx: NonNullable<JsxText>,\n\thParent: HNode<TNode>,\n\tnUsedParent: TNode,\n\t_nRealParent: TNode,\n\tnBefore: TNode | null,\n\tisBatch: boolean,\n) {\n\tconst { adapter } = hParent.$ng;\n\tlet node: TNode | null = null;\n\n\tif (isAtom(jsx)) {\n\t\tbind(hParent.$ng, jsx, () => {\n\t\t\tnode = adapter.text(jsx.get()?.toString() ?? \"\", node);\n\t\t});\n\t}\n\telse {\n\t\t// static nil values are already filtered out by Renderer, never passed to this component\n\t\tnode = adapter.text(jsx.toString(), null);\n\t}\n\n\tinsert(node!, null, hParent, nUsedParent, nBefore, isBatch);\n}\n","import { Text } from \"~/component/Text\";\nimport { isAtom } from \"~/data/Atom\";\nimport { setLifecycle, type Lifecycle } from \"~/data/Lifecycle\";\nimport { createScheduler } from \"~/data/Scheduler\";\nimport type { ElementsType, Mutable, Nil } from \"~/support/types\";\n\nimport type { Adapter, ExtensionsType } from \"./Adapter\";\nimport type { ComponentHandler, JsxResult } from \"./Component\";\nimport { invoke } from \"./support/common\";\nimport { unlinkAll } from \"./data/Dependency\";\n\n/** @internal */\n// @ts-expect-error this is a unique symbol at runtime\nexport const S_COMPONENT: unique symbol = __DEV__ ? Symbol.for(\"pyxis:component\") : Symbol();\n\nexport interface Renderer<TNode, TIntrinsicElements extends ElementsType = ElementsType> {\n\t/**\n\t * Carries information about the available intrinsic elements when using this Renderer.\n\t * @deprecated **Type only, does not exist at runtime!**\n\t */\n\treadonly $elements?: TIntrinsicElements;\n\n\tmount: (root: TNode, jsx: JsxResult) => void;\n\tunmount: () => void;\n}\n\nexport type ElementsOf<TRenderer> = TRenderer extends { readonly $elements?: infer TElements }\n\t? TElements\n\t: {};\n\n\nexport interface MountingGroup<TNode> extends Lifecycle, Hierarchy<TNode> {\n\treadonly $isGroup: true;\n\treadonly $isNative?: never;\n\n\t/** the Adapter rendering this MountingGroup */\n\treadonly adapter: Adapter<TNode>;\n\n\t/** @internal */\n\treadonly $extensions: ExtensionsType<TNode>;\n}\n\nexport interface NativeNode<TNode> extends Hierarchy<TNode> {\n\treadonly $isNative: true;\n\treadonly $isGroup?: never;\n\treadonly $nn: TNode;\n}\n\nexport interface Hierarchy<TNode> {\n\t/** @internal */\n\treadonly $isGroup?: true;\n\n\t/** @internal */\n\treadonly $isNative?: true;\n\n\t/**\n\t * the nearest mounting group - can be self\n\t * @internal\n\t */\n\treadonly $ng: MountingGroup<TNode>;\n\n\t/**\n\t * the nearest *ancestor* group this node belongs to\n\t * @internal\n\t */\n\treadonly $pg: MountingGroup<TNode> | null;\n\n\t/**\n\t * the nearest native node (ancestor or self) - on groups, this is only present in dev mode\n\t * @internal\n\t */\n\treadonly $nn?: TNode;\n\n\t/**\n\t * the first child of this h-node\n\t * @internal\n\t */\n\t$hh?: Nil<HNode<TNode>>;\n\n\t/**\n\t * the last child of this h-node\n\t * @internal\n\t */\n\t$ht?: Nil<HNode<TNode>>;\n\n\t/**\n\t * the previous sibling of this h-node\n\t * @internal\n\t */\n\t$hp?: Nil<HNode<TNode>>;\n\n\t/**\n\t * the next sibling of this h-node\n\t * @internal\n\t */\n\t$hn?: Nil<HNode<TNode>>;\n}\n\nexport type HNode<TNode> =\n\t| MountingGroup<TNode>\n\t| NativeNode<TNode>;\n\n\n/** @internal */\nexport function createRenderer<TNode, TIntrinsicElements extends ElementsType>(\n\tadapter: Adapter<TNode>,\n\textensions: ExtensionsType<TNode>,\n): Renderer<TNode, TIntrinsicElements> {\n\tconst hGroup: Mutable<MountingGroup<TNode> & Renderer<TNode, TIntrinsicElements>> = {\n\t\tadapter: adapter,\n\t\tmounted: false,\n\t\t$isGroup: true,\n\t\t$scheduler: createScheduler(adapter.tick),\n\t\t$extensions: extensions,\n\t\t$life: 1,\n\t\t$pg: null,\n\t\t$ng: null!,\n\t\tunmount: () => unmount(hGroup),\n\t\tmount: (nRoot, jsx) => {\n\t\t\tif (__DEV__) {\n\t\t\t\thGroup.$nn = nRoot;\n\t\t\t}\n\n\t\t\tconst isBatch = Boolean(adapter.batch);\n\t\t\tconst nParent = isBatch ? adapter.batch!() : nRoot;\n\t\t\tmount(jsx, hGroup, nParent, nRoot, null, isBatch);\n\t\t\tif (isBatch) {\n\t\t\t\tadapter.insert(nParent, nRoot, null);\n\t\t\t}\n\t\t},\n\t};\n\n\thGroup.$ng = hGroup;\n\tif (__DEV__) {\n\t\tglobalThis.__PYXIS_ROOT__ ??= hGroup;\n\t}\n\n\treturn hGroup;\n}\n\n/**\n * Creates a sub-group within the provided MountingGroup. Needed whenever a subtree needs to mount\n * or unmount dynamically.\n */\nexport function fork<TNode>(\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null = null,\n): MountingGroup<TNode> {\n\tconst ng = hParent.$ng;\n\tconst hGroup: Mutable<MountingGroup<TNode>> = {\n\t\tadapter: ng.adapter,\n\t\tmounted: false,\n\t\t$isGroup: true,\n\t\t$scheduler: ng.$scheduler,\n\t\t$extensions: ng.$extensions,\n\t\t$life: 1,\n\t\t$pg: ng,\n\t\t$ng: null!,\n\t};\n\n\thGroup.$ng = hGroup;\n\tif (__DEV__) {\n\t\thGroup.$nn = hParent.$nn;\n\t}\n\n\ttrack(hGroup, hParent, hBefore);\n\treturn hGroup;\n}\n\n/**\n * Adds a HNode to the hierarchy.\n */\nexport function track<TNode>(\n\thNode: HNode<TNode>,\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null = null,\n) {\n\t// insert into hierarchy before given sibling\n\tif (hBefore?.$pg === hParent) {\n\t\tif (hBefore.$hp) {\n\t\t\thNode.$hp = hBefore.$hp;\n\t\t\thNode.$hn = hBefore;\n\t\t\thBefore.$hp.$hn = hNode;\n\t\t\thBefore.$hp = hNode;\n\t\t}\n\t\telse {\n\t\t\thNode.$hp = null;\n\t\t\thNode.$hn = hParent.$hh;\n\t\t\tif (hParent.$hh === hBefore) {\n\t\t\t\t// this should always run: since before has no previous sibling, it must be at the\n\t\t\t\t// head, otherwise the hierarchy is malformed and bad things will happen...\n\t\t\t\thBefore.$hp = hNode;\n\t\t\t}\n\n\t\t\thParent.$hh = hNode;\n\t\t}\n\t}\n\t// append at the tail of the hierarchy\n\telse {\n\t\tif (hParent.$ht) {\n\t\t\thParent.$ht.$hn = hNode;\n\t\t\thNode.$hp = hParent.$ht;\n\t\t}\n\t\telse {\n\t\t\thParent.$hh = hNode;\n\t\t}\n\n\t\thParent.$ht = hNode;\n\t}\n}\n\n/**\n * Removes a HNode from the tracking hierarchy.\n */\nexport function untrack<TNode>(hNode: HNode<TNode>) {\n\tif (hNode.$hp) {\n\t\thNode.$hp.$hn = hNode.$hn;\n\t}\n\telse if (hNode.$pg?.$hh === hNode) {\n\t\thNode.$pg.$hh = hNode.$hn;\n\t}\n\n\tif (hNode.$hn) {\n\t\thNode.$hn.$hp = hNode.$hp;\n\t}\n\telse if (hNode.$pg?.$ht === hNode) {\n\t\thNode.$pg.$ht = hNode.$hp;\n\t}\n\n\thNode.$hp = null;\n\thNode.$hn = null;\n}\n\n/**\n * Mounts a MountingGroup to the specified location in the node tree. If the group is already\n * mounted (i.e. its native nodes are already rendered somewhere), it is moved to the new location\n * without re-mounting Pyxis components.\n *\n * Note that for successfully moving a group within the tree, you should first `untrack` the group,\n * then re-`track` it to the new location and only then call `mount` to commit the move.\n * @see {@link track}\n * @see {@link untrack}\n */\nexport function mount<TNode>(\n\tjsx: any,\n\thGroup: MountingGroup<TNode>,\n\tnUsedParent: TNode,\n\tnRealParent: TNode,\n\tnBefore: TNode | null,\n\tisBatch: boolean,\n) {\n\tif (hGroup.mounted) {\n\t\treinsertNodes(hGroup, nUsedParent, nBefore);\n\t\treturn;\n\t}\n\n\tconst previousLifecycle = setLifecycle(hGroup);\n\ttry {\n\t\tmountJsx(jsx, hGroup, nUsedParent, nRealParent, nBefore, isBatch);\n\t}\n\tfinally {\n\t\tsetLifecycle(previousLifecycle);\n\t\thGroup.mounted = true;\n\n\t\t// only dispatch mount notifications when the parent group is already mounted, or if this is the\n\t\t// top-level group - otherwise, mount notification will arrive once the parent mounts\n\t\tif (hGroup.$pg?.mounted !== false) {\n\t\t\tnotifyMounted(hGroup);\n\t\t}\n\t}\n}\n\n/**\n * Only used by `mount`, do not call directly.\n *\n * Recursively (dept-first) runs components' `mounted` callbacks.\n * @see {@link mount}\n * @internal\n */\nfunction notifyMounted<TNode>(hNode: HNode<TNode>) {\n\tlet current = hNode.$hh;\n\twhile (current) {\n\t\tnotifyMounted(current);\n\t\tcurrent = current.$hn;\n\t}\n\n\tlet callbacks;\n\tif (hNode.$isGroup && hNode.mounted && (callbacks = hNode.$onMount)) {\n\t\tconst previousLifecycle = setLifecycle(hNode);\n\t\ttry {\n\t\t\tcallbacks.forEach(invoke);\n\t\t}\n\t\tfinally {\n\t\t\tcallbacks.length = 0;\n\t\t\tsetLifecycle(previousLifecycle);\n\t\t}\n\t}\n}\n\n/**\n * Only used by `mount`, do not call directly.\n *\n * Re-inserts native nodes of the given group to the specified location in the native tree. Only\n * moves the uppermost nodes - any children should move implicitly with them.\n * @see {@link mount}\n * @internal\n */\nfunction reinsertNodes<TNode>(hGroup: MountingGroup<TNode>, nParent: TNode, nBefore: TNode | null) {\n\tconst { adapter } = hGroup;\n\n\tlet current = hGroup.$hh;\n\twhile (current) {\n\t\tif (current.$isNative) {\n\t\t\tadapter.insert(current.$nn, nParent, nBefore);\n\t\t\t// no need to recurse, group is already mounted, so any sub-groups within this native\n\t\t\t// node have been already moved with it\n\t\t}\n\t\telse {\n\t\t\treinsertNodes(current, nParent, nBefore);\n\t\t}\n\n\t\tcurrent = current.$hn;\n\t}\n}\n\n/**\n * Unmounts the contents of a MountingGroup from the node tree. The group itself, though empty,\n * remains usable and can be remounted later.\n */\nexport function unmount<TNode>(group: MountingGroup<TNode>): void;\n\n/** @internal */\nexport function unmount<TNode>(hNode: HNode<TNode>, top?: boolean): void;\nexport function unmount<TNode>(hNode: HNode<TNode>, top: boolean = true) {\n\tif (hNode.$isGroup) {\n\t\tif (hNode.mounted) {\n\t\t\tlet callbacks;\n\t\t\tif (callbacks = hNode.$onUnmount) {\n\t\t\t\tconst previousLifecycle = setLifecycle(hNode);\n\t\t\t\ttry {\n\t\t\t\t\tcallbacks.forEach(invoke);\n\t\t\t\t}\n\t\t\t\tfinally {\n\t\t\t\t\tcallbacks.length = 0;\n\t\t\t\t\tsetLifecycle(previousLifecycle);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\thNode.mounted = false;\n\t\t\thNode.$life += 1;\n\t\t}\n\n\t\t// unmounted groups shouldn't have anything to unlink, but a zombie dependency can have\n\t\t// catastrophic consequences, so...\n\t\tunlinkAll(hNode);\n\t}\n\n\tconst { adapter } = hNode.$ng;\n\tlet current = hNode.$hh;\n\tlet next;\n\n\twhile (current) {\n\t\tif (current.$isNative && top) {\n\t\t\tadapter.remove(current.$nn);\n\t\t\tunmount(current, false);\n\t\t}\n\t\telse {\n\t\t\tunmount(current, top);\n\t\t}\n\n\t\tnext = current.$hn;\n\t\tcurrent.$hp = null;\n\t\tcurrent.$hn = null;\n\t\tcurrent = next;\n\t}\n\n\thNode.$hh = null;\n\thNode.$ht = null;\n}\n\n/**\n * Mounts components described by the JsxResult to the specified location in the node tree.\n */\nexport function mountJsx<TNode>(\n\tjsx: any,\n\thParent: HNode<TNode>,\n\tnUsedParent: TNode,\n\tnRealParent: TNode,\n\tnBefore: TNode | null,\n\tisBatch: boolean,\n) {\n\tswitch (typeof jsx) {\n\t\tcase \"object\":\n\t\t\tif (jsx === null) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (Array.isArray(jsx)) {\n\t\t\t\tconst { length } = jsx;\n\t\t\t\tlet index = 0;\n\t\t\t\tfor (; index < length; index += 1) {\n\t\t\t\t\tmountJsx(jsx[index], hParent, nUsedParent, nRealParent, nBefore, isBatch);\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (!isAtom(jsx)) {\n\t\t\t\t(jsx[S_COMPONENT] as ComponentHandler | undefined)\n\t\t\t\t\t?.(jsx, hParent, nUsedParent, nRealParent, nBefore, isBatch);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// fall through\n\n\t\tcase \"string\":\n\t\tcase \"number\":\n\t\tcase \"boolean\":\n\t\tcase \"bigint\":\n\t\t\tText(jsx, hParent, nUsedParent, nRealParent, nBefore, isBatch);\n\t\t\tbreak;\n\t}\n}\n\n/**\n * Inserts a native node and adds it to the tracking hierarchy. Necessary to preserve render order.\n * Should only be called by component handlers!\n */\nexport function insert<TNode>(\n\tnNode: TNode,\n\tchildren: any,\n\thParent: HNode<TNode>,\n\tnUsedParent: TNode,\n\tnBefore: TNode | null,\n\tisBatch: boolean,\n) {\n\tlet hNative = hParent;\n\tif (hNative.$isGroup) {\n\t\t// parent is a group, so this is its top-level node -> find insertion point\n\t\tlet hBefore = null;\n\t\tif (nBefore) {\n\t\t\tlet current = hParent.$ht;\n\t\t\twhile (current) {\n\t\t\t\tif (current.$isNative && current.$nn === nBefore) {\n\t\t\t\t\thBefore = current;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcurrent = current.$hp;\n\t\t\t}\n\t\t}\n\n\t\ttrack(hNative = {\n\t\t\t$isNative: true,\n\t\t\t$pg: hNative,\n\t\t\t$ng: hNative,\n\t\t\t$nn: nNode,\n\t\t}, hParent, hBefore);\n\t}\n\n\tmountJsx(children, hNative, nNode, nNode, null, isBatch);\n\thParent.$ng.adapter.insert(nNode, nUsedParent, nBefore);\n}\n","import type { Nil } from \"~/support/types\";\nimport type { JsxObject, JsxProps, JsxResult } from \"~/Component\";\nimport { mountJsx, type HNode } from \"~/Renderer\";\n\n// FUTURE: currently TypeScript has a bug causing it to skip checking fragment props in \"react-jsx\" mode\n// allowing users to supply fragment with invalid children\n// https://github.com/microsoft/TypeScript/issues/62358\n\nexport interface FragmentProps {\n\tchildren?: Nil<JsxResult>[];\n}\n\n/**\n * The built-in Fragment Component wrapping multiple Components.\n */\n// @ts-expect-error fake overload to enable use with JSX\nexport function Fragment(props: JsxProps<FragmentProps>): JsxResult;\n\nexport function Fragment<TNode>(\n\tjsx: JsxObject,\n\thParent: HNode<TNode>,\n\tnUsedParent: TNode,\n\tnRealParent: TNode,\n\tnBefore: TNode | null,\n\tisBatch: boolean,\n) {\n\tmountJsx(jsx.children, hParent, nUsedParent, nRealParent, nBefore, isBatch);\n}\n","import type { Nil } from \"~/support/types\";\n\nimport { notify, S_ATOM, type Atom } from \"./Atom\";\nimport { link, unlink, type Dependency } from \"./Dependency\";\nimport { __DEV__assertNotEffect } from \"./Effect\";\nimport { getLifecycle } from \"./Lifecycle\";\n\n/**\n * Describes a Context distributing data throughout the Component hierarchy.\n * @see {@link createContext}\n */\nexport interface Context<T> {\n\t/** @internal */\n\treadonly $symbol: symbol;\n\n\t/**\n\t * A fake property kept for TypeScript to properly type-check Context compatibility.\n\t * @deprecated **Type only, does not exist at runtime!**\n\t */\n\treadonly $contract?: (value: T) => void;\n}\n\n/**\n * Creates a typed Context that can be used to propagate observable data throughout entire component\n * trees without \"prop drilling.\"\n * @see {@link context}\n */\nexport function createContext<T>(devId?: string): Context<T>;\n\nexport function createContext<T>(): Context<T> {\n\tlet $symbol = Symbol();\n\tif (__DEV__) {\n\t\tconst devId = arguments[0];\n\t\t$symbol = globalThis.__PYXIS_HMR__.state.restore(createContext, devId) ?? $symbol;\n\t\tglobalThis.__PYXIS_HMR__.state.preserve(createContext, devId, $symbol);\n\t}\n\n\treturn { $symbol };\n}\n\n\n/** @internal */\nexport interface ContextContainer {\n\t[key: symbol]: unknown;\n\treadonly $parent?: Nil<ContextContainer>;\n}\n\nlet $currentContainer: ContextContainer | null = null;\nlet $isNewContainer = false;\n\n/** @internal */\nexport function getContextContainer() {\n\treturn $currentContainer;\n}\n\n/** @internal */\nexport function setContextContainer(container: ContextContainer | null) {\n\t$currentContainer = container;\n\t$isNewContainer = false;\n}\n\n\ninterface ContextAtom<T> extends Atom<T> {\n\t$dep?: Nil<Dependency>;\n\t$ancestor?: Nil<Atom<T>>;\n\t$value?: T;\n}\n\n/**\n * Gets a consumer Atom for the given Context. This atom will be read-only.\n * @see {@link host}\n */\nexport function consumerOf<T>(context: Context<T>): Atom<T> | null {\n\tif (__DEV__) {\n\t\t__DEV__assertNotEffect();\n\t}\n\n\tconst { $symbol } = context;\n\tlet ptr: Nil<ContextContainer> = $currentContainer;\n\tlet atom;\n\twhile (ptr && !(atom = ptr[$symbol] as Atom<T> | undefined)) {\n\t\tptr = ptr.$parent;\n\t}\n\n\treturn atom ?? null;\n}\n\n/**\n * Marks the current component as a host for the given context. Returns a mutable ContextAtom;\n * Values written to it will be propagated to any descendant component that consumes the context via\n * `consumerOf(context)`.\n * @see {@link consumerOf}\n */\nexport function host<C>(\n\tcontext: C,\n\tdefaultValue?: C extends Context<infer T> ? T : never,\n\tdevId?: string,\n): C extends Context<infer T> ? ContextAtom<T> : never;\n\nexport function host<T>(context: Context<T>, defaultValue?: T) {\n\tif (__DEV__) {\n\t\t__DEV__assertNotEffect();\n\t}\n\n\tif (!$isNewContainer || !$currentContainer) {\n\t\t// split context, current component becomes a host\n\t\t$isNewContainer = true;\n\t\t$currentContainer = {\n\t\t\t$parent: $currentContainer,\n\t\t};\n\t}\n\n\tconst lifecycle = getLifecycle();\n\tif (__DEV__) {\n\t\tconst devId = arguments[2];\n\t\tglobalThis.__PYXIS_HMR__.state.restore(lifecycle, devId, value => {\n\t\t\tdefaultValue = value;\n\t\t});\n\t}\n\n\tconst localAtom: ContextAtom<T> = {\n\t\t[S_ATOM]: true,\n\t\t$lifecycle: lifecycle,\n\t\t$tracksValue: true,\n\t\t$value: defaultValue,\n\t\tget: getLocalValue,\n\t\tset: setValue,\n\t};\n\n\tif (defaultValue === undefined) {\n\t\tconst ancestorAtom = consumerOf(context);\n\t\tif (ancestorAtom) {\n\t\t\tlocalAtom.get = getAncestorValue;\n\t\t\tlocalAtom.$ancestor = ancestorAtom;\n\t\t\tlink(lifecycle, ancestorAtom, localAtom.$dep = {\n\t\t\t\t$fn: notify<T>,\n\t\t\t\t$a0: localAtom,\n\t\t\t});\n\t\t}\n\t}\n\n\tif (__DEV__) {\n\t\tlocalAtom.$devId = arguments[2];\n\t\tif (Object.hasOwn($currentContainer, context.$symbol)) {\n\t\t\tthrow new Error(\"Component declares multiple hosts of the same Context.\");\n\t\t}\n\t}\n\n\t$currentContainer[context.$symbol] = localAtom;\n\treturn localAtom;\n}\n\nfunction getAncestorValue<T>(this: ContextAtom<T>) {\n\treturn this.$ancestor!.get();\n}\n\nfunction getLocalValue<T>(this: ContextAtom<T>) {\n\treturn this.$value!;\n}\n\nfunction setValue<T>(this: ContextAtom<T>, value: T) {\n\tlet oldValue;\n\tif (this.$ancestor) {\n\t\toldValue = this.$ancestor.get();\n\t\tunlink(this.$dep!);\n\t\tthis.$dep = null;\n\t\tthis.$ancestor = null;\n\t\tthis.get = getLocalValue;\n\t}\n\telse {\n\t\toldValue = this.$value;\n\t}\n\n\tthis.$value = value;\n\tif (__DEV__) {\n\t\tglobalThis.__PYXIS_HMR__.state.preserve(this.$lifecycle, this.$devId, value);\n\t}\n\n\treturn !Object.is(oldValue, value);\n}\n","// The Myers diff algorithm is adapted from the implementation by Logan R. Kearsley, MIT license.\n// https://github.com/gliese1337/fast-myers-diff\n//\n//\n// Copyright 2021 Logan R. Kearsley\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and\n// associated documentation files (the \"Software\"), to deal in the Software without restriction,\n// including without limitation the rights to use, copy, modify, merge, publish, distribute,\n// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies or\n// substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT\n// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n/** @internal */\nexport const LC_CHANGE = 1;\n\n/** @internal */\nexport const LC_INSERT = 2;\n\n/** @internal */\nexport const LC_REMOVE = 3;\n\n/** @internal */\nexport const LC_CLEAR = 4;\n\nexport enum ChangeKind {\n\tChange = LC_CHANGE,\n\tInsert = LC_INSERT,\n\tRemove = LC_REMOVE,\n\tClear = LC_CLEAR,\n}\n\nexport interface ListDelta<T> {\n\treadonly changes: ListChange<T>[];\n\tlengthChange: number;\n}\n\nexport type ListChange<T> =\n\t| ListItemChanged<T>\n\t| ListItemInserted<T>\n\t| ListItemRemoved<T>\n\t| ListCleared;\n\nexport interface ListItemChanged<T> {\n\tkind: ChangeKind.Change;\n\tindex: number;\n\toldItem: T;\n\tnewItem: T;\n}\n\nexport interface ListItemInserted<T> {\n\tkind: ChangeKind.Insert;\n\tindex: number;\n\tnewItem: T;\n}\n\nexport interface ListItemRemoved<T> {\n\tkind: ChangeKind.Remove;\n\tindex: number;\n\toldItem: T;\n}\n\nexport interface ListCleared {\n\tkind: ChangeKind.Clear;\n\tindex: number;\n}\n\nexport interface Equals<T> {\n\t(item0: T, item1: T): boolean;\n}\n\ninterface DiffState<T> {\n\treadonly $eq: Equals<T>;\n\treadonly $list0: readonly T[];\n\treadonly $list1: readonly T[];\n\t$index0: number;\n\t$index1: number;\n\t$N: number;\n\t$M: number;\n\t$Z: number;\n\t$c: number;\n\treadonly $buffer: Uint8Array | Uint16Array | Uint32Array;\n\treadonly $stack: number[];\n\t$stackTop: number;\n\t$pxs: number;\n\t$pxe: number;\n\t$pys: number;\n\t$pye: number;\n\t$oxs: number;\n\t$oxe: number;\n\t$oys: number;\n\t$oye: number;\n}\n\n\n/** @internal */\nexport const EMPTY_DELTA: ListDelta<any> = {\n\tchanges: [],\n\tlengthChange: 0,\n};\n\n/** @internal */\nexport function createDelta<T>(): ListDelta<T> {\n\treturn {\n\t\tchanges: [],\n\t\tlengthChange: 0,\n\t};\n}\n\n/** @internal */\nexport function itemChanged<T>({ changes: $changes }: ListDelta<T>, at: number, oldItem: T, newItem: T) {\n\tconst ci = binarySearch($changes, at, latest);\n\tif (ci < 0) {\n\t\t// nothing at this index, add new delta\n\t\t$changes.splice(~ci, 0, {\n\t\t\tkind: LC_CHANGE,\n\t\t\tindex: at,\n\t\t\toldItem,\n\t\t\tnewItem,\n\t\t});\n\t}\n\telse {\n\t\t// delta(s) exist at this index already, there can only be:\n\t\t// - change -> change item\n\t\t// - insert -> change item\n\t\t// - remove -> append change\n\t\tconst current = $changes[ci];\n\t\tswitch (current.kind) {\n\t\t\tcase LC_CHANGE:\n\t\t\tcase LC_INSERT:\n\t\t\t\tcurrent.newItem = newItem;\n\t\t\t\tbreak;\n\n\t\t\tcase LC_REMOVE:\n\t\t\t\t$changes.splice(ci + 1, 0, {\n\t\t\t\t\tkind: LC_CHANGE,\n\t\t\t\t\tindex: at,\n\t\t\t\t\toldItem,\n\t\t\t\t\tnewItem,\n\t\t\t\t});\n\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/** @internal */\nexport function itemInserted<T>(delta: ListDelta<T>, at: number, item: T) {\n\tconst { changes: $changes } = delta;\n\n\tlet ci = binarySearch($changes, at, earliest);\n\tif (ci < 0) {\n\t\t// nothing at this index, add new delta\n\t\tci = ~ci;\n\t\t$changes.splice(ci, 0, {\n\t\t\tkind: LC_INSERT,\n\t\t\tindex: at,\n\t\t\tnewItem: item,\n\t\t});\n\t}\n\telse {\n\t\t// delta(s) exist at this index already, there can only be:\n\t\t// - change -> prepend with insert\n\t\t// - insert -> prepend another (new item before, existing get shifted right)\n\t\t// - remove -> replace with change\n\t\tconst current = $changes[ci];\n\t\tswitch (current.kind) {\n\t\t\tcase LC_CHANGE:\n\t\t\tcase LC_INSERT:\n\t\t\t\t$changes.splice(ci, 0, {\n\t\t\t\t\tkind: LC_INSERT,\n\t\t\t\t\tindex: at,\n\t\t\t\t\tnewItem: item,\n\t\t\t\t});\n\n\t\t\t\tbreak;\n\n\t\t\tcase LC_REMOVE:\n\t\t\t\t// insert cancels the removal -> the slot's old item is now replaced, becomes a change\n\t\t\t\t// (oldItem carries over from the removal, it's the item that was originally here)\n\t\t\t\t(current as unknown as ListItemChanged<T>).kind = LC_CHANGE;\n\t\t\t\t(current as unknown as ListItemChanged<T>).newItem = item;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t// shift the indices of later changes\n\tconst { length } = $changes;\n\twhile (++ci < length) {\n\t\t$changes[ci].index += 1;\n\t}\n\n\t// update the overall change in list length\n\tdelta.lengthChange += 1;\n}\n\n/** @internal */\nexport function itemRemoved<T>(delta: ListDelta<T>, at: number, item: T) {\n\tconst { changes: $changes } = delta;\n\n\tlet ci = binarySearch($changes, at, latest);\n\tif (ci < 0) {\n\t\t// nothing at this index, add new delta\n\t\tci = ~ci;\n\t\t$changes.splice(ci, 0, {\n\t\t\tkind: LC_REMOVE,\n\t\t\tindex: at,\n\t\t\toldItem: item,\n\t\t});\n\t}\n\telse {\n\t\t// delta(s) exist at this index already, there can only be:\n\t\t// - change -> replace with removal\n\t\t// - insert -> remove it\n\t\t// - remove -> append another\n\t\tconst current = $changes[ci];\n\t\tswitch (current.kind) {\n\t\t\tcase LC_CHANGE:\n\t\t\t\t// removal cancels the change -> becomes a plain removal (oldItem carries over from\n\t\t\t\t// the change, it's the item originally at this index)\n\t\t\t\t(current as unknown as ListItemRemoved<T>).kind = LC_REMOVE;\n\t\t\t\t(current as unknown as ListItemChanged<undefined>).newItem = undefined;\n\t\t\t\tbreak;\n\n\t\t\tcase LC_INSERT:\n\t\t\t\t// canceling the insert shifts subsequent entries left so they must be re-indexed\n\t\t\t\t// -> adjust `ci` to start from the correct offset\n\t\t\t\t$changes.splice(ci--, 1);\n\t\t\t\tbreak;\n\n\t\t\tcase LC_REMOVE:\n\t\t\t\t$changes.splice(++ci, 0, {\n\t\t\t\t\tkind: LC_REMOVE,\n\t\t\t\t\tindex: at,\n\t\t\t\t\toldItem: item,\n\t\t\t\t});\n\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t// shift the indices of later changes\n\tconst { length } = $changes;\n\twhile (++ci < length) {\n\t\t$changes[ci].index -= 1;\n\t}\n\n\t// update the overall change in list length\n\tdelta.lengthChange -= 1;\n}\n\n/** @internal */\nexport function listCleared<T>(delta: ListDelta<T>, count: number) {\n\tconst { changes: $changes } = delta;\n\t$changes.length = 0;\n\t$changes.push({\n\t\tkind: LC_CLEAR,\n\t\tindex: -1,\n\t});\n\n\tdelta.lengthChange -= count;\n}\n\n/** @internal */\nexport function listSynced<T>(delta: ListDelta<T>, oldState: readonly T[], newState: readonly T[], eq: Equals<T>) {\n\tlet index = 0;\n\tlet N = oldState.length;\n\tlet M = newState.length;\n\n\t// eliminate common prefix\n\twhile (index < N && index < M && eq(oldState[index], newState[index])) {\n\t\tindex += 1;\n\t}\n\n\t// check for list equality\n\tif (index === N && index === M) {\n\t\treturn;\n\t}\n\n\t// eliminate common suffix\n\twhile (N > index && M > index && eq(oldState[N - 1], newState[M - 1])) {\n\t\tN -= 1;\n\t\tM -= 1;\n\t}\n\n\t// run Myers diff on the smallest possible sub-lists\n\tconst Z = (Math.min(N, M) + 1) * 2;\n\tconst L = N + M;\n\tconst state: DiffState<T> = {\n\t\t$eq: eq,\n\t\t$list0: oldState,\n\t\t$list1: newState,\n\t\t$index0: index,\n\t\t$index1: index,\n\t\t$N: N,\n\t\t$M: M,\n\t\t$Z: Z,\n\t\t$c: 0,\n\t\t$buffer: new (L <= 0xff ? Uint8Array : L <= 0xffff ? Uint16Array : Uint32Array)(Z + Z),\n\t\t$stack: [],\n\t\t$stackTop: 0,\n\t\t$pxs: -1,\n\t\t$pxe: -1,\n\t\t$pys: -1,\n\t\t$pye: -1,\n\t\t$oxs: -1,\n\t\t$oxe: -1,\n\t\t$oys: -1,\n\t\t$oye: -1,\n\t};\n\n\tlet offset = 0;\n\tlet rs, re, is, ie, r, i;\n\tdo {\n\t\tmyersDiff(state);\n\t\tif (state.$c === 1) {\n\t\t\trs = state.$oxs;\n\t\t\tre = state.$oxe;\n\t\t\tis = state.$oys;\n\t\t\tie = state.$oye;\n\t\t}\n\t\telse if (state.$pxs >= 0) {\n\t\t\trs = state.$pxs;\n\t\t\tre = state.$pxe;\n\t\t\tis = state.$pys;\n\t\t\tie = state.$pye;\n\t\t}\n\t\telse {\n\t\t\tbreak;\n\t\t}\n\n\t\tfor (r = rs; r < re; r += 1) {\n\t\t\titemRemoved(delta, rs + offset, oldState[r]); // TODO: verify this\n\t\t}\n\n\t\tfor (i = is; i < ie; i += 1) {\n\t\t\titemInserted(delta, rs + offset, newState[i]);\n\t\t\toffset += 1;\n\t\t}\n\n\t\toffset -= re - rs;\n\t}\n\twhile (state.$c < 2);\n}\n\n\ninterface SearchBias {\n\t(changes: readonly ListChange<unknown>[], index: number, mid: number, min: number, max: number): number;\n}\n\nconst latest: SearchBias = (changes, index, mid, _min, max) => {\n\tlet i = mid;\n\twhile (++i < max && changes[i].index === index) ;\n\treturn i - 1;\n};\n\nconst earliest: SearchBias = (changes, index, mid, min, _max) => {\n\tlet i = mid;\n\twhile (--i >= min && changes[i].index === index) ;\n\treturn i + 1;\n};\n\nfunction binarySearch<T>(changes: readonly ListChange<T>[], index: number, bias: SearchBias) {\n\tlet min = 0;\n\tlet max = changes.length;\n\tlet mid;\n\tlet tmp;\n\n\twhile (min < max) {\n\t\tmid = (min + max) >>> 1;\n\t\ttmp = changes[mid].index;\n\n\t\tif (index < tmp) {\n\t\t\tmax = mid;\n\t\t}\n\t\telse if (index > tmp) {\n\t\t\tmin = mid + 1;\n\t\t}\n\t\telse {\n\t\t\t// found matching index, but there may be more deltas with the same index -> apply bias\n\t\t\treturn bias(changes, index, mid, min, max);\n\t\t}\n\t}\n\n\treturn ~min;\n}\n\nfunction myersDiff<T>(state: DiffState<T>) {\n\tconst { $list0, $list1, $buffer, $stack, $eq } = state;\n\tlet { $index0, $index1, $N, $M, $Z, $c, $stackTop } = state;\n\tlet W, L, parity, offsetX, offsetY, z, h, hMax, k, kMin, kMax, gkm, gkp, u, v, x, y, pkm, pkp, sx;\n\n\twhile (true) {\n\t\tswitch ($c) {\n\t\t\tcase 0: {\n\t\t\t\tZ_block: while ($N > 0 && $M > 0) {\n\t\t\t\t\tW = $N - $M;\n\t\t\t\t\tL = $N + $M;\n\t\t\t\t\tparity = L & 1;\n\t\t\t\t\toffsetX = $index0 + $N - 1;\n\t\t\t\t\toffsetY = $index1 + $M - 1;\n\t\t\t\t\thMax = (L + parity) / 2;\n\n\t\t\t\t\t$buffer.fill(0, 0, $Z + $Z);\n\t\t\t\t\th_loop: for (h = 0; h <= hMax; h += 1) {\n\t\t\t\t\t\tkMin = 2 * Math.max(0, h - $M) - h;\n\t\t\t\t\t\tkMax = h - 2 * Math.max(0, h - $N);\n\n\t\t\t\t\t\t// forward pass\n\t\t\t\t\t\tfor (k = kMin; k <= kMax; k += 2) {\n\t\t\t\t\t\t\tgkm = $buffer[k - 1 - $Z * Math.floor((k - 1)/$Z)];\n\t\t\t\t\t\t\tgkp = $buffer[k + 1 - $Z * Math.floor((k + 1)/$Z)];\n\t\t\t\t\t\t\tu = (k === -h || (k !== h && gkm < gkp)) ? gkp : gkm + 1;\n\t\t\t\t\t\t\tv = u - k;\n\t\t\t\t\t\t\tx = u;\n\t\t\t\t\t\t\ty = v;\n\t\t\t\t\t\t\twhile (x < $N && y < $M && $eq($list0[$index0 + x], $list1[$index1 + y])) {\n\t\t\t\t\t\t\t\tx += 1;\n\t\t\t\t\t\t\t\ty += 1;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t$buffer[k - $Z * Math.floor(k / $Z)] = x;\n\t\t\t\t\t\t\tif (parity === 1 && (z = W - k) >= 1 - h && z < h && x + $buffer[$Z + z - $Z * Math.floor(z / $Z)] >= $N) {\n\t\t\t\t\t\t\t\tif (h > 1 || x !== u) {\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = $index0 + x;\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = $index1 + y;\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = $N - x;\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = $M - y;\n\t\t\t\t\t\t\t\t\t$N = u;\n\t\t\t\t\t\t\t\t\t$M = v;\n\t\t\t\t\t\t\t\t\t$Z = 2 * (Math.min($N, $M) + 1);\n\t\t\t\t\t\t\t\t\tcontinue Z_block;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tbreak h_loop;\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\n\t\t\t\t\t\t// reverse pass\n\t\t\t\t\t\tfor (k = kMin; k <= kMax; k += 2) {\n\t\t\t\t\t\t\tpkm = $buffer[$Z + k - 1 - $Z * Math.floor((k - 1)/$Z)];\n\t\t\t\t\t\t\tpkp = $buffer[$Z + k + 1 - $Z * Math.floor((k + 1)/$Z)];\n\t\t\t\t\t\t\tu = (k === -h || (k !== h && pkm < pkp)) ? pkp : pkm + 1;\n\t\t\t\t\t\t\tv = u - k;\n\t\t\t\t\t\t\tx = u;\n\t\t\t\t\t\t\ty = v;\n\t\t\t\t\t\t\twhile (x < $N && y < $M && $eq($list0[offsetX - x], $list1[offsetY - y])) {\n\t\t\t\t\t\t\t\tx += 1;\n\t\t\t\t\t\t\t\ty += 1;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t$buffer[$Z + k - $Z * Math.floor(k/$Z)] = x;\n\t\t\t\t\t\t\tif (parity === 0 && (z = W - k) >= -h && z <= h && x + $buffer[z - $Z * Math.floor(z/$Z)] >= $N) {\n\t\t\t\t\t\t\t\tif (h > 0 || x !== u) {\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = $index0 + $N - u;\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = $index1 + $M - v;\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = u;\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = v;\n\t\t\t\t\t\t\t\t\t$N = $N - x;\n\t\t\t\t\t\t\t\t\t$M = $M - y;\n\t\t\t\t\t\t\t\t\t$Z = 2 * (Math.min($N, $M) + 1);\n\t\t\t\t\t\t\t\t\tcontinue Z_block;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tbreak h_loop;\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 ($N === $M) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ($M > $N) {\n\t\t\t\t\t\t$index0 += $N;\n\t\t\t\t\t\t$index1 += $N;\n\t\t\t\t\t\t$M -= $N;\n\t\t\t\t\t\t$N = 0;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t$index0 += $M;\n\t\t\t\t\t\t$index1 += $M;\n\t\t\t\t\t\t$N -= $M;\n\t\t\t\t\t\t$M = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\t// we already know either N or M is zero, so we can skip the extra check at the top of the loop\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// yield delete_start, delete_end, insert_start, insert_end\n\t\t\t\t// at this point, at least one of N & M is zero, or we wouldn't have gotten out of the preceding loop yet\n\t\t\t\tif ($N + $M !== 0) {\n\t\t\t\t\tif (state.$pxe === $index0 || state.$pye === $index1) {\n\t\t\t\t\t\t// it is a contiguous difference, extend the existing one\n\t\t\t\t\t\tstate.$pxe = $index0 + $N;\n\t\t\t\t\t\tstate.$pye = $index1 + $M;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsx = state.$pxs;\n\t\t\t\t\t\tstate.$oxs = state.$pxs;\n\t\t\t\t\t\tstate.$oxe = state.$pxe;\n\t\t\t\t\t\tstate.$oys = state.$pys;\n\t\t\t\t\t\tstate.$oye = state.$pye;\n\n\t\t\t\t\t\t// defer this one until we can check the next one\n\t\t\t\t\t\tstate.$pxs = $index0;\n\t\t\t\t\t\tstate.$pxe = $index0 + $N;\n\t\t\t\t\t\tstate.$pys = $index1;\n\t\t\t\t\t\tstate.$pye = $index1 + $M;\n\n\t\t\t\t\t\tif (sx >= 0) {\n\t\t\t\t\t\t\tstate.$index0 = $index0;\n\t\t\t\t\t\t\tstate.$index1 = $index1;\n\t\t\t\t\t\t\tstate.$N = $N;\n\t\t\t\t\t\t\tstate.$M = $M;\n\t\t\t\t\t\t\tstate.$Z = $Z;\n\t\t\t\t\t\t\tstate.$stackTop = $stackTop;\n\t\t\t\t\t\t\tstate.$c = 1;\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcase 1: {\n\t\t\t\tif ($stackTop === 0) {\n\t\t\t\t\tstate.$c = 2;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t$M = $stack[--$stackTop];\n\t\t\t\t$N = $stack[--$stackTop];\n\t\t\t\t$index1 = $stack[--$stackTop];\n\t\t\t\t$index0 = $stack[--$stackTop];\n\t\t\t\t$Z = 2 * (Math.min($N, $M) + 1);\n\t\t\t\t$c = 0;\n\t\t\t}\n\t\t}\n\t}\n}\n","import type { Nil } from \"~/support/types\";\n\nimport { isAtom, notify, S_ATOM, type Atom, type MaybeAtom } from \"./Atom\";\nimport { link, unlink, type Dependency } from \"./Dependency\";\nimport { __DEV__assertNotEffect } from \"./Effect\";\nimport { getLifecycle, type Lifecycle } from \"./Lifecycle\";\nimport { scheduleTick } from \"./Scheduler\";\n\nexport interface ProxyAtom<T> extends Atom<T> {\n\t/**\n\t * Binds this ProxyAtom to a new value. If it is an Atom, the proxy will mirror it, otherwise it\n\t * will be a read-only atom with a static value until rebound.\n\t */\n\tuse(value: MaybeAtom<T>): void;\n\n\t/** @internal */\n\tuse(value: MaybeAtom<T>, canNotify?: boolean): void;\n\n\n\t/** @internal */\n\t$dep?: Dependency;\n\n\t/** @internal */\n\t$bound?: Nil<Atom<T>>;\n\n\t/** @internal */\n\t$value?: Nil<T>;\n}\n\n/**\n * Creates a ProxyAtom bound to the provided initial value. If it is an Atom, the proxy will mirror\n * it, otherwise it will be a read-only atom with a static value until rebound.\n */\nexport function proxyOf<T>(initialValue: MaybeAtom<T>, lifecycle = getLifecycle()): ProxyAtom<T> {\n\tif (__DEV__) {\n\t\t__DEV__assertNotEffect();\n\t}\n\n\t// `set` is assigned by the use call below\n\tconst self: Omit<ProxyAtom<T>, \"set\"> = {\n\t\t[S_ATOM]: true,\n\t\t$lifecycle: lifecycle,\n\t\tuse,\n\t\tget: getStaticValue,\n\t};\n\n\tself.use(initialValue, false);\n\treturn self as ProxyAtom<T>;\n}\n\nfunction use<T>(this: ProxyAtom<T>, value: MaybeAtom<T>, canNotify: boolean = true) {\n\tif (this.$dep) {\n\t\tunlink(this.$dep);\n\t}\n\n\tconst oldValue = this.get();\n\tif (isAtom(value)) {\n\t\tthis.$bound = value;\n\t\tthis.$value = null;\n\t\tthis.get = getBoundValue;\n\t\tthis.set = setBoundValue;\n\t\tlink(this.$lifecycle, value, this.$dep ??= {\n\t\t\t$fn: notify<T>,\n\t\t\t$a0: this,\n\t\t});\n\t}\n\telse {\n\t\tthis.$bound = null;\n\t\tthis.$value = value;\n\t\tthis.get = getStaticValue;\n\t\tthis.set = setStaticValue;\n\t}\n\n\tif (canNotify && !Object.is(oldValue, this.get())) {\n\t\tscheduleTick(this.$lifecycle, this.$notify ??= {\n\t\t\t$fn: notify,\n\t\t\t$a0: this,\n\t\t});\n\t}\n}\n\nfunction getBoundValue<T>(this: ProxyAtom<T>) {\n\t// calling raw `get` doesn't report access, which is what we want\n\t// sites accessing this proxy atom should do so via read, which will report\n\t// access on the proxy rather than the bound atom which may change\n\treturn this.$bound!.get();\n}\n\nfunction setBoundValue<T>(this: ProxyAtom<T>, value: T) {\n\t// set the bound atom and schedule a notification if it changed - copies the\n\t// behavior of `write`, skipping parts we don't need here.\n\tconst atom = this.$bound!;\n\tif (atom.set(value)) {\n\t\tscheduleTick(atom.$lifecycle, atom.$notify ??= {\n\t\t\t$fn: notify,\n\t\t\t$a0: atom,\n\t\t});\n\t}\n\n\t// always return false, even if the bound atom changed - this way the\n\t// `write` and `update` functions won't schedule a redundant notification\n\t// for this proxy\n\treturn false;\n}\n\nfunction getStaticValue<T>(this: ProxyAtom<T>) {\n\treturn this.$value!;\n}\n\nfunction setStaticValue(this: ProxyAtom<any>) {\n\treturn false;\n}\n\n/** @internal */\nexport type ProxyObject =\n\t& { proxied: any }\n\t& { [_ in PropertyKey]?: ProxyAtom<any> };\n\nexport type Proxied<T, P extends readonly (keyof T)[]> =\n\t& { readonly proxied: T }\n\t& { readonly [K in P[number]]: ProxyAtom<T[K] extends MaybeAtom<infer V> ? V : T[K]> };\n\nconst EMPTY_SOURCE: Record<PropertyKey, unknown> = {};\n\n/**\n * Copies select keys from a data object into a new object where values are all wrapped in\n * ProxyAtoms and can be updated later.\n * @see {@link updateProxy}\n * @internal\n **/\nexport function createProxy(lifecycle: Lifecycle, data: any, keys: readonly PropertyKey[]) {\n\tconst source = isObject(data) ? data : EMPTY_SOURCE;\n\tconst proxy = {} as ProxyObject;\n\tconst { length } = keys;\n\n\tlet index = 0;\n\tlet key;\n\n\tfor (; index < length; index += 1) {\n\t\tkey = keys[index];\n\t\tproxy[key] = proxyOf(source[key], lifecycle);\n\t}\n\n\tproxy.proxied = data;\n\treturn proxy;\n}\n\n/**\n * Updates the values proxied by a previously created proxy object. The keys array must be the same\n * as was used during creation (or a subset).\n * @see {@link createProxy}\n * @internal\n **/\nexport function updateProxy(proxy: ProxyObject, data: any, keys: readonly PropertyKey[]) {\n\tconst source = isObject(data) ? data : EMPTY_SOURCE;\n\tconst { length } = keys;\n\tproxy.proxied = data;\n\n\tlet index = 0;\n\tlet key;\n\n\tfor (; index < length; index += 1) {\n\t\tkey = keys[index];\n\t\tproxy[key]!.use(source[key]);\n\t}\n}\n\nfunction isObject(value: unknown): value is Record<PropertyKey, unknown> {\n\treturn value !== null && typeof value === \"object\";\n}\n","import { getContextContainer, setContextContainer } from \"~/data/Context\";\nimport { link } from \"~/data/Dependency\";\nimport { withLifecycle } from \"~/data/Lifecycle\";\nimport type { ReadonlyList } from \"~/data/List\";\nimport { LC_CHANGE, LC_CLEAR, LC_INSERT, LC_REMOVE } from \"~/data/ListDelta\";\nimport { createProxy, updateProxy, type Proxied } from \"~/data/ProxyAtom\";\nimport type { DataTemplate, JsxObject, JsxProps, JsxResult } from \"~/Component\";\nimport { fork, insert, mount, track, unmount, untrack, type MountingGroup, type HNode } from \"~/Renderer\";\n\nexport interface RemountIteratorProps<T> {\n\tsource: ReadonlyList<T>;\n\tproxy?: never; // discriminator\n\tchildren: [ template: DataTemplate<T> ];\n}\n\nexport interface ProxyIteratorProps<T, P extends readonly (keyof T)[]> {\n\tsource: ReadonlyList<T>;\n\tproxy: P;\n\tchildren: [ template: DataTemplate<Proxied<T, P>> ];\n}\n\ninterface IteratorItemGroup<TNode> extends MountingGroup<TNode> {\n\t$marker: TNode;\n\t$data?: any;\n}\n\ninterface PendingItem<T> {\n\treadonly $index: number;\n\treadonly $item: T;\n}\n\n/**\n * The built-in Iterator Component efficiently rendering collections of items\n * based on updates from a Pyxis `list`.\n */\n// @ts-expect-error fake overload to enable use with JSX\nexport function Iterator<T>(props: JsxProps<RemountIteratorProps<T>>): JsxResult;\n\nexport function Iterator<T, P extends readonly (keyof T)[]>(props: JsxProps<ProxyIteratorProps<T, P>>): JsxResult;\n\nexport function Iterator<TNode, T>(\n\tjsx: JsxObject,\n\thParent: HNode<TNode>,\n\tnUsedParent: TNode,\n\tnRealParent: TNode,\n\tnBefore: TNode | null,\n\tisBatch: boolean,\n) {\n\tconst source = jsx.source as ReadonlyList<T>;\n\tconst proxyKeys = jsx.proxy as readonly PropertyKey[] | undefined;\n\tconst isProxy = proxyKeys !== undefined;\n\tconst template = jsx.children[0] as DataTemplate<T>;\n\n\t// create master group\n\tconst hGroup = fork(hParent) as MountingGroup<TNode>;\n\tconst context = getContextContainer();\n\n\tconst { adapter } = hGroup;\n\tconst shouldBatch = Boolean(adapter.batch);\n\tconst nListEndMarker = __DEV__ ? adapter.marker(\"/Iterator\") : adapter.marker();\n\n\t// list change handler\n\tlet items: IteratorItemGroup<TNode>[];\n\tlet skipDelta = Boolean(source.$delta);\n\tconst onDelta = () => {\n\t\tif (skipDelta) {\n\t\t\t// a delta might've been pending during initial render, but we already rendered against\n\t\t\t// the lists's up-to-date state, so such delta must be skipped -> bail out\n\t\t\tskipDelta = false;\n\t\t\treturn;\n\t\t}\n\n\t\tconst delta = source.$delta!;\n\t\tconst { changes, lengthChange } = delta;\n\t\tconst cMax = changes.length;\n\t\tconst iMax = items.length + lengthChange;\n\t\tconst newItems = new Array<IteratorItemGroup<TNode>>(iMax);\n\t\tconst pending: PendingItem<T>[] = [];\n\t\tlet recycled: IteratorItemGroup<TNode>[] = [];\n\t\tlet item: IteratorItemGroup<TNode>;\n\t\tlet inserted = 0;\n\t\tlet ci = 0; // change index\n\t\tlet oi = 0; // old items index\n\t\tlet ni = 0; // new items index\n\t\tlet change;\n\t\tlet ref;\n\t\tlet tmp;\n\n\t\t// batching\n\t\tlet isLocalBatch = false;\n\t\tlet nBatchParent = nRealParent;\n\t\tlet nBatchBefore: TNode | null = null;\n\n\t\tfor (; ci < cMax; ci += 1) {\n\t\t\tchange = changes[ci];\n\n\t\t\t// copy unchanged items\n\t\t\twhile (ni < change.index) {\n\t\t\t\tnewItems[ni++] = items[oi++];\n\t\t\t}\n\n\t\t\t// apply change\n\t\t\tswitch (change.kind) {\n\t\t\t\tcase LC_CHANGE:\n\t\t\t\t\titem = (newItems[ni++] = items[oi++]);\n\t\t\t\t\tif (isProxy) {\n\t\t\t\t\t\tupdateProxy(item.$data, change.newItem, proxyKeys);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// no need to untrack and re-track, position doesn't change\n\t\t\t\t\t\tunmount(item);\n\n\t\t\t\t\t\t// unmount removes marker, we must re-insert it\n\t\t\t\t\t\tref = items[oi]?.$marker ?? nListEndMarker;\n\t\t\t\t\t\tinsert(\n\t\t\t\t\t\t\t/* hNode = */ item.$marker,\n\t\t\t\t\t\t\t/* children = */ null,\n\t\t\t\t\t\t\t/* hParent = */ item,\n\t\t\t\t\t\t\t/* nUsedParent = */ nRealParent,\n\t\t\t\t\t\t\t/* nBefore = */ ref,\n\t\t\t\t\t\t\t/* isBatch = */ false,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tsetContextContainer(context);\n\t\t\t\t\t\tmount(\n\t\t\t\t\t\t\t/* jsx = */ withLifecycle(item, template, (item.$data = change.newItem)),\n\t\t\t\t\t\t\t/* hGroup = */ item,\n\t\t\t\t\t\t\t/* nUsedParent = */ nRealParent,\n\t\t\t\t\t\t\t/* nRealParent = */ nRealParent,\n\t\t\t\t\t\t\t/* nBefore = */ ref,\n\t\t\t\t\t\t\t/* isBatch = */ false,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase LC_INSERT:\n\t\t\t\t\tif (!isProxy || inserted < lengthChange) {\n\t\t\t\t\t\t// we're either in remount mode, or no more items are available for recycling\n\t\t\t\t\t\titem = (newItems[ni++] = fork(hGroup, items[oi]) as IteratorItemGroup<TNode>);\n\t\t\t\t\t\titem.$marker = __DEV__ ? adapter.marker(\"IteratorItem\") : adapter.marker();\n\t\t\t\t\t\titem.$data = isProxy ? createProxy(item, change.newItem, proxyKeys) : change.newItem;\n\t\t\t\t\t\tinserted += 1;\n\n\t\t\t\t\t\tref = items[oi]?.$marker ?? nListEndMarker;\n\t\t\t\t\t\tif (!isLocalBatch) {\n\t\t\t\t\t\t\tif (shouldBatch) {\n\t\t\t\t\t\t\t\tisLocalBatch = true;\n\t\t\t\t\t\t\t\tnBatchParent = adapter.batch!();\n\t\t\t\t\t\t\t\tnBatchBefore = null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tnBatchBefore = ref;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// insert start marker to preserve position in the document\n\t\t\t\t\t\tinsert(\n\t\t\t\t\t\t\t/* hNode = */ item.$marker,\n\t\t\t\t\t\t\t/* children = */ null,\n\t\t\t\t\t\t\t/* hParent = */ item,\n\t\t\t\t\t\t\t/* nUsedParent = */ nBatchParent,\n\t\t\t\t\t\t\t/* nBefore = */ nBatchBefore,\n\t\t\t\t\t\t\t/* isBatch = */ isLocalBatch,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tsetContextContainer(context);\n\t\t\t\t\t\tmount(\n\t\t\t\t\t\t\t/* jsx = */ withLifecycle(item, template, item.$data),\n\t\t\t\t\t\t\t/* hGroup = */ item,\n\t\t\t\t\t\t\t/* nUsedParent = */ nBatchParent,\n\t\t\t\t\t\t\t/* nRealParent = */ nRealParent,\n\t\t\t\t\t\t\t/* nBefore = */ nBatchBefore,\n\t\t\t\t\t\t\t/* isBatch = */ isLocalBatch,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (isLocalBatch && (\n\t\t\t\t\t\t\t// we must commit the current batch if:\n\t\t\t\t\t\t\tinserted >= lengthChange ||\t\t// next insert will use recycled\n\t\t\t\t\t\t\t!(tmp = changes[ci + 1]) ||\t\t// no next change exists\n\t\t\t\t\t\t\ttmp.kind !== LC_INSERT ||\t\t// next change is not an insert\n\t\t\t\t\t\t\ttmp.index !== ni\t\t\t\t// next insert is not consecutive\n\t\t\t\t\t\t)) {\n\t\t\t\t\t\t\tadapter.insert(nBatchParent, nRealParent, ref);\n\t\t\t\t\t\t\tnBatchParent = nRealParent;\n\t\t\t\t\t\t\tisLocalBatch = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// we know enough items will be removed -> add a pending item\n\t\t\t\t\t\tpending.push({\n\t\t\t\t\t\t\t$index: ni++,\n\t\t\t\t\t\t\t$item: change.newItem,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase LC_REMOVE:\n\t\t\t\t\titem = items[oi++];\n\t\t\t\t\tif (isProxy) {\n\t\t\t\t\t\trecycled.push(item);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tunmount(item);\n\t\t\t\t\t}\n\n\t\t\t\t\tuntrack(item);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase LC_CLEAR:\n\t\t\t\t\t// clear is always the first change within a delta, has index = -1 and is only\n\t\t\t\t\t// ever followed by inserts - thus we can directly recycle the items array, it\n\t\t\t\t\t// won't get mutated\n\t\t\t\t\tif (isProxy) {\n\t\t\t\t\t\trecycled = items;\n\t\t\t\t\t\trecycled.forEach(untrack);\n\t\t\t\t\t\toi = items.length;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\twhile (oi < items.length) {\n\t\t\t\t\t\t\titem = items[oi++];\n\t\t\t\t\t\t\tunmount(item);\n\t\t\t\t\t\t\tuntrack(item);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// copy remaining unchanged\n\t\twhile (ni < iMax) {\n\t\t\tnewItems[ni++] = items[oi++];\n\t\t}\n\n\t\t// fulfill pending items with recycled ones\n\t\tlet pi = pending.length - 1; // pending items index\n\t\tlet ri = recycled.length - 1; // recycled items index\n\t\twhile (pi >= 0) {\n\t\t\ttmp = pending[pi--];\n\t\t\titem = (newItems[tmp.$index] = recycled[ri--]);\n\t\t\tupdateProxy(item.$data, tmp.$item, proxyKeys!);\n\t\t\ttrack(item, hGroup, ref = newItems[tmp.$index + 1]);\n\n\t\t\tsetContextContainer(context);\n\t\t\tmount(\n\t\t\t\t/* jsx = */ withLifecycle(item, template, item.$data),\n\t\t\t\t/* hGroup = */ item,\n\t\t\t\t/* nUsedParent = */ nRealParent,\n\t\t\t\t/* nRealParent = */ nRealParent,\n\t\t\t\t/* nBefore = */ ref?.$marker ?? nListEndMarker,\n\t\t\t\t/* isBatch = */ false,\n\t\t\t);\n\t\t}\n\n\t\t// unmount unused\n\t\twhile (ri >= 0) {\n\t\t\titem = recycled[ri--];\n\t\t\tunmount(item);\n\t\t\tuntrack(item);\n\t\t}\n\n\t\titems = newItems;\n\t};\n\n\tlink(hGroup, source, { $fn: onDelta });\n\n\t// initial render\n\t{\n\t\tlet nBatchParent = nUsedParent;\n\t\tlet nBatchBefore = nBefore;\n\n\t\tconst isLocalBatch = shouldBatch && !isBatch && source.$items.length > 0;\n\t\tif (isLocalBatch) {\n\t\t\tnBatchParent = adapter.batch!();\n\t\t\tnBatchBefore = null;\n\t\t}\n\n\t\tconst isAnyBatch = isLocalBatch || isBatch;\n\t\titems = source.$items.map((data) => {\n\t\t\tconst item = fork(hGroup) as IteratorItemGroup<TNode>;\n\t\t\titem.$marker = __DEV__ ? adapter.marker(\"IteratorItem\") : adapter.marker();\n\t\t\titem.$data = isProxy ? createProxy(item, data, proxyKeys) : data;\n\n\t\t\tinsert(item.$marker, null, item, nBatchParent, nBatchBefore, isAnyBatch);\n\t\t\tmount(\n\t\t\t\t/* jsx = */ withLifecycle(item, template, item.$data),\n\t\t\t\t/* hGroup = */ item,\n\t\t\t\t/* nUsedParent = */ nBatchParent,\n\t\t\t\t/* nRealParent = */ nRealParent,\n\t\t\t\t/* nBefore = */ nBatchBefore,\n\t\t\t\t/* isBatch = */ isAnyBatch,\n\t\t\t);\n\n\t\t\treturn item;\n\t\t});\n\n\t\t// insert end marker to preserve position in the document\n\t\tinsert(nListEndMarker, null, hGroup, nBatchParent, nBatchBefore, isAnyBatch);\n\n\t\t// commit batch, if it's local\n\t\tif (isLocalBatch) {\n\t\t\tadapter.insert(nBatchParent, nUsedParent, nBefore);\n\t\t}\n\t}\n\n\t// content is already rendered, only call mount (with empty jsx) to propagate mount notifications\n\tmount(null, hGroup, nUsedParent, nRealParent, nBefore, isBatch);\n}\n","import { isAtom } from \"~/data/Atom\";\nimport type { JsxObject } from \"~/Component\";\nimport { insert, type HNode } from \"~/Renderer\";\nimport { bind } from \"~/data/Dependency\";\n\nconst RE_EXT = /^([^:]+?):(.+)$/;\n\n/** @internal */\n// @ts-expect-error this is a unique symbol at runtime\nexport const S_TAG_NAME: unique symbol = __DEV__ ? Symbol.for(\"pyxis:tagName\") : Symbol();\n\nexport function Native<TNode>(\n\tjsx: JsxObject,\n\thParent: HNode<TNode>,\n\tnUsedParent: TNode,\n\t_nRealParent: TNode,\n\tnBefore: TNode | null,\n\tisBatch: boolean,\n) {\n\tconst hGroup = hParent.$ng;\n\tconst { adapter, $extensions } = hGroup;\n\tconst nNode = adapter.element(jsx[S_TAG_NAME]!);\n\n\tlet name;\n\tlet match;\n\tlet value;\n\n\t// for..in doesn't iterate symbol keys, so we don't need to manually exclude\n\t// internal symbols (S_COMPONENT, S_TAG_NAME, S_DEV_INFO), just children\n\tfor (name in jsx) {\n\t\tmatch = RE_EXT.exec(name);\n\t\tvalue = jsx[name];\n\t\tif (match) {\n\t\t\t$extensions[match[1]]?.set(nNode, match[2], value, hGroup);\n\t\t}\n\t\telse if (name !== \"children\") {\n\t\t\tif (isAtom(value)) {\n\t\t\t\tconst prop = name;\n\t\t\t\tconst atom = value;\n\t\t\t\tbind(hGroup, atom, () => {\n\t\t\t\t\tadapter.set(nNode, prop, atom.get());\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tadapter.set(nNode, name, value);\n\t\t\t}\n\t\t}\n\t}\n\n\tinsert(nNode, jsx.children, hParent, nUsedParent, nBefore, isBatch);\n}\n","import { isAtom, read, type MaybeAtom, type ReadAtom } from \"~/data/Atom\";\nimport { getContextContainer, setContextContainer } from \"~/data/Context\";\nimport { link } from \"~/data/Dependency\";\nimport { effect } from \"~/data/Effect\";\nimport { withLifecycle } from \"~/data/Lifecycle\";\nimport { createProxy, updateProxy, type Proxied, type ProxyObject } from \"~/data/ProxyAtom\";\nimport type { Nil } from \"~/support/types\";\nimport type { DataTemplate, JsxChildren, JsxObject, JsxProps, JsxResult } from \"~/Component\";\nimport { insert, mount, mountJsx, fork, unmount, type HNode } from \"~/Renderer\";\n\nexport interface ShowProps {\n\twhen?: MaybeAtom<boolean>;\n\tchildren: JsxChildren;\n}\n\nexport interface ShowDataProps<T> {\n\twhen?: MaybeAtom<boolean>;\n\tproxy?: never;\n\tdata: MaybeAtom<T>;\n\tchildren: [ template: DataTemplate<T> | ReadAtom<Nil<DataTemplate<T>>> ];\n}\n\nexport interface ShowProxyDataProps<T, P extends readonly (keyof T)[]> {\n\twhen?: MaybeAtom<boolean>;\n\tproxy: P;\n\tdata: MaybeAtom<T>;\n\tchildren: [ template: DataTemplate<Proxied<T, P>> | ReadAtom<Nil<DataTemplate<Proxied<T, P>>>> ];\n}\n\n/**\n * The built-in Show Component dynamically mounting and unmounting a Template\n * based on a reactive condition result.\n */\n// @ts-expect-error fake overload to enable use with JSX\nexport function Show(props: JsxProps<ShowProps>): JsxResult;\nexport function Show<T>(props: JsxProps<ShowDataProps<T>>): JsxResult;\nexport function Show<T, P extends readonly (keyof T)[]>(props: JsxProps<ShowProxyDataProps<T, P>>): JsxResult;\n\nexport function Show<TNode>(\n\tjsx: JsxObject,\n\thParent: HNode<TNode>,\n\tnUsedParent: TNode,\n\tnRealParent: TNode,\n\tnBefore: TNode | null,\n\tisBatch: boolean,\n) {\n\tconst when = jsx.when as MaybeAtom<boolean> | undefined;\n\tif (!isAtom(when) && when === false) {\n\t\t// when is statically set to false -> bail out early\n\t\treturn;\n\t}\n\n\tconst { children, data } = jsx;\n\tconst proxyKeys = jsx.proxy as readonly PropertyKey[] | undefined;\n\tconst template: MaybeAtom<(data: any) => any> = Object.hasOwn(jsx, \"data\")\n\t\t? children[0] as MaybeAtom<DataTemplate<any>> // enforced by overload typings\n\t\t: () => children;\n\n\tlet dataOrProxy: unknown = data;\n\tif (proxyKeys) {\n\t\tif (isAtom(data)) {\n\t\t\tdataOrProxy = createProxy(hParent.$ng, data.get(), proxyKeys);\n\t\t\tlink(hParent.$ng, data, {\n\t\t\t\t$fn: () => {\n\t\t\t\t\tupdateProxy(dataOrProxy as ProxyObject, data.get(), proxyKeys);\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\tdataOrProxy = createProxy(hParent.$ng, data, proxyKeys);\n\t\t}\n\t}\n\n\t// prepare batching\n\tconst adapter = hParent.$ng.adapter;\n\tconst shouldBatch = Boolean(adapter.batch);\n\n\t// a sub-group for re-mounting is only necessary when either:\n\t// - `when` can change\n\t// - `template` can change\n\t// - `data` can change and we're not using a proxy\n\n\tif (!(isAtom(when) || isAtom(template) || (!proxyKeys && isAtom(data)))) {\n\t\tconst isLocalBatch = shouldBatch && !isBatch;\n\t\tlet nBatchParent = nUsedParent;\n\t\tlet nBatchBefore = nBefore;\n\t\tif (isLocalBatch) {\n\t\t\tnBatchParent = adapter.batch!();\n\t\t\tnBatchBefore = null;\n\t\t}\n\n\t\tmountJsx(\n\t\t\t/* jsx = */ template(dataOrProxy),\n\t\t\t/* hParent = */ hParent,\n\t\t\t/* nUsedParent = */ nBatchParent,\n\t\t\t/* nRealParent = */ nRealParent,\n\t\t\t/* nBefore = */ nBatchBefore,\n\t\t\t/* isBatch = */ isLocalBatch || isBatch,\n\t\t);\n\n\t\tif (isLocalBatch) {\n\t\t\tadapter.insert(nBatchParent, nUsedParent, nBefore);\n\t\t}\n\n\t\treturn;\n\t}\n\n\t// re-mounts may be necessary -> create a sub-group\n\tconst hGroup = fork(hParent);\n\tconst context = getContextContainer();\n\n\t// (re-)render effect\n\tlet nMarker: TNode | null = nBefore;\n\teffect(() => {\n\t\tif (read(when) === false) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst isLocalBatch = shouldBatch && !isBatch;\n\t\tlet nBatchParent = nUsedParent;\n\t\tlet nBatchBefore = nMarker;\n\t\tif (isLocalBatch) {\n\t\t\tnBatchParent = adapter.batch!();\n\t\t\tnBatchBefore = null;\n\t\t}\n\n\t\tsetContextContainer(context);\n\t\tmount(\n\t\t\t/* jsx = */ withLifecycle(hGroup, read(template), read(dataOrProxy)),\n\t\t\t/* hGroup = */ hGroup,\n\t\t\t/* nUsedParent = */ nBatchParent,\n\t\t\t/* nRealParent = */ nRealParent,\n\t\t\t/* nBefore = */ nBatchBefore,\n\t\t\t/* isBatch = */ isLocalBatch || isBatch,\n\t\t);\n\n\t\tif (isLocalBatch) {\n\t\t\tadapter.insert(nBatchParent, nUsedParent, nMarker);\n\t\t}\n\n\t\treturn () => unmount(hGroup);\n\t}, hParent.$ng);\n\n\t// insert marker to preserve position in the document\n\tnMarker = __DEV__ ? adapter.marker(\"/Show\") : adapter.marker();\n\tinsert(\n\t\t/* hNode = */ nMarker,\n\t\t/* children = */ null,\n\t\t/* hParent = */ hParent,\n\t\t/* nUsedParent = */ nUsedParent,\n\t\t/* nBefore = */ nBefore,\n\t\t/* isBatch = */ isBatch,\n\t);\n\n\t// forget stale batch before future re-renders\n\tisBatch = false;\n\tnUsedParent = nRealParent;\n}\n","import { notify, S_ATOM, type Atom } from \"./Atom\";\nimport { getLifecycle } from \"./Lifecycle\";\nimport { unlink } from \"./Dependency\";\nimport { __DEV__assertNotEffect, resolve, type Effect, type EffectDependency } from \"./Effect\";\nimport { scheduleTick } from \"./Scheduler\";\n\n/**\n * Holds a value derived from values of other Atoms, managing reactions to their changes.\n * Derivations are read-only. Use the `read` function to access its value.\n * @see {@link read}\n */\nexport interface Derivation<T = unknown> extends Atom<T>, Effect<T> {\n\t/** @internal */\n\t$dirty: boolean;\n\n\t/** @internal */\n\t$value: T;\n}\n\n/**\n * Creates a Derivation - an Atom with its value computed from other Atoms. The block runs once\n * eagerly to compute the initial value, then re-runs within scheduler ticks whenever its source\n * Atoms change. Observers are only notified if the new value differs from the previous.\n */\nexport function derived<T>(block: () => T, lifecycle = getLifecycle()): Derivation<T> {\n\tif (__DEV__) {\n\t\t__DEV__assertNotEffect();\n\t}\n\n\tconst atom: Derivation<T> = {\n\t\t[S_ATOM]: true,\n\t\t$dirty: false,\n\t\t$value: null!,\n\t\t$tracksValue: true,\n\t\t$lifecycle: lifecycle,\n\t\t$life: lifecycle.$life,\n\t\t$lastValue: null!,\n\t\t$cycle: 0,\n\t\t$block: block,\n\t\t$react: scheduleNotify,\n\t\tget: getValue,\n\t\tset: setValue,\n\t};\n\n\tconst value = resolve(atom) as T;\n\tatom.$value = value;\n\tatom.$lastValue = value;\n\n\treturn atom;\n}\n\nfunction scheduleNotify(this: EffectDependency, derivation: Derivation<any>, cycle: number) {\n\tif (\n\t\t// derivation was scheduled in a previous life and this run is now stale\n\t\tderivation.$life !== derivation.$lifecycle.$life ||\n\n\t\t// when we get an update from a stale dependency, the reported cycle number will be lower\n\t\t// than our current one (see the reportAccess function). We can unlink the dep and bail out.\n\t\tderivation.$cycle > cycle\n\t) {\n\t\tunlink(this);\n\t\treturn;\n\t}\n\n\t// we're already within a scheduler tick; the effect will therefore run synchronously despite\n\t// being \"scheduled\" - this also gives priority to already scheduled updates and prevents\n\t// infinite loops when dependency cycles exist\n\tderivation.$dirty = true;\n\tscheduleTick(derivation.$lifecycle, derivation.$notify ??= {\n\t\t$fn: notify,\n\t\t$a0: derivation,\n\t});\n}\n\nfunction getValue<T>(this: Derivation<T>): T {\n\t// life number must match, otherwise we'd re-link deps within a lifecycle that already ended\n\tif (this.$dirty && this.$life === this.$lifecycle.$life) {\n\t\tthis.$value = resolve(this) as T;\n\t\tthis.$dirty = false;\n\t}\n\n\treturn this.$value!;\n}\n\nfunction setValue() {\n\treturn false;\n}\n","import { invoke } from \"~/support/common\";\nimport type { Nil } from \"~/support/types\";\n\nimport { getLifecycle, type Lifecycle } from \"./Lifecycle\";\nimport type { DependencyList } from \"./Dependency\";\nimport { __DEV__assertNotEffect, reportAccess } from \"./Effect\";\nimport { createDelta, itemChanged, itemInserted, itemRemoved, listCleared, listSynced, type Equals, type ListDelta } from \"./ListDelta\";\nimport { scheduleTick, scheduleTock, type UpdateCallback } from \"./Scheduler\";\n\nexport interface ReadonlyList<T> extends Iterable<T>, DependencyList {\n\t/**\n\t * Gets the size of this List.\n\t * Reactive in effects and derivations.\n\t */\n\tsize(): number;\n\n\t/**\n\t * Gets the item at the specified index. Return undefined when outside of the List's bounds.\n\t * Reactive in effects and derivations.\n\t */\n\tget(index: number): T | undefined;\n\n\t/**\n\t * Gets a set of changes made to this List within the current tick. Returns null when no changes\n\t * were made.\n\t * Reactive in effects and derivations.\n\t */\n\tdelta(): ListDelta<T> | null;\n\n\t/**\n\t * Gets the underlying array of items. The array is read-only, mutating it will cause observers\n\t * to go out of sync.\n\t * Non-reactive in effects and derivations.\n\t */\n\traw(): readonly T[];\n\n\t/**\n\t * Runs the provided callback for each item of this List.\n\t * Reactive in effects and derivations.\n\t */\n\tforEach(callback: (item: T, index: number) => void, thisArg?: any): void;\n\n\t/** @internal */\n\treadonly $lifecycle: Lifecycle;\n\n\t/** @internal */\n\t$items: readonly T[];\n\n\t/** @internal */\n\t$delta: ListDelta<T> | null;\n\n\t/** @internal */\n\t$notify?: UpdateCallback<[ self: List<T> ]>;\n\n\t/** @internal */\n\t$cleanup?: UpdateCallback<[ self: List<T> ]>;\n\n\t/**\n\t * The ID of this List, used in development mode.\n\t * @internal\n\t */\n\t$devId?: string;\n}\n\nexport interface List<T> extends ReadonlyList<T> {\n\t/**\n\t * Sets the item at the specified index to a new value.\n\t * Observers are notified of this mutation.\n\t * @throws RangeError when index is out of bounds.\n\t */\n\tset(index: number, item: T): void;\n\n\t/**\n\t * Removes all items from this List.\n\t * Observers are notified of this mutation.\n\t */\n\tclear(): void;\n\n\t/**\n\t * Inserts a new item at the specified index.\n\t * Observers are notified of this mutation.\n\t * @throws RangeError when index is out of bounds.\n\t */\n\tinsertAt(index: number, item: T): void;\n\n\t/**\n\t * Inserts a new item at the start of this List.\n\t * Observers are notified of this mutation.\n\t */\n\tinsertFirst(item: T): void;\n\n\t/**\n\t * Inserts a new item at the end of this List.\n\t * Observers are notified of this mutation.\n\t */\n\tinsertLast(item: T): void;\n\n\t/**\n\t * Attempts to find and remove the first matching item from this List.\n\t * Observers are notified of this mutation.\n\t * @returns true if an item was found and removed, false otherwise.\n\t */\n\tremove(item: T): boolean;\n\n\t/**\n\t * Removes the item at the specified index.\n\t * Observers are notified of this mutation.\n\t * @returns the removed item.\n\t * @throws RangeError when index is out of bounds.\n\t */\n\tremoveAt(index: number): T;\n\n\t/**\n\t * Attempts to remove the first item of this List.\n\t * Observers are notified of this mutation.\n\t * @returns the removed item, or undefined if the List is empty.\n\t */\n\tremoveFirst(): T | undefined;\n\n\t/**\n\t * Attempts to remove the last item of this List.\n\t * Observers are notified of this mutation.\n\t * @returns the removed item, or undefined if the List is empty.\n\t */\n\tremoveLast(): T | undefined;\n\n\t/** @internal */\n\t$items: T[];\n}\n\n/**\n * Creates an empty List. This List emits deltas with each mutation which can be observed by\n * Components to efficiently update the rendered state.\n */\nexport function listOf<T>(): List<T>;\nexport function listOf<T>(source: Nil<never>, lifecycle?: Lifecycle, devId?: string): List<T>;\n\n/**\n * Creates a List initialized with items copied from the provided Iterable. This List emits deltas\n * with each mutation which can be observed by Components to efficiently update the rendered state.\n */\nexport function listOf<T>(source: Iterable<T>, lifecycle?: Lifecycle, devId?: string): List<T>;\n\nexport function listOf<T>(source?: Nil<Iterable<T>>, lifecycle = getLifecycle()): List<T> {\n\tif (__DEV__) {\n\t\t__DEV__assertNotEffect();\n\n\t\tconst devId = arguments[2];\n\t\tglobalThis.__PYXIS_HMR__.state.restore(lifecycle, devId, value => {\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tsource = value;\n\t\t\t}\n\t\t});\n\t}\n\n\tconst items = source ? Array.from(source) : [];\n\tconst list: List<T> = {\n\t\t$lifecycle: lifecycle,\n\t\t$items: items,\n\t\t$delta: null,\n\t\t[Symbol.iterator]: getIterator,\n\t\tsize,\n\t\tget,\n\t\tdelta,\n\t\traw,\n\t\tforEach,\n\t\tset,\n\t\tclear,\n\t\tinsertAt,\n\t\tinsertFirst,\n\t\tinsertLast,\n\t\tremove,\n\t\tremoveAt,\n\t\tremoveFirst,\n\t\tremoveLast,\n\t};\n\n\tif (__DEV__) {\n\t\tlist.$devId = arguments[2];\n\t}\n\n\treturn list;\n}\n\n/**\n * Synchronizes the provided List with the given data source. After this operation, the list will\n * contain an exact copy of the source.\n *\n * Note: This function is separated instead of being a List method since the underlying diff\n * algorithm (Myers) is a relatively large chunk of code which would otherwise always get included\n * into bundled builds. This way, tools like Terser can eliminate the extra code when unused.\n */\nexport function sync<T>(list: List<T>, source: readonly T[], eq: Equals<T> = defaultEquals) {\n\tconst oldState = list.$items;\n\tlist.$items = source.slice();\n\tlistSynced(list.$delta ??= createDelta(), oldState, source, eq);\n\tlistMutated(list);\n}\n\nfunction size(this: List<any>) {\n\treportAccess(this);\n\treturn this.$items.length;\n}\n\nfunction get(this: List<any>, index: number) {\n\treportAccess(this);\n\treturn this.$items[index];\n}\n\nfunction delta<T>(this: List<T>) {\n\treportAccess(this);\n\treturn this.$delta;\n}\n\nfunction raw<T>(this: List<T>): readonly T[] {\n\treturn this.$items;\n}\n\nfunction forEach<T>(this: List<T>, callback: (item: T, index: number) => void, thisArg?: any) {\n\treportAccess(this);\n\tthis.$items.forEach(callback, thisArg);\n}\n\nfunction getIterator<T>(this: List<T>) {\n\treportAccess(this);\n\treturn this.$items[Symbol.iterator]();\n}\n\nfunction set<T>(this: List<T>, index: number, newItem: T) {\n\tassertIndex(this, index);\n\n\tconst oldItem = this.$items[index];\n\tif (Object.is(newItem, oldItem)) {\n\t\treturn;\n\t}\n\n\tthis.$items[index] = newItem;\n\n\t// only emit deltas when there are observers\n\tif (this.$dh) {\n\t\titemChanged(this.$delta ??= createDelta(), index, oldItem, newItem);\n\t\tlistMutated(this);\n\t}\n}\n\nfunction clear(this: List<any>) {\n\tconst count = this.$items.length;\n\tthis.$items.length = 0;\n\n\t// only emit deltas when there are observers\n\tif (this.$dh) {\n\t\tlistCleared(this.$delta ??= createDelta(), count);\n\t\tlistMutated(this);\n\t}\n}\n\nfunction insertAt<T>(this: List<T>, index: number, item: T) {\n\tconst { $items } = this;\n\tif (index === $items.length) {\n\t\t$items.push(item);\n\t}\n\telse {\n\t\tassertIndex(this, index);\n\t\tthis.$items.splice(index, 0, item);\n\t}\n\n\t// only emit deltas when there are observers\n\tif (this.$dh) {\n\t\titemInserted(this.$delta ??= createDelta(), index, item);\n\t\tlistMutated(this);\n\t}\n}\n\nfunction insertFirst<T>(this: List<T>, item: T) {\n\tthis.insertAt(0, item);\n}\n\nfunction insertLast<T>(this: List<T>, item: T) {\n\tthis.insertAt(this.$items.length, item);\n}\n\nfunction remove<T>(this: List<any>, item: T) {\n\tconst index = this.$items.indexOf(item);\n\tif (index === -1) {\n\t\treturn false;\n\t}\n\n\tthis.removeAt(index);\n\treturn true;\n}\n\nfunction removeAt<T>(this: List<T>, index: number) {\n\tassertIndex(this, index);\n\tconst item = this.$items.splice(index, 1)[0];\n\n\t// only emit deltas when there are observers\n\tif (this.$dh) {\n\t\titemRemoved(this.$delta ??= createDelta(), index, item);\n\t\tlistMutated(this);\n\t}\n\n\treturn item;\n}\n\nfunction removeFirst<T>(this: List<T>) {\n\treturn this.$items.length > 0 ? this.removeAt(0) : undefined;\n}\n\nfunction removeLast<T>(this: List<T>) {\n\tconst { length } = this.$items;\n\treturn length > 0 ? this.removeAt(length - 1) : undefined;\n}\n\nfunction assertIndex(list: List<any>, index: number) {\n\tif (index >= list.$items.length || index < 0) {\n\t\tif (__DEV__) {\n\t\t\tthrow new RangeError(\"list index out of bounds\");\n\t\t}\n\t\telse {\n\t\t\tthrow new RangeError();\n\t\t}\n\t}\n}\n\nfunction defaultEquals<T>(item0: T, item1: T) {\n\treturn Object.is(item0, item1);\n}\n\nfunction listMutated(list: List<any>) {\n\tif (__DEV__) {\n\t\tglobalThis.__PYXIS_HMR__.state.preserve(list.$lifecycle, list.$devId, list.$items);\n\t}\n\n\tscheduleTick(list.$lifecycle, list.$notify ??= {\n\t\t$fn: notify,\n\t\t$a0: list,\n\t});\n\n\tscheduleTock(list.$lifecycle, list.$cleanup ??= {\n\t\t$fn: cleanup,\n\t\t$a0: list,\n\t});\n}\n\nfunction notify(list: List<any>) {\n\tlet current = list.$dh;\n\tlet next;\n\n\twhile (current) {\n\t\tnext = current.$an;\n\t\tinvoke(current);\n\t\tcurrent = next;\n\t}\n}\n\nfunction cleanup(list: List<any>) {\n\tlist.$delta = null;\n}\n","import { isAtom, type Atom } from \"~/data/Atom\";\nimport type { ElementsType, NodeType } from \"~/support/types\";\nimport type { ExtensionProps } from \"~/Adapter\";\nimport type { MountingGroup } from \"~/Renderer\";\nimport { getLifecycle, onMounted, onUnmounted } from \"~/data/Lifecycle\";\n\nexport interface RefExtensionType {\n\t<TExtensionKey extends string, TElements extends ElementsType>(extensionKey: TExtensionKey, elements: TElements): {\n\t\t[TElementName in keyof TElements]: TElements[TElementName] & ExtensionProps<TExtensionKey, {\n\t\t\treadonly atom?: Atom<NodeType<TElements[TElementName]> | null>;\n\t\t\treadonly call?: RefFn<NodeType<TElements[TElementName]>>;\n\t\t}>;\n\t};\n\n\tset: (node: any, prop: string, value: any, group?: MountingGroup<any>) => void;\n}\n\nexport interface RefFn<TNode> {\n\t(node: TNode | null): void;\n}\n\n/**\n * Extension adding direct reference access to any element. Recommended prefix:\n * `\"ref\"`\n *\n * References can be stored into atoms:\n * ```tsx\n * const wrapperRef = atomOf<HTMLDivElement>();\n * <div ref:atom={wrapperRef} />\n * ```\n * or handled with a custom callback:\n * ```tsx\n * const onWrapperRef = (node: HTMLDivElement) => { ... };\n * <div ref:call={onWrapperRef} />\n * ```\n */\nexport const RefExtension = {\n\tset: (node: any, kind: string, value: any) => {\n\t\tlet method;\n\t\tswitch (kind) {\n\t\t\tcase \"atom\":\n\t\t\t\tif (!isAtom(value)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tmethod = refAtom;\n\t\t\t\tbreak;\n\n\t\t\tcase \"call\":\n\t\t\t\tif (typeof value !== \"function\") {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tmethod = refCall;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\n\t\tconst lifecycle = getLifecycle();\n\t\tonMounted(lifecycle, {\n\t\t\t$fn: method,\n\t\t\t$a0: value,\n\t\t\t$a1: node,\n\t\t});\n\n\t\tonUnmounted(lifecycle, {\n\t\t\t$fn: method,\n\t\t\t$a0: value,\n\t\t\t$a1: null,\n\t\t});\n\t},\n} as RefExtensionType;\n\nfunction refAtom(atom: Atom<any>, node: any) {\n\tatom.set(node);\n}\n\nfunction refCall(setter: RefFn<any>, node: any) {\n\tsetter(node);\n}\n","import { peek, read } from \"~/data/Atom\";\nimport type { JsxText } from \"~/Component\";\n\nimport type { Nil } from \"./types\";\n\nfunction tag(\n\taccess: (value: JsxText) => Nil<string | number | bigint | boolean>,\n\tstrings: TemplateStringsArray,\n\tvalues: readonly JsxText[],\n): string {\n\tconst { length } = values;\n\n\tlet index = 0;\n\tlet text = strings[0];\n\twhile (index < length) {\n\t\ttext += access(values[index]) + strings[++index];\n\t}\n\n\treturn text;\n}\n\n/**\n * A template literal tag that automatically wraps each substitution in a `read` call.\n * @see {@link read}\n */\nexport function reads(strings: TemplateStringsArray, ...values: JsxText[]) {\n\treturn tag(read, strings, values);\n}\n\n/**\n * A template literal tag that automatically wraps each substitution in a `peek` call.\n * @see {@link peek}\n */\nexport function peeks(strings: TemplateStringsArray, ...values: JsxText[]) {\n\treturn tag(peek, strings, values);\n}\n","import type { ElementsType } from \"~/support/types\";\n\nimport type { Adapter, Extension, ExtensionsType } from \"./Adapter\";\nimport { createRenderer, type Renderer } from \"./Renderer\";\n\nexport interface PyxisBuilder<TNode, TIntrinsicElements extends ElementsType> {\n\tbuild: () => Renderer<TNode, TIntrinsicElements>;\n\n\textend: <TExtensionKey extends string, TExtendedIntrinsicElements extends ElementsType>(\n\t\textensionKey: TExtensionKey,\n\t\textension: (extensionKey: TExtensionKey, intrinsicElements: TIntrinsicElements) => TExtendedIntrinsicElements,\n\t) => PyxisBuilder<TNode, Merged<TExtendedIntrinsicElements>>;\n}\n\ntype MergeIntersection<T> = { [K in keyof T]: T[K] } & {};\n\ntype Merged<T> = { [K in keyof T]: MergeIntersection<T[K]> };\n\nexport function pyxis<TNode, TIntrinsicElements extends ElementsType>(adapter: Adapter<TNode, TIntrinsicElements>) {\n\tconst extensions: ExtensionsType<TNode> = {};\n\tconst builder = {\n\t\tbuild: () => createRenderer(adapter, extensions),\n\t\textend: (extensionKey: string, extension: Extension<TNode>) => {\n\t\t\textensions[extensionKey] = extension;\n\t\t\treturn builder;\n\t\t},\n\t};\n\n\treturn builder as PyxisBuilder<TNode, TIntrinsicElements>;\n}\n","import type { S_TAG_NAME } from \"~/component/Native\";\nimport type { MaybeReadAtom } from \"~/data/Atom\";\nimport { getContextContainer, setContextContainer } from \"~/data/Context\";\nimport { unmounted } from \"~/data/Lifecycle\";\nimport type { Nil, PropsType } from \"~/support/types\";\n\nimport { mount, mountJsx, S_COMPONENT, fork, unmount, type HNode, insert } from \"./Renderer\";\n\n/**\n * Represents a Pyxis Component function responsible for setting up a view model and returning a\n * chunk of JSX to be rendered.\n */\nexport interface Component<TProps extends PropsType = {}> {\n\t(props: TProps): JsxResult;\n}\n\nexport type PropsOf<T> = T extends Component<infer TProps> ? TProps : unknown;\n\n/**\n * Represents a template function returning a chunk of JSX to be rendered with specific input data.\n */\nexport interface DataTemplate<TData> {\n\t(data: TData): JsxResult;\n}\n\nexport interface ComponentBlock {\n\t(props: PropsType): JsxResult;\n}\n\nexport function component<TPropsArg extends [ {} ]>(\n\tblock: (...args: TPropsArg) => JsxResult,\n\tdevId?: string,\n): (...args: [ props: JsxProps<TPropsArg[0]> ]) => JsxResult;\n\nexport function component(\n\tblock: ComponentBlock,\n): ComponentHandler {\n\tlet devId: string | undefined; // gets removed by bundler in production\n\tif (__DEV__) {\n\t\tdevId = arguments[1];\n\t\tdevId && globalThis.__PYXIS_HMR__.component.upsert(devId, block);\n\t}\n\n\treturn (jsx, hParent, nUsedParent, nRealParent, nBefore, isBatch) => {\n\t\tconst context = getContextContainer();\n\t\ttry {\n\t\t\tif (__DEV__) {\n\t\t\t\tif (!import.meta.hot || !devId) {\n\t\t\t\t\tsetContextContainer(context);\n\t\t\t\t\tmountJsx(block(jsx), hParent, nUsedParent, nRealParent, nBefore, isBatch);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst hGroup = fork(hParent);\n\t\t\t\tconst nMarker = hGroup.adapter.marker(`/${devId}`);\n\t\t\t\tinsert(nMarker, null, hParent, nUsedParent, nBefore, isBatch);\n\n\t\t\t\tconst unsubscribe = globalThis.__PYXIS_HMR__.component.subscribe(devId, impl => {\n\t\t\t\t\tunmount(hGroup);\n\n\t\t\t\t\tsetContextContainer(context);\n\t\t\t\t\tmount(\n\t\t\t\t\t\t/* jsx = */ {\n\t\t\t\t\t\t\t...jsx,\n\t\t\t\t\t\t\t[S_COMPONENT]: (() => (\n\t\t\t\t\t\t\t\tmountJsx(impl(jsx), hGroup, nUsedParent, nRealParent, nMarker, isBatch)\n\t\t\t\t\t\t\t)) satisfies ComponentHandler,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t/* hGroup = */ hGroup,\n\t\t\t\t\t\t/* nUsedParent = */ nUsedParent,\n\t\t\t\t\t\t/* nRealParent = */ nRealParent,\n\t\t\t\t\t\t/* nBefore = */ nMarker,\n\t\t\t\t\t\t/* isBatch = */ isBatch,\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tunmounted(unsubscribe);\n\n\t\t\t\t// forget stale batch before future re-renders\n\t\t\t\tnUsedParent = nRealParent;\n\t\t\t\tisBatch = false;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsetContextContainer(context);\n\t\t\t\tmountJsx(block(jsx), hParent, nUsedParent, nRealParent, nBefore, isBatch);\n\t\t\t}\n\t\t}\n\t\tfinally {\n\t\t\t// reset back to this Component's container, prevents leakage of branched off child contexts\n\t\t\tsetContextContainer(context);\n\t\t}\n\t};\n}\n\n/**\n * Infers the props object for use with JSX. Because Pyxis always supplies components with child\n * arrays (or tuples), the type needs to be adjusted to reflect the internal mechanics.\n */\nexport type JsxProps<T> =\n\t& { readonly [K in keyof T]: K extends \"children\" ? JsxChildrenProp<T[K]> : T[K] }\n\t& (\"children\" extends keyof T ? {} : { readonly children?: [] });\n\n/**\n * When typing children as a single value tuple, it becomes unusable in 'react-jsx' mode. TS rejects\n * valid uses of such components with the error: \"This JSX tag's children prop expects type '[T]'\n * which requires multiple children, but only a single child was provided.\"\n *\n * Likely related to the fact that single children are passed to jsx() factory without wrapping\n * arrays.\n *\n * This utility type unwraps single value tuples, avoiding the problem.\n */\nexport type JsxChildrenProp<T> = T extends readonly [ any, any, ...any[] ]\n\t// component requires 2+ children, safe to pass the type as-is, just attach the readonly modifier\n\t? T extends readonly [ ...infer C ]\n\t\t? readonly [ ...C ]\n\t\t: T\n\t: T extends readonly [ infer SC ]\n\t\t// component requires a single child, unwrap the tuple\n\t\t? SC\n\t\t: T extends readonly (infer C)[]\n\t\t\t// component requires any number of children, pass as-is, but also append the unwrapped\n\t\t\t// type to allow single child use\n\t\t\t? readonly C[] | C\n\t\t\t// children typed as a non-array type, pass as-is\n\t\t\t: T;\n\n/**\n * Primitive types accepted to render as text.\n */\nexport type JsxText = MaybeReadAtom<Nil<string | number | boolean | bigint>>;\n\n/**\n * Describes the objects returned by JSX factories.\n *\n * Pyxis uses very lightweight factories returning the props object directly,\n * adding a few extra props:\n *\n * - S_COMPONENT ... hidden, contains a reference to the ComponentHandler function\n * - S_TAG_NAME ... hidden, specifies the tag name, only populated for native elements\n * - children ... always present and always an array, empty array for childless components\n */\nexport interface JsxObject {\n\t[propName: string]: unknown;\n\treadonly children: readonly unknown[];\n\n\t/** @internal */\n\treadonly [S_COMPONENT]: ComponentHandler;\n\n\t/** @internal */\n\treadonly [S_TAG_NAME]?: string;\n}\n\n/**\n * Union of all admissible values within JSX.\n */\nexport type JsxResult = JsxObject | JsxText;\n\n/**\n * The type of JSX elements accepted as individual children by common components.\n */\nexport type JsxChildren = JsxResult | readonly JsxChildren[];\n\n/**\n * Utility type adding the standard `children` prop to the given props type.\n */\nexport type WithChildren<T extends PropsType> = T & { children?: JsxChildren };\n\n/** @internal */\nexport interface ComponentHandler {\n\t<TNode>(\n\t\tjsx: JsxObject,\n\t\thParent: HNode<TNode>,\n\t\tnUsedParent: TNode,\n\t\tnRealParent: TNode,\n\t\tnBefore: TNode | null,\n\t\tisBatch: boolean,\n\t): void;\n}\n","import { Native, S_TAG_NAME } from \"~/component/Native\";\nimport type { PropsType } from \"~/support/types\";\nimport type { Component, JsxResult } from \"~/Component\";\nimport { S_COMPONENT } from \"~/Renderer\";\n\nconst EMPTY_ARRAY = Object.freeze([] as const);\n\nexport function jsx(\n\ttagName: string,\n\tprops: PropsType,\n\tkey?: any,\n): JsxResult;\n\nexport function jsx<TProps extends PropsType>(\n\tcomponent: Component<TProps>,\n\tprops: TProps,\n\tkey?: any,\n): JsxResult;\n\nexport function jsx(\n\tcomponentOrTagName: Component<PropsType> | string,\n\tprops: any,\n\tkey?: any,\n) {\n\tconst { children } = props;\n\n\t// the `jsx` (dynamic) variant is called without wrapping arrays around\n\t// children, however it is also used for children provided from a variable\n\t// which may itself be an array, so we have to check\n\tprops.children = children === undefined\n\t\t? EMPTY_ARRAY\n\t\t: Array.isArray(children)\n\t\t\t? children\n\t\t\t: [ children ];\n\n\t// put back the `key` prop\n\tprops.key ??= key;\n\n\t// attach component info\n\tif (typeof componentOrTagName === \"string\") {\n\t\tprops[S_COMPONENT] = Native;\n\t\tprops[S_TAG_NAME] = componentOrTagName;\n\t}\n\telse {\n\t\tprops[S_COMPONENT] = componentOrTagName;\n\t}\n\n\treturn props;\n}\n\n\nexport function jsxs(\n\ttagName: string,\n\tprops: PropsType,\n\tkey?: any,\n): JsxResult;\n\nexport function jsxs<TProps extends PropsType>(\n\tcomponent: Component<TProps>,\n\tprops: TProps,\n\tkey?: any,\n): JsxResult;\n\nexport function jsxs(\n\tcomponentOrTagName: Component<PropsType> | string,\n\tprops: any,\n\tkey?: any,\n) {\n\t// the `jsxs` (static) variant is called with a wrapping array around\n\t// children, so we don't have to check it.\n\n\t// put back the `key` prop\n\tprops.key ??= key;\n\n\t// attach component info\n\tif (typeof componentOrTagName === \"string\") {\n\t\tprops[S_COMPONENT] = Native;\n\t\tprops[S_TAG_NAME] = componentOrTagName;\n\t}\n\telse {\n\t\tprops[S_COMPONENT] = componentOrTagName;\n\t}\n\n\treturn props;\n}\n"],"mappings":";AAyBA,IAAa,oBAAb,MAA+B;CAC9B,AAAiB,6BAAa,IAAI,IAA+B;CACjE,AAAQ,kBAAkB;CAE1B,AAAO,GAAG,IAAY,IAAkD;EACvE,MAAM,QAAQ,KAAK,WAAW,IAAI,EAAE;EACpC,IAAI,CAAC,OACJ,MAAM,IAAI,MAAM,sCAAsC,GAAG,EAAE;EAG5D,MAAM,WAAiC;GAAE;GAAI;EAAM;EACnD,IAAI,MAAM,IAAI;GACb,MAAM,GAAG,KAAK;GACd,SAAS,KAAK,MAAM;EACrB,OAEC,MAAM,KAAK;EAGZ,MAAM,KAAK;EACX,GAAG,MAAM,SAAS;EAElB,OAAO;CACR;CAEA,AAAO,IAAI,UAAgC;EAC1C,MAAM,EAAE,UAAU;EAClB,IAAI,SAAS,IACZ,SAAS,GAAG,KAAK,SAAS;OAEtB,IAAI,MAAM,OAAO,UACrB,MAAM,KAAK,SAAS;EAGrB,IAAI,SAAS,IACZ,SAAS,GAAG,KAAK,SAAS;OAEtB,IAAI,MAAM,OAAO,UACrB,MAAM,KAAK,SAAS;EAGrB,SAAS,KAAK;EACd,SAAS,KAAK;CACf;CAEA,AAAO,UAAU,IAAY,IAA4B;EACxD,MAAM,WAAW,KAAK,GAAG,IAAI,EAAE;EAC/B,aAAa,KAAK,IAAI,QAAQ;CAC/B;CAEA,AAAO,OAAO,IAAY,WAA2B;EACpD,MAAM,QAAQ,KAAK,WAAW,IAAI,EAAE;EACpC,IAAI,CAAC,OAAO;GACX,KAAK,WAAW,IAAI,IAAI;I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rB,cAAc;IACd,UAAU;GACX;EAKD,UACQ;GAEP,oBAAoB,OAAO;EAC5B;CACD;AACD;;;;ACvFA,MAAM,cAAc,OAAO,OAAO,CAAC,CAAU;AAc7C,SAAgB,IACf,oBACA,OACA,KACC;CACD,MAAM,EAAE,aAAa;CAKrB,MAAM,WAAW,aAAa,SAC3B,cACA,MAAM,QAAQ,QAAQ,IACrB,WACA,CAAE,QAAS;CAGf,MAAM,QAAQ;CAGd,IAAI,OAAO,uBAAuB,UAAU;EAC3C,MAAM,eAAe;EACrB,MAAM,cAAc;CACrB,OAEC,MAAM,eAAe;CAGtB,OAAO;AACR;AAeA,SAAgB,KACf,oBACA,OACA,KACC;CAKD,MAAM,QAAQ;CAGd,IAAI,OAAO,uBAAuB,UAAU;EAC3C,MAAM,eAAe;EACrB,MAAM,cAAc;CACrB,OAEC,MAAM,eAAe;CAGtB,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"core-dev.js","names":["scheduleReaction","getValue","setValue","getUpstreamValue"],"sources":["../src/support/common.ts","../src/dev/ComponentRegistry.ts","../src/dev/StateRegistry.ts","../src/symbols.ts","../src/Runtime.ts","../src/data/Dependency.ts","../src/Component.ts","../src/data/Lifecycle.ts","../src/data/Scheduler.ts","../src/data/Effect.ts","../src/data/Atom.ts","../src/Renderer.ts","../src/component/Fragment.ts","../src/data/ListDelta.ts","../src/data/ProxyAtom.ts","../src/support/template.ts","../src/component/Iterator.ts","../src/component/Native.ts","../src/component/Show.ts","../src/data/Context.ts","../src/data/Derivation.ts","../src/data/List.ts","../src/Adapter.ts","../src/extension/RefExtension.ts","../src/support/atoms.ts","../src/jsx.ts","../src/RendererBuilder.ts","../src/exports/core-dev.ts"],"sourcesContent":["import type { ArgsMax3, Callback } from \"./types\";\n\n/**\n * Invokes a {@link Callback} passing stored arguments and forwarding its return value.\n */\nexport function invoke<TArgs extends ArgsMax3, TReturn>(callback: Callback<TArgs, TReturn>): TReturn;\nexport function invoke(callback: Callback<ArgsMax3>) {\n\treturn callback.fn(\n\t\tcallback.a0,\n\t\tcallback.a1,\n\t\tcallback.a2,\n\t);\n}\n\n/**\n * Does absolutely nothing.\n * @internal\n */\nexport function noop() {}\n\n/**\n * Re-throws a list of collected errors.\n * @internal\n */\nexport function rethrow(errors: readonly unknown[] | null | undefined) {\n\tif (errors) {\n\t\tif (errors.length > 1) {\n\t\t\tthrow new AggregateError(errors);\n\t\t}\n\n\t\tif (errors.length === 1) {\n\t\t\tthrow errors[0];\n\t\t}\n\t}\n}\n\n/**\n * A plain, empty object (cast to any) internal to Pyxis, guaranteed to never equal any value\n * arriving from user code.\n * @internal\n */\nexport const UNIQUE_VALUE: any = Object.create(null);\n","import { rethrow } from \"~/support/common\";\nimport type { ComponentBlock } from \"~/Component\";\n\ndeclare global {\n\t// we expect this global to exist in ~all environments\n\tfunction queueMicrotask(callback: () => void): void;\n}\n\nexport interface HotComponentEntry {\n\tcomponent: ComponentBlock;\n\tdirty: boolean;\n\tisDispatching: boolean;\n\tneedsCleanup: boolean;\n\tlh?: HotComponentListener | null;\n\tlt?: HotComponentListener | null;\n}\n\nexport interface HotComponentListener {\n\treadonly fn: HotComponentListenerFn;\n\treadonly entry: HotComponentEntry;\n\tisActive: boolean;\n\tlp?: HotComponentListener | null;\n\tln?: HotComponentListener | null;\n}\n\nexport interface HotComponentListenerFn {\n\t(component: ComponentBlock): void;\n}\n\nexport class ComponentRegistry {\n\tprivate readonly components = new Map<string, HotComponentEntry>();\n\tprivate isPendingUpdate = false;\n\n\tpublic on(id: string, fn: HotComponentListenerFn): HotComponentListener {\n\t\tconst entry = this.components.get(id);\n\t\tif (!entry) {\n\t\t\tthrow new Error(`no component was registered under \"${id}\"`);\n\t\t}\n\n\t\t// initial run - if it throws, subscription won't get registered\n\t\tfn(entry.component);\n\n\t\t// register subscription\n\t\tconst listener: HotComponentListener = {\n\t\t\tfn,\n\t\t\tentry,\n\t\t\tisActive: true,\n\t\t};\n\n\t\tif (entry.lt) {\n\t\t\tentry.lt.ln = listener;\n\t\t\tlistener.lp = entry.lt;\n\t\t}\n\t\telse {\n\t\t\tentry.lh = listener;\n\t\t}\n\n\t\tentry.lt = listener;\n\n\t\treturn listener;\n\t}\n\n\tpublic off(listener: HotComponentListener) {\n\t\tif (!listener.isActive) {\n\t\t\treturn;\n\t\t}\n\n\t\tlistener.isActive = false;\n\t\tif (listener.entry.isDispatching) {\n\t\t\tlistener.entry.needsCleanup = true;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.unlink(listener);\n\t}\n\n\tprivate unlink(listener: HotComponentListener) {\n\t\tconst { entry } = listener;\n\t\tif (listener.lp) {\n\t\t\tlistener.lp.ln = listener.ln;\n\t\t}\n\t\telse if (entry.lh === listener) {\n\t\t\tentry.lh = listener.ln;\n\t\t}\n\n\t\tif (listener.ln) {\n\t\t\tlistener.ln.lp = listener.lp;\n\t\t}\n\t\telse if (entry.lt === listener) {\n\t\t\tentry.lt = listener.lp;\n\t\t}\n\n\t\tlistener.lp = null;\n\t\tlistener.ln = null;\n\t}\n\n\tpublic subscribe(id: string, fn: HotComponentListenerFn) {\n\t\tconst listener = this.on(id, fn);\n\t\treturn () => this.off(listener);\n\t}\n\n\tpublic upsert(id: string, component: ComponentBlock) {\n\t\tconst entry = this.components.get(id);\n\t\tif (!entry) {\n\t\t\tthis.components.set(id, {\n\t\t\t\tcomponent,\n\t\t\t\tdirty: false,\n\t\t\t\tisDispatching: false,\n\t\t\t\tneedsCleanup: false,\n\t\t\t});\n\n\t\t\treturn;\n\t\t}\n\n\t\tentry.component = component;\n\t\tentry.dirty = true;\n\t\tif (!this.isPendingUpdate) {\n\t\t\tqueueMicrotask(this.update);\n\t\t\tthis.isPendingUpdate = true;\n\t\t}\n\t}\n\n\tprivate readonly update = () => {\n\t\tlet errors: unknown[] | undefined;\n\n\t\tthis.isPendingUpdate = false;\n\t\tthis.components.forEach(entry => {\n\t\t\tif (!entry.dirty) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tentry.dirty = false;\n\t\t\tentry.isDispatching = true;\n\n\t\t\tconst component = entry.component;\n\t\t\tconst last = entry.lt;\n\t\t\tlet current = entry.lh;\n\t\t\tlet next;\n\n\t\t\ttry {\n\t\t\t\twhile (current) {\n\t\t\t\t\tif (current.isActive) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tcurrent.fn(component);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (ex) {\n\t\t\t\t\t\t\t(errors ??= []).push(ex);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// new subscribers already receive their initial call through ::on\n\t\t\t\t\tif (current === last) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrent = current.ln;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tentry.isDispatching = false;\n\t\t\t\tif (entry.needsCleanup) {\n\t\t\t\t\tcurrent = entry.lh;\n\t\t\t\t\twhile (current) {\n\t\t\t\t\t\tnext = current.ln;\n\t\t\t\t\t\tif (!current.isActive) {\n\t\t\t\t\t\t\tthis.unlink(current);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcurrent = next;\n\t\t\t\t\t}\n\n\t\t\t\t\tentry.needsCleanup = false;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\trethrow(errors);\n\t};\n}\n","type StateMap = { [K in string]?: unknown };\n\nexport class StateRegistry {\n\tprivate readonly state = new WeakMap<WeakKey, StateMap>();\n\n\tpublic preserve(handle: WeakKey | undefined, devId: string | undefined, value: any) {\n\t\tif (!handle || !devId) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet map = this.state.get(handle);\n\t\tif (!map) {\n\t\t\tthis.state.set(handle, map = {});\n\t\t}\n\n\t\tmap[devId] = value;\n\t}\n\n\tpublic restore<T = any>(handle: WeakKey | undefined, devId: string | undefined): T;\n\tpublic restore<T>(handle: WeakKey | undefined, devId: string | undefined, block: (value: any) => T): T | undefined;\n\tpublic restore(handle: WeakKey | undefined, devId: string | undefined, block?: (value: any) => any) {\n\t\tif (!handle || !devId) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst map = this.state.get(handle);\n\t\tif (!map || !Object.hasOwn(map, devId)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn block\n\t\t\t? block(map[devId])\n\t\t\t: map[devId];\n\t}\n}\n","export const S_ATOM: unique symbol = Symbol.for(\"pyxis:atom\");\nexport const S_COMPONENT: unique symbol = Symbol.for(\"pyxis:component\");\nexport const S_TAG_NAME: unique symbol = Symbol.for(\"pyxis:tagName\");\n\n/** used as a key to attach and access dev info on JSX objects */\nexport const S_DEV_INFO: unique symbol = Symbol.for(\"pyxis:devInfo\");\n\n/** @internal */\nexport const S_RUNTIME: unique symbol = Symbol.for(\"pyxis:runtime\");\n","import type { ContextContainer } from \"./data/Context\";\nimport type { Effect } from \"./data/Effect\";\nimport type { Lifecycle } from \"./data/Lifecycle\";\nimport type { ComponentRegistry } from \"./dev/ComponentRegistry\";\nimport type { StateRegistry } from \"./dev/StateRegistry\";\nimport type { MountingGroup } from \"./Renderer\";\nimport type { Extension } from \"./Adapter\";\nimport { S_RUNTIME } from \"./symbols\";\n\nexport interface Runtime {\n\t/** routing for extension props applied by reference (via the `ext` utility) */\n\treadonly x: { [K in string]?: ExtensionPropDestination };\n\n\t/** auto-increment index used to assign unique keys to extensions */\n\t$extIndex: number;\n\n\t/** the current Lifecycle */\n\t$currentLifecycle: Lifecycle | null;\n\n\t/** the currently running Effect */\n\t$currentEffect: Effect<any> | null;\n\n\t/** the current ContextContainer */\n\t$currentContext: ContextContainer | null;\n\n\t/**\n\t * whether the current context container {@link $currentContext} (if any) was newly created within the\n\t * current component\n\t */\n\t$currentContextNew: boolean;\n\n\t/** Active render operations; reused between mounts. */\n\t$mounts?: MountingGroup<any>[];\n\n\t/** Teardowns deferred until the outermost render finishes. Allocated only when needed. */\n\t$unmounts?: { $group: MountingGroup<any>; $life: number; $destroy: boolean }[] | null;\n\n\t/** hot module reload registry for components, only used in dev builds */\n\t$hmrComponent?: ComponentRegistry;\n\n\t/** hot module reload registry for atom state, only used in dev builds */\n\t$hmrState?: StateRegistry;\n\n\t/** when running component code, tracks the Lifecycle given to that component, only used in dev builds */\n\t$componentEvalLifecycle?: Lifecycle | null;\n\n\t/** when running component code, tracks the Effect (if any) within which it's running, only used in dev builds */\n\t$componentEvalEffect?: Effect<any> | null;\n}\n\nexport interface ExtensionPropDestination {\n\treadonly $ext: Extension<any>;\n\treadonly $prop: string;\n}\n\n// @ts-ignore-error\nexport const runtime: Runtime = (globalThis[S_RUNTIME] ??= {\n\tx: {},\n\t$extIndex: 0,\n\t$currentLifecycle: null,\n\t$currentEffect: null,\n\t$currentContext: null,\n\t$currentContextNew: false,\n} satisfies Runtime);\n","import { invoke, rethrow } from \"~/support/common\";\nimport type { ArgsMax3, Callback, Nil } from \"~/support/types\";\n\nimport type { Lifecycle } from \"./Lifecycle\";\nimport type { UpdateCallback } from \"./Scheduler\";\n\n/**\n * A dependency callback of an Atom. The callback will be run whenever the relevant Atom changes.\n */\nexport interface Dependency<TArgs extends ArgsMax3 = ArgsMax3> extends Callback<TArgs> {\n\t/** @internal */\n\t$lifecycle?: Nil<Lifecycle>;\n\n\t/** @internal */\n\t$target?: Nil<DependencyList<TArgs>>;\n\n\t/**\n\t * Previous Dependency within an Atom's dependency list.\n\t * @internal\n\t */\n\t$ap?: Nil<Dependency<TArgs>>;\n\n\t/**\n\t * Next Dependency within an Atom's dependency list.\n\t * @internal\n\t */\n\t$an?: Nil<Dependency<TArgs>>;\n\n\t/**\n\t * Previous Dependency within a Lifecycle's dependency list.\n\t * @internal\n\t */\n\t$lp?: Nil<Dependency>;\n\n\t/**\n\t * Next Dependency within an Lifecycle's dependency list.\n\t * @internal\n\t */\n\t$ln?: Nil<Dependency>;\n}\n\n/**\n * Represents an object capable of holding links to Dependencies and dispatching notifications\n * to them.\n */\nexport interface DependencyList<TArgs extends ArgsMax3 = ArgsMax3> {\n\t/**\n\t * The head of the dependencies linked list.\n\t * @internal\n\t */\n\t$dh?: Nil<Dependency<TArgs>>;\n\n\t/**\n\t * The tail of the dependencies linked list.\n\t * @internal\n\t */\n\t$dt?: Nil<Dependency<TArgs>>;\n\n\t/**\n\t * Tracks whether notifications are currently being dispatched.\n\t * @internal\n\t */\n\t$xa?: boolean;\n\n\t/**\n\t * During notification dispatch, tracks the next dependency to be notified.\n\t * @internal\n\t */\n\t$xn?: Nil<Dependency>;\n\n\t/**\n\t * The notify callback of this DependencyList.\n\t * @internal\n\t */\n\t$notify?: Nil<UpdateCallback>;\n\n\t/**\n\t * In chained data relations (proxy and context atoms), tracks the upstream atom forwarding\n\t * notifications to this atom.\n\t */\n\t$upstream?: Nil<DependencyList>;\n\n\t/**\n\t * Tracks whether the next notification must be delivered overriding any optimizations that may\n\t * otherwise try to skip it.\n\t * @internal\n\t */\n\t$force?: boolean;\n}\n\n/**\n * Invokes the provided {@link Dependency} and binds it to run again with each notification emitted\n * by the specified target. The return value of the initial run is forwarded.\n */\nexport function bind<TArgs extends ArgsMax3, TResult>(\n\tlifecycle: Lifecycle,\n\ttarget: DependencyList,\n\tdependency: Dependency & Callback<TArgs, TResult>,\n): TResult {\n\tlink(lifecycle, target, dependency);\n\treturn invoke(dependency);\n}\n\n/**\n * Links a {@link Dependency} to an {@link Atom} and {@link Lifecycle}.\n */\nexport function link<TArgs extends ArgsMax3>(lifecycle: Lifecycle, target: DependencyList, dep: Dependency<TArgs>): void;\nexport function link(lifecycle: Lifecycle, target: DependencyList, dep: Dependency) {\n\t// link to target\n\tif (target.$dt) {\n\t\ttarget.$dt.$an = dep;\n\t\tdep.$ap = target.$dt;\n\t}\n\telse {\n\t\ttarget.$dh = dep;\n\t}\n\n\tdep.$target = target;\n\ttarget.$dt = dep;\n\n\t// link to lifecycle\n\tif (lifecycle.$dt) {\n\t\tlifecycle.$dt.$ln = dep;\n\t\tdep.$lp = lifecycle.$dt;\n\t}\n\telse {\n\t\tlifecycle.$dh = dep;\n\t}\n\n\tdep.$lifecycle = lifecycle;\n\tlifecycle.$dt = dep;\n\n\t// advance cursor when dispatch is currently active\n\tif (target.$xa && !target.$xn) {\n\t\ttarget.$xn = dep;\n\t}\n\n\t// if there is already a pending update notification, ensure it is delivered regardless of any\n\t// optimizations, since the new observer (dep) may have seen an intermediate state and may need\n\t// the notification to actually synchronize\n\tlet update;\n\tdo {\n\t\tupdate = target.$notify;\n\t\tif (update && update.$se === update.$lifecycle!.$scheduler.$epoch) {\n\t\t\ttarget.$force = true;\n\t\t}\n\n\t\ttarget = target.$upstream!;\n\t}\n\twhile (target);\n}\n\n/**\n * Unlinks a Dependency from the Atom and Lifecycle it has been linked to.\n */\nexport function unlink(dep: Dependency) {\n\tconst target = dep.$target;\n\tif (!target) {\n\t\treturn; // already unlinked?\n\t}\n\n\t// advance cursor when dispatch is currently active\n\tif (target.$xa && target.$xn === dep) {\n\t\ttarget.$xn = dep.$an;\n\t}\n\n\t// unlink from target (atom)\n\tif (dep.$ap) {\n\t\tdep.$ap.$an = dep.$an;\n\t}\n\telse if (target.$dh === dep) {\n\t\ttarget.$dh = dep.$an;\n\t}\n\n\tif (dep.$an) {\n\t\tdep.$an.$ap = dep.$ap;\n\t}\n\telse if (target.$dt === dep) {\n\t\ttarget.$dt = dep.$ap;\n\t}\n\n\tdep.$target = null;\n\tdep.$ap = null;\n\tdep.$an = null;\n\n\t// unlink from lifecycle\n\tconst lifecycle = dep.$lifecycle!;\n\tif (dep.$lp) {\n\t\tdep.$lp.$ln = dep.$ln;\n\t}\n\telse if (lifecycle.$dh === dep) {\n\t\tlifecycle.$dh = dep.$ln;\n\t}\n\n\tif (dep.$ln) {\n\t\tdep.$ln.$lp = dep.$lp;\n\t}\n\telse if (lifecycle.$dt === dep) {\n\t\tlifecycle.$dt = dep.$lp;\n\t}\n\n\tdep.$lifecycle = null;\n\tdep.$lp = null;\n\tdep.$ln = null;\n}\n\n/**\n * Unlinks all Dependencies managed by the given Lifecycle.\n * @internal\n */\nexport function teardown(lifecycle: Lifecycle) {\n\tlet dep = lifecycle.$dh;\n\tlet target;\n\tlet next;\n\n\twhile (dep) {\n\t\ttarget = dep.$target!;\n\n\t\t// advance cursor when dispatch is currently active\n\t\tif (target.$xa && target.$xn === dep) {\n\t\t\ttarget.$xn = dep.$an;\n\t\t}\n\n\t\t// unlink from target (atom)\n\t\tif (dep.$ap) {\n\t\t\tdep.$ap.$an = dep.$an;\n\t\t}\n\t\telse if (target.$dh === dep) {\n\t\t\ttarget.$dh = dep.$an;\n\t\t}\n\n\t\tif (dep.$an) {\n\t\t\tdep.$an.$ap = dep.$ap;\n\t\t}\n\t\telse if (target.$dt === dep) {\n\t\t\ttarget.$dt = dep.$ap;\n\t\t}\n\n\t\t// teardown the dependency - we're removing everything from the Lifecycle, so we don't have\n\t\t// to preserve the linked list's consistency during this loop\n\t\tnext = dep.$ln;\n\t\tdep.$lifecycle = null;\n\t\tdep.$target = null;\n\t\tdep.$ap = null;\n\t\tdep.$an = null;\n\t\tdep.$lp = null;\n\t\tdep.$ln = null;\n\t\tdep = next;\n\t}\n\n\tlifecycle.$dh = null;\n\tlifecycle.$dt = null;\n\n\tlifecycle.$life += 1;\n\n\tlet callbacks;\n\tif ((callbacks = lifecycle.$onMount)) {\n\t\tcallbacks.length = 0;\n\t}\n\n\tif ((callbacks = lifecycle.$onUnmount)) {\n\t\tcallbacks.length = 0;\n\t}\n}\n\n/**\n * Invokes all linked dependency callbacks. Resilient against mutations of the list throughout the\n * dispatch (as long as they only happen via the `link`, `unlink`, or `teardown` functions).\n * @internal\n */\nexport function notify(list: DependencyList) {\n\t// init cursor\n\tlist.$xa = true;\n\tlist.$xn = list.$dh;\n\n\t// invoke all observer callbacks, catching any errors\n\tlet errors: unknown[] | undefined;\n\tlet current;\n\twhile ((current = list.$xn)) {\n\t\t// the callback may run arbitrary user code, which could lead to mutations of the linked\n\t\t// list we're iterating -> we advance the cursor first; the link, unlink, unlinkAll\n\t\t// functions check and adjust it when necessary; this loop will then advance to the correct\n\t\t// next dependency\n\t\tlist.$xn = current.$an;\n\t\ttry {\n\t\t\tinvoke(current);\n\t\t}\n\t\tcatch (ex) {\n\t\t\t(errors ??= []).push(ex);\n\t\t}\n\t}\n\n\t// clear cursor\n\tlist.$xa = false;\n\tlist.$xn = null;\n\n\t// fail, if there were any errors\n\trethrow(errors);\n}\n","import type { MaybeAtom } from \"~/data/Atom\";\nimport { onceUnmounted } from \"~/data/Lifecycle\";\nimport type { Nil, PropsType } from \"~/support/types\";\n\nimport { mount, mountJsx, fork, unmount, type HNode, insert } from \"./Renderer\";\nimport { runtime } from \"./Runtime\";\nimport { S_COMPONENT, S_DEV_INFO, S_TAG_NAME } from \"./symbols\";\n\n/**\n * Represents a Pyxis Component function responsible for setting up a view model and returning a\n * chunk of JSX to be rendered.\n */\nexport interface Component<TProps extends PropsType = {}> {\n\t(props: TProps): JsxResult;\n}\n\nexport type PropsOf<T> = T extends Component<infer TProps> ? TProps : unknown;\n\n/**\n * Represents a template function returning a chunk of JSX to be rendered with specific input data.\n */\nexport interface DataTemplate<TData> {\n\t(data: TData): JsxResult;\n}\n\nexport interface ComponentBlock {\n\t(props: PropsType): JsxResult;\n}\n\nexport function component<TPropsArg extends [ {} ]>(\n\tblock: (...args: TPropsArg) => JsxResult,\n\tdevId?: string,\n): (...args: [ props: JsxProps<TPropsArg[0]> ]) => JsxResult;\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function component(\n\tblock: ComponentBlock,\n): ComponentHandler {\n\tlet devId: string | undefined; // gets removed by bundler in production\n\tif (__DEV__) {\n\t\tdevId = arguments[1];\n\t\tdevId && runtime.$hmrComponent!.upsert(devId, block);\n\t}\n\n\treturn (props, hParent, hBefore, nUsedParent, nRealParent, isBatch) => {\n\t\tconst capturedContext = runtime.$currentContext;\n\t\tconst capturedContextNew = runtime.$currentContextNew;\n\t\ttry {\n\t\t\tif (__DEV__) {\n\t\t\t\tif (!import.meta.hot || !devId) {\n\t\t\t\t\tmountJsx(__DEV__evalComponent(block, props), hParent, hBefore, nUsedParent, nRealParent, isBatch);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst hGroup = fork(hParent, hBefore);\n\t\t\t\tlet hMarker = hBefore;\n\n\t\t\t\tconst unsubscribe = runtime.$hmrComponent!.subscribe(devId, impl => {\n\t\t\t\t\tunmount(hGroup);\n\t\t\t\t\tmount(\n\t\t\t\t\t\t/* jsx = */ {\n\t\t\t\t\t\t\t...props,\n\t\t\t\t\t\t\t[S_COMPONENT]: (() => (\n\t\t\t\t\t\t\t\tmountJsx(__DEV__evalComponent(impl, props), hGroup, hMarker, nUsedParent, nRealParent, isBatch)\n\t\t\t\t\t\t\t)) satisfies ComponentHandler,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t/* hParent = */ hGroup,\n\t\t\t\t\t\t/* hBefore = */ hMarker,\n\t\t\t\t\t\t/* nUsedParent = */ nUsedParent,\n\t\t\t\t\t\t/* nRealParent = */ nRealParent,\n\t\t\t\t\t\t/* isBatch = */ isBatch,\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tonceUnmounted(hParent.$ng, { fn: unsubscribe });\n\n\t\t\t\t// Initial content renders before the marker, matching Show's batching order.\n\t\t\t\thMarker = insert(hGroup.adapter.marker(`/${devId}`), null, hParent, hBefore, nUsedParent, isBatch, true);\n\n\t\t\t\t// forget stale batch before future re-renders\n\t\t\t\tnUsedParent = nRealParent;\n\t\t\t\tisBatch = false;\n\t\t\t}\n\t\t\telse {\n\t\t\t\truntime.$currentContextNew = false; // reset context container\n\t\t\t\tmountJsx(block(props), hParent, hBefore, nUsedParent, nRealParent, isBatch);\n\t\t\t}\n\t\t}\n\t\tfinally {\n\t\t\t// reset back to this Component's container, prevents leakage of branched off child contexts\n\t\t\truntime.$currentContext = capturedContext;\n\t\t\truntime.$currentContextNew = capturedContextNew;\n\t\t}\n\t};\n}\n\nfunction __DEV__evalComponent(block: ComponentBlock, props: JsxObject) {\n\tconst prevLifecycle = runtime.$componentEvalLifecycle ?? null;\n\tconst prevEffect = runtime.$componentEvalEffect ?? null;\n\truntime.$componentEvalLifecycle = runtime.$currentLifecycle;\n\truntime.$componentEvalEffect = runtime.$currentEffect;\n\truntime.$currentContextNew = false; // reset context container\n\ttry {\n\t\treturn block(props);\n\t}\n\tfinally {\n\t\truntime.$componentEvalLifecycle = prevLifecycle;\n\t\truntime.$componentEvalEffect = prevEffect;\n\t}\n}\n\nexport function __DEV__assertIsDirectComponentCode(fn: string) {\n\tif (!runtime.$componentEvalLifecycle || runtime.$componentEvalLifecycle !== runtime.$currentLifecycle) {\n\t\tthrow new Error(`\"${fn}\" can only be used directly within components.`);\n\t}\n\n\tif (runtime.$componentEvalEffect !== runtime.$currentEffect) {\n\t\tthrow new Error(`\"${fn}\" cannot be used within effects or derivations.`);\n\t}\n}\n\n/**\n * Infers the props object for use with JSX. Because Pyxis always supplies components with child\n * arrays (or tuples), the type needs to be adjusted to reflect the internal mechanics.\n */\nexport type JsxProps<T> =\n\t& { readonly [K in keyof T]: K extends \"children\" ? JsxChildrenProp<T[K]> : T[K] }\n\t& (\"children\" extends keyof T ? {} : { readonly children?: [] });\n\n/**\n * When typing children as a single value tuple, it becomes unusable in 'react-jsx' mode. TS rejects\n * valid uses of such components with the error: \"This JSX tag's children prop expects type '[T]'\n * which requires multiple children, but only a single child was provided.\"\n *\n * Likely related to the fact that single children are passed to jsx() factory without wrapping\n * arrays.\n *\n * This utility type unwraps single value tuples, avoiding the problem.\n */\nexport type JsxChildrenProp<T> = T extends readonly [ any, any, ...any[] ]\n\t// component requires 2+ children, safe to pass the type as-is, just attach the readonly modifier\n\t? T extends readonly [ ...infer C ]\n\t\t? readonly [ ...C ]\n\t\t: T\n\t: T extends readonly [ infer SC ]\n\t\t// component requires a single child, unwrap the tuple\n\t\t? SC\n\t\t: T extends readonly (infer C)[]\n\t\t\t// component requires any number of children, pass as-is, but also append the unwrapped\n\t\t\t// type to allow single child use\n\t\t\t? readonly C[] | C\n\t\t\t// children typed as a non-array type, pass as-is\n\t\t\t: T;\n\n/**\n * Primitive values (or Atoms of such primitives) accepted as text children. Nil and boolean values\n * do not render any text.\n */\nexport type JsxText = MaybeAtom<Nil<string | number | boolean | bigint>>;\n\n/**\n * Describes the objects returned by JSX factories.\n *\n * Pyxis uses lightweight factories returning the props object directly, only adding a few extra\n * symbol-keyed props.\n */\nexport interface JsxObject {\n\t[propName: string]: unknown;\n\n\t/** specifies the ComponentHandler function used to render this object */\n\treadonly [S_COMPONENT]: ComponentHandler;\n\n\t/** specifies the native element tag name, only populated for native elements */\n\treadonly [S_TAG_NAME]?: string;\n\n\t/** holds source code location of individual JSX nodes, only populated in dev mode */\n\treadonly [S_DEV_INFO]?: JsxDevSourceInfo;\n\n\t/** always present and always an array, empty array for childless components */\n\treadonly children: readonly unknown[];\n}\n\nexport interface JsxDevSourceInfo {\n\treadonly fileName: string;\n\treadonly lineNumber: number;\n\treadonly columnNumber: number;\n}\n\n/**\n * Union of all admissible values within JSX.\n */\nexport type JsxResult = JsxObject | JsxText;\n\n/**\n * The type of JSX elements accepted as individual children by common components.\n */\nexport type JsxChildren = JsxResult | readonly JsxChildren[];\n\n/**\n * Utility type adding the standard `children` prop to the given props type.\n */\nexport type WithChildren<T extends PropsType> = T & { children?: JsxChildren };\n\n/**\n * A handler function rendering a specific Component type. This is the real shape of Pyxis\n * components used internally by the framework. `hBefore` is a tracked native anchor. When\n * `isBatch` is true, native insertions append while `hBefore` still determines the position in the\n * tracking hierarchy.\n */\nexport interface ComponentHandler {\n\t<TNode>(\n\t\tjsx: JsxObject,\n\t\thParent: HNode<TNode>,\n\t\thBefore: HNode<TNode> | null,\n\t\tnUsedParent: TNode,\n\t\tnRealParent: TNode,\n\t\tisBatch: boolean,\n\t): void;\n}\n\n// Required base typings for JSX; Element and IntrinsicElements are supplied by adapter libraries\n// or user code when using prefixed extensions\ndeclare global {\n\tnamespace JSX {\n\t\tinterface ElementChildrenAttribute {\n\t\t\tchildren: {};\n\t\t}\n\t}\n}\n","import type { ArgsMax3, Callback, Nil } from \"~/support/types\";\nimport { runtime } from \"~/Runtime\";\n\nimport type { DependencyList } from \"./Dependency\";\nimport type { Scheduler } from \"./Scheduler\";\nimport { __DEV__assertIsDirectComponentCode } from \"~/Component\";\n\nexport interface Lifecycle extends DependencyList {\n\t/** gets a boolean indicating whether this Lifecycle is currently mounted or not */\n\treadonly mounted: boolean;\n\n\t/** @internal */\n\treadonly $scheduler: Scheduler;\n\n\t/**\n\t * tracks the life of this lifecycle, incremented each time it is resurrected - used for\n\t * detecting stale updates scheduled in a previous life\n\t * @internal\n\t */\n\t$life: number;\n\n\t/** @internal */\n\t$onMount?: Nil<Callback[]>;\n\n\t/** @internal */\n\t$onUnmount?: Nil<Callback[]>;\n}\n\nexport interface MountBlock {\n\t(): (() => void) | void;\n}\n\nexport interface UnmountBlock {\n\t(): void;\n}\n\n\n/**\n * Registers a block of code to run once the current Component has mounted.\n *\n * If a teardown callback is returned, it will be run just before the Component unmounts (equivalent\n * to adding a separate `unmounted` block).\n * @see {@link unmounted}\n */\nexport function mounted(block: MountBlock, lifecycle?: Lifecycle) {\n\tif (__DEV__ && lifecycle === undefined) {\n\t\t__DEV__assertIsDirectComponentCode(mounted.name);\n\t}\n\n\tlifecycle ??= getLifecycle();\n\tonceMounted(lifecycle, {\n\t\tfn: invokeMountedCallback,\n\t\ta0: lifecycle,\n\t\ta1: block,\n\t});\n}\n\n/**\n * Similar to {@link mounted}, but instead accepts a {@link Callback} object. Useful in hot paths\n * where it may be desirable to reuse callback objects, avoid closures, or {@link Lifecycle} needs\n * to be tightly controlled.\n * @see {@link mounted}\n */\nexport function onceMounted<TArgs extends ArgsMax3>(lifecycle: Lifecycle, callback: Callback<TArgs>) {\n\t(lifecycle.$onMount ??= []).push(callback as Callback);\n}\n\n/** @internal */\nexport function invokeMountedCallback(lifecycle: Lifecycle, block: MountBlock): void;\nexport function invokeMountedCallback<TArg>(lifecycle: Lifecycle, block: (arg: TArg) => (() => void) | void, arg: TArg): void;\nexport function invokeMountedCallback(lifecycle: Lifecycle, block: (arg: any) => (() => void) | void, arg?: any) {\n\tconst life = lifecycle.$life;\n\tconst dispose = block(arg);\n\tif (dispose) {\n\t\tif (lifecycle.$life > life) {\n\t\t\tdispose();\n\t\t\treturn;\n\t\t}\n\n\t\tonceUnmounted(lifecycle, { fn: dispose });\n\t}\n}\n\n\n/**\n * Registers a block of code to run once the current Component is just about to unmount.\n * @see {@link mounted}\n */\nexport function unmounted(block: UnmountBlock, lifecycle?: Lifecycle) {\n\tif (__DEV__ && lifecycle === undefined) {\n\t\t__DEV__assertIsDirectComponentCode(unmounted.name);\n\t}\n\n\tonceUnmounted(lifecycle ?? getLifecycle(), { fn: block });\n}\n\n/**\n * Similar to {@link unmounted}, but instead accepts a {@link Callback} object. Useful in hot paths\n * where it may be desirable to reuse callback objects, avoid closures, or {@link Lifecycle} needs\n * to be tightly controlled.\n * @see {@link unmounted}\n */\nexport function onceUnmounted<TArgs extends ArgsMax3>(lifecycle: Lifecycle, callback: Callback<TArgs>) {\n\t(lifecycle.$onUnmount ??= []).push(callback as Callback);\n}\n\n\n/**\n * Gets the Lifecycle of the calling component.\n */\nexport function getLifecycle(): Lifecycle {\n\tif (__DEV__ && !runtime.$currentLifecycle) {\n\t\tthrow new Error(\"Cannot get current lifecycle. Are you creating an Atom outside of a Component?\");\n\t}\n\n\treturn runtime.$currentLifecycle!;\n}\n\n/**\n * Runs a block of code with the provided Lifecycle. Calls to `getLifecycle` within the block will\n * return the specified object.\n * @see {@link getLifecycle}\n */\nexport function withLifecycle<TArgs extends ArgsMax3, TReturn>(\n\tlifecycle: Lifecycle,\n\tblock: (...args: TArgs) => TReturn,\n\t...args: TArgs\n): TReturn;\n\nexport function withLifecycle(\n\tlifecycle: Lifecycle,\n\tblock: (a0: any, a1: any, a2: any) => any,\n\ta0?: any,\n\ta1?: any,\n\ta2?: any,\n) {\n\tconst prevLifecycle = runtime.$currentLifecycle;\n\truntime.$currentLifecycle = lifecycle;\n\n\ttry {\n\t\treturn block(a0, a1, a2);\n\t}\n\tfinally {\n\t\truntime.$currentLifecycle = prevLifecycle;\n\t}\n}\n","import { invoke, rethrow } from \"~/support/common\";\nimport type { ArgsMax3, Callback } from \"~/support/types\";\nimport { runtime } from \"~/Runtime\";\n\nimport { getLifecycle, type Lifecycle } from \"./Lifecycle\";\n\n/**\n * Manages a queue of scheduled updates.\n * @internal\n */\nexport interface Scheduler {\n\t/**\n\t * Schedules a new tick to execute, unless one is already pending or executing.\n\t */\n\treadonly $scheduleTick: () => void;\n\n\t/**\n\t * Array of pending effect update callbacks, cleared after each tick.\n\t */\n\treadonly $onEffect: UpdateCallback[];\n\n\t/**\n\t * Array of pending update callbacks, cleared after each tick.\n\t */\n\treadonly $onTick: UpdateCallback[];\n\n\t/**\n\t * Array of pending end-of-tick callbacks, cleared after each tick.\n\t */\n\t$onTock: UpdateCallback[];\n\n\t/**\n\t * Increments with each scheduler tick. Identifies pending callbacks and invalidates any\n\t * discarded callbacks when a tick throws.\n\t */\n\t$epoch: number;\n}\n\n/**\n * An update callback that can be scheduled.\n * @see {@link Scheduler}\n * @internal\n */\nexport interface UpdateCallback<TArgs extends ArgsMax3 = ArgsMax3> extends Callback<TArgs> {\n\t/**\n\t * The Lifecycle responsible for this callback.\n\t */\n\t$lifecycle?: Lifecycle;\n\n\t/**\n\t * The life number of the Lifecycle when this callback was scheduled.\n\t */\n\t$life?: number;\n\n\t/**\n\t * Schedule epoch - tracked to deduplicate callbacks while they are pending. Cleared before\n\t * execution so a running callback can schedule itself again.\n\t */\n\t$se?: number;\n}\n\n/**\n * A function able to schedule a callback to be executed at a later time, e.g. `queueMicrotask`.\n * The function must guarantee that the callback will be eventually executed.\n */\nexport interface TickFn {\n\t(onTick: () => void): void;\n}\n\n/** @internal */\n/*@__NO_SIDE_EFFECTS__*/\nexport function createScheduler(tick: TickFn) {\n\tconst effects: UpdateCallback[] = [];\n\tconst ticks: UpdateCallback[] = [];\n\tlet tocks: UpdateCallback[] = [];\n\tlet tocksParked: UpdateCallback[] = [];\n\tlet isPending = false;\n\n\tconst scheduler: Scheduler = {\n\t\t$epoch: 1,\n\t\t$onEffect: effects,\n\t\t$onTick: ticks,\n\t\t$onTock: tocks,\n\t\t$scheduleTick: () => {\n\t\t\tif (isPending) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tisPending = true;\n\t\t\ttick(update);\n\t\t},\n\t};\n\n\tconst update = () => {\n\t\tconst prevLifecycle = runtime.$currentLifecycle;\n\t\tconst epoch = scheduler.$epoch;\n\t\tlet errors: unknown[] | undefined;\n\t\tlet effectIndex = 0;\n\t\tlet tickIndex = 0;\n\t\tlet callback;\n\n\t\t// Array lengths are re-read on each cycle, as they may increase when additional\n\t\t// callbacks get queued by the code we're invoking.\n\n\t\tdo {\n\t\t\t// drain tick queue first\n\t\t\twhile (tickIndex < ticks.length) {\n\t\t\t\tcallback = ticks[tickIndex++];\n\t\t\t\tcallback.$se = 0;\n\t\t\t\tif (callback.$life === callback.$lifecycle!.$life) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\truntime.$currentLifecycle = callback.$lifecycle!;\n\t\t\t\t\t\tinvoke(callback);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (ex) {\n\t\t\t\t\t\t(errors ??= []).push(ex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// run the next effect, then repeat - the effect may schedule additional ticks\n\t\t\tif (effectIndex < effects.length) {\n\t\t\t\tcallback = effects[effectIndex++];\n\t\t\t\tcallback.$se = 0;\n\t\t\t\tif (callback.$life === callback.$lifecycle!.$life) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\truntime.$currentLifecycle = callback.$lifecycle!;\n\t\t\t\t\t\tinvoke(callback);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (ex) {\n\t\t\t\t\t\t(errors ??= []).push(ex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\twhile (tickIndex < ticks.length || effectIndex < effects.length);\n\n\t\t// The main queue drained, tick phase is now done. There may still be pending tocks\n\t\t// queued, but at this point the current epoch is sealed. If tock callbacks schedule\n\t\t// additional work, it will be queued for the next future update rather than executed\n\t\t// synchronously in this one.\n\n\t\teffects.length = 0;\n\t\tticks.length = 0;\n\n\t\tscheduler.$onTock = tocksParked;\n\t\tscheduler.$epoch = epoch + 1;\n\n\t\t// run pending tocks\n\t\tconst { length } = tocks;\n\t\tlet tockIndex = 0;\n\n\t\tfor (; tockIndex < length; tockIndex += 1) {\n\t\t\tcallback = tocks[tockIndex];\n\n\t\t\t// An earlier tock may have queued this same callback for the next tick (i.e. it is\n\t\t\t// now in both the `tocks` and `tocksParked` queues and is marked with the future\n\t\t\t// epoch number). If this happens, we must keep its pending marker intact,\n\t\t\t// otherwise we can reset it normally.\n\t\t\tif (callback.$se === epoch) {\n\t\t\t\tcallback.$se = 0;\n\t\t\t}\n\n\t\t\tif (callback.$life === callback.$lifecycle!.$life) {\n\t\t\t\ttry {\n\t\t\t\t\truntime.$currentLifecycle = callback.$lifecycle!;\n\t\t\t\t\tinvoke(callback);\n\t\t\t\t}\n\t\t\t\tcatch (ex) {\n\t\t\t\t\t(errors ??= []).push(ex);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// clear tocks queue\n\t\tconst tmp = tocksParked;\n\t\ttocksParked = tocks;\n\t\ttocks = tmp;\n\n\t\ttocksParked.length = 0;\n\n\t\t// unlock and re-schedule if needed\n\t\tisPending = false;\n\t\tif (ticks.length || tocks.length) {\n\t\t\tscheduler.$scheduleTick();\n\t\t}\n\n\t\t// restore original lifecycle\n\t\truntime.$currentLifecycle = prevLifecycle;\n\n\t\t// re-throw errors, if there were any\n\t\trethrow(errors);\n\t};\n\n\treturn scheduler;\n}\n\nfunction schedule(lifecycle: Lifecycle, queue: UpdateCallback[], callback: UpdateCallback) {\n\t// always update lifecycle metadata - the callback object may have been reused while the\n\t// lifecycle changed, which could happen in a single tick, so this cannot skipped\n\tcallback.$lifecycle = lifecycle;\n\tcallback.$life = lifecycle.$life;\n\n\tconst scheduler = lifecycle.$scheduler;\n\tif (callback.$se === scheduler.$epoch) {\n\t\t// This callback is already pending; It will observe the latest state when it runs.\n\t\treturn;\n\t}\n\n\tcallback.$se = scheduler.$epoch;\n\tqueue.push(callback);\n\tscheduler.$scheduleTick();\n}\n\n/** @internal */\nexport function scheduleEffect(lifecycle: Lifecycle, callback: UpdateCallback) {\n\tschedule(lifecycle, lifecycle.$scheduler.$onEffect, callback);\n}\n\n/**\n * Runs a block of code on the next tick of the scheduler, synchronized with other updates. Unless\n * a tick is already pending, a new one is scheduled.\n *\n * Atoms written within the block will deliver their update notifications synchronously within the\n * same tick.\n */\nexport function tick(block: () => void, lifecycle = getLifecycle()) {\n\tschedule(lifecycle, lifecycle.$scheduler.$onTick, { fn: block });\n}\n\n/**\n * Similar to {@link tick}, but instead accepts a {@link Callback} object. Useful in hot paths\n * where it may be desirable to reuse callback objects and/or avoid closures.\n * @see {@link tick}\n */\nexport function scheduleTick<TArgs extends ArgsMax3>(lifecycle: Lifecycle, callback: Callback<TArgs>) {\n\tschedule(lifecycle, lifecycle.$scheduler.$onTick, callback as UpdateCallback);\n}\n\n/**\n * Runs a block of code immediately after the next tick of the scheduler, once all regular updates\n * have finished. Unless a tick is already pending, a new one is scheduled.\n *\n * While it is possible to write Atoms within the block, their update notifications are\n * no longer delivered in the same scheduler tick - they're postponed to the next one.\n */\nexport function tock(block: () => void, lifecycle = getLifecycle()) {\n\tschedule(lifecycle, lifecycle.$scheduler.$onTock, { fn: block });\n}\n\n/**\n * Similar to {@link tock}, but instead accepts a {@link Callback} object. Useful in hot paths\n * where it may be desirable to reuse callback objects and/or avoid closures.\n * @see {@link tock}\n */\nexport function scheduleTock<TArgs extends ArgsMax3>(lifecycle: Lifecycle, callback: Callback<TArgs>) {\n\tschedule(lifecycle, lifecycle.$scheduler.$onTock, callback as UpdateCallback);\n}\n","import type { ArgsMax3, Nil } from \"~/support/types\";\n\nimport { getLifecycle, onceUnmounted, type Lifecycle } from \"./Lifecycle\";\nimport { link, unlink, type Dependency, type DependencyList } from \"./Dependency\";\nimport { scheduleEffect, type UpdateCallback } from \"./Scheduler\";\nimport { runtime } from \"~/Runtime\";\n\nexport interface EffectBlock {\n\t(): (() => void) | void;\n}\n\nexport interface Effect<T> {\n\t/** @internal */\n\treadonly $lifecycle: Lifecycle;\n\n\t/** @internal */\n\treadonly $life: number;\n\n\t/** @internal */\n\treadonly $block: () => T;\n\n\t/** @internal */\n\treadonly $react: (effect: this, cycle: number) => void;\n\n\t/**\n\t * Keeps track of the effect run cycle, incrementing on each effect run. Used to detect stale\n\t * dependencies and lazily unlink them.\n\t * @internal\n\t */\n\t$cycle: number;\n\n\t/**\n\t * The head of the effect dependencies linked list.\n\t * @internal\n\t */\n\t$eh?: Nil<EffectDependency>;\n\n\t/**\n\t * The tail of the effect dependencies linked list.\n\t * @internal\n\t */\n\t$et?: Nil<EffectDependency>;\n\n\t/**\n\t * The number of previously unseen Atoms accessed during the current Effect run.\n\t * @internal\n\t */\n\t$rc?: number;\n\n\t/** @internal */\n\t$deps?: WeakMap<DependencyList, EffectDependency>;\n\n\t/** @internal */\n\t$resolve?: UpdateCallback<[ effect: this ]>;\n\n\t/** @internal */\n\t$dispose?: Nil<() => void>;\n\n\t/** @internal */\n\t$tracksUnmount?: true;\n}\n\n/** @internal */\nexport interface EffectDependency extends Dependency<[ effect: Effect<any>, cycle: number ]> {\n\t/**\n\t * Previous EffectDependency within an Effect's dependency list.\n\t */\n\t$ep?: Nil<EffectDependency>;\n\n\t/**\n\t * Next EffectDependency within an Effect's dependency list.\n\t */\n\t$en?: Nil<EffectDependency>;\n}\n\n/**\n * Creates an Effect - a block of logic executed each time any of the Atoms accessed within it\n * change. The block is first synchronously executed when the Effect is created. Atoms may be\n * written or even created within the block, but note that writing an Atom this Effect depends on\n * may cause an infinite update loop when the state doesn't converge to a point where no more\n * re-runs of this Effect are required.\n *\n * When a teardown callback is returned, it will be run before the next re-run of this Effect, or\n * once the enclosing Component unmounts, whichever comes first.\n */\nexport function effect(block: EffectBlock, lifecycle = getLifecycle()) {\n\trunEffect({\n\t\t$lifecycle: lifecycle,\n\t\t$life: lifecycle.$life,\n\t\t$block: block,\n\t\t$react: scheduleReaction,\n\t\t$cycle: 0,\n\t});\n}\n\nfunction scheduleReaction(this: EffectDependency, effect: Effect<ReturnType<EffectBlock>>, cycle: number) {\n\t// lazy cleanup: when we get an update from a stale dependency, the reported cycle will be lower\n\t// than our current one (see the reportAccess function). We can unlink and skip the effect.\n\tif (effect.$cycle > cycle) {\n\t\tunlinkEffectDep(effect, this);\n\t\treturn;\n\t}\n\n\t// we're already within a scheduler tick; the effect will therefore run synchronously despite\n\t// being \"scheduled\" - this also gives priority to already queued updates and coalesces\n\t// additional re-run attempts while the first one is still pending.\n\tscheduleEffect(effect.$lifecycle, effect.$resolve ??= {\n\t\tfn: runEffect,\n\t\ta0: effect,\n\t});\n}\n\nfunction runEffect(effect: Effect<ReturnType<EffectBlock>>) {\n\tconst lifecycle = effect.$lifecycle;\n\n\t// effect was scheduled in a previous life and is now stale\n\tif (effect.$life !== lifecycle.$life) {\n\t\treturn;\n\t}\n\n\tteardownEffect(effect);\n\n\t// the teardown may have unmounted the owner lifecycle\n\tif (effect.$life !== lifecycle.$life) {\n\t\treturn;\n\t}\n\n\teffect.$dispose = resolve(effect) as Nil<() => void>;\n\n\t// the effect body also may cause the owner to unmount... if so, dispose immediately\n\tif (effect.$life !== lifecycle.$life) {\n\t\tteardownEffect(effect);\n\t\treturn;\n\t}\n\n\tif (!effect.$tracksUnmount && effect.$dispose) {\n\t\teffect.$tracksUnmount = true;\n\t\tonceUnmounted(lifecycle, {\n\t\t\tfn: teardownEffect,\n\t\t\ta0: effect,\n\t\t});\n\t}\n}\n\nfunction teardownEffect(effect: Effect<ReturnType<EffectBlock>>) {\n\tconst fn = effect.$dispose;\n\tif (!fn) {\n\t\treturn;\n\t}\n\n\tconst prevLifecycle = runtime.$currentLifecycle;\n\truntime.$currentLifecycle = effect.$lifecycle;\n\teffect.$dispose = null;\n\n\ttry {\n\t\tfn();\n\t}\n\tfinally {\n\t\truntime.$currentLifecycle = prevLifecycle;\n\t}\n}\n\n/**\n * Resolves an Effect: runs user logic tracking accessed Atoms and updating dependency links.\n * Returned value is forwarded.\n * @internal\n */\nexport function resolve<TEffect extends Effect<any>>(effect: TEffect): TEffect extends Effect<infer T> ? T : unknown {\n\teffect.$rc = 0;\n\n\tconst cycle = (effect.$cycle += 1);\n\tconst prevLifecycle = runtime.$currentLifecycle;\n\tconst prevEffect = runtime.$currentEffect;\n\tconst prevTail = effect.$et;\n\truntime.$currentLifecycle = effect.$lifecycle;\n\truntime.$currentEffect = effect;\n\n\ttry {\n\t\treturn effect.$block();\n\t}\n\tfinally {\n\t\truntime.$currentLifecycle = prevLifecycle;\n\t\truntime.$currentEffect = prevEffect;\n\n\t\t// on re-runs, check if new Atoms were accessed - if so, eagerly cleanup\n\t\tif (cycle > 1 && effect.$rc > 0 && prevTail) {\n\t\t\tlet current = effect.$eh;\n\t\t\tlet next;\n\n\t\t\twhile (current) {\n\t\t\t\tnext = current.$en;\n\t\t\t\tif (current.a1! < cycle) {\n\t\t\t\t\tunlinkEffectDep(effect, current);\n\t\t\t\t}\n\n\t\t\t\t// beyond the previous tail, there can only be new dependencies -> cleanup done\n\t\t\t\tif (current === prevTail) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcurrent = next;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Unlinks an EffectDependency from the Effect, its Lifecycle and the target Atom. Also deletes its\n * entry from the deps WeakMap.\n * @internal\n */\nexport function unlinkEffectDep<TEffect extends Effect<any>>(effect: TEffect, dep: EffectDependency) {\n\tif (dep.$ep) {\n\t\tdep.$ep.$en = dep.$en;\n\t}\n\telse if (effect.$eh === dep) {\n\t\teffect.$eh = dep.$en;\n\t}\n\n\tif (dep.$en) {\n\t\tdep.$en.$ep = dep.$ep;\n\t}\n\telse if (effect.$et === dep) {\n\t\teffect.$et = dep.$ep;\n\t}\n\n\tdep.$ep = null;\n\tdep.$en = null;\n\n\teffect.$deps?.delete(dep.$target!);\n\tunlink(dep);\n}\n\n/**\n * Reports an Atom has been accessed. Does nothing if not within an Effect.\n * @internal\n */\nexport function reportAccess(atom: DependencyList) {\n\tconst currentEffect = runtime.$currentEffect;\n\tif (!currentEffect || currentEffect.$life !== currentEffect.$lifecycle.$life) {\n\t\treturn;\n\t}\n\n\t// look for a Dependency object already linked to this Atom\n\tconst deps = currentEffect.$deps;\n\tlet dep: EffectDependency | null | undefined;\n\tlet count = 0;\n\n\tif (deps) {\n\t\tdep = deps.get(atom);\n\t}\n\telse {\n\t\tdep = currentEffect.$eh;\n\t\twhile (dep) {\n\t\t\tcount += 1;\n\t\t\tif (dep.$target === atom) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdep = dep.$en;\n\t\t}\n\t}\n\n\tif (dep) {\n\t\t// Dependency found, refresh its cycle number\n\t\tdep.a1 = currentEffect.$cycle;\n\t\tif (!dep.$lifecycle) {\n\t\t\t// Dependency has become temporarily stale and got unlinked while still lingering in\n\t\t\t// the $deps WeakMap - that's okay, but it must be re-linked to work again\n\t\t\tlink(currentEffect.$lifecycle, atom, dep);\n\t\t}\n\t}\n\telse {\n\t\t// no Dependency found, link a new one for this Atom\n\t\tlink(currentEffect.$lifecycle, atom, dep = {\n\t\t\tfn: currentEffect.$react,\n\t\t\ta0: currentEffect,\n\t\t\ta1: currentEffect.$cycle,\n\t\t});\n\n\t\tif (deps) {\n\t\t\tdeps.set(atom, dep);\n\t\t}\n\t\telse if (count >= 5) {\n\t\t\t// this Effect now has enough Dependencies to justify a WeakMap for faster lookups\n\t\t\tconst map = currentEffect.$deps = new WeakMap<DependencyList, EffectDependency>();\n\n\t\t\t// insert existing Dependencies to the map\n\t\t\tlet current = currentEffect.$eh;\n\t\t\tdo {\n\t\t\t\tmap.set(current!.$target!, current!);\n\t\t\t}\n\t\t\twhile (current = current!.$en);\n\n\t\t\t// insert the new Dependency\n\t\t\tmap.set(atom, dep);\n\t\t}\n\n\t\t// link to the Effect itself (the link function only links to Lifecycle and the Atom)\n\t\tif (currentEffect.$et) {\n\t\t\tcurrentEffect.$et.$en = dep;\n\t\t\tdep.$ep = currentEffect.$et;\n\t\t}\n\t\telse {\n\t\t\tcurrentEffect.$eh = dep;\n\t\t}\n\n\t\tcurrentEffect.$et = dep;\n\t\tcurrentEffect.$rc! += 1;\n\t}\n}\n\n/**\n * Runs a block of code removed from any effects. Accessing atoms within this block will be ignored\n * by any effect that may otherwise be observing this code.\n */\nexport function noEffect<TArgs extends ArgsMax3, TReturn>(\n\tblock: (...args: TArgs) => TReturn,\n\t...args: TArgs\n): TReturn;\n\nexport function noEffect(\n\tblock: (a0: any, a1: any, a2: any) => any,\n\ta0?: any,\n\ta1?: any,\n\ta2?: any,\n) {\n\tconst prevEffect = runtime.$currentEffect;\n\truntime.$currentEffect = null;\n\n\ttry {\n\t\treturn block(a0, a1, a2);\n\t}\n\tfinally {\n\t\truntime.$currentEffect = prevEffect;\n\t}\n}\n","import type { Nil } from \"~/support/types\";\nimport { runtime } from \"~/Runtime\";\nimport { S_ATOM } from \"~/symbols\";\n\nimport { notify, type DependencyList } from \"./Dependency\";\nimport { reportAccess } from \"./Effect\";\nimport { getLifecycle, type Lifecycle } from \"./Lifecycle\";\nimport { scheduleTick } from \"./Scheduler\";\n\n/**\n * Holds any single value, managing reactions to its changes. A bare Atom is read-only. Use the\n * `read` and `peek` functions to access its value.\n * @see {@link read}\n * @see {@link peek}\n * @see {@link WriteAtom}\n */\nexport interface Atom<out T = unknown> extends DependencyList {\n\t/** Pyxis Atom type guard marker. */\n\treadonly [S_ATOM]: true;\n\n\t/** @internal */\n\treadonly $lifecycle: Lifecycle;\n\n\t/** @internal */\n\t$tracksValue?: boolean;\n\n\t/** @internal */\n\t$lastValue?: T;\n\n\t/**\n\t * The ID of this Atom, only present in development mode with transpiler.\n\t * @internal\n\t */\n\t$devId?: string;\n\n\t/**\n\t * Gets the value of this Atom. Only use this method when the target is guaranteed to be an\n\t * Atom, otherwise it is recommended to use the `read` or `peek` functions.\n\t *\n\t * This method does *not* report access, thus within effects it is analogous to `peek`.\n\t * @see {@link read}\n\t * @see {@link peek}\n\t */\n\tget: () => T;\n}\n\n/**\n * Holds any single value, managing reactions to its changes. Values of WriteAtom are mutable and\n * can be freely changed at any time. Use the `read`, `peek`, `write` or `update` functions to\n * access or manipulate its value.\n * @see {@link read}\n * @see {@link peek}\n * @see {@link write}\n * @see {@link update}\n * @see {@link Atom}\n */\nexport interface WriteAtom<T = unknown> extends Atom<T> {\n\t/**\n\t * Sets the value of this Atom. Does nothing if this Atom is readonly. This method does *not*\n\t * emit any change notification to the Atom's observers; Using it recklessly can leave observers\n\t * out of date with stale state! Please make sure you know exactly what you're doing; It is\n\t * *strongly* recommended to use the `write` or `update` functions instead.\n\t *\n\t * @returns Boolean indicating whether the value of this Atom changed.\n\t * @see {@link write}\n\t * @see {@link update}\n\t */\n\tset: (value: T) => boolean;\n}\n\ninterface DirectAtom<T> extends WriteAtom<any> {\n\t$value: T;\n}\n\n/**\n * Union of the given type or an Atom of that type. Use the `read`, `peek` or `isAtom` functions to\n * interact with such values.\n * @see {@link read}\n * @see {@link peek}\n * @see {@link isAtom}\n */\nexport type MaybeAtom<T> = Atom<T> | T;\n\n/**\n * Union of the given type or a WriteAtom of that type. Use the `read`, `peek`, `write`, `update` or\n * `isAtom` functions to interact with such values.\n * @see {@link read}\n * @see {@link peek}\n * @see {@link write}\n * @see {@link update}\n * @see {@link isAtom}\n */\nexport type MaybeWriteAtom<T> = WriteAtom<T> | T;\n\n/**\n * Creates an empty WriteAtom; i.e. value set to `undefined`.\n */\nexport function atomOf<T>(): WriteAtom<T | undefined>;\n\n/**\n * Creates a WriteAtom initialized to the provided value.\n *\n * If the provided initial value is itself an Atom, its value is automatically unwrapped.\n *\n * If you're intentionally creating an Atom intended to hold other Atoms, create an empty Atom first\n * and write it separately, e.g.:\n *\n * ```ts\n * const atom = atomOf<Atom<number>>();\n * write(atom, otherAtom);\n * ```\n */\nexport function atomOf<T>(initialValue: MaybeAtom<T>, lifecycle?: Lifecycle, devId?: string): WriteAtom<T>;\n\nexport function atomOf<T>(initialValue?: MaybeAtom<T>, lifecycle = getLifecycle()) {\n\tif (isAtom(initialValue)) {\n\t\tinitialValue = initialValue.get();\n\t}\n\n\tconst atom: DirectAtom<T> = {\n\t\t[S_ATOM]: true,\n\t\t$value: initialValue as T,\n\t\t$tracksValue: true,\n\t\t$lifecycle: lifecycle,\n\t\t$lastValue: initialValue,\n\t\tget: getValue,\n\t\tset: setValue,\n\t};\n\n\tif (__DEV__) {\n\t\tconst devId = arguments[2];\n\t\tatom.$devId = devId;\n\t\truntime.$hmrState!.restore(lifecycle, devId, value => {\n\t\t\tatom.$value = value;\n\t\t\tatom.$lastValue = value;\n\t\t});\n\t}\n\n\treturn atom;\n}\n\nfunction getValue<T>(this: DirectAtom<T>) {\n\treturn this.$value;\n}\n\nfunction setValue<T>(this: DirectAtom<T>, value: T) {\n\tif (Object.is(this.$value, value)) {\n\t\treturn false;\n\t}\n\n\tthis.$value = value;\n\tif (__DEV__) {\n\t\truntime.$hmrState!.preserve(this.$lifecycle, this.$devId, value);\n\t}\n\n\treturn true;\n}\n\n/**\n * Atom type guard, checks if the provided input is an Atom.\n */\nexport function isAtom<T = unknown>(input: Nil<MaybeWriteAtom<T>>): input is WriteAtom<T>;\nexport function isAtom<T = unknown>(input: Nil<MaybeAtom<T>>): input is Atom<T>;\nexport function isAtom<T = unknown>(input: unknown): input is WriteAtom<T>;\nexport function isAtom(input: unknown): input is WriteAtom<any> {\n\treturn (\n\t\tinput !== null &&\n\t\ttypeof input === \"object\" &&\n\t\t(input as { [S_ATOM]?: true })[S_ATOM] === true\n\t);\n}\n\n/**\n * Checks if the provided input is an Atom and reads its value. Non-atom inputs are returned as-is.\n * Reports read access when inside an effect.\n * @see {@link isAtom}\n * @see {@link peek}\n * @see {@link write}\n * @see {@link update}\n */\nexport function read<A>(input: A): A extends MaybeAtom<infer T> ? T : never;\nexport function read<T>(input: MaybeAtom<T>) {\n\tif (isAtom<T>(input)) {\n\t\treportAccess(input);\n\t\treturn input.get();\n\t}\n\n\treturn input;\n}\n\n/**\n * Checks if the provided input is an Atom and reads its value. Non-atom inputs are returned as-is.\n * Does NOT report read access when inside an effect.\n * @see {@link isAtom}\n * @see {@link read}\n * @see {@link write}\n * @see {@link update}\n */\nexport function peek<A>(input: A): A extends MaybeAtom<infer T> ? T : never;\nexport function peek<T>(input: MaybeAtom<T>): T {\n\tif (isAtom<T>(input)) {\n\t\treturn input.get();\n\t}\n\n\treturn input;\n}\n\n/**\n * Checks if the provided input is an Atom, writes its value and returns the new value.\n *\n * Writing readonly Atoms is simply a no-op. Their current value will be returned and the provided\n * new value discarded.\n *\n * Non-atom inputs are never modified in any way. Instead the provided new value is discarded and\n * the input is returned as-is.\n * @see {@link isAtom}\n * @see {@link read}\n * @see {@link peek}\n * @see {@link update}\n */\nexport function write<A>(\n\tinput: A,\n\tvalue: A extends WriteAtom<infer T> ? T : never,\n\tforce?: boolean,\n): A extends MaybeWriteAtom<infer T> ? T : never;\n\nexport function write<T>(input: MaybeWriteAtom<T>, value: T, force = false): T {\n\tif (!isAtom(input)) {\n\t\treturn input;\n\t}\n\n\tif (input.set(value) || force) {\n\t\tif (input.$dh) {\n\t\t\tinput.$force ||= force;\n\t\t\tscheduleAtomNotification(input);\n\t\t}\n\t\telse if (input.$tracksValue) {\n\t\t\treturn (input.$lastValue = input.get());\n\t\t}\n\t}\n\n\treturn input.get();\n}\n\n/**\n * Checks if the provided input is an Atom, updates its value using the provided transform function\n * and returns the new value.\n *\n * Updating readonly Atoms is simply a no-op. Their current value will be returned and the\n * transformed new value discarded.\n *\n * Non-atom inputs are never modified in any way and the input is returned as-is.\n * @see {@link isAtom}\n * @see {@link read}\n * @see {@link peek}\n * @see {@link write}\n */\nexport function update<A>(\n\tinput: A,\n\ttransform: A extends WriteAtom<infer T> ? (value: T) => T : never,\n\tforce?: boolean,\n): A extends MaybeWriteAtom<infer T> ? T : never;\n\nexport function update<T>(input: MaybeWriteAtom<T>, transform: (value: T) => T, force = false): T {\n\tif (!isAtom(input)) {\n\t\treturn input;\n\t}\n\n\tconst value = transform(input.get());\n\tif (input.set(value) || force) {\n\t\tif (input.$dh) {\n\t\t\tinput.$force ||= force;\n\t\t\tscheduleAtomNotification(input);\n\t\t}\n\t\telse if (input.$tracksValue) {\n\t\t\treturn (input.$lastValue = input.get());\n\t\t}\n\t}\n\n\treturn input.get();\n}\n\n/**\n * Schedules a notification to be emitted for the given Atom.\n * @internal\n */\nexport function scheduleAtomNotification<T>(atom: Atom<T>) {\n\tscheduleTick(atom.$lifecycle, atom.$notify ??= {\n\t\tfn: notifyAtomObservers,\n\t\ta0: atom,\n\t});\n}\n\n/**\n * Notifies the dependencies of an Atom.\n * @internal\n */\nexport function notifyAtomObservers<T>(atom: Atom<T>) {\n\t// optimization: when Atom changes multiple times within a single update and ends up with the\n\t// same value it started with, the notification can be skipped, unless forced - this flag is set\n\t// either by users via the `write` or `update` functions, or by the framework when a new\n\t// observer joins while a notification is already pending and might've seen an outdated value\n\tif (atom.$tracksValue) {\n\t\tconst newValue = atom.get();\n\t\tif (!atom.$force && Object.is(atom.$lastValue, newValue)) {\n\t\t\treturn;\n\t\t}\n\n\t\tatom.$lastValue = newValue;\n\t}\n\n\tatom.$force = false;\n\tnotify(atom);\n}\n","import { isAtom, type Atom } from \"~/data/Atom\";\nimport type { ContextContainer } from \"~/data/Context\";\nimport { bind, teardown, type Dependency } from \"~/data/Dependency\";\nimport type { Lifecycle } from \"~/data/Lifecycle\";\nimport { createScheduler } from \"~/data/Scheduler\";\nimport { invoke, rethrow } from \"~/support/common\";\nimport type { ArgsMax3, ElementsType, Mutable, Nil } from \"~/support/types\";\n\nimport type { Adapter, ExtensionsType } from \"./Adapter\";\nimport type { ComponentHandler, JsxResult } from \"./Component\";\nimport { runtime } from \"./Runtime\";\nimport { S_COMPONENT } from \"./symbols\";\n\nexport interface Renderer<TNode, TElements extends ElementsType = ElementsType> extends Lifecycle {\n\t/**\n\t * Carries information about the available intrinsic elements when using this Renderer.\n\t * @deprecated **Type only, does not exist at runtime!**\n\t */\n\treadonly $elements?: TElements;\n\n\tmount: (root: TNode, jsx: JsxResult) => MountingGroup<TNode>;\n\tunmount: (group: MountingGroup<TNode>) => void;\n}\n\n/** Extracts the typings of intrinsic elements supported by the given Renderer. */\nexport type ElementsOf<TRenderer, TFallback extends ElementsType = {}> = (\n\tTRenderer extends { readonly $elements?: infer TElements extends ElementsType }\n\t\t? TElements\n\t\t: TFallback\n);\n\n\nexport interface MountingGroup<TNode> extends Lifecycle, Hierarchy<TNode> {\n\t/** @internal */\n\treadonly $isGroup: true;\n\n\t/** @internal */\n\treadonly $isNative?: never;\n\n\t/** the Adapter rendering this MountingGroup */\n\treadonly adapter: Adapter<TNode>;\n\n\t/** @internal */\n\treadonly $extensions: ExtensionsType<TNode>;\n\n\t/** @internal */\n\treadonly $context: ContextContainer | null;\n\n\t/** @internal */\n\tmounted: boolean;\n\n\t/**\n\t * active render nesting depth - only the outermost invocation occupies the mount stack\n\t * @internal\n\t */\n\t$depth: number;\n\n\t/**\n\t * tracks whether all mounting work has been completed and that this Lifecycle can be\n\t * \"officially\" mounted\n\t * @internal\n\t */\n\t$canMount?: boolean;\n}\n\ninterface NativeNode<TNode> extends Hierarchy<TNode> {\n\t/** @internal */\n\treadonly $isNative: true;\n\n\t/** @internal */\n\treadonly $isGroup?: never;\n\n\t/** @internal */\n\treadonly $nn: TNode;\n}\n\ninterface Hierarchy<TNode> {\n\t/** @internal */\n\treadonly $isGroup?: true;\n\n\t/** @internal */\n\treadonly $isNative?: true;\n\n\t/**\n\t * the nearest mounting group - can be self\n\t * @internal\n\t */\n\treadonly $ng: MountingGroup<TNode>;\n\n\t/**\n\t * the nearest native node (ancestor or self) - on groups, this is only present in dev mode\n\t * @internal\n\t */\n\treadonly $nn?: TNode;\n\n\t/**\n\t * the parent h-node of this h-node\n\t * @internal\n\t */\n\t$ph: HNode<TNode> | null;\n\n\t/**\n\t * the first child of this h-node\n\t * @internal\n\t */\n\t$hh?: Nil<HNode<TNode>>;\n\n\t/**\n\t * the last child of this h-node\n\t * @internal\n\t */\n\t$ht?: Nil<HNode<TNode>>;\n\n\t/**\n\t * the previous sibling of this h-node\n\t * @internal\n\t */\n\t$hp?: Nil<HNode<TNode>>;\n\n\t/**\n\t * the next sibling of this h-node\n\t * @internal\n\t */\n\t$hn?: Nil<HNode<TNode>>;\n\n\t/**\n\t * tracks whether unmounting is in progress for this node, guarding against duplicate or cyclic\n\t * unmount attempts\n\t */\n\t$isUnmounting?: boolean;\n}\n\nexport type HNode<TNode> =\n\t| MountingGroup<TNode>\n\t| NativeNode<TNode>;\n\n\n/** @internal */\n/*@__NO_SIDE_EFFECTS__*/\nexport function createRenderer<TNode, TIntrinsicElements extends ElementsType>(\n\tadapter: Adapter<TNode>,\n\textensions: ExtensionsType<TNode>,\n): Renderer<TNode, TIntrinsicElements> {\n\tconst hRoot: Mutable<MountingGroup<TNode> & Renderer<TNode, TIntrinsicElements>> = {\n\t\tadapter: adapter,\n\t\tmounted: true,\n\t\t$isGroup: true,\n\t\t$scheduler: createScheduler(adapter.tick),\n\t\t$extensions: extensions,\n\t\t$context: null,\n\t\t$depth: 0,\n\t\t$life: 1,\n\t\t$ng: null!,\n\t\t$ph: null,\n\t\tunmount: destroy,\n\t\tmount: (nRoot, jsx) => {\n\t\t\tconst hGroup = fork(hRoot, null, null);\n\t\t\ttry {\n\t\t\t\twillMount(hGroup, () => {\n\t\t\t\t\tconst isBatch = !!adapter.batch;\n\t\t\t\t\tconst nParent = isBatch ? adapter.batch!() : nRoot;\n\t\t\t\t\tmount(jsx, hGroup, null, nParent, nRoot, isBatch);\n\t\t\t\t\tif (isBatch) {\n\t\t\t\t\t\tadapter.insert(nParent, nRoot, null);\n\t\t\t\t\t\tflush(hGroup);\n\t\t\t\t\t}\n\t\t\t\t})();\n\n\t\t\t\treturn hGroup;\n\t\t\t}\n\t\t\tcatch (ex) {\n\t\t\t\tdestroy(hGroup, [ ex ]);\n\t\t\t}\n\t\t},\n\t};\n\n\thRoot.$ng = hRoot;\n\treturn hRoot;\n}\n\n/**\n * Unmounts a MountingGroup and removes it from the hierarchy. The removal is guaranteed even if\n * user code throws during unmount. Also clears refs to its original parent node. Destroyed groups\n * cannot be reused.\n */\nexport function destroy<TNode>(hGroup: MountingGroup<TNode>): void;\n\n/** @internal */\nexport function destroy<TNode>(hGroup: MountingGroup<TNode>, errors: [ unknown, ...unknown[] ]): never;\n\nexport function destroy<TNode>(hGroup: MountingGroup<TNode>, errors?: unknown[]) {\n\tif (!hGroup.$isUnmounting && !deferUnmount(hGroup, true)) {\n\t\terrors = doUnmount(hGroup, errors);\n\t\tuntrack(hGroup);\n\t\thGroup.$ph = null;\n\t}\n\n\trethrow(errors);\n}\n\n/**\n * Creates a sub-group within the provided MountingGroup. Needed whenever a subtree needs to mount\n * or unmount dynamically.\n */\nexport function fork<TNode>(\n\thParent: HNode<TNode>,\n\thBefore?: HNode<TNode> | null,\n): MountingGroup<TNode>;\n\n/** @internal */\nexport function fork<TNode>(\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null,\n\tcontext: ContextContainer | null,\n): MountingGroup<TNode>\n\nexport function fork<TNode>(\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null = null,\n\tcontext: ContextContainer | null = runtime.$currentContext,\n): MountingGroup<TNode> {\n\tconst ng = hParent.$ng;\n\tconst hGroup: Mutable<MountingGroup<TNode>> = {\n\t\tadapter: ng.adapter,\n\t\tmounted: false,\n\t\t$isGroup: true,\n\t\t$scheduler: ng.$scheduler,\n\t\t$extensions: ng.$extensions,\n\t\t$context: context,\n\t\t$depth: 0,\n\t\t$life: 1,\n\t\t$ng: null!,\n\t\t$ph: hParent,\n\t};\n\n\thGroup.$ng = hGroup;\n\tif (__DEV__) {\n\t\thGroup.$nn = hParent.$nn;\n\t}\n\n\ttrack(hGroup, hParent, hBefore);\n\treturn hGroup;\n}\n\n/**\n * Inserts a HNode to the hierarchy. When reusing nodes, callers must make sure `untrack` has been\n * previously called on the node to be re-inserted.\n * @see {@link untrack}\n */\nexport function track<TNode>(\n\thNode: HNode<TNode>,\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null = null,\n) {\n\t// insert into hierarchy before given sibling\n\tif (hBefore?.$ph === hParent) {\n\t\tif (hBefore.$hp) {\n\t\t\thNode.$hp = hBefore.$hp;\n\t\t\thNode.$hn = hBefore;\n\t\t\thBefore.$hp.$hn = hNode;\n\t\t\thBefore.$hp = hNode;\n\t\t}\n\t\telse {\n\t\t\thNode.$hp = null;\n\t\t\thNode.$hn = hParent.$hh;\n\t\t\tif (hParent.$hh === hBefore) {\n\t\t\t\t// this should always run: since before has no previous sibling, it must be at the\n\t\t\t\t// head, otherwise the hierarchy is malformed and bad things will happen...\n\t\t\t\thBefore.$hp = hNode;\n\t\t\t}\n\n\t\t\thParent.$hh = hNode;\n\t\t}\n\t}\n\t// append at the tail of the hierarchy\n\telse {\n\t\tif (hParent.$ht) {\n\t\t\thParent.$ht.$hn = hNode;\n\t\t\thNode.$hp = hParent.$ht;\n\t\t}\n\t\telse {\n\t\t\thParent.$hh = hNode;\n\t\t}\n\n\t\thParent.$ht = hNode;\n\t}\n\n\thNode.$ph = hParent;\n}\n\n/**\n * Removes a HNode from the tracking hierarchy. Removed nodes may be reused and re-inserted using\n * the `track` function.\n * @see {@link track}\n */\nexport function untrack<TNode>(hNode: HNode<TNode>) {\n\tif (hNode.$hp) {\n\t\thNode.$hp.$hn = hNode.$hn;\n\t}\n\telse if (hNode.$ph?.$hh === hNode) {\n\t\thNode.$ph.$hh = hNode.$hn;\n\t}\n\n\tif (hNode.$hn) {\n\t\thNode.$hn.$hp = hNode.$hp;\n\t}\n\telse if (hNode.$ph?.$ht === hNode) {\n\t\thNode.$ph.$ht = hNode.$hp;\n\t}\n\n\thNode.$hp = null;\n\thNode.$hn = null;\n}\n\n/**\n * Creates a reusable callback for a complete render operation, including reactive reads, nested\n * mounts and batch commits. Each invocation defers conflicting unmounts until the outermost render\n * finishes, preserves the caller's reactive tracking, and returns the block's result unchanged.\n *\n * Deferred teardown errors are reported by the outermost render, after all requests are processed.\n */\nexport function willMount<TNode, TArgs extends ArgsMax3, TResult>(\n\thGroup: MountingGroup<TNode>,\n\tblock: (...args: TArgs) => TResult,\n): (...args: TArgs) => TResult;\n\nexport function willMount<TNode>(\n\thGroup: MountingGroup<TNode>,\n\tblock: (...args: ArgsMax3) => any,\n) {\n\treturn (a0?: any, a1?: any, a2?: any) => {\n\t\tconst mounts = runtime.$mounts ??= [];\n\t\tif (++hGroup.$depth === 1) {\n\t\t\tmounts.push(hGroup);\n\t\t}\n\n\t\tlet errors: unknown[] | undefined;\n\t\ttry {\n\t\t\treturn block(a0, a1, a2);\n\t\t}\n\t\tcatch (ex) {\n\t\t\t(errors ??= []).push(ex);\n\t\t}\n\t\tfinally {\n\t\t\tif (--hGroup.$depth === 0) {\n\t\t\t\tmounts.pop();\n\t\t\t}\n\n\t\t\tfinishMount(errors);\n\t\t}\n\t};\n}\n\n/**\n * Mounts JSX into a group that is not already mounted. When rendering into an externally owned\n * batch, enclose the complete operation (including the commit and `flush`) in {@link willMount}.\n */\nexport function mount<TNode>(\n\tjsx: any,\n\thParent: MountingGroup<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnUsedParent: TNode,\n\tnRealParent: TNode,\n\tisBatch: boolean,\n) {\n\tif (hParent.mounted) {\n\t\treturn;\n\t}\n\n\tconst mounts = runtime.$mounts ??= [];\n\tif (++hParent.$depth === 1) {\n\t\tmounts.push(hParent);\n\t}\n\n\tconst prevLifecycle = runtime.$currentLifecycle;\n\tconst prevEffect = runtime.$currentEffect;\n\tconst prevContext = runtime.$currentContext;\n\tconst prevContextNew = runtime.$currentContextNew;\n\truntime.$currentLifecycle = hParent;\n\truntime.$currentContext = hParent.$context;\n\truntime.$currentContextNew = false;\n\truntime.$currentEffect = null;\n\n\tlet errors: unknown[] | undefined;\n\ttry {\n\t\tmountJsx(jsx, hParent, hBefore, nUsedParent, nRealParent, isBatch);\n\n\t\thParent.$canMount = true;\n\t\tif (!isBatch) {\n\t\t\tflush(hParent);\n\t\t}\n\t}\n\tcatch (ex) {\n\t\t(errors ??= []).push(ex);\n\t}\n\n\truntime.$currentLifecycle = prevLifecycle;\n\truntime.$currentEffect = prevEffect;\n\truntime.$currentContext = prevContext;\n\truntime.$currentContextNew = prevContextNew;\n\tif (--hParent.$depth === 0) {\n\t\tmounts.pop();\n\t}\n\n\tif (errors?.length && !deferUnmount(hParent)) {\n\t\terrors = doUnmount(hParent, errors);\n\t}\n\n\tfinishMount(errors);\n}\n\n/**\n * Processes deferred unmount requests once the outermost render finishes. Throws collected errors,\n * if any.\n */\nfunction finishMount(errors: unknown[] | undefined) {\n\tif (!runtime.$mounts!.length) {\n\t\t// nested renders get a separate queue while this one is being drained\n\t\tconst pending = runtime.$unmounts;\n\t\truntime.$unmounts = null;\n\n\t\tif (pending) {\n\t\t\tconst { length } = pending;\n\t\t\tlet index = 0;\n\t\t\tlet request;\n\n\t\t\tfor (; index < length; index += 1) {\n\t\t\t\trequest = pending[index];\n\n\t\t\t\t// an earlier ancestor teardown may have already ended this generation\n\t\t\t\tif (request.$life !== request.$group.$life) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\terrors = doUnmount(request.$group, errors);\n\t\t\t\tif (request.$destroy) {\n\t\t\t\t\tuntrack(request.$group);\n\t\t\t\t\trequest.$group.$ph = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\trethrow(errors);\n}\n\n/** Queues only teardown requests that would interrupt an active render. */\nfunction deferUnmount<TNode>(hGroup: MountingGroup<TNode>, isDestroy = false) {\n\tconst mounts = runtime.$mounts;\n\tif (!mounts?.length) {\n\t\treturn false;\n\t}\n\n\tconst lifecycle = runtime.$currentLifecycle as MountingGroup<TNode> | null;\n\tconst { length } = mounts;\n\tlet index = 0;\n\tlet active;\n\n\tfor (; index < length; index += 1) {\n\t\tactive = mounts[index];\n\t\t// mount callbacks can run on a descendant of the mount's own group\n\t\tif (\n\t\t\tancestorContainsNode(hGroup, active) || (\n\t\t\t\tlifecycle?.$isGroup &&\n\t\t\t\tancestorContainsNode(active, lifecycle) &&\n\t\t\t\tancestorContainsNode(hGroup, lifecycle)\n\t\t\t)\n\t\t) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (index === length) {\n\t\treturn false;\n\t}\n\n\tconst pending = runtime.$unmounts ??= [];\n\tconst pendingLength = pending.length;\n\tlet pendingIndex = 0;\n\tlet request;\n\n\tfor (; pendingIndex < pendingLength; pendingIndex += 1) {\n\t\trequest = pending[pendingIndex];\n\t\tif (request.$group === hGroup && request.$life === hGroup.$life) {\n\t\t\trequest.$destroy ||= isDestroy;\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tpending.push({\n\t\t$group: hGroup,\n\t\t$life: hGroup.$life,\n\t\t$destroy: isDestroy,\n\t});\n\n\treturn true;\n}\n\nfunction ancestorContainsNode<TNode>(hAncestor: HNode<TNode>, hNode: HNode<TNode> | null) {\n\twhile (hNode) {\n\t\tif (hNode === hAncestor) {\n\t\t\treturn true;\n\t\t}\n\n\t\thNode = hNode.$ph;\n\t}\n\n\treturn false;\n}\n\n/**\n * Marks the provided hGroup and all of its descendants as mounted and dispatches notifications\n * where appropriate.\n *\n * Normally this happens automatically as part of calling {@link mount}, but it is necessary to\n * flush manually when rendering into a batch. Batch owners are responsible for calling this\n * function once the batch has been committed.\n */\nexport function flush<TNode>(hGroup: MountingGroup<TNode>) {\n\t// only dispatch mount notifications when the parent group is already mounted, or if this is the\n\t// top-level group - otherwise, mount notification will arrive once the parent mounts\n\tif (hGroup.$ph?.$ng.mounted !== false) {\n\t\tconst prevLifecycle = runtime.$currentLifecycle;\n\t\tconst prevEffect = runtime.$currentEffect;\n\t\truntime.$currentEffect = null;\n\n\t\tconst mounts = runtime.$mounts ??= [];\n\t\tif (++hGroup.$depth === 1) {\n\t\t\tmounts.push(hGroup);\n\t\t}\n\n\t\tconst errors = doFlush(hGroup, undefined);\n\n\t\truntime.$currentLifecycle = prevLifecycle;\n\t\truntime.$currentEffect = prevEffect;\n\t\tif (--hGroup.$depth === 0) {\n\t\t\tmounts.pop();\n\t\t}\n\n\t\tfinishMount(errors);\n\t}\n}\n\n/**\n * Recursively (dept-first) runs components' `mounted` callbacks.\n * @see {@link mount}\n * @internal\n */\nfunction doFlush<TNode>(hNode: HNode<TNode>, errors: unknown[] | undefined): unknown[] | undefined {\n\tlet current = hNode.$hh;\n\twhile (current) {\n\t\terrors = doFlush(current, errors);\n\t\tcurrent = current.$hn;\n\t}\n\n\tif (hNode.$isGroup && hNode.$canMount && !hNode.mounted) {\n\t\thNode.mounted = true;\n\n\t\tif (hNode.$onMount?.length) {\n\t\t\t// the callbacks array may change when a callback causes a nested unmount run\n\t\t\tconst callbacks = hNode.$onMount;\n\t\t\tlet index = 0;\n\n\t\t\truntime.$currentLifecycle = hNode;\n\t\t\tfor (; index < callbacks.length; index += 1) {\n\t\t\t\ttry {\n\t\t\t\t\tinvoke(callbacks[index]);\n\t\t\t\t}\n\t\t\t\tcatch (ex) {\n\t\t\t\t\t(errors ??= []).push(ex);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcallbacks.length = 0;\n\t\t}\n\t}\n\n\treturn errors;\n}\n\n/**\n * Re-inserts native nodes of the given group to the specified location in the native tree. Only\n * moves the uppermost nodes - any children are assumed to move implicitly with them.\n * @see {@link mount}\n * @internal\n */\nexport function reinsertNodes<TNode>(hParent: MountingGroup<TNode>, hBefore: HNode<TNode> | null, nParent: TNode) {\n\tif (!hParent.mounted) {\n\t\treturn;\n\t}\n\n\tconst { adapter } = hParent;\n\tconst nAnchor = hBefore?.$nn ?? null;\n\tlet current = hParent.$hh;\n\n\twhile (current) {\n\t\tif (current.$isNative) {\n\t\t\tadapter.insert(current.$nn, nParent, nAnchor);\n\t\t\t// no need to recurse, group is already mounted, so any sub-groups within this native\n\t\t\t// node have already been moved with it\n\t\t}\n\t\telse {\n\t\t\treinsertNodes(current, hBefore, nParent);\n\t\t}\n\n\t\tcurrent = current.$hn;\n\t}\n}\n\n/**\n * Unmounts the contents of a MountingGroup from the node tree. The group itself, though empty,\n * remains usable and can be remounted later.\n *\n * If teardown would interrupt an active render, it is deferred until the outermost render\n * operation finishes. Any teardown errors are then reported by that operation.\n */\nexport function unmount<TNode>(hGroup: MountingGroup<TNode>): void;\n\n/** @internal */\nexport function unmount<TNode>(hGroup: MountingGroup<TNode>, errors?: unknown[]): void;\n\nexport function unmount<TNode>(hGroup: MountingGroup<TNode>, errors?: unknown[]) {\n\tif (deferUnmount(hGroup)) {\n\t\trethrow(errors);\n\t\treturn;\n\t}\n\n\terrors = doUnmount(hGroup, errors);\n\trethrow(errors);\n}\n\nfunction doUnmount<TNode>(hGroup: MountingGroup<TNode>, errors: unknown[] | undefined) {\n\tconst prevLifecycle = runtime.$currentLifecycle;\n\tconst prevEffect = runtime.$currentEffect;\n\truntime.$currentEffect = null;\n\n\terrors = unmountNode(hGroup, errors, true);\n\truntime.$currentLifecycle = prevLifecycle;\n\truntime.$currentEffect = prevEffect;\n\n\treturn errors;\n}\n\nfunction unmountNode<TNode>(hNode: HNode<TNode>, errors: unknown[] | undefined, top: boolean): unknown[] | undefined {\n\tif (hNode.$isUnmounting) {\n\t\treturn errors;\n\t}\n\n\thNode.$isUnmounting = true;\n\n\tif (hNode.$isGroup) {\n\t\t// regardless of mounted state, always run teardown callbacks when there are any\n\t\tif (hNode.$onUnmount?.length) {\n\t\t\t// the callbacks array may change when a callback causes a nested unmount run\n\t\t\tconst callbacks = hNode.$onUnmount;\n\t\t\tlet index = 0;\n\n\t\t\truntime.$currentLifecycle = hNode;\n\t\t\tfor (; index < callbacks.length; index += 1) {\n\t\t\t\ttry {\n\t\t\t\t\tinvoke(callbacks[index]);\n\t\t\t\t}\n\t\t\t\tcatch (ex) {\n\t\t\t\t\t(errors ??= []).push(ex);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tteardown(hNode); // also clears mount and unmount callback arrays\n\t\thNode.mounted = false;\n\t\thNode.$canMount = false;\n\t}\n\n\tconst { adapter } = hNode.$ng;\n\tlet current = hNode.$hh;\n\tlet next;\n\n\twhile (current) {\n\t\tif (current.$isNative && top) {\n\t\t\ttry {\n\t\t\t\tadapter.remove(current.$nn);\n\t\t\t}\n\t\t\tcatch (ex) {\n\t\t\t\t(errors ??= []).push(ex);\n\t\t\t}\n\n\t\t\terrors = unmountNode(current, errors, false);\n\t\t}\n\t\telse {\n\t\t\terrors = unmountNode(current, errors, top);\n\t\t}\n\n\t\tnext = current.$hn;\n\t\tcurrent.$hp = null;\n\t\tcurrent.$hn = null;\n\t\tcurrent.$ph = null;\n\t\tcurrent = next;\n\t}\n\n\thNode.$hh = null;\n\thNode.$ht = null;\n\thNode.$isUnmounting = false;\n\n\treturn errors;\n}\n\n/**\n * Mounts components described by JSX to the specified location in the node tree.\n */\nexport function mountJsx<TNode>(\n\tjsx: any,\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnUsedParent: TNode,\n\tnRealParent: TNode,\n\tisBatch: boolean,\n) {\n\tswitch (typeof jsx) {\n\t\tcase \"object\":\n\t\t\tif (jsx === null) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (Array.isArray(jsx)) {\n\t\t\t\tconst text = mountJsxArray(jsx, hParent, hBefore, nUsedParent, nRealParent, isBatch);\n\t\t\t\tif (text) {\n\t\t\t\t\tmountStaticText(text, hParent, hBefore, nUsedParent, isBatch);\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (isAtom(jsx)) {\n\t\t\t\tmountDynamicText(jsx, hParent, hBefore, nUsedParent, isBatch);\n\t\t\t}\n\t\t\telse {\n\t\t\t\t(jsx[S_COMPONENT] as ComponentHandler | undefined)?.(jsx, hParent, hBefore, nUsedParent, nRealParent, isBatch);\n\t\t\t}\n\n\t\t\tbreak;\n\n\t\tcase \"string\":\n\t\t\tif (jsx === \"\") {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// fall through\n\n\t\tcase \"number\":\n\t\tcase \"bigint\":\n\t\t\tmountStaticText(\"\" + jsx, hParent, hBefore, nUsedParent, isBatch);\n\t\t\tbreak;\n\t}\n}\n\n/**\n * Mounts components described by an array of JSX items to the specified location in the node tree.\n * Returns pending static text.\n */\nfunction mountJsxArray<TNode>(\n\tjsx: readonly any[],\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnUsedParent: TNode,\n\tnRealParent: TNode,\n\tisBatch: boolean,\n\ttext: string = \"\",\n): string {\n\tconst { length } = jsx;\n\tlet index = 0;\n\tlet item;\n\n\tfor (; index < length; index += 1) {\n\t\titem = jsx[index];\n\t\tswitch (typeof item) {\n\t\t\tcase \"string\":\n\t\t\tcase \"number\":\n\t\t\tcase \"bigint\":\n\t\t\t\ttext += item;\n\t\t\t\tbreak;\n\n\t\t\tcase \"boolean\":\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tif (item === null || item === undefined) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (Array.isArray(item)) {\n\t\t\t\t\ttext = mountJsxArray(item, hParent, hBefore, nUsedParent, nRealParent, isBatch, text);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (text) {\n\t\t\t\t\tmountStaticText(text, hParent, hBefore, nUsedParent, isBatch);\n\t\t\t\t\ttext = \"\";\n\t\t\t\t}\n\n\t\t\t\tmountJsx(item, hParent, hBefore, nUsedParent, nRealParent, isBatch);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn text;\n}\n\n/**\n * Mounts a text node with static content to the specified location in the node tree.\n */\nfunction mountStaticText<TNode>(\n\ttext: string,\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnUsedParent: TNode,\n\tisBatch: boolean,\n) {\n\tconst node = hParent.$ng.adapter.text(text, null);\n\tinsert(node, null, hParent, hBefore, nUsedParent, isBatch);\n}\n\n/**\n * Mounts a text node with dynamic content to the specified location in the node tree. An observer\n * is setup to drive reactions, updating the rendered text as needed.\n */\nfunction mountDynamicText<TNode>(\n\tatom: Atom<Nil<string | number | bigint | boolean>>,\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnUsedParent: TNode,\n\tisBatch: boolean,\n) {\n\tconst node = bind(hParent.$ng, atom, {\n\t\tfn: setBoundText<TNode>,\n\t\ta0: hParent.$ng.adapter,\n\t\ta1: null,\n\t});\n\n\tinsert(node, null, hParent, hBefore, nUsedParent, isBatch);\n}\n\nfunction setBoundText<TNode>(\n\tthis: Dependency<[ Adapter<TNode>, TNode | null ]>,\n\tadapter: Adapter<TNode>,\n\tnode: TNode | null,\n) {\n\tconst value = (this.$target! as Atom).get();\n\treturn (\n\t\t// setting `a1` allows us to hold the rendered node as a state of the bound Dependency object\n\t\tthis.a1 = adapter.text(\n\t\t\tvalue === null || value === undefined || typeof value === \"boolean\" ? \"\" : \"\" + value,\n\t\t\tnode,\n\t\t)\n\t);\n}\n\n/**\n * Inserts a native node and adds it to the tracking hierarchy. Necessary to preserve render order.\n * Returns the newly created tracking node, or null when tracking is skipped. Only a direct child\n * of hParent is used as a tracking insertion point; an outer anchor means appending within hParent.\n * Batched native insertions append, while hBefore still determines the tracking position.\n * Should only be called by component handlers!\n */\nexport function insert<TNode>(\n\tnNode: TNode,\n\tchildren: any,\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnUsedParent: TNode,\n\tisBatch: boolean,\n\tforceTrack: true,\n): NativeNode<TNode>;\n\nexport function insert<TNode>(\n\tnNode: TNode,\n\tchildren: any,\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnUsedParent: TNode,\n\tisBatch: boolean,\n\tforceTrack?: boolean,\n): NativeNode<TNode> | null;\n\nexport function insert<TNode>(\n\tnNode: TNode,\n\tchildren: any,\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnUsedParent: TNode,\n\tisBatch: boolean,\n\tforceTrack = false,\n) {\n\tlet hNative = hParent;\n\tif (hNative.$isGroup || forceTrack) {\n\t\t// Track top-level nodes of groups, or explicitly requested nodes such as markers.\n\t\ttrack(hNative = {\n\t\t\t$isNative: true,\n\t\t\t$ng: hParent.$ng,\n\t\t\t$nn: nNode,\n\t\t\t$ph: hParent,\n\t\t}, hParent, hBefore);\n\t}\n\n\t// Children belong to a new native parent; the outer sibling anchor does not apply to them.\n\tmountJsx(children, hNative, null, nNode, nNode, isBatch);\n\thParent.$ng.adapter.insert(nNode, nUsedParent, isBatch ? null : hBefore?.$nn ?? null);\n\n\treturn hNative === hParent ? null : hNative as NativeNode<TNode>;\n}\n","import type { Nil } from \"~/support/types\";\nimport type { JsxObject, JsxProps, JsxResult } from \"~/Component\";\nimport { mountJsx, type HNode } from \"~/Renderer\";\n\n// FUTURE: currently TypeScript has a bug causing it to skip checking fragment props in \"react-jsx\" mode\n// allowing users to supply fragment with invalid children\n// https://github.com/microsoft/TypeScript/issues/62358\n\nexport interface FragmentProps {\n\tchildren?: Nil<JsxResult>[];\n}\n\n/**\n * The built-in Fragment Component wrapping multiple Components.\n */\n// @ts-expect-error fake overload to enable use with JSX\nexport function Fragment(props: JsxProps<FragmentProps>): JsxResult;\n\nexport function Fragment<TNode>(\n\tjsx: JsxObject,\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnUsedParent: TNode,\n\tnRealParent: TNode,\n\tisBatch: boolean,\n) {\n\tmountJsx(jsx.children, hParent, hBefore, nUsedParent, nRealParent, isBatch);\n}\n","// The Myers diff algorithm is adapted from the implementation by Logan R. Kearsley, MIT license.\n// https://github.com/gliese1337/fast-myers-diff\n//\n//\n// Copyright 2021 Logan R. Kearsley\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and\n// associated documentation files (the \"Software\"), to deal in the Software without restriction,\n// including without limitation the rights to use, copy, modify, merge, publish, distribute,\n// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies or\n// substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT\n// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n// List Change (LC) types defined as constants as they seem to play nicer with bundlers and/or\n// minifiers. TS enums often get flagged as code with side-effects, resisting DCE, inlining etc.\n\nexport const LC_CHANGE = 1;\nexport const LC_INSERT = 2;\nexport const LC_REMOVE = 3;\nexport const LC_CLEAR = 4;\n\n/** @internal */\nexport interface PendingListDelta<T> {\n\tsnapshot?: T[];\n\tchanges: ListChange<T>[];\n\trelSize: number;\n}\n\nexport interface ListDelta<T> {\n\t/** raw snapshot of the List as observed at the time this ListDelta was emitted */\n\treadonly snapshot: readonly T[];\n\n\t/** changes made to the List since its last update */\n\treadonly changes: readonly ListChange<T>[];\n\n\t/** the relative change of the List size (its item count) */\n\treadonly relSize: number;\n}\n\nexport type ListChange<T> =\n\t| ListItemChanged<T>\n\t| ListItemInserted<T>\n\t| ListItemRemoved<T>\n\t| ListCleared;\n\nexport interface ListItemChanged<T> {\n\tkind: typeof LC_CHANGE;\n\tindex: number;\n\toldItem: T;\n\tnewItem: T;\n}\n\nexport interface ListItemInserted<T> {\n\tkind: typeof LC_INSERT;\n\tindex: number;\n\tnewItem: T;\n}\n\nexport interface ListItemRemoved<T> {\n\tkind: typeof LC_REMOVE;\n\tindex: number;\n\toldItem: T;\n}\n\nexport interface ListCleared {\n\tkind: typeof LC_CLEAR;\n\tindex: number;\n}\n\nexport interface Equals<T> {\n\t(item0: T, item1: T): boolean;\n}\n\ninterface DiffState<T> {\n\treadonly $eq: Equals<T>;\n\treadonly $list0: readonly T[];\n\treadonly $list1: readonly T[];\n\t$index0: number;\n\t$index1: number;\n\t$N: number;\n\t$M: number;\n\t$Z: number;\n\t$c: number;\n\treadonly $buffer: Uint8Array | Uint16Array | Uint32Array;\n\treadonly $stack: number[];\n\t$stackTop: number;\n\t$pxs: number;\n\t$pxe: number;\n\t$pys: number;\n\t$pye: number;\n\t$oxs: number;\n\t$oxe: number;\n\t$oys: number;\n\t$oye: number;\n}\n\n\n/** @internal */\nexport function itemChanged<T>({ changes: $changes }: PendingListDelta<T>, at: number, oldItem: T, newItem: T) {\n\tconst ci = binarySearch($changes, at, latest);\n\tif (ci < 0) {\n\t\t// nothing at this index, add new delta\n\t\t$changes.splice(~ci, 0, {\n\t\t\tkind: LC_CHANGE,\n\t\t\tindex: at,\n\t\t\toldItem,\n\t\t\tnewItem,\n\t\t});\n\t}\n\telse {\n\t\t// delta(s) exist at this index already, there can only be:\n\t\t// - change -> change item\n\t\t// - insert -> change item\n\t\t// - remove -> append change\n\t\tconst current = $changes[ci];\n\t\tswitch (current.kind) {\n\t\t\tcase LC_CHANGE:\n\t\t\tcase LC_INSERT:\n\t\t\t\tcurrent.newItem = newItem;\n\t\t\t\tbreak;\n\n\t\t\tcase LC_REMOVE:\n\t\t\t\t$changes.splice(ci + 1, 0, {\n\t\t\t\t\tkind: LC_CHANGE,\n\t\t\t\t\tindex: at,\n\t\t\t\t\toldItem,\n\t\t\t\t\tnewItem,\n\t\t\t\t});\n\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/** @internal */\nexport function itemInserted<T>(delta: PendingListDelta<T>, at: number, item: T) {\n\tconst { changes: $changes } = delta;\n\n\tlet ci = binarySearch($changes, at, earliest);\n\tif (ci < 0) {\n\t\t// nothing at this index, add new delta\n\t\tci = ~ci;\n\t\t$changes.splice(ci, 0, {\n\t\t\tkind: LC_INSERT,\n\t\t\tindex: at,\n\t\t\tnewItem: item,\n\t\t});\n\t}\n\telse {\n\t\t// delta(s) exist at this index already, there can only be:\n\t\t// - change -> prepend with insert\n\t\t// - insert -> prepend another (new item before, existing get shifted right)\n\t\t// - remove -> replace with change\n\t\tconst current = $changes[ci];\n\t\tswitch (current.kind) {\n\t\t\tcase LC_CHANGE:\n\t\t\tcase LC_INSERT:\n\t\t\t\t$changes.splice(ci, 0, {\n\t\t\t\t\tkind: LC_INSERT,\n\t\t\t\t\tindex: at,\n\t\t\t\t\tnewItem: item,\n\t\t\t\t});\n\n\t\t\t\tbreak;\n\n\t\t\tcase LC_REMOVE:\n\t\t\t\t// insert cancels the removal -> the slot's old item is now replaced, becomes a change\n\t\t\t\t// (oldItem carries over from the removal, it's the item that was originally here)\n\n\t\t\t\tif (Object.is(current.oldItem, item)) {\n\t\t\t\t\t// the inserted item matches the removed one -> remove this change entirely\n\t\t\t\t\t$changes.splice(ci--, 1);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// convert removal to a change\n\t\t\t\t\t(current as unknown as ListItemChanged<T>).kind = LC_CHANGE;\n\t\t\t\t\t(current as unknown as ListItemChanged<T>).newItem = item;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t// shift the indices of later changes\n\tconst { length } = $changes;\n\twhile (++ci < length) {\n\t\t$changes[ci].index += 1;\n\t}\n\n\t// update the overall change in list length\n\tdelta.relSize += 1;\n}\n\n/** @internal */\nexport function itemRemoved<T>(delta: PendingListDelta<T>, at: number, item: T) {\n\tconst { changes: $changes } = delta;\n\n\tlet ci = binarySearch($changes, at, latest);\n\tif (ci < 0) {\n\t\t// nothing at this index, add new delta\n\t\tci = ~ci;\n\t\t$changes.splice(ci, 0, {\n\t\t\tkind: LC_REMOVE,\n\t\t\tindex: at,\n\t\t\toldItem: item,\n\t\t});\n\t}\n\telse {\n\t\t// delta(s) exist at this index already, there can only be:\n\t\t// - change -> replace with removal\n\t\t// - insert -> remove it\n\t\t// - remove -> append another\n\t\tconst current = $changes[ci];\n\t\tswitch (current.kind) {\n\t\t\tcase LC_CHANGE:\n\t\t\t\t// removal cancels the change -> becomes a plain removal (oldItem carries over from\n\t\t\t\t// the change, it's the item originally at this index)\n\t\t\t\t(current as unknown as ListItemRemoved<T>).kind = LC_REMOVE;\n\t\t\t\t(current as unknown as ListItemChanged<undefined>).newItem = undefined;\n\t\t\t\tbreak;\n\n\t\t\tcase LC_INSERT:\n\t\t\t\t// canceling the insert shifts subsequent entries left so they must be re-indexed\n\t\t\t\t// -> adjust `ci` to start from the correct offset\n\t\t\t\t$changes.splice(ci--, 1);\n\t\t\t\tbreak;\n\n\t\t\tcase LC_REMOVE:\n\t\t\t\t$changes.splice(++ci, 0, {\n\t\t\t\t\tkind: LC_REMOVE,\n\t\t\t\t\tindex: at,\n\t\t\t\t\toldItem: item,\n\t\t\t\t});\n\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t// shift the indices of later changes\n\tconst { length } = $changes;\n\twhile (++ci < length) {\n\t\t$changes[ci].index -= 1;\n\t}\n\n\t// update the overall change in list length\n\tdelta.relSize -= 1;\n}\n\n/** @internal */\nexport function listCleared<T>(delta: PendingListDelta<T>, count: number) {\n\tdelta.changes.length = 0;\n\tdelta.relSize -= count;\n\tif (delta.relSize === 0) {\n\t\t// the list was already empty\n\t\treturn;\n\t}\n\n\tdelta.changes.push({\n\t\tkind: LC_CLEAR,\n\t\tindex: -1,\n\t});\n}\n\n/** @internal */\nexport function listSynced<T>(delta: PendingListDelta<T>, oldState: readonly T[], newState: readonly T[], eq: Equals<T>) {\n\tlet index = 0;\n\tlet N = oldState.length;\n\tlet M = newState.length;\n\n\t// eliminate common prefix\n\twhile (index < N && index < M && eq(oldState[index], newState[index])) {\n\t\tindex += 1;\n\t}\n\n\t// check for list equality\n\tif (index === N && index === M) {\n\t\treturn false;\n\t}\n\n\t// eliminate common suffix\n\twhile (N > index && M > index && eq(oldState[N - 1], newState[M - 1])) {\n\t\tN -= 1;\n\t\tM -= 1;\n\t}\n\n\tN -= index;\n\tM -= index;\n\n\t// run Myers diff on the smallest possible sub-lists\n\tconst Z = (Math.min(N, M) + 1) * 2;\n\tconst L = N + M;\n\tconst state: DiffState<T> = {\n\t\t$eq: eq,\n\t\t$list0: oldState,\n\t\t$list1: newState,\n\t\t$index0: index,\n\t\t$index1: index,\n\t\t$N: N,\n\t\t$M: M,\n\t\t$Z: Z,\n\t\t$c: 0,\n\t\t$buffer: new (L <= 0xff ? Uint8Array : L <= 0xffff ? Uint16Array : Uint32Array)(Z + Z),\n\t\t$stack: [],\n\t\t$stackTop: 0,\n\t\t$pxs: -1,\n\t\t$pxe: -1,\n\t\t$pys: -1,\n\t\t$pye: -1,\n\t\t$oxs: -1,\n\t\t$oxe: -1,\n\t\t$oys: -1,\n\t\t$oye: -1,\n\t};\n\n\tlet offset = 0;\n\tlet hasChanges = false;\n\tlet rs, re, is, ie, r, i;\n\tdo {\n\t\tmyersDiff(state);\n\t\tif (state.$c === 1) {\n\t\t\trs = state.$oxs;\n\t\t\tre = state.$oxe;\n\t\t\tis = state.$oys;\n\t\t\tie = state.$oye;\n\t\t}\n\t\telse if (state.$pxs >= 0) {\n\t\t\trs = state.$pxs;\n\t\t\tre = state.$pxe;\n\t\t\tis = state.$pys;\n\t\t\tie = state.$pye;\n\t\t}\n\t\telse {\n\t\t\tbreak;\n\t\t}\n\n\t\tfor (r = rs; r < re; r += 1) {\n\t\t\titemRemoved(delta, rs + offset, oldState[r]);\n\t\t\thasChanges = true;\n\t\t}\n\n\t\tfor (i = is; i < ie; i += 1) {\n\t\t\titemInserted(delta, rs + offset, newState[i]);\n\t\t\thasChanges = true;\n\t\t\toffset += 1;\n\t\t}\n\n\t\toffset -= re - rs;\n\t}\n\twhile (state.$c < 2);\n\n\treturn hasChanges;\n}\n\n\ninterface SearchBias {\n\t(changes: readonly ListChange<unknown>[], index: number, mid: number, min: number, max: number): number;\n}\n\nconst latest: SearchBias = (changes, index, mid, _min, max) => {\n\tlet i = mid;\n\twhile (++i < max && changes[i].index === index) ;\n\treturn i - 1;\n};\n\nconst earliest: SearchBias = (changes, index, mid, min, _max) => {\n\tlet i = mid;\n\twhile (--i >= min && changes[i].index === index) ;\n\treturn i + 1;\n};\n\nfunction binarySearch<T>(changes: readonly ListChange<T>[], index: number, bias: SearchBias) {\n\tlet min = 0;\n\tlet max = changes.length;\n\tlet mid;\n\tlet tmp;\n\n\twhile (min < max) {\n\t\tmid = (min + max) >>> 1;\n\t\ttmp = changes[mid].index;\n\n\t\tif (index < tmp) {\n\t\t\tmax = mid;\n\t\t}\n\t\telse if (index > tmp) {\n\t\t\tmin = mid + 1;\n\t\t}\n\t\telse {\n\t\t\t// found matching index, but there may be more deltas with the same index -> apply bias\n\t\t\treturn bias(changes, index, mid, min, max);\n\t\t}\n\t}\n\n\treturn ~min;\n}\n\nfunction myersDiff<T>(state: DiffState<T>) {\n\tconst { $list0, $list1, $buffer, $stack, $eq } = state;\n\tlet { $index0, $index1, $N, $M, $Z, $c, $stackTop } = state;\n\tlet W, L, parity, offsetX, offsetY, z, h, hMax, k, kMin, kMax, gkm, gkp, u, v, x, y, pkm, pkp, sx;\n\n\twhile (true) {\n\t\tswitch ($c) {\n\t\t\tcase 0: {\n\t\t\t\tZ_block: while ($N > 0 && $M > 0) {\n\t\t\t\t\tW = $N - $M;\n\t\t\t\t\tL = $N + $M;\n\t\t\t\t\tparity = L & 1;\n\t\t\t\t\toffsetX = $index0 + $N - 1;\n\t\t\t\t\toffsetY = $index1 + $M - 1;\n\t\t\t\t\thMax = (L + parity) / 2;\n\n\t\t\t\t\t$buffer.fill(0, 0, $Z + $Z);\n\t\t\t\t\th_loop: for (h = 0; h <= hMax; h += 1) {\n\t\t\t\t\t\tkMin = 2 * Math.max(0, h - $M) - h;\n\t\t\t\t\t\tkMax = h - 2 * Math.max(0, h - $N);\n\n\t\t\t\t\t\t// forward pass\n\t\t\t\t\t\tfor (k = kMin; k <= kMax; k += 2) {\n\t\t\t\t\t\t\tgkm = $buffer[k - 1 - $Z * Math.floor((k - 1)/$Z)];\n\t\t\t\t\t\t\tgkp = $buffer[k + 1 - $Z * Math.floor((k + 1)/$Z)];\n\t\t\t\t\t\t\tu = (k === -h || (k !== h && gkm < gkp)) ? gkp : gkm + 1;\n\t\t\t\t\t\t\tv = u - k;\n\t\t\t\t\t\t\tx = u;\n\t\t\t\t\t\t\ty = v;\n\t\t\t\t\t\t\twhile (x < $N && y < $M && $eq($list0[$index0 + x], $list1[$index1 + y])) {\n\t\t\t\t\t\t\t\tx += 1;\n\t\t\t\t\t\t\t\ty += 1;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t$buffer[k - $Z * Math.floor(k / $Z)] = x;\n\t\t\t\t\t\t\tif (parity === 1 && (z = W - k) >= 1 - h && z < h && x + $buffer[$Z + z - $Z * Math.floor(z / $Z)] >= $N) {\n\t\t\t\t\t\t\t\tif (h > 1 || x !== u) {\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = $index0 + x;\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = $index1 + y;\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = $N - x;\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = $M - y;\n\t\t\t\t\t\t\t\t\t$N = u;\n\t\t\t\t\t\t\t\t\t$M = v;\n\t\t\t\t\t\t\t\t\t$Z = 2 * (Math.min($N, $M) + 1);\n\t\t\t\t\t\t\t\t\tcontinue Z_block;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tbreak h_loop;\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\n\t\t\t\t\t\t// reverse pass\n\t\t\t\t\t\tfor (k = kMin; k <= kMax; k += 2) {\n\t\t\t\t\t\t\tpkm = $buffer[$Z + k - 1 - $Z * Math.floor((k - 1)/$Z)];\n\t\t\t\t\t\t\tpkp = $buffer[$Z + k + 1 - $Z * Math.floor((k + 1)/$Z)];\n\t\t\t\t\t\t\tu = (k === -h || (k !== h && pkm < pkp)) ? pkp : pkm + 1;\n\t\t\t\t\t\t\tv = u - k;\n\t\t\t\t\t\t\tx = u;\n\t\t\t\t\t\t\ty = v;\n\t\t\t\t\t\t\twhile (x < $N && y < $M && $eq($list0[offsetX - x], $list1[offsetY - y])) {\n\t\t\t\t\t\t\t\tx += 1;\n\t\t\t\t\t\t\t\ty += 1;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t$buffer[$Z + k - $Z * Math.floor(k/$Z)] = x;\n\t\t\t\t\t\t\tif (parity === 0 && (z = W - k) >= -h && z <= h && x + $buffer[z - $Z * Math.floor(z/$Z)] >= $N) {\n\t\t\t\t\t\t\t\tif (h > 0 || x !== u) {\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = $index0 + $N - u;\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = $index1 + $M - v;\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = u;\n\t\t\t\t\t\t\t\t\t$stack[$stackTop++] = v;\n\t\t\t\t\t\t\t\t\t$N = $N - x;\n\t\t\t\t\t\t\t\t\t$M = $M - y;\n\t\t\t\t\t\t\t\t\t$Z = 2 * (Math.min($N, $M) + 1);\n\t\t\t\t\t\t\t\t\tcontinue Z_block;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tbreak h_loop;\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 ($N === $M) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ($M > $N) {\n\t\t\t\t\t\t$index0 += $N;\n\t\t\t\t\t\t$index1 += $N;\n\t\t\t\t\t\t$M -= $N;\n\t\t\t\t\t\t$N = 0;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t$index0 += $M;\n\t\t\t\t\t\t$index1 += $M;\n\t\t\t\t\t\t$N -= $M;\n\t\t\t\t\t\t$M = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\t// we already know either N or M is zero, so we can skip the extra check at the top of the loop\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// yield delete_start, delete_end, insert_start, insert_end\n\t\t\t\t// at this point, at least one of N & M is zero, or we wouldn't have gotten out of the preceding loop yet\n\t\t\t\tif ($N + $M !== 0) {\n\t\t\t\t\tif (state.$pxe === $index0 || state.$pye === $index1) {\n\t\t\t\t\t\t// it is a contiguous difference, extend the existing one\n\t\t\t\t\t\tstate.$pxe = $index0 + $N;\n\t\t\t\t\t\tstate.$pye = $index1 + $M;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsx = state.$pxs;\n\t\t\t\t\t\tstate.$oxs = state.$pxs;\n\t\t\t\t\t\tstate.$oxe = state.$pxe;\n\t\t\t\t\t\tstate.$oys = state.$pys;\n\t\t\t\t\t\tstate.$oye = state.$pye;\n\n\t\t\t\t\t\t// defer this one until we can check the next one\n\t\t\t\t\t\tstate.$pxs = $index0;\n\t\t\t\t\t\tstate.$pxe = $index0 + $N;\n\t\t\t\t\t\tstate.$pys = $index1;\n\t\t\t\t\t\tstate.$pye = $index1 + $M;\n\n\t\t\t\t\t\tif (sx >= 0) {\n\t\t\t\t\t\t\tstate.$index0 = $index0;\n\t\t\t\t\t\t\tstate.$index1 = $index1;\n\t\t\t\t\t\t\tstate.$N = $N;\n\t\t\t\t\t\t\tstate.$M = $M;\n\t\t\t\t\t\t\tstate.$Z = $Z;\n\t\t\t\t\t\t\tstate.$stackTop = $stackTop;\n\t\t\t\t\t\t\tstate.$c = 1;\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcase 1: {\n\t\t\t\tif ($stackTop === 0) {\n\t\t\t\t\tstate.$c = 2;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t$M = $stack[--$stackTop];\n\t\t\t\t$N = $stack[--$stackTop];\n\t\t\t\t$index1 = $stack[--$stackTop];\n\t\t\t\t$index0 = $stack[--$stackTop];\n\t\t\t\t$Z = 2 * (Math.min($N, $M) + 1);\n\t\t\t\t$c = 0;\n\t\t\t}\n\t\t}\n\t}\n}\n","import { UNIQUE_VALUE } from \"~/support/common\";\nimport type { Nil } from \"~/support/types\";\nimport { S_ATOM } from \"~/symbols\";\n\nimport { isAtom, scheduleAtomNotification, type MaybeAtom, type WriteAtom } from \"./Atom\";\nimport { link, unlink, type Dependency } from \"./Dependency\";\nimport { getLifecycle, type Lifecycle } from \"./Lifecycle\";\n\nexport interface ProxyAtom<T> extends WriteAtom<T> {\n\t/**\n\t * Binds this ProxyAtom to a new value. If it is an Atom, the proxy will mirror it, otherwise it\n\t * will be a read-only atom with a static value until rebound.\n\t * Binding a proxy to itself throws in development and is ignored in production.\n\t */\n\tuse(value: MaybeAtom<T>): void;\n\n\t/** @internal */\n\tuse(value: MaybeAtom<T>, isInit?: boolean): void;\n\n\t/** @internal */\n\t$dep?: Dependency;\n\n\t/** @internal */\n\t$upstream?: Nil<WriteAtom<T>>;\n\n\t/** @internal */\n\t$value?: Nil<T>;\n}\n\n/**\n * Creates a ProxyAtom bound to the provided initial value. If it is an Atom, the proxy will mirror\n * it, otherwise it will be a read-only atom with a static value until rebound via its `use` method.\n */\nexport function proxyOf<T>(initialValue: MaybeAtom<T>, lifecycle = getLifecycle()): ProxyAtom<T> {\n\t// `set` is assigned by the use call below\n\tconst self: Omit<ProxyAtom<T>, \"get\" | \"set\"> = {\n\t\t[S_ATOM]: true,\n\t\t$lifecycle: lifecycle,\n\t\tuse,\n\t};\n\n\tself.use(initialValue, true);\n\treturn self as ProxyAtom<T>;\n}\n\nfunction use<T>(this: ProxyAtom<T>, value: MaybeAtom<T>, isInit: boolean = false) {\n\tif (value === this) {\n\t\tif (__DEV__) {\n\t\t\tthrow new Error(\"ProxyAtom cannot proxy itself\");\n\t\t}\n\n\t\treturn;\n\t}\n\n\tconst upstream = this.$upstream;\n\tif (upstream && upstream === value) {\n\t\t// value is an Atom and we're already forwarding it, nothing to do\n\t\treturn;\n\t}\n\n\tlet shouldNotify = true;\n\tif (isAtom(value)) {\n\t\tif (!upstream || isInit) {\n\t\t\t// switching from static to forwarding mode\n\t\t\tthis.$value = null;\n\t\t\tthis.$tracksValue = false;\n\t\t\tthis.$lastValue = null!;\n\t\t\tthis.get = getUpstreamValue;\n\t\t\tthis.set = setUpstreamValue;\n\t\t}\n\t\telse {\n\t\t\t// staying in forwarding mode, but re-linking to a different Atom\n\t\t\tunlink(this.$dep!);\n\t\t}\n\n\t\t// all Atoms actually implement the WriteAtom interface\n\t\tthis.$upstream = value as WriteAtom<T>;\n\t\tlink(this.$lifecycle, value, this.$dep ??= {\n\t\t\tfn: scheduleAtomNotification,\n\t\t\ta0: this,\n\t\t});\n\t}\n\telse {\n\t\tif (upstream || isInit) {\n\t\t\t// switching from forwarding to static mode\n\t\t\tthis.$upstream = null;\n\t\t\tthis.$tracksValue = true;\n\t\t\tthis.$lastValue = UNIQUE_VALUE;\n\t\t\tthis.get = getStaticValue;\n\t\t\tthis.set = setStaticValue;\n\n\t\t\tif (!isInit) {\n\t\t\t\tunlink(this.$dep!);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t// staying in static mode, notification may be skipped if the value didn't change\n\t\t\tshouldNotify = !Object.is(this.$value, value);\n\t\t}\n\n\t\tthis.$value = value;\n\t}\n\n\tif (this.$dh) {\n\t\tif (shouldNotify) {\n\t\t\tscheduleAtomNotification(this);\n\t\t}\n\t}\n\telse if (this.$tracksValue) {\n\t\tthis.$lastValue = value as any;\n\t}\n}\n\nfunction getUpstreamValue<T>(this: ProxyAtom<T>) {\n\t// Calling raw `get` doesn't report access, which is what we want here. Sites accessing this\n\t// proxy atom would do so via `read`, which then reports access on this proxy rather than the\n\t// upstream atom, which may change\n\treturn this.$upstream!.get();\n}\n\nfunction setUpstreamValue<T>(this: ProxyAtom<T>, value: T) {\n\t// set the upstream atom and schedule a notification if it changed - copies the behavior of\n\t// `write`, skipping parts we don't need here\n\tconst atom = this.$upstream!;\n\tif (atom.set(value) && atom.$dh) {\n\t\tscheduleAtomNotification(atom);\n\t}\n\n\t// Always return false, even if the upstream changed. This way, `write` and `update` functions\n\t// don't schedule notifications, which is desirable. The proxy forwards notifications from the\n\t// upstream Atom, which will have one already scheduled if the value changed.\n\treturn false;\n}\n\nfunction getStaticValue<T>(this: ProxyAtom<T>) {\n\treturn this.$value!;\n}\n\nfunction setStaticValue(this: ProxyAtom<any>) {\n\treturn false;\n}\n\n/** @internal */\nexport type ProxyObject =\n\t& { proxied: any }\n\t& { [_ in PropertyKey]?: ProxyAtom<any> };\n\nexport type Proxied<T, P extends readonly (keyof T)[]> =\n\t& { readonly proxied: T }\n\t& { readonly [K in P[number]]: ProxyAtom<T[K] extends MaybeAtom<infer V> ? V : T[K]> };\n\n/**\n * Copies select keys from a data object into a new object where values are all wrapped in\n * ProxyAtoms and can be updated later.\n * @see {@link updateProxy}\n * @internal\n **/\nexport function createProxy(lifecycle: Lifecycle, data: any, keys: readonly PropertyKey[]) {\n\tconst source: Record<PropertyKey, unknown> = isObject(data) ? data : UNIQUE_VALUE;\n\tconst proxy = Object.create(null) as ProxyObject;\n\tconst { length } = keys;\n\n\tlet index = 0;\n\tlet key;\n\n\tfor (; index < length; index += 1) {\n\t\tkey = keys[index];\n\t\tproxy[key] = proxyOf(source[key], lifecycle);\n\t}\n\n\tproxy.proxied = data;\n\treturn proxy;\n}\n\n/**\n * Updates the values proxied by a previously created proxy object. The keys array must be the same\n * as was used during creation (or a subset).\n * @see {@link createProxy}\n * @internal\n **/\nexport function updateProxy(proxy: ProxyObject, data: any, keys: readonly PropertyKey[]) {\n\tconst source: Record<PropertyKey, unknown> = isObject(data) ? data : UNIQUE_VALUE;\n\tconst { length } = keys;\n\tproxy.proxied = data;\n\n\tlet index = 0;\n\tlet key;\n\n\tfor (; index < length; index += 1) {\n\t\tkey = keys[index];\n\t\tproxy[key]!.use(source[key]);\n\t}\n}\n\nfunction isObject(value: unknown): value is Record<PropertyKey, unknown> {\n\treturn value !== null && typeof value === \"object\";\n}\n","import type { ComponentHandler, DataTemplate, JsxObject } from \"~/Component\";\nimport { mount, mountJsx, type HNode, type MountingGroup } from \"~/Renderer\";\nimport { S_COMPONENT } from \"~/symbols\";\n\ninterface TemplateJsx extends JsxObject {\n\t[S_COMPONENT]: ComponentHandler;\n\tt: DataTemplate<any> | null;\n\td: any;\n}\n\nfunction Template<TNode>(\n\tjsx: TemplateJsx,\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnUsedParent: TNode,\n\tnRealParent: TNode,\n\tisBatch: boolean,\n) {\n\tmountJsx(jsx.t?.(jsx.d), hParent, hBefore, nUsedParent, nRealParent, isBatch);\n}\n\nconst REUSED_JSX = {\n\t[S_COMPONENT]: Template,\n} as TemplateJsx;\n\nexport function mountTemplate<TNode, TData>(\n\ttemplate: DataTemplate<TData>,\n\tdata: TData,\n\thParent: MountingGroup<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnUsedParent: TNode,\n\tnRealParent: TNode,\n\tisBatch: boolean,\n) {\n\tREUSED_JSX.t = template;\n\tREUSED_JSX.d = data;\n\ttry {\n\t\tmount(REUSED_JSX, hParent, hBefore, nUsedParent, nRealParent, isBatch);\n\t}\n\tfinally {\n\t\tREUSED_JSX.t = null;\n\t\tREUSED_JSX.d = null;\n\t}\n}\n","import type { ReadonlyList } from \"~/data/List\";\nimport { LC_CHANGE, LC_CLEAR, LC_INSERT, LC_REMOVE, type ListDelta, type ListItemInserted } from \"~/data/ListDelta\";\nimport { createProxy, updateProxy, type Proxied } from \"~/data/ProxyAtom\";\nimport { rethrow } from \"~/support/common\";\nimport { mountTemplate } from \"~/support/template\";\nimport type { DataTemplate, JsxObject, JsxProps, JsxResult } from \"~/Component\";\nimport { destroy, flush, fork, insert, mount, reinsertNodes, track, unmount, untrack, willMount, type HNode, type MountingGroup } from \"~/Renderer\";\n\nexport interface RemountIteratorProps<T> {\n\tsource: ReadonlyList<T>;\n\tproxy?: never; // discriminator\n\tchildren: [ template: DataTemplate<T> ];\n}\n\nexport interface ProxyIteratorProps<T, P extends readonly (keyof T)[]> {\n\tsource: ReadonlyList<T>;\n\tproxy: P & (\"proxied\" extends P[number] ? never : unknown);\n\tchildren: [ template: DataTemplate<Proxied<T, P>> ];\n}\n\ninterface IteratorItemGroup<TNode> extends MountingGroup<TNode> {\n\t$marker: Extract<HNode<TNode>, { $isNative: true }>;\n\t$data?: any;\n}\n\n/**\n * The built-in Iterator Component efficiently rendering collections of items\n * based on updates from a Pyxis `list`.\n */\n// @ts-expect-error fake overload to enable use with JSX\nexport function Iterator<T>(props: JsxProps<RemountIteratorProps<T>>): JsxResult;\n\nexport function Iterator<T, P extends readonly (keyof T)[]>(props: JsxProps<ProxyIteratorProps<T, P>>): JsxResult;\n\nexport function Iterator<TNode, T>(\n\tjsx: JsxObject,\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnUsedParent: TNode,\n\tnRealParent: TNode,\n\tisBatch: boolean,\n) {\n\tconst source = jsx.source as ReadonlyList<T>;\n\tconst proxyKeys = jsx.proxy as readonly PropertyKey[] | undefined;\n\tconst isProxy = proxyKeys !== undefined;\n\tconst template = jsx.children[0] as DataTemplate<T>;\n\n\t// create master group and marker\n\tconst hGroup = fork(hParent, hBefore) as MountingGroup<TNode>;\n\tconst { adapter } = hGroup;\n\tconst shouldBatch = !!adapter.batch;\n\tconst nListEndMarker = __DEV__ ? adapter.marker(\"/Iterator\") : adapter.marker();\n\n\t// declare rendering routines\n\tlet renderedItems: IteratorItemGroup<TNode>[] | undefined;\n\tlet hListEndMarker: HNode<TNode> | null = null;\n\n\tconst renderInitialItems = (\n\t\tinitItems: readonly T[],\n\t\thInitBefore: HNode<TNode> | null,\n\t\tnInitParent: TNode,\n\t\tinitIsBatch: boolean,\n\t) => {\n\t\tlet nBatchParent = nInitParent;\n\n\t\tconst isLocalBatch = shouldBatch && !initIsBatch && initItems.length > 0;\n\t\tconst isAnyBatch = isLocalBatch || initIsBatch;\n\t\tif (isLocalBatch) {\n\t\t\tnBatchParent = adapter.batch!();\n\t\t}\n\n\t\tlet errors: unknown[] | undefined;\n\t\trenderedItems = initItems.map((data) => {\n\t\t\tconst item = createItem(\n\t\t\t\t/* hParent = */ hGroup,\n\t\t\t\t/* hBefore = */ hListEndMarker ?? hInitBefore,\n\t\t\t\t/* nParent = */ nBatchParent,\n\t\t\t\t/* isBatch = */ isAnyBatch,\n\t\t\t\t/* data = */ data,\n\t\t\t\t/* proxyKeys = */ proxyKeys,\n\t\t\t);\n\n\t\t\ttry {\n\t\t\t\tmountTemplate(\n\t\t\t\t\t/* template = */ template,\n\t\t\t\t\t/* data = */ item.$data,\n\t\t\t\t\t/* hParent = */ item,\n\t\t\t\t\t/* hBefore = */ hInitBefore,\n\t\t\t\t\t/* nUsedParent = */ nBatchParent,\n\t\t\t\t\t/* nRealParent = */ nRealParent,\n\t\t\t\t\t/* isBatch = */ isAnyBatch,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcatch (ex) {\n\t\t\t\t(errors ??= []).push(ex);\n\t\t\t}\n\n\t\t\treturn item;\n\t\t});\n\n\t\t// commit batch if it's local\n\t\tif (isLocalBatch) {\n\t\t\tadapter.insert(nBatchParent, nInitParent, hInitBefore?.$nn ?? null);\n\t\t\terrors = flushItems(renderedItems, 0, renderedItems.length, errors);\n\t\t}\n\n\t\trethrow(errors);\n\t};\n\n\t// subscribe to list updates - done first so that any mutations of the list occurring as a side\n\t// effect of rendering don't get dropped if the list has no (other) subscribers\n\tsource.delta(willMount(hGroup, (delta: ListDelta<T>) => {\n\t\tif (!renderedItems) {\n\t\t\trenderInitialItems(delta.snapshot, hListEndMarker, nRealParent, false);\n\t\t\treturn;\n\t\t}\n\n\t\tconst { changes, relSize } = delta;\n\t\tconst cMax = changes.length;\n\t\tconst iMax = renderedItems.length + relSize;\n\t\tlet newItems = renderedItems;\n\t\tlet errors: unknown[] | undefined;\n\t\tlet pending: number[] | undefined;\n\t\tlet recycled: IteratorItemGroup<TNode>[] | undefined;\n\t\tlet item: IteratorItemGroup<TNode>;\n\t\tlet inserted = 0;\n\t\tlet ci = 0; // change index\n\t\tlet oi = 0; // old items index\n\t\tlet ni = 0; // new items index\n\t\tlet change;\n\t\tlet ref;\n\t\tlet tmp;\n\n\t\t// batching\n\t\tlet isLocalBatch = false;\n\t\tlet nBatchParent = nRealParent;\n\t\tlet batchStart = 0;\n\n\t\tfor (; ci < cMax; ci += 1) {\n\t\t\tchange = changes[ci];\n\n\t\t\t// reuse item array until the first structural edit; LC_CHANGE alone doesn't restructure\n\t\t\tif (newItems === renderedItems) {\n\t\t\t\tif (change.kind === LC_CHANGE) {\n\t\t\t\t\toi = ni = change.index;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tnewItems = new Array<IteratorItemGroup<TNode>>(iMax);\n\t\t\t\t\toi = ni = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// copy unchanged items\n\t\t\twhile (ni < change.index) {\n\t\t\t\tnewItems[ni++] = renderedItems[oi++];\n\t\t\t}\n\n\t\t\t// apply change\n\t\t\tswitch (change.kind) {\n\t\t\t\tcase LC_CHANGE:\n\t\t\t\t\titem = (newItems[ni++] = renderedItems[oi++]);\n\t\t\t\t\tif (isProxy) {\n\t\t\t\t\t\tupdateProxy(item.$data, change.newItem, proxyKeys);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// no need to untrack and re-track, position doesn't change\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tunmount(item);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (ex) {\n\t\t\t\t\t\t\t(errors ??= []).push(ex);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// The marker belongs to the main group and survives content teardown.\n\t\t\t\t\t\tref = renderedItems[oi]?.$marker ?? hListEndMarker;\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tmountTemplate(\n\t\t\t\t\t\t\t\t/* template = */ template,\n\t\t\t\t\t\t\t\t/* data = */ (item.$data = change.newItem),\n\t\t\t\t\t\t\t\t/* hParent = */ item,\n\t\t\t\t\t\t\t\t/* hBefore = */ ref,\n\t\t\t\t\t\t\t\t/* nUsedParent = */ nRealParent,\n\t\t\t\t\t\t\t\t/* nRealParent = */ nRealParent,\n\t\t\t\t\t\t\t\t/* isBatch = */ false,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (ex) {\n\t\t\t\t\t\t\t(errors ??= []).push(ex);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase LC_INSERT:\n\t\t\t\t\tif (!isProxy || inserted < relSize) {\n\t\t\t\t\t\t// we're either in remount mode, or no more items are available for recycling\n\t\t\t\t\t\tref = renderedItems[oi]?.$marker ?? hListEndMarker;\n\t\t\t\t\t\tif (!isLocalBatch) {\n\t\t\t\t\t\t\tif (shouldBatch) {\n\t\t\t\t\t\t\t\tisLocalBatch = true;\n\t\t\t\t\t\t\t\tbatchStart = ni;\n\t\t\t\t\t\t\t\tnBatchParent = adapter.batch!();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tinserted += 1;\n\t\t\t\t\t\titem = (newItems[ni++] = createItem(\n\t\t\t\t\t\t\t/* hParent = */ hGroup,\n\t\t\t\t\t\t\t/* hBefore = */ renderedItems[oi]?.$marker ?? hListEndMarker,\n\t\t\t\t\t\t\t/* nParent = */ nBatchParent,\n\t\t\t\t\t\t\t/* isBatch = */ isLocalBatch,\n\t\t\t\t\t\t\t/* data = */ change.newItem,\n\t\t\t\t\t\t\t/* proxyKeys = */ proxyKeys,\n\t\t\t\t\t\t));\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tmountTemplate(\n\t\t\t\t\t\t\t\t/* template = */ template,\n\t\t\t\t\t\t\t\t/* data = */ item.$data,\n\t\t\t\t\t\t\t\t/* hParent = */ item,\n\t\t\t\t\t\t\t\t/* hBefore = */ ref,\n\t\t\t\t\t\t\t\t/* nUsedParent = */ nBatchParent,\n\t\t\t\t\t\t\t\t/* nRealParent = */ nRealParent,\n\t\t\t\t\t\t\t\t/* isBatch = */ isLocalBatch,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (ex) {\n\t\t\t\t\t\t\t(errors ??= []).push(ex);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (isLocalBatch && (\n\t\t\t\t\t\t\t// we must commit the current batch if:\n\t\t\t\t\t\t\tinserted >= relSize ||\t\t// next insert will use recycled\n\t\t\t\t\t\t\t!(tmp = changes[ci + 1]) ||\t// no next change exists\n\t\t\t\t\t\t\ttmp.kind !== LC_INSERT ||\t// next change is not an insert\n\t\t\t\t\t\t\ttmp.index !== ni\t\t\t// next insert is not consecutive\n\t\t\t\t\t\t)) {\n\t\t\t\t\t\t\tadapter.insert(nBatchParent, nRealParent, ref.$nn);\n\t\t\t\t\t\t\terrors = flushItems(newItems, batchStart, ni, errors);\n\t\t\t\t\t\t\tnBatchParent = nRealParent;\n\t\t\t\t\t\t\tisLocalBatch = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// we know enough items will be removed -> add a pending item\n\t\t\t\t\t\t(pending ??= []).push(ci);\n\t\t\t\t\t\tni += 1;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase LC_REMOVE:\n\t\t\t\t\titem = renderedItems[oi++];\n\t\t\t\t\tif (isProxy) {\n\t\t\t\t\t\t(recycled ??= []).push(item);\n\t\t\t\t\t\tuntrackItem(item);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tdestroyItem(item);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (ex) {\n\t\t\t\t\t\t\t(errors ??= []).push(ex);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase LC_CLEAR:\n\t\t\t\t\t// clear is always the first change within a delta, has index = -1 and is only\n\t\t\t\t\t// ever followed by inserts - thus we can directly recycle the items array, it\n\t\t\t\t\t// won't get mutated\n\t\t\t\t\tif (isProxy) {\n\t\t\t\t\t\trecycled = renderedItems;\n\t\t\t\t\t\trecycled.forEach(untrackItem);\n\t\t\t\t\t\toi = renderedItems.length;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\twhile (oi < renderedItems.length) {\n\t\t\t\t\t\t\titem = renderedItems[oi++];\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tdestroyItem(item);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcatch (ex) {\n\t\t\t\t\t\t\t\t(errors ??= []).push(ex);\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\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// copy remaining unchanged\n\t\tif (newItems !== renderedItems) {\n\t\t\twhile (ni < iMax) {\n\t\t\t\tnewItems[ni++] = renderedItems[oi++];\n\t\t\t}\n\t\t}\n\n\t\t// fulfill pending items with recycled ones\n\t\tlet pi = pending ? pending.length - 1 : -1; // pending items index\n\t\tlet ri = recycled ? recycled.length - 1 : -1; // recycled items index\n\t\twhile (pi >= 0) {\n\t\t\ttmp = changes[pending![pi--]] as ListItemInserted<T>;\n\t\t\titem = (newItems[tmp.index] = recycled![ri--]);\n\t\t\tupdateProxy(item.$data, tmp.newItem, proxyKeys!);\n\n\t\t\tref = newItems[tmp.index + 1];\n\t\t\ttrack(item.$marker, hGroup, ref?.$marker ?? hListEndMarker);\n\t\t\ttrack(item, hGroup, ref?.$marker ?? hListEndMarker);\n\n\t\t\tadapter.insert(item.$marker.$nn, nRealParent, ref?.$marker.$nn ?? nListEndMarker);\n\t\t\treinsertNodes(\n\t\t\t\t/* hParent = */ item,\n\t\t\t\t/* hBefore = */ ref?.$marker ?? hListEndMarker,\n\t\t\t\t/* nParent = */ nRealParent,\n\t\t\t);\n\t\t}\n\n\t\t// destroy unused\n\t\twhile (ri >= 0) {\n\t\t\titem = recycled![ri--];\n\t\t\ttry {\n\t\t\t\tdestroyItem(item);\n\t\t\t}\n\t\t\tcatch (ex) {\n\t\t\t\t(errors ??= []).push(ex);\n\t\t\t}\n\t\t}\n\n\t\trenderedItems = newItems;\n\t\trethrow(errors);\n\t}), hGroup);\n\n\t// render current stable state, or wait for incoming delta if already dirty\n\tif (!source.dirty()) {\n\t\tsource.stable(snapshot => {\n\t\t\trenderInitialItems(snapshot, hBefore, nUsedParent, isBatch);\n\t\t});\n\t}\n\n\t// insert master position marker\n\thListEndMarker = insert(\n\t\t/* nNode = */ nListEndMarker,\n\t\t/* children = */ null,\n\t\t/* hParent = */ hGroup,\n\t\t/* hBefore = */ hBefore,\n\t\t/* nUsedParent = */ nUsedParent,\n\t\t/* isBatch = */ isBatch,\n\t\t/* forceTrack = */ true,\n\t);\n\n\t// mark hGroup as mounted and propagate mount notifications to items if already rendered\n\tmount(\n\t\t/* jsx = */ null,\n\t\t/* hParent = */ hGroup,\n\t\t/* hBefore = */ hBefore,\n\t\t/* nUsedParent = */ nUsedParent,\n\t\t/* nRealParent = */ nRealParent,\n\t\t/* isBatch = */ isBatch,\n\t);\n}\n\n/**\n * Flushes a range of items delimited by start (inclusive) and end (exclusive). Errors are caught\n * and collected, the errors array (if any) is returned.\n */\nfunction flushItems<TNode>(items: IteratorItemGroup<TNode>[], start: number, end: number, errors: unknown[] | undefined) {\n\tlet index = start;\n\tfor (; index < end; index += 1) {\n\t\ttry {\n\t\t\tflush(items[index]);\n\t\t}\n\t\tcatch (ex) {\n\t\t\t(errors ??= []).push(ex);\n\t\t}\n\t}\n\n\treturn errors;\n}\n\n/**\n * Creates a h-group for an iterator item with a position marker inserted into the master\n * iterator-wide h-group, holding the position of the item within the node tree.\n */\nfunction createItem<TNode>(\n\thParent: MountingGroup<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnParent: TNode,\n\tisBatch: boolean,\n\tdata: unknown,\n\tproxyKeys: readonly PropertyKey[] | undefined,\n) {\n\t// track position markers under the master group, rather than individual per-item groups\n\t// doing so simplifies handling of failed item renders\n\tconst marker = insert(\n\t\t/* nNode = */ __DEV__ ? hParent.adapter.marker(\"IteratorItem\") : hParent.adapter.marker(),\n\t\t/* children = */ null,\n\t\t/* hParent = */ hParent,\n\t\t/* hBefore = */ hBefore,\n\t\t/* nUsedParent = */ nParent,\n\t\t/* isBatch = */ isBatch,\n\t\t/* forceTrack = */ true,\n\t);\n\n\t// prepare per-item group for the actual content of the item\n\tconst item = fork(hParent, hBefore, hParent.$context) as IteratorItemGroup<TNode>;\n\titem.$marker = marker;\n\titem.$data = proxyKeys !== undefined\n\t\t? createProxy(item, data, proxyKeys)\n\t\t: data;\n\n\treturn item;\n}\n\n/**\n * Removes an iterator item as well as its position marker from the tracking hierarchy.\n */\nfunction untrackItem<TNode>(item: IteratorItemGroup<TNode>) {\n\tuntrack(item.$marker);\n\tuntrack(item);\n}\n\n/**\n * Destroys an iterator item that is no longer needed. Also destroys its position marker.\n */\nfunction destroyItem<TNode>(item: IteratorItemGroup<TNode>) {\n\ttry {\n\t\tdestroy(item);\n\t}\n\tfinally {\n\t\tconst marker = item.$marker;\n\t\titem.adapter.remove(marker.$nn);\n\t\tuntrack(marker);\n\t\tmarker.$ph = null;\n\t}\n}\n","import { isAtom, type Atom } from \"~/data/Atom\";\nimport { link, type Dependency } from \"~/data/Dependency\";\nimport type { Adapter } from \"~/Adapter\";\nimport type { JsxObject } from \"~/Component\";\nimport { insert, type HNode } from \"~/Renderer\";\nimport { runtime } from \"~/Runtime\";\nimport { S_TAG_NAME } from \"~/symbols\";\n\nexport function Native<TNode>(\n\tjsx: JsxObject,\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnUsedParent: TNode,\n\t_nRealParent: TNode,\n\tisBatch: boolean,\n) {\n\tconst hGroup = hParent.$ng;\n\tconst { adapter, $extensions } = hGroup;\n\tconst nNode = adapter.element(jsx[S_TAG_NAME]!);\n\n\tlet name;\n\tlet index;\n\tlet value;\n\tlet target;\n\n\t// for..in doesn't iterate symbol keys, so we don't need to manually exclude internal symbols\n\t// (S_COMPONENT, S_TAG_NAME, S_DEV_INFO), just the children prop\n\t//\n\t// also, since props from transpiled JSX are always plain objects, we shouldn't need to run\n\t// checks to exclude inherited fields\n\tfor (name in jsx) {\n\t\tindex = name.indexOf(\":\");\n\t\tvalue = jsx[name];\n\n\t\tif (index === 0) {\n\t\t\t// reserved ':' prefix for extension props set by reference via the `ext` utility\n\t\t\tif ((target = runtime.x[name])) {\n\t\t\t\ttarget.$ext.set(nNode, target.$prop, value, hGroup);\n\t\t\t}\n\t\t\telse if (__DEV__) {\n\t\t\t\tthrow new Error(`invalid reserved prop \"${name}\"`);\n\t\t\t}\n\t\t}\n\t\telse if (index > 0) {\n\t\t\t// regular prefixed extension props\n\t\t\t$extensions[name.slice(0, index)]?.set(nNode, name.slice(index + 1), value, hGroup);\n\t\t}\n\t\telse if (name !== \"children\") {\n\t\t\tif (isAtom(value)) {\n\t\t\t\tlink(hGroup, value, {\n\t\t\t\t\tfn: setBoundProp,\n\t\t\t\t\ta0: adapter,\n\t\t\t\t\ta1: nNode,\n\t\t\t\t\ta2: name,\n\t\t\t\t});\n\n\t\t\t\tvalue = value.get();\n\t\t\t}\n\n\t\t\tadapter.set(nNode, name, value);\n\t\t}\n\t}\n\n\tinsert(nNode, jsx.children, hParent, hBefore, nUsedParent, isBatch);\n\treturn nNode;\n}\n\nfunction setBoundProp<TNode>(\n\tthis: Dependency,\n\tadapter: Adapter<TNode>,\n\tnode: TNode,\n\tprop: string,\n) {\n\tadapter.set(node, prop, (this.$target as Atom).get());\n}\n","import { isAtom, read, type MaybeAtom, type Atom } from \"~/data/Atom\";\nimport { link } from \"~/data/Dependency\";\nimport { effect } from \"~/data/Effect\";\nimport { createProxy, updateProxy, type Proxied, type ProxyObject } from \"~/data/ProxyAtom\";\nimport { mountTemplate } from \"~/support/template\";\nimport type { Nil } from \"~/support/types\";\nimport type { DataTemplate, JsxChildren, JsxObject, JsxProps, JsxResult } from \"~/Component\";\nimport { flush, fork, insert, mountJsx, unmount, willMount, type HNode } from \"~/Renderer\";\n\nexport interface ShowProps {\n\twhen?: MaybeAtom<boolean>;\n\tchildren: JsxChildren;\n}\n\nexport interface ShowDataProps<T> {\n\twhen?: MaybeAtom<boolean>;\n\tproxy?: never;\n\tdata: MaybeAtom<T>;\n\tchildren: [ template: DataTemplate<T> | Atom<Nil<DataTemplate<T>>> ];\n}\n\nexport interface ShowProxyDataProps<T, P extends readonly (keyof T)[]> {\n\twhen?: MaybeAtom<boolean>;\n\tproxy: P & (\"proxied\" extends P[number] ? never : unknown);\n\tdata: MaybeAtom<T>;\n\tchildren: [ template: DataTemplate<Proxied<T, P>> | Atom<Nil<DataTemplate<Proxied<T, P>>>> ];\n}\n\n/**\n * The built-in Show Component dynamically mounting and unmounting a Template\n * based on a reactive condition result.\n */\n// @ts-expect-error fake overload to enable use with JSX\nexport function Show(props: JsxProps<ShowProps>): JsxResult;\nexport function Show<T>(props: JsxProps<ShowDataProps<T>>): JsxResult;\nexport function Show<T, P extends readonly (keyof T)[]>(props: JsxProps<ShowProxyDataProps<T, P>>): JsxResult;\n\nexport function Show<TNode>(\n\tprops: JsxObject,\n\thParent: HNode<TNode>,\n\thBefore: HNode<TNode> | null,\n\tnUsedParent: TNode,\n\tnRealParent: TNode,\n\tisBatch: boolean,\n) {\n\tconst when = props.when as MaybeAtom<boolean> | undefined;\n\tif (!isAtom(when) && when === false) {\n\t\t// when is statically set to false -> bail out early\n\t\treturn;\n\t}\n\n\tconst { children, data } = props;\n\tconst proxyKeys = props.proxy as readonly PropertyKey[] | undefined;\n\tconst template: MaybeAtom<(data: any) => any> = Object.hasOwn(props, \"data\")\n\t\t? children[0] as MaybeAtom<DataTemplate<any>> // enforced by overload typings\n\t\t: () => children;\n\n\tlet dataOrProxy: unknown = data;\n\tif (proxyKeys) {\n\t\tif (isAtom(data)) {\n\t\t\tdataOrProxy = createProxy(hParent.$ng, data.get(), proxyKeys);\n\t\t\tlink(hParent.$ng, data, {\n\t\t\t\tfn: updateShowProxy,\n\t\t\t\ta0: dataOrProxy as ProxyObject,\n\t\t\t\ta1: data,\n\t\t\t\ta2: proxyKeys,\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\tdataOrProxy = createProxy(hParent.$ng, data, proxyKeys);\n\t\t}\n\t}\n\n\t// prepare batching\n\tconst adapter = hParent.$ng.adapter;\n\tconst shouldBatch = !!adapter.batch;\n\n\t// a sub-group for re-mounting is only necessary when either:\n\t// - `when` can change\n\t// - `template` can change\n\t// - `data` can change and we're not using a proxy\n\n\tif (!(isAtom(when) || isAtom(template) || (!proxyKeys && isAtom(data)))) {\n\t\tconst isLocalBatch = shouldBatch && !isBatch;\n\t\tlet nBatchParent = nUsedParent;\n\t\tif (isLocalBatch) {\n\t\t\tnBatchParent = adapter.batch!();\n\t\t}\n\n\t\tmountJsx(\n\t\t\t/* jsx = */ template(dataOrProxy),\n\t\t\t/* hParent = */ hParent,\n\t\t\t/* hBefore = */ hBefore,\n\t\t\t/* nUsedParent = */ nBatchParent,\n\t\t\t/* nRealParent = */ nRealParent,\n\t\t\t/* isBatch = */ isLocalBatch || isBatch,\n\t\t);\n\n\t\tif (isLocalBatch) {\n\t\t\tadapter.insert(nBatchParent, nUsedParent, hBefore?.$nn ?? null);\n\t\t}\n\n\t\treturn;\n\t}\n\n\t// re-mounts may be necessary -> create a sub-group\n\tconst hGroup = fork(hParent, hBefore);\n\tconst dispose = () => unmount(hGroup);\n\n\t// (re-)render effect\n\tlet hMarker: HNode<TNode> | null = hBefore;\n\teffect(willMount(hGroup, () => {\n\t\tif (read(when) === false) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst isLocalBatch = shouldBatch && !isBatch;\n\t\tlet nBatchParent = nUsedParent;\n\t\tif (isLocalBatch) {\n\t\t\tnBatchParent = adapter.batch!();\n\t\t}\n\n\t\tmountTemplate(\n\t\t\t/* template = */ read(template),\n\t\t\t/* data = */ read(dataOrProxy),\n\t\t\t/* hParent = */ hGroup,\n\t\t\t/* hBefore = */ hMarker,\n\t\t\t/* nUsedParent = */ nBatchParent,\n\t\t\t/* nRealParent = */ nRealParent,\n\t\t\t/* isBatch = */ isLocalBatch || isBatch,\n\t\t);\n\n\t\tif (isLocalBatch) {\n\t\t\tadapter.insert(nBatchParent, nUsedParent, hMarker?.$nn ?? null);\n\t\t\ttry {\n\t\t\t\tflush(hGroup);\n\t\t\t}\n\t\t\tcatch (ex) {\n\t\t\t\tunmount(hGroup, [ ex ]);\n\t\t\t}\n\t\t}\n\n\t\treturn dispose;\n\t}), hParent.$ng);\n\n\t// insert marker to preserve position in the document\n\thMarker = insert(\n\t\t/* hNode = */ __DEV__ ? adapter.marker(\"/Show\") : adapter.marker(),\n\t\t/* children = */ null,\n\t\t/* hParent = */ hParent,\n\t\t/* hBefore = */ hBefore,\n\t\t/* nUsedParent = */ nUsedParent,\n\t\t/* isBatch = */ isBatch,\n\t\t/* forceTrack = */ true,\n\t);\n\n\t// forget stale batch before future re-renders\n\tisBatch = false;\n\tnUsedParent = nRealParent;\n}\n\nfunction updateShowProxy(proxy: ProxyObject, source: Atom, keys: readonly PropertyKey[]) {\n\tupdateProxy(proxy, source.get(), keys);\n}\n","import { UNIQUE_VALUE } from \"~/support/common\";\nimport type { Nil } from \"~/support/types\";\nimport { __DEV__assertIsDirectComponentCode } from \"~/Component\";\nimport { runtime } from \"~/Runtime\";\nimport { S_ATOM } from \"~/symbols\";\n\nimport { scheduleAtomNotification, type Atom, type WriteAtom } from \"./Atom\";\nimport { link, unlink, type Dependency } from \"./Dependency\";\nimport { getLifecycle, type Lifecycle } from \"./Lifecycle\";\n\n/**\n * Describes a Context propagating data throughout the Component hierarchy.\n * @see {@link contextOf}\n */\nexport interface Context<T> {\n\t/** @internal */\n\treadonly $symbol: symbol;\n\n\t/**\n\t * Carries typings of the data propagated by this Context. Typed as a function to enforce\n\t * correct variance of the generic value type.\n\t * @deprecated **Type only, does not exist at runtime!**\n\t */\n\treadonly $contract?: (value: T) => T;\n}\n\n/**\n * Creates a typed Context allowing propagation of observable data throughout entire component trees\n * without \"prop drilling.\"\n */\nexport function contextOf<T>(devId?: string): Context<T>;\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function contextOf<T>(): Context<T> {\n\tif (__DEV__) {\n\t\tconst devId = arguments[0];\n\t\tconst $symbol = runtime.$hmrState!.restore(contextOf, devId) ?? Symbol();\n\t\truntime.$hmrState!.preserve(contextOf, devId, $symbol);\n\t\treturn { $symbol };\n\t}\n\telse {\n\t\treturn { $symbol: Symbol() };\n\t}\n}\n\n\n/** @internal */\nexport interface ContextContainer {\n\t[key: symbol]: ContextAtom<any> | undefined;\n\treadonly $parent: ContextContainer | null;\n}\n\n/** @internal */\ninterface ContextAtom<T> extends WriteAtom<T> {\n\t$dep?: Nil<Dependency>;\n\t$upstream?: Nil<WriteAtom<T>>;\n\t$value?: T;\n\n\t/** tracks whether value has been defined, only used in dev builds */\n\t$defined?: boolean;\n\n\t/** cached readonly consumer Atom, only used in dev builds */\n\t$consumer?: ContextAtom<T>;\n}\n\n\n/**\n * Augments the current Component to act as a host (aka provider) of the given Context. Returns a\n * mutable Atom carrying the contextual value propagated to all descendant Components that consume\n * the Context.\n *\n * When a default value is specified, it will immediately be used as the hosted value, overriding\n * any value hosted by ancestors of this Component.\n *\n * Without a default value specified, the Context initializes as \"transparent,\" forwarding values\n * hosted by ancestors of this Component. Once the returned Atom is written into for the first time,\n * it breaks this link and begins hosting the new value from that point onwards. In forwarding mode,\n * if no ancestor hosts the Context, the value is not well defined and reading the Atom fails until\n * at least one of the hosts define a value.\n *\n * Descendants of this Component are able to consume the hosted value via `contextual(context)`\n * receiving a readonly Atom.\n *\n * Note that due to how JavaScript arguments are handled, `undefined` is always treated as no\n * default provided, even if it is an allowed value of the Context. To explicitly initialize hosts\n * to the literal value `undefined`, you need to write the Atom separately, e.g.:\n *\n * ```ts\n * const MyContext = contextOf<number | undefined>();\n *\n * // ...then, within a component:\n * const value = host(MyContext);\n * write(value, undefined);\n * ```\n * @see {@link contextual}\n */\nexport function host<C>(\n\tcontext: C,\n\tdefaultValue?: C extends Context<infer T> ? T : never,\n\tlifecycle?: Lifecycle,\n\tdevId?: string,\n): C extends Context<infer T> ? WriteAtom<T> : never;\n\nexport function host<T>(context: Context<T>, defaultValue?: T, lifecycle = getLifecycle()) {\n\tif (__DEV__) {\n\t\t__DEV__assertIsDirectComponentCode(host.name);\n\t}\n\n\tif (!runtime.$currentContextNew || !runtime.$currentContext) {\n\t\t// fork context container -> current component becomes a host\n\t\truntime.$currentContextNew = true;\n\t\truntime.$currentContext = {\n\t\t\t$parent: runtime.$currentContext,\n\t\t};\n\t}\n\n\tlet isUndefined = defaultValue === undefined;\n\tif (__DEV__) {\n\t\tconst devId = arguments[3];\n\t\truntime.$hmrState!.restore(lifecycle, devId, value => {\n\t\t\tdefaultValue = value;\n\t\t\tisUndefined = false;\n\t\t});\n\t}\n\n\tconst localAtom: ContextAtom<T> = {\n\t\t[S_ATOM]: true,\n\t\t$lifecycle: lifecycle,\n\t\t$value: defaultValue,\n\t\tget: getHostedValue,\n\t\tset: setHostedValue,\n\t};\n\n\tlet upstream;\n\tif (isUndefined && (upstream = lookupUpstream(context))) {\n\t\t// start in forwarding mode\n\t\tlocalAtom.get = getUpstreamValue;\n\t\tlocalAtom.$upstream = upstream;\n\t\tlink(lifecycle, upstream, localAtom.$dep = {\n\t\t\tfn: scheduleAtomNotification,\n\t\t\ta0: localAtom,\n\t\t});\n\t}\n\telse {\n\t\t// start in hosting mode\n\t\tlocalAtom.$tracksValue = true;\n\t\tlocalAtom.$lastValue = defaultValue;\n\t\tif (__DEV__) {\n\t\t\tlocalAtom.$defined = !isUndefined;\n\t\t}\n\t}\n\n\tif (__DEV__) {\n\t\tlocalAtom.$devId = arguments[3];\n\t\tif (Object.hasOwn(runtime.$currentContext, context.$symbol)) {\n\t\t\tthrow new Error(\"Component declares multiple hosts of the same Context.\");\n\t\t}\n\t}\n\n\truntime.$currentContext[context.$symbol] = localAtom;\n\treturn localAtom;\n}\n\n/**\n * Gets a readonly Atom carrying the value inherited from the nearest ancestor of the current\n * Component hosting the specified Context. This call fails if no ancestor is hosting the Context.\n * @see {@link host}\n */\nexport function contextual<T>(context: Context<T>): Atom<T> {\n\tif (__DEV__) {\n\t\t__DEV__assertIsDirectComponentCode(contextual.name);\n\t}\n\n\tconst atom = lookupUpstream(context);\n\tif (__DEV__) {\n\t\tif (!atom) {\n\t\t\tthrow new Error(\"No ancestor is hosting this Context.\");\n\t\t}\n\n\t\t// in dev builds, we create a separate consumer Atom forwarding the hosted value with a\n\t\t// trapped ::set overload that throws on invocation, enforcing the readonly constraint which\n\t\t// is otherwise only guarded by types in prod builds\n\t\tlet consumer = atom.$consumer;\n\t\tif (!consumer) {\n\t\t\tconsumer = atom.$consumer = {\n\t\t\t\t[S_ATOM]: true,\n\t\t\t\t$lifecycle: atom.$lifecycle,\n\t\t\t\t$upstream: atom,\n\t\t\t\tget: getUpstreamValue,\n\t\t\t\tset: __DEV__setConsumerValue,\n\t\t\t};\n\n\t\t\tlink(atom.$lifecycle, atom, {\n\t\t\t\tfn: scheduleAtomNotification,\n\t\t\t\ta0: consumer,\n\t\t\t});\n\t\t}\n\n\t\treturn consumer;\n\t}\n\n\treturn atom!;\n}\n\nfunction lookupUpstream<T>(context: Context<T>): ContextAtom<T> | undefined {\n\tconst { $symbol } = context;\n\tlet ptr: Nil<ContextContainer> = runtime.$currentContext;\n\tlet atom;\n\twhile (ptr && !(atom = ptr[$symbol])) {\n\t\tptr = ptr.$parent;\n\t}\n\n\treturn atom;\n}\n\nfunction getUpstreamValue<T>(this: ContextAtom<T>) {\n\treturn this.$upstream!.get();\n}\n\nfunction getHostedValue<T>(this: ContextAtom<T>) {\n\tif (__DEV__ && !this.$defined) {\n\t\tthrow new Error(\"Cannot read Context before it has been initialized.\");\n\t}\n\n\treturn this.$value!;\n}\n\nfunction setHostedValue<T>(this: ContextAtom<T>, value: T) {\n\tlet didChange = true;\n\tif (this.$upstream) {\n\t\t// switching from forwarding to hosting mode\n\t\tunlink(this.$dep!);\n\t\tthis.$upstream = null;\n\t\tthis.$dep = null;\n\t\tthis.$tracksValue = true;\n\t\tthis.$lastValue = UNIQUE_VALUE;\n\t\tthis.get = getHostedValue;\n\t}\n\telse {\n\t\tdidChange = !Object.is(this.$value, value);\n\t}\n\n\tthis.$value = value;\n\tif (__DEV__) {\n\t\tthis.$defined = true;\n\t\truntime.$hmrState!.preserve(this.$lifecycle, this.$devId, value);\n\t}\n\n\treturn didChange;\n}\n\nfunction __DEV__setConsumerValue(): never {\n\tthrow new Error(\"Contextual Atoms cannot be written.\");\n}\n","import { S_ATOM } from \"~/symbols\";\n\nimport { scheduleAtomNotification, type Atom, type WriteAtom } from \"./Atom\";\nimport { resolve, unlinkEffectDep, type Effect, type EffectDependency } from \"./Effect\";\nimport { getLifecycle } from \"./Lifecycle\";\n\n/**\n * Holds a value derived from values of other Atoms, managing reactions to their changes.\n * Derivations are read-only. Use the `read` function to access its value.\n * @see {@link read}\n */\nexport interface Derivation<T = unknown> extends Atom<T> {\n\t/** @internal */\n\t$dirty: boolean;\n\n\t/** @internal */\n\t$value: T;\n}\n\n/** @internal */\ninterface DerivationInternal<T> extends Derivation<T>, WriteAtom<T>, Effect<T> {}\n\n/**\n * Creates a Derivation - an Atom with its value computed from other Atoms. The block runs once\n * eagerly to compute the initial value, then re-runs within scheduler ticks whenever its source\n * Atoms change. Observers are only notified if the new value differs from the previous.\n */\nexport function derived<T>(block: () => T, lifecycle = getLifecycle()): Derivation<T> {\n\tconst atom: DerivationInternal<T> = {\n\t\t[S_ATOM]: true,\n\t\t$dirty: false,\n\t\t$value: null!,\n\t\t$tracksValue: true,\n\t\t$lifecycle: lifecycle,\n\t\t$life: lifecycle.$life,\n\t\t$lastValue: null!,\n\t\t$cycle: 0,\n\t\t$block: block,\n\t\t$react: scheduleReaction,\n\t\tget: getValue,\n\t\tset: setValue,\n\t};\n\n\tconst value = resolve(atom) as T;\n\tatom.$value = value;\n\tatom.$lastValue = value;\n\n\treturn atom;\n}\n\nfunction scheduleReaction(this: EffectDependency, derivation: DerivationInternal<any>, cycle: number) {\n\tif (\n\t\t// derivation was scheduled in a previous life and this run is now stale\n\t\tderivation.$life !== derivation.$lifecycle.$life ||\n\n\t\t// when we get an update from a stale dependency, the reported cycle number will be lower\n\t\t// than our current one (see the reportAccess function). We can unlink the dep and bail out.\n\t\tderivation.$cycle > cycle\n\t) {\n\t\tunlinkEffectDep(derivation, this);\n\t\treturn;\n\t}\n\n\t// we're already within a scheduler tick; the effect will therefore run synchronously despite\n\t// being \"scheduled\" - this also gives priority to already queued updates and coalesces\n\t// additional notifications while the first one is still pending.\n\tderivation.$dirty = true;\n\tscheduleAtomNotification(derivation);\n}\n\nfunction getValue<T>(this: DerivationInternal<T>): T {\n\t// life number must match, otherwise we'd re-link deps within a lifecycle that already ended\n\tif (this.$dirty && this.$life === this.$lifecycle.$life) {\n\t\tthis.$value = resolve(this) as T;\n\t\tthis.$dirty = false;\n\t}\n\n\treturn this.$value!;\n}\n\nfunction setValue() {\n\treturn false;\n}\n","import type { Nil } from \"~/support/types\";\nimport { runtime } from \"~/Runtime\";\n\nimport { link, notify, type DependencyList } from \"./Dependency\";\nimport { reportAccess } from \"./Effect\";\nimport { getLifecycle, withLifecycle, type Lifecycle } from \"./Lifecycle\";\nimport { itemChanged, itemInserted, itemRemoved, listCleared, listSynced, type Equals, type ListDelta, type PendingListDelta } from \"./ListDelta\";\nimport { scheduleTick, type UpdateCallback } from \"./Scheduler\";\n\nexport interface ReadonlyList<T> extends Iterable<T>, DependencyList {\n\t/**\n\t * Gets the size of this List.\n\t *\n\t * Reactive in effects and derivations.\n\t */\n\tsize(): number;\n\n\t/**\n\t * Gets the item at the specified index. Return undefined when outside of the List's bounds.\n\t *\n\t * Reactive in effects and derivations.\n\t */\n\tget(index: number): T | undefined;\n\n\t/**\n\t * Gets a boolean indicating whether changes have been made to this List that have not yet been\n\t * delivered to its observers.\n\t *\n\t * Non-reactive in effects and derivations.\n\t */\n\tdirty(): boolean;\n\n\t/**\n\t * Registers a callback to run whenever one or more changes are made to this List. The callback\n\t * receives a ListDelta object describing all changes made since the last notification.\n\t *\n\t * Non-reactive in effects and derivations.\n\t */\n\tdelta(block: (delta: ListDelta<T>) => void, lifecycle?: Lifecycle): void;\n\n\t/**\n\t * Gets the underlying array of items of this List. The array is read-only, but may change when\n\t * the List itself is mutated.\n\t *\n\t * Non-reactive in effects and derivations.\n\t *\n\t * *Mutating the array directly (e.g. in unchecked JS code) will cause any and all observers to\n\t * go out of sync, breaking the rendered state in unpredictable ways!*\n\t */\n\traw(): readonly T[];\n\n\t/**\n\t * Runs a block of code for each item of this List.\n\t *\n\t * Reactive in effects and derivations.\n\t */\n\tforEach(block: (item: T, index: number) => void): void;\n\n\t/**\n\t * Runs a block of code with a stable, immutable snapshot of the items within this List. The\n\t * List itself may be mutated as a result of running this code, but the provided snapshot will\n\t * not reflect any such changes.\n\t *\n\t * Non-reactive in effects and derivations.\n\t */\n\tstable<R>(block: (snapshot: readonly T[]) => R): R;\n\n\t/** @internal */\n\treadonly $lifecycle: Lifecycle;\n\n\t/** @internal */\n\t$items: readonly T[];\n\n\t/** @internal */\n\t$committedDelta: ListDelta<T> | null;\n\n\t/** @internal */\n\t$pendingDelta: PendingListDelta<T> | null;\n\n\t/** @internal */\n\t$afterNotify?: Nil<UpdateCallback<[ self: List<T> ]>>;\n\n\t/** @internal */\n\t$lock: number;\n\n\t/**\n\t * The ID of this List, only used in dev builds.\n\t * @internal\n\t */\n\t$devId?: string;\n}\n\nexport interface List<T> extends ReadonlyList<T> {\n\t/**\n\t * Sets the item at the specified index to a new value.\n\t * Observers are notified of this mutation.\n\t * @throws RangeError when index is out of bounds.\n\t */\n\tset(index: number, item: T): void;\n\n\t/**\n\t * Removes all items from this List.\n\t * Observers are notified of this mutation.\n\t */\n\tclear(): void;\n\n\t/**\n\t * Inserts a new item at the specified index.\n\t * Observers are notified of this mutation.\n\t * @throws RangeError when index is out of bounds.\n\t */\n\tinsertAt(index: number, item: T): void;\n\n\t/**\n\t * Inserts a new item at the start of this List.\n\t * Observers are notified of this mutation.\n\t */\n\tinsertFirst(item: T): void;\n\n\t/**\n\t * Inserts a new item at the end of this List.\n\t * Observers are notified of this mutation.\n\t */\n\tinsertLast(item: T): void;\n\n\t/**\n\t * Attempts to find and remove the first matching item from this List.\n\t * Observers are notified of this mutation.\n\t * @returns true if an item was found and removed, false otherwise.\n\t */\n\tremove(item: T): boolean;\n\n\t/**\n\t * Removes the item at the specified index.\n\t * Observers are notified of this mutation.\n\t * @returns the removed item.\n\t * @throws RangeError when index is out of bounds.\n\t */\n\tremoveAt(index: number): T;\n\n\t/**\n\t * Attempts to remove the first item of this List.\n\t * Observers are notified of this mutation.\n\t * @returns the removed item, or undefined if the List is empty.\n\t */\n\tremoveFirst(): T | undefined;\n\n\t/**\n\t * Attempts to remove the last item of this List.\n\t * Observers are notified of this mutation.\n\t * @returns the removed item, or undefined if the List is empty.\n\t */\n\tremoveLast(): T | undefined;\n\n\t/** @internal */\n\t$items: T[];\n}\n\n/**\n * Creates an empty List. This List emits deltas with each mutation which can be observed by\n * Components to efficiently update the rendered state.\n */\nexport function listOf<T>(): List<T>;\nexport function listOf<T>(source: Nil<never>, lifecycle?: Lifecycle, devId?: string): List<T>;\n\n/**\n * Creates a List initialized with items copied from the provided Iterable. This List emits deltas\n * with each mutation which can be observed by Components to efficiently update the rendered state.\n */\nexport function listOf<T>(source: Iterable<T>, lifecycle?: Lifecycle, devId?: string): List<T>;\n\nexport function listOf<T>(source?: Nil<Iterable<T>>, lifecycle = getLifecycle()): List<T> {\n\tif (__DEV__) {\n\t\tconst devId = arguments[2];\n\t\truntime.$hmrState!.restore(lifecycle, devId, value => {\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tsource = value;\n\t\t\t}\n\t\t});\n\t}\n\n\tconst items = source ? Array.from(source) : [];\n\tconst list: List<T> = {\n\t\t$items: items,\n\t\t$lifecycle: lifecycle,\n\t\t$committedDelta: null,\n\t\t$pendingDelta: null,\n\t\t$lock: 0,\n\t\t[Symbol.iterator]: getIterator,\n\t\tsize,\n\t\tget,\n\t\tdirty,\n\t\tdelta,\n\t\traw,\n\t\tforEach,\n\t\tstable,\n\t\tset,\n\t\tclear,\n\t\tinsertAt,\n\t\tinsertFirst,\n\t\tinsertLast,\n\t\tremove,\n\t\tremoveAt,\n\t\tremoveFirst,\n\t\tremoveLast,\n\t};\n\n\tif (__DEV__) {\n\t\tlist.$devId = arguments[2];\n\t}\n\n\treturn list;\n}\n\n/**\n * Synchronizes the provided List with the given data source. After this operation, the list will\n * contain an exact copy of the source.\n *\n * Note: This function is separated instead of being a List method as the underlying diff algorithm\n * (Myers) is a relatively large chunk of code which would otherwise always get bundled into\n * applications. This way, tools like Terser can easily eliminate the extra code when unused.\n */\nexport function sync<T>(list: List<T>, source: Iterable<T>, eq: Equals<T> = Object.is) {\n\tconst oldItems = list.$items;\n\tconst newItems = Array.from(source);\n\tlist.$items = newItems;\n\n\tif (__DEV__) {\n\t\t__DEV__preserveState(list);\n\t}\n\n\tif (!list.$dh && !list.$xa) {\n\t\t// skip emitting deltas when there are no observers\n\t\treturn;\n\t}\n\n\t// make sure that if no changes are detected, an empty delta isn't left on the List\n\tconst delta = initDelta(list);\n\tif (listSynced(delta, oldItems, newItems, eq)) {\n\t\tlist.$pendingDelta = delta;\n\t\tscheduleListNotification(list);\n\t}\n}\n\nfunction size(this: List<any>) {\n\treportAccess(this);\n\treturn this.$items.length;\n}\n\nfunction get(this: List<any>, index: number) {\n\treportAccess(this);\n\treturn this.$items[index];\n}\n\nfunction dirty(this: List<any>) {\n\tif (this.$xa) {\n\t\t// currently notifying observers\n\t\treturn true;\n\t}\n\n\tconst delta = this.$pendingDelta;\n\tif (!delta) {\n\t\treturn false;\n\t}\n\n\t// a delta is pending, check that the notification is scheduled within an active lifecycle and that the delta contains changes\n\tconst pending = this.$notify;\n\treturn (!pending || pending.$life === pending.$lifecycle!.$life) && delta.changes.length > 0;\n}\n\nfunction delta<T>(this: List<T>, block: (delta: ListDelta<T>) => void, lifecycle: Lifecycle = getLifecycle()) {\n\tlink(lifecycle, this, {\n\t\tfn: invokeDeltaBlock<T>,\n\t\ta0: this,\n\t\ta1: lifecycle,\n\t\ta2: block,\n\t});\n}\n\nfunction raw<T>(this: List<T>): readonly T[] {\n\treturn this.$items;\n}\n\nfunction forEach<T>(this: List<T>, callback: (item: T, index: number) => void) {\n\treportAccess(this);\n\tthis.$items.forEach(callback);\n}\n\nfunction stable<T, R>(this: List<T>, block: (snapshot: readonly T[]) => R) {\n\ttry {\n\t\tthis.$lock += 1;\n\t\treturn block(this.$items);\n\t}\n\tfinally {\n\t\tthis.$lock = Math.max(this.$lock - 1, 0);\n\t}\n}\n\nfunction getIterator<T>(this: List<T>) {\n\treportAccess(this);\n\treturn this.$items[Symbol.iterator]();\n}\n\nfunction set<T>(this: List<T>, index: number, newItem: T) {\n\tassertIndex(this, index);\n\n\tconst oldItem = this.$items[index];\n\tif (Object.is(newItem, oldItem)) {\n\t\treturn;\n\t}\n\n\tcopyOnWrite(this);\n\tthis.$items[index] = newItem;\n\n\tif (__DEV__) {\n\t\t__DEV__preserveState(this);\n\t}\n\n\t// only emit deltas when there are observers\n\tif (this.$dh || this.$xa) {\n\t\titemChanged(this.$pendingDelta = initDelta(this), index, oldItem, newItem);\n\t\tscheduleListNotification(this);\n\t}\n}\n\nfunction clear(this: List<any>) {\n\tconst count = this.$items.length;\n\tif (this.$lock > 0) {\n\t\tthis.$items = [];\n\t\tthis.$lock = 0;\n\t}\n\telse {\n\t\tthis.$items.length = 0;\n\t}\n\n\tif (__DEV__) {\n\t\t__DEV__preserveState(this);\n\t}\n\n\t// only emit deltas when there are observers\n\tif (this.$dh || this.$xa) {\n\t\tlistCleared(this.$pendingDelta = initDelta(this), count);\n\t\tscheduleListNotification(this);\n\t}\n}\n\nfunction insertAt<T>(this: List<T>, index: number, item: T) {\n\tif (index === this.$items.length) {\n\t\tcopyOnWrite(this);\n\t\tthis.$items.push(item);\n\t}\n\telse {\n\t\tassertIndex(this, index);\n\t\tcopyOnWrite(this);\n\t\tthis.$items.splice(index, 0, item);\n\t}\n\n\tif (__DEV__) {\n\t\t__DEV__preserveState(this);\n\t}\n\n\t// only emit deltas when there are observers\n\tif (this.$dh || this.$xa) {\n\t\titemInserted(this.$pendingDelta = initDelta(this), index, item);\n\t\tscheduleListNotification(this);\n\t}\n}\n\nfunction insertFirst<T>(this: List<T>, item: T) {\n\tthis.insertAt(0, item);\n}\n\nfunction insertLast<T>(this: List<T>, item: T) {\n\tthis.insertAt(this.$items.length, item);\n}\n\nfunction remove<T>(this: List<any>, item: T) {\n\tconst index = this.$items.indexOf(item);\n\tif (index === -1) {\n\t\treturn false;\n\t}\n\n\tthis.removeAt(index);\n\treturn true;\n}\n\nfunction removeAt<T>(this: List<T>, index: number) {\n\tassertIndex(this, index);\n\tcopyOnWrite(this);\n\tconst item = this.$items.splice(index, 1)[0];\n\n\tif (__DEV__) {\n\t\t__DEV__preserveState(this);\n\t}\n\n\t// only emit deltas when there are observers\n\tif (this.$dh || this.$xa) {\n\t\titemRemoved(this.$pendingDelta = initDelta(this), index, item);\n\t\tscheduleListNotification(this);\n\t}\n\n\treturn item;\n}\n\nfunction removeFirst<T>(this: List<T>) {\n\treturn this.$items.length > 0 ? this.removeAt(0) : undefined;\n}\n\nfunction removeLast<T>(this: List<T>) {\n\tconst { length } = this.$items;\n\treturn length > 0 ? this.removeAt(length - 1) : undefined;\n}\n\n\nfunction assertIndex(list: List<any>, index: number) {\n\tif (!Number.isInteger(index)) {\n\t\tif (__DEV__) {\n\t\t\tthrow new TypeError(\"list index must be an integer\");\n\t\t}\n\t\telse {\n\t\t\tthrow new TypeError();\n\t\t}\n\t}\n\n\tif (index >= list.$items.length || index < 0) {\n\t\tif (__DEV__) {\n\t\t\tthrow new RangeError(\"list index out of bounds\");\n\t\t}\n\t\telse {\n\t\t\tthrow new RangeError();\n\t\t}\n\t}\n}\n\nfunction initDelta<T>(list: List<T>): PendingListDelta<T> {\n\tif (list.$pendingDelta) {\n\t\tconst pending = list.$notify;\n\t\tif (!pending || pending.$life === pending.$lifecycle!.$life) {\n\t\t\treturn list.$pendingDelta;\n\t\t}\n\t}\n\n\treturn {\n\t\tchanges: [],\n\t\trelSize: 0,\n\t};\n}\n\nfunction copyOnWrite(list: List<any>) {\n\tif (list.$lock > 0) {\n\t\tlist.$items = list.$items.slice();\n\t\tlist.$lock = 0;\n\t}\n}\n\nfunction scheduleListNotification(list: List<any>) {\n\tscheduleTick(list.$lifecycle, list.$notify ??= {\n\t\tfn: notifyListObservers,\n\t\ta0: list,\n\t});\n}\n\nfunction notifyListObservers(list: List<any>) {\n\t// Keep the delivered delta stable for observers. Mutations made while notifying accumulate in a\n\t// separate delta for the next pass.\n\n\tconst delta = list.$pendingDelta!;\n\tlist.$pendingDelta = null;\n\n\t// unless forced, skip notifications whenever the delta is a no-op\n\tif (list.$force || delta.changes.length > 0) {\n\t\tdelta.snapshot = list.$items;\n\t\tlist.$committedDelta = delta as ListDelta<any>;\n\t\tlist.$lock += 1; // protect the snapshot\n\t\tlist.$force = false;\n\n\t\ttry {\n\t\t\tnotify(list);\n\t\t}\n\t\tfinally {\n\t\t\tlist.$committedDelta = null;\n\t\t\tlist.$lock = Math.max(list.$lock - 1, 0);\n\t\t}\n\t}\n}\n\nfunction invokeDeltaBlock<T>(list: List<T>, lifecycle: Lifecycle, block: (delta: ListDelta<T>) => void) {\n\twithLifecycle(lifecycle, block, list.$committedDelta!);\n}\n\nfunction __DEV__preserveState(list: List<any>) {\n\truntime.$hmrState!.preserve(list.$lifecycle, list.$devId, list.$items);\n}\n","import type { TickFn } from \"~/data/Scheduler\";\nimport type { ElementsType, S_ELEM_NAME, S_NODE_TYPE } from \"~/support/types\";\n\nimport type { MountingGroup } from \"./Renderer\";\nimport { runtime } from \"./Runtime\";\n\nexport interface Adapter<TNode, TElements extends ElementsType = ElementsType> {\n\t/**\n\t * Carries information about the available intrinsic elements when using this Adapter.\n\t * @deprecated **Type only, does not exist at runtime!**\n\t */\n\treadonly $elements?: TElements;\n\n\t/**\n\t * A function able to schedule a callback to be executed at a later time, e.g. `queueMicrotask`.\n\t * The function must guarantee that the callback will be eventually executed.\n\t */\n\treadonly tick: TickFn;\n\n\t/**\n\t * Creates a native (intrinsic) element node by the element name.\n\t */\n\treadonly element: (\n\t\tname: string,\n\t) => TNode;\n\n\t/**\n\t * Creates or updates a text node. In both cases the node is returned.\n\t */\n\treadonly text: (\n\t\tvalue: string,\n\t\tnode: TNode | null,\n\t) => TNode;\n\n\t/**\n\t * Creates a marker node used to preserve a position within the node tree.\n\t */\n\treadonly marker: (\n\t\tcomment?: string,\n\t) => TNode;\n\n\t/**\n\t * Creates a batch to which nodes can be inserted \"offline,\" without causing any updates. The\n\t * batch is later inserted all at once using the `insert` function, causing only a single\n\t * update.\n\t *\n\t * Adapters may omit this function when batching is not supported.\n\t */\n\treadonly batch?: () => TNode;\n\n\t/**\n\t * Inserts the given `node` as a child of the `parent`. If `before` is provided, the child will\n\t * be inserted just before the referenced node (which itself must be a child of the parent),\n\t * otherwise the child is inserted at the end, becoming the new last child of the parent.\n\t */\n\treadonly insert: (\n\t\tnode: TNode,\n\t\tparent: TNode,\n\t\tbefore: TNode | null,\n\t) => void;\n\n\t/**\n\t * Removes a node from the hierarchy.\n\t */\n\treadonly remove: (\n\t\tnode: TNode,\n\t) => void;\n\n\t/**\n\t * Sets a named property of the given node.\n\t */\n\treadonly set: (\n\t\telem: TNode,\n\t\tprop: string,\n\t\tvalue: any,\n\t) => void;\n}\n\nexport type ExtensionsType<TNode> = { [_ in string]?: Extension<TNode> };\n\nexport interface Extension<TNode, TPropMapping extends ExtensionPropMapping<unknown> = ExtensionPropMapping<unknown>> {\n\t/**\n\t * Unique prop prefix of this Extension used for props set by reference (via the {@link ext}\n\t * utility).\n\t * @internal\n\t */\n\treadonly $prefix: string;\n\n\t/**\n\t * Carries a mapping type used to infer the props this extension adds to native elements.\n\t * @deprecated **Type only, does not exist at runtime!**\n\t */\n\treadonly $mapping?: TPropMapping;\n\n\t/**\n\t * Sets a named extension property of the given element. The prop name arrives unprefixed, i.e.\n\t * without any extension key prefix.\n\t */\n\treadonly set: (\n\t\tnode: TNode,\n\t\tprop: string,\n\t\tvalue: any,\n\t\tgroup: MountingGroup<TNode>,\n\t) => void;\n}\n\nexport interface ExtensionPropMapping<TNode> {\n\t/** Will contain a concrete type of the element for which props are being mapped. */\n\tnode: TNode;\n\n\t/** Will contain a name of the element for which props are being mapped. */\n\tname: string;\n\n\t/**\n\t * Override this field with an inferred object containing typed extension props. Prop names\n\t * should be plain, do not include their extension prefix. It will be added automatically.\n\t *\n\t * To infer concrete types, you may use:\n\t *\n\t * - `this[\"node\"]` ... concrete type of the element node\n\t * - `this[\"name\"]` ... the name of the element, as used in JSX\n\t */\n\textension: {};\n}\n\n/** Creates an extension with a shared-runtime ID independent of its registered JSX prefix. */\n/*@__NO_SIDE_EFFECTS__*/\nexport function extension<TNode, TPropMapping extends ExtensionPropMapping<TNode>>(\n\tpropSetter: Extension<TNode>[\"set\"],\n): Extension<TNode, TPropMapping> {\n\treturn {\n\t\t$prefix: `:${(++runtime.$extIndex).toString(16)}:`,\n\t\tset: propSetter,\n\t};\n}\n\n/**\n * Builds a set of extension props using an Extension reference rather than relying on a globally\n * registered prefixed extension props. The resulting object is intended to be ...spread directly\n * onto JSX elements.\n *\n * Typically used in libraries where relying on a specific prefix convention would limit the users.\n * Does not require an active component lifecycle. Repeated spreads use the last value for each\n * extension/prop pair, while props from different extensions remain independent.\n */\nexport function ext<TMapping extends ExtensionPropMapping<any>, TNodeType, TElemName>(\n\textension: Extension<any, TMapping>,\n\textensionProps: (TMapping & { node: TNodeType; name: TElemName; })[\"extension\"],\n\ttargetPropsObject: { [_ in string]?: any } = {},\n): {\n\treadonly [S_NODE_TYPE]?: TNodeType;\n\treadonly [S_ELEM_NAME]?: TElemName;\n} {\n\tconst prefix = extension.$prefix;\n\tif (__DEV__ && typeof prefix !== \"string\") {\n\t\tthrow new Error(\"the extension was not created through the `extension()` factory and cannot be used\");\n\t}\n\n\tconst routing = runtime.x;\n\tlet prop;\n\tlet route;\n\n\t// Typical usage declares plain objects inline with the `ext` call, we are very unlikely to\n\t// receive objects with inherited fields here, so we skip the extra checks. It's already bad\n\t// enough that library code incurs the penalty of running this function for every extension it\n\t// uses...\n\t//\n\t// FUTURE: This would be remedied with a pre-compiler, though... *wink*\n\tfor (prop in extensionProps) {\n\t\troute = prefix + prop;\n\t\trouting[route] ??= {\n\t\t\t$ext: extension,\n\t\t\t$prop: prop,\n\t\t};\n\n\t\ttargetPropsObject[route] = (extensionProps as { [_ in string]: any })[prop];\n\t}\n\n\treturn targetPropsObject;\n}\n","import { isAtom, write, type WriteAtom } from \"~/data/Atom\";\nimport { invokeMountedCallback, onceMounted, onceUnmounted } from \"~/data/Lifecycle\";\nimport { extension, type ExtensionPropMapping } from \"~/Adapter\";\n\ninterface RefPropMapping extends ExtensionPropMapping<unknown> {\n\textension: RefProps<this[\"node\"]>;\n}\n\ninterface RefProps<TNode> {\n\treadonly atom?: WriteAtom<TNode | null>;\n\treadonly call?: RefFn<TNode>;\n}\n\nexport interface RefFn<TNode> {\n\t(node: TNode): (() => void) | void;\n}\n\n/**\n * Extension adding direct reference access to any element. Recommended prefix: `\"ref\"`\n *\n * References can be stored into Atoms:\n *\n * ```tsx\n * const wrapperRef = atomOf<HTMLDivElement | null>(null);\n * <div ref:atom={wrapperRef} />\n * ```\n *\n * The Atom will be set to the referenced node once it mounts. Later, when the node unmounts, the\n * Atom is set back to `null`.\n *\n * References can also be received via callbacks:\n *\n * ```tsx\n * const onWrapperRef = (node: HTMLDivElement) => {\n * // ...\n * };\n *\n * <div ref:call={onWrapperRef} />\n * ```\n *\n * Ref callbacks are only called when the node mounts, they never receive `null`. Instead,\n * unmounted nodes may be handled by returning a teardown callback.\n */\nexport const RefExtension = /*@__PURE__*/ extension<any, RefPropMapping>((node, prop, value, group) => {\n\tswitch (prop) {\n\t\tcase \"atom\":\n\t\t\tif (isAtom(value)) {\n\t\t\t\tonceMounted(group, {\n\t\t\t\t\tfn: write,\n\t\t\t\t\ta0: value,\n\t\t\t\t\ta1: node,\n\t\t\t\t});\n\n\t\t\t\tonceUnmounted(group, {\n\t\t\t\t\tfn: write,\n\t\t\t\t\ta0: value,\n\t\t\t\t\ta1: null,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tbreak;\n\n\t\tcase \"call\":\n\t\t\tif (typeof value === \"function\") {\n\t\t\t\tonceMounted(group, {\n\t\t\t\t\tfn: invokeMountedCallback,\n\t\t\t\t\ta0: group,\n\t\t\t\t\ta1: value,\n\t\t\t\t\ta2: node,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tbreak;\n\t}\n});\n","import { atomOf, isAtom, peek, read, update, write, type WriteAtom, type MaybeWriteAtom, type Atom } from \"~/data/Atom\";\nimport { derived } from \"~/data/Derivation\";\nimport { getLifecycle, type Lifecycle } from \"~/data/Lifecycle\";\n\nimport { noop } from \"./common\";\nimport type { Flatten } from \"./types\";\n\n/**\n * A template string tag that creates a Derivation Atom from the tagged template. The derivation\n * automatically observes any Atoms among substitutions and updates the resulting string whenever\n * one or more of these Atoms change.\n *\n * Substitutions use String conversion; Failed conversions get replaced with `[error]`. Ideally,\n * you'd want to make sure `String(yourValue)` never fails.\n */\nexport function text(strings: TemplateStringsArray, ...values: unknown[]) {\n\tconst { length } = values;\n\treturn derived(() => {\n\t\tlet result = strings[0];\n\t\tlet index = 0;\n\t\tlet value;\n\n\t\twhile (index < length) {\n\t\t\tvalue = read(values[index]);\n\n\t\t\t// only catch stringification errors\n\t\t\ttry {\n\t\t\t\tvalue = String(value);\n\t\t\t}\n\t\t\tcatch {\n\t\t\t\tvalue = \"[error]\";\n\t\t\t}\n\n\t\t\tresult += value + strings[++index];\n\t\t}\n\n\t\treturn result;\n\t});\n}\n\n/**\n * Creates a callback wrapping a call to the {@link write} function. Useful for decluttering inline\n * event handlers in JSX templates.\n * @see {@link write}\n */\nexport function writes<A>(\n\tinput: A,\n\tvalue: A extends WriteAtom<infer T> ? T : never,\n\tforce?: boolean,\n): () => void;\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function writes<T>(input: MaybeWriteAtom<T>, value: T, force?: boolean) {\n\treturn isAtom(input)\n\t\t? () => void write(input, value, force)\n\t\t: noop;\n}\n\n/**\n * Creates a callback wrapping a call to the {@link update} function. Useful for decluttering inline\n * event handlers in JSX templates.\n * @see {@link update}\n */\nexport function updates<A>(\n\tinput: A,\n\ttransform: A extends WriteAtom<infer T> ? (value: T) => T : never,\n\tforce?: boolean,\n): () => void;\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function updates<T>(input: MaybeWriteAtom<T>, transform: (value: T) => T, force?: boolean) {\n\treturn isAtom(input)\n\t\t? () => void update(input, transform, force)\n\t\t: noop;\n}\n\n\n/**\n * Extracts the type of value represented by the given type, unwrapping Atoms if they're part of the\n * type.\n */\nexport type ValueType<T> = T extends Atom<infer V> ? V : T;\n\n/**\n * Infers an object with its fields' values wrapped in Atoms. Optionally, if a specific TKeys union\n * is provided, only select fields will be wrapped.\n */\nexport type AtomsOf<TData extends { readonly [K in string]: any }, TKeys extends (keyof TData & (string | number)) | undefined = undefined> = (\n\tundefined extends TKeys\n\t\t? {\n\t\t\t[K in keyof TData as K extends string | number ? K : never]: undefined extends TData[K]\n\t\t\t\t? MaybeWriteAtom<ValueType<TData[K]>>\n\t\t\t\t: WriteAtom<ValueType<TData[K]>>;\n\t\t}\n\t\t: Flatten<(\n\t\t\t& { [K in TKeys & keyof TData & (string | number)] -?: WriteAtom<ValueType<TData[K]>> }\n\t\t\t& Omit<Pick<TData, keyof TData & (string | number)>, TKeys & keyof TData>\n\t\t)>\n);\n\n/**\n * Creates a new data object mapped from the one provided, with its fields' values wrapped in\n * mutable Atoms. Optionally, a tuple of keys can be given to only wrap the select fields, copying\n * others as-is.\n */\nexport function atomsOf<TData extends { readonly [K in string]: any }>(\n\tdata: TData,\n\tlifecycle?: Lifecycle,\n): AtomsOf<TData>;\n\nexport function atomsOf<TData extends { readonly [K in string]: any }, const TKeys extends readonly (keyof TData & (string | number))[]>(\n\tdata: TData,\n\tkeys: TKeys & (number extends TKeys[\"length\"] ? never : unknown),\n\tlifecycle?: Lifecycle,\n): AtomsOf<TData, TKeys[number]>;\n\nexport function atomsOf(\n\tdata: { readonly [K in string]: any },\n\tkeysOrLifecycle?: readonly (string | number)[] | Lifecycle,\n\tmaybeLifecycle?: Lifecycle,\n) {\n\tlet keys: readonly (string | number)[] | undefined;\n\tlet lifecycle: Lifecycle | undefined;\n\n\tif (keysOrLifecycle === undefined || Array.isArray(keysOrLifecycle)) {\n\t\tkeys = keysOrLifecycle as (readonly (string | number)[] | undefined);\n\t\tlifecycle = maybeLifecycle;\n\t}\n\telse {\n\t\tlifecycle = keysOrLifecycle as (Lifecycle | undefined);\n\t}\n\n\tlifecycle ??= getLifecycle();\n\n\tconst result: { [K in string]: WriteAtom<any> } = Object.create(null);\n\tif (keys) {\n\t\tconst { length } = keys;\n\t\tlet index = 0;\n\t\tlet key;\n\n\t\tfor (; index < length; index += 1) {\n\t\t\tkey = keys[index];\n\t\t\tresult[key] = atomOf(data[key], lifecycle);\n\t\t}\n\n\t\tfor (key in data) {\n\t\t\tif (result[key] === undefined) {\n\t\t\t\tresult[key] = data[key];\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tlet key;\n\t\tfor (key in data) {\n\t\t\tresult[key] = atomOf(data[key], lifecycle);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Assigns values taken from the provided data object to the store (typically previously created\n * via {@link atomsOf}). Optionally, a tuple of keys can be given to treat select fields as\n * guaranteed Atoms while copying others as-is. Typically, you'd pass the same keys tuple to both\n * `atomsOf` and later `assign` calls.\n */\nexport function assign<TData extends { readonly [K in string]: any }, TStore extends AtomsOf<TData>>(\n\tstore: TStore,\n\tdata: TData,\n\tlifecycle?: Lifecycle,\n): TStore;\n\nexport function assign<TData extends { readonly [K in string]: any }, const TKeys extends readonly (keyof TData & (string | number))[], TStore extends AtomsOf<TData, TKeys[number]>>(\n\tstore: TStore,\n\tdata: TData,\n\tkeys: TKeys & (number extends TKeys[\"length\"] ? never : unknown),\n\tlifecycle?: Lifecycle,\n): TStore;\n\nexport function assign(\n\tstore: { [K in string]?: WriteAtom<any> },\n\tdata: { readonly [K in string]: any },\n\tkeysOrLifecycle?: readonly (string | number)[] | Lifecycle,\n\tmaybeLifecycle?: Lifecycle,\n) {\n\tlet keys: readonly (string | number)[] | undefined;\n\tlet lifecycle: Lifecycle | undefined;\n\n\tif (keysOrLifecycle === undefined || Array.isArray(keysOrLifecycle)) {\n\t\tkeys = keysOrLifecycle as (readonly (string | number)[] | undefined);\n\t\tlifecycle = maybeLifecycle;\n\t}\n\telse {\n\t\tlifecycle = keysOrLifecycle as (Lifecycle | undefined);\n\t}\n\n\tif (keys) {\n\t\tconst { length } = keys;\n\t\tconst visited: { [K in string]?: true } = Object.create(null);\n\t\tlet index = 0;\n\t\tlet key;\n\n\t\tfor (; index < length; index += 1) {\n\t\t\tkey = keys[index];\n\t\t\twrite(store[key], peek(data[key]));\n\t\t\tvisited[key] = true;\n\t\t}\n\n\t\tfor (key in data) {\n\t\t\tif (!visited[key]) {\n\t\t\t\tstore[key] = data[key];\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tlet key;\n\t\tlet atom;\n\n\t\tfor (key in store) {\n\t\t\tatom = store[key];\n\t\t\tif (isAtom(atom)) {\n\t\t\t\twrite(atom, peek(data[key]));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tstore[key] = atomOf(data[key], lifecycle ??= getLifecycle());\n\t\t\t}\n\t\t}\n\n\t\tfor (key in data) {\n\t\t\tif (!Object.hasOwn(store, key)) {\n\t\t\t\tstore[key] = atomOf(data[key], lifecycle ??= getLifecycle());\n\t\t\t}\n\t\t}\n\t}\n\n\treturn store;\n}\n","import { Native } from \"~/component/Native\";\nimport type { PropsType } from \"~/support/types\";\nimport type { Component, JsxResult } from \"~/Component\";\n\nimport { S_COMPONENT, S_TAG_NAME } from \"./symbols\";\n\nconst EMPTY_ARRAY = [] as const;\n\nexport function jsx(\n\ttagName: string,\n\tprops: PropsType,\n\tkey?: any,\n): JsxResult;\n\nexport function jsx<TProps extends PropsType>(\n\tcomponent: Component<TProps>,\n\tprops: TProps,\n\tkey?: any,\n): JsxResult;\n\nexport function jsx(\n\tcomponentOrTagName: Component<PropsType> | string,\n\tprops: any,\n\tkey?: any,\n) {\n\tconst { children } = props;\n\n\t// the `jsx` (dynamic) variant is called without wrapping arrays around children, however it is\n\t// also used when children come from a variable, which may carry an array, so we have to check\n\tprops.children = children === undefined\n\t\t? EMPTY_ARRAY\n\t\t: Array.isArray(children)\n\t\t\t? children\n\t\t\t: [ children ];\n\n\t// put back the `key` prop\n\tprops.key ??= key;\n\n\t// attach component info\n\tif (typeof componentOrTagName === \"string\") {\n\t\tprops[S_COMPONENT] = Native;\n\t\tprops[S_TAG_NAME] = componentOrTagName;\n\t}\n\telse {\n\t\tprops[S_COMPONENT] = componentOrTagName;\n\t}\n\n\treturn props;\n}\n\n\nexport function jsxs(\n\ttagName: string,\n\tprops: PropsType,\n\tkey?: any,\n): JsxResult;\n\nexport function jsxs<TProps extends PropsType>(\n\tcomponent: Component<TProps>,\n\tprops: TProps,\n\tkey?: any,\n): JsxResult;\n\nexport function jsxs(\n\tcomponentOrTagName: Component<PropsType> | string,\n\tprops: any,\n\tkey?: any,\n) {\n\t// the `jsxs` (static) variant is always given a wrapping array around children,\n\t// so we don't have to check it\n\n\t// put back the `key` prop\n\tprops.key ??= key;\n\n\t// attach component info\n\tif (typeof componentOrTagName === \"string\") {\n\t\tprops[S_COMPONENT] = Native;\n\t\tprops[S_TAG_NAME] = componentOrTagName;\n\t}\n\telse {\n\t\tprops[S_COMPONENT] = componentOrTagName;\n\t}\n\n\treturn props;\n}\n","import type { ElementsType, Flatten, NodeType, PropsType } from \"~/support/types\";\n\nimport type { Adapter, Extension, ExtensionPropMapping, ExtensionsType } from \"./Adapter\";\nimport { createRenderer, type Renderer } from \"./Renderer\";\n\nexport interface RendererBuilder<TNode, TElements extends ElementsType, TUsedPrefixes extends string = never> {\n\tcreate: () => Renderer<TNode, TElements>;\n\n\textend: <TPrefix extends string, TExtension extends Extension<TNode>>(\n\t\tprefix: TPrefix & (TPrefix extends TUsedPrefixes ? never : unknown),\n\t\textension: TExtension,\n\t) => RendererBuilder<\n\t\tTNode,\n\t\tExtendedElements<TNode, TElements, TExtension, TPrefix>,\n\t\tTUsedPrefixes | TPrefix\n\t>;\n}\n\ntype ExtendedElements<TNode, TElements extends ElementsType, TExtension extends Extension<TNode>, TPrefix extends string> = (\n\tTExtension extends { readonly $mapping?: infer TMapping extends ExtensionPropMapping<unknown> }\n\t\t? {\n\t\t\t[TElementName in keyof TElements]: (\n\t\t\t\t(TMapping & { node: NodeType<TElements[TElementName]>; name: TElementName; })[\"extension\"] extends (infer TExtensionProps extends PropsType)\n\t\t\t\t\t? [ keyof TExtensionProps ] extends [ never ]\n\t\t\t\t\t\t? TElements[TElementName]\n\t\t\t\t\t\t: Flatten<TElements[TElementName] & PrefixedProps<TExtensionProps, TPrefix>>\n\t\t\t\t\t: TElements[TElementName]\n\t\t\t);\n\t\t}\n\t\t: TElements\n);\n\ntype PrefixedProps<TProps extends PropsType, TPrefix extends string> = {\n\treadonly [TPrefixed in `${TPrefix}:${keyof TProps & string}`]?: (\n\t\tTPrefixed extends `${TPrefix}:${infer TName extends (keyof TProps & string)}`\n\t\t\t? TProps[TName]\n\t\t\t: never\n\t);\n};\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function renderer<TNode, TElements extends ElementsType>(adapter: Adapter<TNode, TElements>) {\n\tconst extensions: ExtensionsType<TNode> = {};\n\tconst builder: RendererBuilder<TNode, TElements> = {\n\t\tcreate: () => createRenderer(adapter, extensions),\n\t\textend: (extensionKey: string, extension: any) => {\n\t\t\tif (__DEV__ && !/^[a-z_$][a-z0-9_$-]*$/i.test(extensionKey)) {\n\t\t\t\tthrow new Error(`invalid extension key: \"${extensionKey}\"`);\n\t\t\t}\n\n\t\t\textensions[extensionKey] = extension;\n\t\t\treturn builder as any;\n\t\t},\n\t};\n\n\treturn builder;\n}\n","import { ComponentRegistry } from \"~/dev/ComponentRegistry\";\nimport { StateRegistry } from \"~/dev/StateRegistry\";\nimport { runtime } from \"~/Runtime\";\n\nruntime.$hmrComponent ??= new ComponentRegistry();\nruntime.$hmrState ??= new StateRegistry();\n\nexport { S_DEV_INFO } from \"~/symbols\";\nexport * from \"./core\";\n"],"mappings":";AAMA,SAAgB,OAAO,UAA8B;CACpD,OAAO,SAAS,GACf,SAAS,IACT,SAAS,IACT,SAAS,EACV;AACD;AAMA,SAAgB,OAAO,CAAC;AAMxB,SAAgB,QAAQ,QAA+C;CACtE,IAAI,QAAQ;EACX,IAAI,OAAO,SAAS,GACnB,MAAM,IAAI,eAAe,MAAM;EAGhC,IAAI,OAAO,WAAW,GACrB,MAAM,OAAO;CAEf;AACD;A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