aberdeen 1.4.1 → 1.4.3

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.
@@ -3,9 +3,9 @@
3
3
  "sources": ["../src/helpers/reverseSortedSet.ts", "../src/aberdeen.ts"],
4
4
  "sourcesContent": [
5
5
  "// Meta-data is saved in-place on ReverseSorted items.\n// - Items in the set should indicate they support {[ptr: ReverseSortedSetPointer]: SELF}\nexport type ReverseSortedSetPointer = symbol;\n\n// ReverseSortedSet saves the skip links for all required levels on the object itself\ntype SkipItem<T> = { [idx: ReverseSortedSetPointer]: T };\n\n/**\n * A set-like collection of objects that can do iteration sorted by a specified index property.\n * It also allows retrieving an object by its index property, and quickly getting the object\n * that comes immediately after a given object.\n *\n * It's implemented as a skiplist, maintaining all meta-data as part of the objects that it\n * is tracking, for performance.\n */\nexport class ReverseSortedSet<T extends SkipItem<T>, KeyPropT extends keyof T> {\n\t// A fake item, that is not actually T, but *does* contain symbols pointing at the first item for each level.\n\tprivate tail: SkipItem<T>;\n\t// As every SkipList instance has its own symbols, an object can be included in more than one SkipList.\n\tprivate symbols: ReverseSortedSetPointer[];\n\n\t/**\n\t * Create an empty SortedSet.\n\t *\n\t * @param keyProp The name of the property that should be used as the index of this collection. Comparison\n\t * using `<` will be done on this property, so it should probably be a number or a string (or something that\n\t * has a useful toString-conversion).\n\t */\n\tconstructor(private keyProp: KeyPropT) {\n\t\tthis.tail = {} as SkipItem<T>;\n\t\tthis.symbols = [Symbol(0)];\n\t}\n\n\t/**\n\t * Add an object to the `SortedSet`.\n\t *\n\t * @param item The object to be added to the set. One or more properties with\n\t * `Symbol` keys will be added to it, for `SortedSet` internals.\n\t * @returns `true` if the item was added, or `false` if it was *not* added\n\t * because the item already was part of this set.\n\t *\n\t * Note that though an item object may only be part of a particular `SortedSet`\n\t * once, index properties may be duplicate and an item object may be part of\n\t * more than one `SortedSet`.\n\t *\n\t * **IMPORTANT:** After adding an object, do not modify its index property,\n\t * as this will lead to undefined (broken) behavior on the entire set.\n\t *\n\t * Time complexity: O(log n)\n\t */\n\tadd(item: T): boolean {\n\t\tif (this.symbols[0] in item) return false; // Already included\n\n\t\t// Start at level 1. Keep upping the level by 1 with 1/8 chance.\n\t\tconst level = 1 + (Math.clz32(Math.random() * 0xffffffff) >> 2);\n\t\tfor (let l = this.symbols.length; l < level; l++)\n\t\t\tthis.symbols.push(Symbol(l));\n\n\t\tconst keyProp = this.keyProp;\n\t\tconst key = item[keyProp];\n\n\t\t// prev is always a complete T, current might be tail only contain pointers\n\t\tlet prev: T | undefined;\n\t\tlet current: SkipItem<T> = this.tail;\n\t\tfor (let l = this.symbols.length - 1; l >= 0; l--) {\n\t\t\tconst symbol = this.symbols[l];\n\t\t\twhile ((prev = current[symbol]) && prev[keyProp] > key) current = prev;\n\t\t\tif (l < level) {\n\t\t\t\t(item as SkipItem<T>)[symbol] = current[symbol];\n\t\t\t\tcurrent[symbol] = item;\n\t\t\t}\n\t\t}\n\n\t\treturn true; // Added\n\t}\n\n\t/**\n\t * @param item An object to test for inclusion in the set.\n\t * @returns true if this object item is already part of the set.\n\t */\n\thas(item: T): boolean {\n\t\treturn this.symbols[0] in item;\n\t}\n\n\t/**\n\t * Remove and return the last item.\n\t * @returns what was previously the last item in the sorted set, or `undefined` if the set was empty.\n\t */\n\tfetchLast(): T | undefined {\n\t\tconst item = this.tail[this.symbols[0]];\n\t\tif (item) {\n\t\t\tthis.remove(item);\n\t\t\treturn item;\n\t\t}\n\t}\n\n\t/**\n\t * @returns whether the set is empty (`true`) or has at least one item (`false`).\n\t */\n\tisEmpty(): boolean {\n\t\treturn this.tail[this.symbols[0]] === undefined;\n\t}\n\n\t/**\n\t * Retrieve an item object based on its index property value.\n\t *\n\t * @param indexValue The index property value to search for.\n\t * @returns `undefined` if the index property value does not exist in the `SortedSet` or\n\t * otherwise the *first* item object that has this index value (meaning any further\n\t * instances can be iterated using `next()`).\n\t *\n\t * Time complexity: O(log n)\n\t */\n\tget(indexValue: T[KeyPropT]): T | undefined {\n\t\tconst keyProp = this.keyProp;\n\n\t\t// prev is always a complete T, current might be tail only contain pointers\n\t\tlet prev: T | undefined;\n\t\tlet current: SkipItem<T> = this.tail;\n\t\tfor (let l = this.symbols.length - 1; l >= 0; l--) {\n\t\t\tconst symbol = this.symbols[l];\n\t\t\twhile ((prev = current[symbol]) && prev[keyProp] > indexValue)\n\t\t\t\tcurrent = prev;\n\t\t}\n\t\treturn current[this.symbols[0]]?.[keyProp] === indexValue\n\t\t\t? current[this.symbols[0]]\n\t\t\t: undefined;\n\t}\n\n\t/**\n\t * The iterator will go through the items in reverse index-order.\n\t */\n\t*[Symbol.iterator](): IterableIterator<T> {\n\t\tconst symbol = this.symbols[0];\n\t\tlet node = this.tail[symbol];\n\t\twhile (node) {\n\t\t\tyield node;\n\t\t\tnode = node[symbol];\n\t\t}\n\t}\n\n\t/**\n\t * Given an item object, returns the one that comes right before in the set.\n\t * @param item The object to start from.\n\t * @returns The next object, or `undefined` if there is none.\n\t *\n\t * Time complexity: O(1)\n\t */\n\tprev(item: T): T | undefined {\n\t\treturn item[this.symbols[0]];\n\t}\n\n\t/**\n\t * Remove an item object from the set, deleting all meta-data keys that\n\t * were created on `add()`.\n\t * @param item The object to be removed.\n\t * @returns `true` on success or `false` when the item was not part of the set.\n\t *\n\t * Time complexity: O(log n)\n\t */\n\tremove(item: T): boolean {\n\t\tif (!(this.symbols[0] in item)) return false;\n\t\tconst keyProp = this.keyProp;\n\t\tconst prop = item[keyProp];\n\n\t\t// prev is always a complete T, current might be tail only contain pointers\n\t\tlet prev: T | undefined;\n\t\tlet current: SkipItem<T> = this.tail;\n\t\tfor (let l = this.symbols.length - 1; l >= 0; l--) {\n\t\t\tconst symbol = this.symbols[l];\n\t\t\twhile ((prev = current[symbol]) && prev[keyProp] >= prop && prev !== item)\n\t\t\t\tcurrent = prev;\n\t\t\tif (prev === item) {\n\t\t\t\tcurrent[symbol] = prev[symbol];\n\t\t\t\tdelete prev[symbol];\n\t\t\t}\n\t\t}\n\n\t\treturn prev === item;\n\t}\n\n\t/**\n\t * Remove all items for the set.\n\t *\n\t * Time complexity: O(n)\n\t */\n\tclear(): void {\n\t\tconst symbol = this.symbols[0];\n\t\tlet current = this.tail;\n\t\twhile (current) {\n\t\t\tconst prev = current[symbol];\n\t\t\tfor (const symbol of this.symbols) {\n\t\t\t\tif (!(symbol in current)) break;\n\t\t\t\tdelete current[symbol];\n\t\t\t}\n\t\t\tcurrent = prev;\n\t\t}\n\t\tthis.tail = {};\n\t}\n}\n",
6
- "import { ReverseSortedSet } from \"./helpers/reverseSortedSet.js\";\nimport type { ReverseSortedSetPointer } from \"./helpers/reverseSortedSet.js\";\n\n/*\n * QueueRunner\n *\n * `queue()`d runners are executed on the next timer tick, by order of their\n * `prio` values.\n */\ninterface QueueRunner {\n\tprio: number; // Higher values have higher priority\n\tqueueRun(): void;\n\n\t[ptr: ReverseSortedSetPointer]: QueueRunner;\n}\n\nlet sortedQueue: ReverseSortedSet<QueueRunner, \"prio\"> | undefined; // When set, a runQueue is scheduled or currently running.\nlet runQueueDepth = 0; // Incremented when a queue event causes another queue event to be added. Reset when queue is empty. Throw when >= 42 to break (infinite) recursion.\nlet topRedrawScope: Scope | undefined; // The scope that triggered the current redraw. Elements drawn at this scope level may trigger 'create' animations.\n\n/** @internal */\nexport type TargetType = any[] | { [key: string | symbol]: any } | Map<any, any>;\n\n\nfunction queue(runner: QueueRunner) {\n\tif (!sortedQueue) {\n\t\tsortedQueue = new ReverseSortedSet<QueueRunner, \"prio\">(\"prio\");\n\t\tsetTimeout(runQueue, 0);\n\t} else if (!(runQueueDepth & 1)) {\n\t\trunQueueDepth++; // Make it uneven\n\t\tif (runQueueDepth > 98) {\n\t\t\tthrow new Error(\"Too many recursive updates from observes\");\n\t\t}\n\t}\n\tsortedQueue.add(runner);\n}\n\n/**\n * Forces the immediate and synchronous execution of all pending reactive updates.\n *\n * Normally, changes to observed data sources (like proxied objects or arrays)\n * are processed asynchronously in a batch after a brief timeout (0ms). This function\n * allows you to bypass the timeout and process the update queue immediately.\n *\n * This can be useful in specific scenarios where you need the DOM to be updated\n * synchronously.\n *\n * This function is re-entrant, meaning it is safe to call `runQueue` from within\n * a function that is itself being executed as part of an update cycle triggered\n * by a previous (or the same) `runQueue` call.\n *\n * @example\n * ```typescript\n * const data = proxy(\"before\");\n *\n * $({text: data});\n * console.log(1, document.body.innerHTML); // before\n *\n * // Make an update that should cause the DOM to change.\n * data.value = \"after\";\n *\n * // Normally, the DOM update would happen after a timeout.\n * // But this causes an immediate update:\n * runQueue();\n *\n * console.log(2, document.body.innerHTML); // after\n * ```\n */\nexport function runQueue(): void {\n\tlet time = Date.now();\n\twhile (sortedQueue) {\n\t\tconst runner = sortedQueue.fetchLast();\n\t\tif (!runner) break;\n\t\tif (runQueueDepth & 1) runQueueDepth++; // Make it even\n\t\trunner.queueRun();\n\t}\n\tsortedQueue = undefined;\n\trunQueueDepth = 0;\n\ttime = Date.now() - time;\n\tif (time > 9) console.debug(`Aberdeen queue took ${time}ms`);\n}\n\n/**\n * A sort key, as used by {@link onEach}, is a value that determines the order of items. It can\n * be a number, string, or an array of numbers/strings. The sort key is used to sort items\n * based on their values. The sort key can also be `undefined`, which indicates that the item\n * should be ignored.\n * @internal\n */\nexport type SortKeyType = number | string | Array<number | string> | undefined | void;\n\n/**\n * Given an integer number or a string, this function returns a string that can be concatenated\n * with other strings to create a composed sort key, that follows natural number ordering.\n */\nfunction partToStr(part: number | string): string {\n\tif (typeof part === \"string\") {\n\t\treturn `${part}\\x01`; // end-of-string\n\t}\n\tlet result = \"\";\n\tlet num = Math.abs(Math.round(part));\n\tconst negative = part < 0;\n\twhile (num > 0) {\n\t\t/*\n\t\t * We're reserving a few character codes:\n\t\t * 0 - for compatibility\n\t\t * 1 - separator between string array items\n\t\t * 65535 - for compatibility\n\t\t */\n\t\tresult = String.fromCharCode(\n\t\t\tnegative ? 65534 - (num % 65533) : 2 + (num % 65533),\n\t\t) + result;\n\t\tnum = Math.floor(num / 65533);\n\t}\n\t// Prefix the number of digits, counting down from 128 for negative and up for positive\n\treturn (\n\t\tString.fromCharCode(128 + (negative ? -result.length : result.length)) +\n\t\tresult\n\t);\n}\n\n/**\n * Creates a new string that has the opposite sort order compared to the input string.\n *\n * This is achieved by flipping the bits of each character code in the input string.\n * The resulting string is intended for use as a sort key, particularly with the\n * `makeKey` function in {@link onEach}, to achieve a descending sort order.\n *\n * **Warning:** The output string will likely contain non-printable characters or\n * appear as gibberish and should not be displayed to the user.\n *\n * @example\n * ```typescript\n * const users = proxy([\n * { id: 1, name: 'Charlie', score: 95 },\n * { id: 2, name: 'Alice', score: 100 },\n * { id: 3, name: 'Bob', score: 90 },\n * ]);\n *\n * onEach(users, (user) => {\n * $(`p#${user.name}: ${user.score}`);\n * }, (user) => invertString(user.name)); // Reverse alphabetic order\n * ```\n *\n * @param input The string whose sort order needs to be inverted.\n * @returns A new string that will sort in the reverse order of the input string.\n * @see {@link onEach} for usage with sorting.\n */\nexport function invertString(input: string): string {\n\tlet result = \"\";\n\tfor (let i = 0; i < input.length; i++) {\n\t\tresult += String.fromCodePoint(65535 - input.charCodeAt(i));\n\t}\n\treturn result;\n}\n\n// Each new scope gets a lower prio than all scopes before it, by decrementing\n// this counter.\nlet lastPrio = 0;\n\nabstract class Scope implements QueueRunner {\n\t// Scopes are to be handled in creation order. This will make sure that parents are\n\t// handled before their children (as they should), and observes are executed in the\n\t// order of the source code.\n\tprio: number = --lastPrio;\n\n\t[ptr: ReverseSortedSetPointer]: this;\n\n\tonChange(index: any): void {\n\t\tqueue(this);\n\t}\n\tabstract queueRun(): void;\n\n\tabstract getLastNode(): Node | undefined;\n\tabstract getPrecedingNode(): Node | undefined;\n\tabstract delete(): void;\n\n\tremove() {\n\t\t// Remove any nodes\n\t\tconst lastNode = this.getLastNode();\n\t\tif (lastNode) removeNodes(lastNode, this.getPrecedingNode());\n\n\t\t// Run any cleaners\n\t\tthis.delete();\n\t}\n\n\t// toString(): string {\n\t// \treturn `${this.constructor.name}`\n\t// }\n}\n\n/**\n * Execute a function once, after all currently scheduled jobs are completed.\n */\nclass DelayedOneTimeRunner implements QueueRunner {\n\tprio: number = --lastPrio;\n\t[ptr: ReverseSortedSetPointer]: this;\n\tconstructor(\n\t\tpublic queueRun: () => void\n\t) {\n\t\tqueue(this);\n\t}\n}\n\n/**\n * All Scopes that can hold nodes and subscopes, including `SimpleScope` and `OnEachItemScope`\n * but *not* `OnEachScope`, are `ContentScope`s.\n */\nabstract class ContentScope extends Scope {\n\t// The list of clean functions to be called when this scope is cleaned. These can\n\t// be for child scopes, subscriptions as well as `clean(..)` hooks.\n\tcleaners: Array<{ delete: (scope: Scope) => void } | (() => void)>;\n\n\tabstract svg: boolean;\n\tabstract el: Element;\n\n\tconstructor(\n\t\tcleaners: Array<{ delete: (scope: Scope) => void } | (() => void)> = [],\n\t) {\n\t\tsuper();\n\t\tthis.cleaners = cleaners;\n\t}\n\n\tlastChild: Node | Scope | undefined;\n\n\t// Should be subclassed in most cases..\n\tredraw() {}\n\n\tgetLastNode(): Node | undefined {\n\t\treturn findLastNodeInPrevSiblings(this.lastChild);\n\t}\n\n\t/**\n\t * Call cleaners and make sure the scope is not queued.\n\t * It is called `delete`, so that the list of cleaners can also contain `Set`s.\n\t */\n\tdelete(/* ignore observer argument */) {\n\t\tfor (const cleaner of this.cleaners) {\n\t\t\tif (typeof cleaner === \"function\") cleaner();\n\t\t\telse cleaner.delete(this); // pass in observer argument, in case `cleaner` is a `Set`\n\t\t}\n\t\tthis.cleaners.length = 0;\n\t\tsortedQueue?.remove(this); // This is very fast and O(1) when not queued\n\n\t\t// To prepare for a redraw or to help GC when we're being removed:\n\t\tthis.lastChild = undefined;\n\t}\n\n\tqueueRun() {\n\t\tthis.remove();\n\n\t\ttopRedrawScope = this;\n\t\tthis.redraw();\n\t\ttopRedrawScope = undefined;\n\t}\n\n\tgetInsertAfterNode() {\n\t\treturn this.getLastNode() || this.getPrecedingNode();\n\t}\n\n\tonChange() {\n\t\tqueue(this);\n\t}\n\n\tgetChildPrevSibling() {\n\t\treturn this.lastChild;\n\t}\n}\n\nclass ChainedScope extends ContentScope {\n\t// The node or scope right before this scope that has the same `parentElement`.\n\tpublic prevSibling: Node | Scope | undefined;\n\n\tconstructor(\n\t\t// The parent DOM element we'll add our child nodes to.\n\t\tpublic el: Element,\n\t\t// Whether this scope is within an SVG namespace context\n\t\tpublic svg: boolean,\n\t\t// When true, we share our 'cleaners' list with the parent scope.\n\t\tuseParentCleaners = false,\n\t) {\n\t\tsuper(useParentCleaners ? currentScope.cleaners : []);\n\t\t\n\t\tif (el === currentScope.el) {\n\t\t\t// If `currentScope` is not actually a ChainedScope, prevSibling will be undefined, as intended\n\t\t\tthis.prevSibling = currentScope.getChildPrevSibling();\n\t\t\tcurrentScope.lastChild = this;\n\t\t} else {\n\t\t\tthis.prevSibling = el.lastChild || undefined;\n\t\t}\n\n\t\t// We're always adding ourselve as a cleaner, in order to run our own cleaners\n\t\t// and to remove ourselve from the queue (if we happen to be in there).\n\t\tif (!useParentCleaners) currentScope.cleaners.push(this);\n\t}\n\n\tgetPrecedingNode(): Node | undefined {\n\t\treturn findLastNodeInPrevSiblings(this.prevSibling);\n\t}\n\n\tgetChildPrevSibling() {\n\t\treturn this.lastChild || this.prevSibling;\n\t}\n}\n\n/**\n * @internal\n * A `RegularScope` is created with a `render` function that is run initially,\n * and again when any of the `Store`s that this function reads are changed. Any\n * DOM elements that is given a `render` function for its contents has its own scope.\n * The `Scope` manages the position in the DOM tree elements created by `render`\n * are inserted at. Before a rerender, all previously created elements are removed\n * and the `clean` functions for the scope and all sub-scopes are called.\n */\nclass RegularScope extends ChainedScope {\n\tconstructor(\n\t\tel: Element,\n\t\tsvg: boolean,\n\t\t// The function that will be reactively called. Elements it creates using `$` are\n\t\t// added to the appropriate position within `parentElement`.\n\t\tpublic renderer: () => any,\n\t) {\n\t\tsuper(el, svg);\n\n\t\t// Do the initial run\n\t\tthis.redraw();\n\t}\n\n\tredraw() {\n\t\tconst savedScope = currentScope;\n\t\tcurrentScope = this;\n\t\ttry {\n\t\t\tthis.renderer();\n\t\t} catch (e) {\n\t\t\t// Throw the error async, so the rest of the rendering can continue\n\t\t\thandleError(e, true);\n\t\t}\n\t\tcurrentScope = savedScope;\n\t}\n}\n\nclass RootScope extends ContentScope {\n\tel = document.body;\n\tsvg = false;\n\tgetPrecedingNode(): Node | undefined {\n\t\treturn undefined;\n\t}\n}\n\nclass MountScope extends ContentScope {\n\tsvg: boolean;\n\tconstructor(\n\t\t// The parent DOM element we'll add our child nodes to\n\t\tpublic el: Element,\n\t\t// The function that\n\t\tpublic renderer: () => any,\n\t) {\n\t\tsuper();\n\t\tthis.svg = el.namespaceURI === 'http://www.w3.org/2000/svg';\n\t\t\n\t\tthis.redraw();\n\t\tcurrentScope.cleaners.push(this);\n\t}\n\n\tredraw() {\n\t\tRegularScope.prototype.redraw.call(this);\n\t}\n\n\tgetPrecedingNode(): Node | undefined {\n\t\treturn undefined;\n\t}\n\n\tdelete() {\n\t\t// We can't rely on our parent scope to remove all our nodes for us, as our parent\n\t\t// probably has a totally different `parentElement`. Therefore, our `delete()` does\n\t\t// what `_remove()` does for regular scopes.\n\t\tremoveNodes(this.getLastNode(), this.getPrecedingNode());\n\t\tsuper.delete();\n\t}\n\n\tremove() {\n\t\tthis.delete();\n\t}\n}\n\n// Remove node and all its preceding siblings (uptil and excluding preNode)\n// from the DOM, using onDestroy if applicable.\nfunction removeNodes(\n\tnode: Node | null | undefined,\n\tpreNode: Node | null | undefined,\n) {\n\twhile (node && node !== preNode) {\n\t\tconst prevNode: Node | null = node.previousSibling;\n\t\tconst onDestroy = onDestroyMap.get(node);\n\t\tif (onDestroy && node instanceof Element) {\n\t\t\tif (onDestroy !== true) {\n\t\t\t\tif (typeof onDestroy === \"function\") {\n\t\t\t\t\tonDestroy(node);\n\t\t\t\t} else {\n\t\t\t\t\tdestroyWithClass(node, onDestroy);\n\t\t\t\t}\n\t\t\t\t// This causes the element to be ignored from this function from now on:\n\t\t\t\tonDestroyMap.set(node, true);\n\t\t\t}\n\t\t\t// Ignore the deleting element\n\t\t} else {\n\t\t\t(node as Element | Text).remove();\n\t\t}\n\t\tnode = prevNode;\n\t}\n}\n\n// Get a reference to the last node within `sibling` or any of its preceding siblings.\n// If a `Node` is given, that node is returned.\nfunction findLastNodeInPrevSiblings(\n\tsibling: Node | Scope | undefined,\n): Node | undefined {\n\tif (!sibling || sibling instanceof Node) return sibling;\n\treturn sibling.getLastNode() || sibling.getPrecedingNode();\n}\n\nclass ResultScope<T> extends ChainedScope {\n\tpublic result: ValueRef<T> = optProxy({ value: undefined });\n\n\tconstructor(\n\t\tpublic renderer: () => T,\n\t) {\n\t\tsuper(currentScope.el, currentScope.svg);\n\t\tthis.redraw();\n\t}\n\n\tredraw() {\n\t\tconst savedScope = currentScope;\n\t\tcurrentScope = this;\n\t\ttry {\n\t\t\tthis.result.value = this.renderer();\n\t\t} catch (e) {\n\t\t\t// Throw the error async, so the rest of the rendering can continue\n\t\t\thandleError(e, true);\n\t\t}\n\t\tcurrentScope = savedScope;\n\t}\n}\n\n/**\n * A `Scope` subclass optimized for reactively setting just a single element property\n * based on a proxied reference.\n */\n\nclass SetArgScope extends ChainedScope {\n\tpublic svg = false;\n\tconstructor(\n\t\tel: Element,\n\t\tprivate key: string,\n\t\tprivate target: { value: any },\n\t) {\n\t\tsuper(el, el.namespaceURI === 'http://www.w3.org/2000/svg');\n\t\tthis.redraw();\n\t}\n\tredraw() {\n\t\tconst savedScope = currentScope;\n\t\tcurrentScope = this;\n\t\tapplyArg(this.el, this.key, this.target.value);\n\t\tcurrentScope = savedScope;\n\t}\n}\n\n/** @internal */\nclass OnEachScope extends Scope {\n\t// biome-ignore lint/correctness/noInvalidUseBeforeDeclaration: circular, as currentScope is initialized with a Scope\n\tparentElement: Element = currentScope.el;\n\tprevSibling: Node | Scope | undefined;\n\n\t/** The data structure we are iterating */\n\ttarget: TargetType;\n\n\t/** All item scopes, by array index or object key. This is used for removing an item scope when its value\n\t * disappears, and calling all subscope cleaners. */\n\tbyIndex: Map<any, OnEachItemScope> = new Map();\n\n\t/** The reverse-ordered list of item scopes, not including those for which makeSortKey returned undefined. */\n\tsortedSet: ReverseSortedSet<OnEachItemScope, \"sortKey\"> =\n\t\tnew ReverseSortedSet(\"sortKey\");\n\n\t/** Indexes that have been created/removed and need to be handled in the next `queueRun`. */\n\tchangedIndexes: Set<any> = new Set();\n\n\tconstructor(\n\t\tproxy: TargetType,\n\t\t/** A function that renders an item */\n\t\tpublic renderer: (value: any, key: any) => void,\n\t\t/** A function returning a number/string/array that defines the position of an item */\n\t\tpublic makeSortKey?: (value: any, key: any) => SortKeyType,\n\t) {\n\t\tsuper();\n\t\tconst target: TargetType = (this.target =\n\t\t\t(proxy as any)[TARGET_SYMBOL] || proxy);\n\n\t\tsubscribe(target, ANY_SYMBOL, this);\n\t\tthis.prevSibling = currentScope.getChildPrevSibling();\n\t\tcurrentScope.lastChild = this;\n\n\t\tcurrentScope.cleaners.push(this);\n\n\t\t// Do _addChild() calls for initial items\n\t\tif (target instanceof Array) {\n\t\t\tfor (let i = 0; i < target.length; i++) {\n\t\t\t\tnew OnEachItemScope(this, i, false);\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const key of (target instanceof Map ? target.keys() : Object.keys(target))) {\n\t\t\t\tnew OnEachItemScope(this, key, false);\n\t\t\t}\n\t\t}\n\t}\n\n\tgetPrecedingNode(): Node | undefined {\n\t\treturn findLastNodeInPrevSiblings(this.prevSibling);\n\t}\n\n\tonChange(index: any) {\n\t\tif (!(this.target instanceof Array) || typeof index === \"number\")\n\t\t\tthis.changedIndexes.add(index);\n\t\tqueue(this);\n\t}\n\n\tqueueRun() {\n\t\tconst indexes = this.changedIndexes;\n\t\tthis.changedIndexes = new Set();\n\t\tfor (const index of indexes) {\n\t\t\tconst oldScope = this.byIndex.get(index);\n\t\t\tif (oldScope) oldScope.remove();\n\n\t\t\tif (this.target instanceof Map ? this.target.has(index) : index in this.target) {\n\t\t\t\t// Item still exists\n\t\t\t\tnew OnEachItemScope(this, index, true);\n\t\t\t} else {\n\t\t\t\t// Item has disappeared\n\t\t\t\tthis.byIndex.delete(index);\n\t\t\t}\n\t\t}\n\t\ttopRedrawScope = undefined;\n\t}\n\n\tdelete() {\n\t\t// Propagate to all our subscopes\n\t\tfor (const scope of this.byIndex.values()) {\n\t\t\tscope.delete();\n\t\t}\n\n\t\tsortedQueue?.remove(this); // This is very fast and O(1) when not queued\n\n\t\t// Help garbage collection:\n\t\tthis.byIndex.clear();\n\t\tsetTimeout(() => {\n\t\t\t// Unsure if this is a good idea. It takes time, but presumably makes things a lot easier for GC...\n\t\t\tthis.sortedSet.clear();\n\t\t}, 1);\n\t}\n\n\tgetLastNode(): Node | undefined {\n\t\tfor (const scope of this.sortedSet) {\n\t\t\t// Iterates starting at last child scope.\n\t\t\tconst node = scope.getActualLastNode();\n\t\t\tif (node) return node;\n\t\t}\n\t}\n}\n\n/** @internal */\nclass OnEachItemScope extends ContentScope {\n\tsortKey: string | number | undefined; // When undefined, this scope is currently not showing in the list\n\tpublic el: Element;\n\tpublic svg: boolean;\n\n\tconstructor(\n\t\tpublic parent: OnEachScope,\n\t\tpublic itemIndex: any,\n\t\ttopRedraw: boolean,\n\t) {\n\t\tsuper();\n\t\tthis.el = parent.parentElement;\n\t\t\n\t\t// Inherit SVG namespace state from current scope\n\t\tthis.svg = currentScope.svg;\n\n\t\tthis.parent.byIndex.set(this.itemIndex, this);\n\n\t\t// Okay, this is hacky. In case our first (actual) child is a ChainedScope, we won't be able\n\t\t// to provide it with a reliable prevSibling. Therefore, we'll pretend to be that sibling,\n\t\t// doing what's need for this case in `getLastNode`.\n\t\t// For performance, we prefer not having to create additional 'fake sibling' objects for each item.\n\t\tthis.lastChild = this;\n\n\t\t// Don't register to be cleaned by parent scope, as the OnEachScope will manage this for us (for efficiency)\n\n\t\tif (topRedraw) topRedrawScope = this;\n\t\tthis.redraw();\n\t}\n\n\tgetPrecedingNode(): Node | undefined {\n\t\t// As apparently we're interested in the node insert position, we'll need to become part\n\t\t// of the sortedSet now (if we weren't already).\n\t\t// This will do nothing and barely take any time of `this` is already part of the set:\n\t\tthis.parent.sortedSet.add(this);\n\n\t\tconst preScope = this.parent.sortedSet.prev(this);\n\t\t// As preScope should have inserted itself as its first child, this should\n\t\t// recursively call getPrecedingNode() on preScope in case it doesn't\n\t\t// have any actual nodes as children yet.\n\t\tif (preScope) return findLastNodeInPrevSiblings(preScope.lastChild);\n\t\treturn this.parent.getPrecedingNode();\n\t}\n\n\tgetLastNode(): Node | undefined {\n\t\t// Hack! As explain in the constructor, this getLastNode method actually\n\t\t// does not return the last node, but the preceding one.\n\t\treturn this.getPrecedingNode();\n\t}\n\n\tgetActualLastNode(): Node | undefined {\n\t\tlet child = this.lastChild;\n\n\t\twhile (child && child !== this) {\n\t\t\tif (child instanceof Node) return child;\n\t\t\tconst node = child.getLastNode();\n\t\t\tif (node) return node;\n\t\t\tchild = child.getPrecedingNode();\n\t\t}\n\t}\n\n\tqueueRun() {\n\t\t/* c8 ignore next */\n\t\tif (currentScope !== ROOT_SCOPE) internalError(4);\n\n\t\t// We're not calling `remove` here, as we don't want to remove ourselves from\n\t\t// the sorted set. `redraw` will take care of that, if needed.\n\t\t// Also, we can't use `getLastNode` here, as we've hacked it to return the\n\t\t// preceding node instead.\n\t\tif (this.sortKey !== undefined) {\n\t\t\tconst lastNode = this.getActualLastNode();\n\t\t\tif (lastNode) removeNodes(lastNode, this.getPrecedingNode());\n\t\t}\n\n\t\tthis.delete();\n\t\tthis.lastChild = this; // apply the hack (see constructor) again\n\n\t\ttopRedrawScope = this;\n\t\tthis.redraw();\n\t\ttopRedrawScope = undefined;\n\t}\n\n\tredraw() {\n\t\t// Have the makeSortKey function return an ordering int/string/array.\n\n\t\t// Note that we're NOT subscribing on target[itemIndex], as the OnEachScope uses\n\t\t// a wildcard subscription to delete/recreate any scopes when that changes.\n\t\t// We ARE creating a proxy around the value though (in case its an object/array),\n\t\t// so we'll have our own scope subscribe to changes on that.\n\t\tlet value: any;\n\t\tconst target = this.parent.target;\n\t\tlet itemIndex = this.itemIndex;\n\t\tif (target instanceof Map) {\n\t\t\tvalue = optProxy(target.get(itemIndex));\n\t\t\t// For Maps, the key may be an object. If so, we'll proxy it as well.\n\t\t\titemIndex = optProxy(itemIndex);\n\t\t} else {\n\t\t\tvalue = optProxy((target as any)[itemIndex]);\n\t\t}\n\n\t\t// Since makeSortKey may get() the Store, we'll need to set currentScope first.\n\t\tconst savedScope = currentScope;\n\t\tcurrentScope = this;\n\n\t\tlet sortKey: undefined | string | number;\n\t\ttry {\n\t\t\tif (this.parent.makeSortKey) {\n\t\t\t\tconst rawSortKey = this.parent.makeSortKey(value, itemIndex);\n\t\t\t\tif (rawSortKey != null)\n\t\t\t\t\tsortKey =\n\t\t\t\t\t\trawSortKey instanceof Array\n\t\t\t\t\t\t\t? rawSortKey.map(partToStr).join(\"\")\n\t\t\t\t\t\t\t: rawSortKey;\n\t\t\t} else {\n\t\t\t\tsortKey = itemIndex;\n\t\t\t}\n\t\t\tif (typeof sortKey === \"number\") sortKey = partToStr(sortKey);\n\n\t\t\tif (this.sortKey !== sortKey) {\n\t\t\t\t// If the sortKey is changed, make sure `this` is removed from the\n\t\t\t\t// set before setting the new sortKey to it.\n\t\t\t\tthis.parent.sortedSet.remove(this); // Very fast if `this` is not in the set\n\t\t\t\tthis.sortKey = sortKey;\n\t\t\t}\n\n\t\t\t// We're not adding `this` to the `sortedSet` (yet), as that may not be needed,\n\t\t\t// in case no nodes are created. We'll do it just-in-time in `getPrecedingNode`.\n\n\t\t\tif (sortKey != null) this.parent.renderer(value, itemIndex);\n\t\t} catch (e) {\n\t\t\thandleError(e, sortKey != null);\n\t\t}\n\n\t\tcurrentScope = savedScope;\n\t}\n\n\tgetInsertAfterNode() {\n\t\tif (this.sortKey == null) internalError(1);\n\t\t// Due to the `this` being the first child for `this` hack, this will look\n\t\t// for the preceding node as well, if we don't have nodes ourselves.\n\t\treturn findLastNodeInPrevSiblings(this.lastChild);\n\t}\n\n\tremove() {\n\t\t// We can't use getLastNode here, as we've hacked it to return the preceding\n\t\t// node instead.\n\t\tif (this.sortKey !== undefined) {\n\t\t\tconst lastNode = this.getActualLastNode();\n\t\t\tif (lastNode) removeNodes(lastNode, this.getPrecedingNode());\n\n\t\t\tthis.parent.sortedSet.remove(this);\n\t\t\tthis.sortKey = undefined;\n\t\t}\n\n\t\tthis.delete();\n\t}\n}\n\nfunction addNode(el: Element, node: Node) {\n\tif (el !== currentScope.el) {\n\t\tel.appendChild(node);\n\t\treturn;\n\t}\n\tconst parentEl = currentScope.el;\n\tconst prevNode = currentScope.getInsertAfterNode();\n\tparentEl.insertBefore(\n\t\tnode,\n\t\tprevNode ? prevNode.nextSibling : parentEl.firstChild,\n\t);\n\tcurrentScope.lastChild = node;\n}\n\n/**\n * This global is set during the execution of a `Scope.render`. It is used by\n * functions like `$` and `clean`.\n */\nconst ROOT_SCOPE = new RootScope();\nlet currentScope: ContentScope = ROOT_SCOPE;\n\n/**\n * Execute a function in a never-cleaned root scope. Even {@link unmountAll} will not\n * clean up observers/nodes created by the function.\n * @param func The function to execute.\n * @returns The return value of the function.\n * @internal\n */\nexport function leakScope<T>(func: () => T): T {\n\tconst savedScope = currentScope;\n\tcurrentScope = new RootScope();\n\ttry {\n\t\treturn func();\n\t} finally {\n\t\tcurrentScope = savedScope;\n\t}\n}\n\n/**\n * A special Node observer index to subscribe to any value in the map changing.\n */\nconst ANY_SYMBOL = Symbol(\"any\");\n\n/**\n * When our proxy objects need to lookup `obj[TARGET_SYMBOL]` it returns its\n * target, to be used in our wrapped methods.\n */\nconst TARGET_SYMBOL = Symbol(\"target\");\n\n/**\n * Symbol used internally to track Map size without clashing with actual Map keys named \"size\".\n */\nconst MAP_SIZE_SYMBOL = Symbol(\"mapSize\");\n\nconst subscribers = new WeakMap<\n\tTargetType,\n\tMap<\n\t\tany,\n\t\tSet<Scope | ((index: any, newData: any, oldData: any) => void)>\n\t>\n>();\nlet peeking = 0; // When > 0, we're not subscribing to any changes\n\nfunction subscribe(\n\ttarget: any,\n\tindex: symbol | string | number,\n\tobserver:\n\t\t| Scope\n\t\t| ((\n\t\t\t\tindex: any,\n\t\t\t\tnewData: any,\n\t\t\t\toldData: any,\n\t\t ) => void) = currentScope,\n) {\n\tif (observer === ROOT_SCOPE || peeking) return;\n\n\tlet byTarget = subscribers.get(target);\n\tif (!byTarget) subscribers.set(target, (byTarget = new Map()));\n\n\t// No need to subscribe to specific keys if we're already subscribed to ANY\n\tif (index !== ANY_SYMBOL && byTarget.get(ANY_SYMBOL)?.has(observer)) return;\n\n\tlet byIndex = byTarget.get(index);\n\tif (!byIndex) byTarget.set(index, (byIndex = new Set()));\n\n\tif (byIndex.has(observer)) return;\n\n\tbyIndex.add(observer);\n\n\tif (observer === currentScope) {\n\t\tcurrentScope.cleaners.push(byIndex);\n\t} else {\n\t\tcurrentScope.cleaners.push(() => {\n\t\t\tbyIndex.delete(observer);\n\t\t});\n\t}\n}\n\n/**\n * Records in TypeScript pretend that they can have number keys, but in reality they are converted to string.\n * This type changes (number | something) types to (string | something) types, maintaining typing precision as much as possible.\n * @internal\n */\ntype KeyToString<K> = K extends number ? string : K extends string | symbol ? K : K extends number | infer U ? string | U : K;\n\nexport function onEach<K, T>(\n\ttarget: Map<K, undefined | T>,\n\trender: (value: T, key: K) => void,\n\tmakeKey?: (value: T, key: K) => SortKeyType,\n): void;\nexport function onEach<T>(\n\ttarget: ReadonlyArray<undefined | T>,\n\trender: (value: T, index: number) => void,\n\tmakeKey?: (value: T, index: number) => SortKeyType,\n): void;\nexport function onEach<K extends string | number | symbol, T>(\n\ttarget: Record<K, undefined | T>,\n\trender: (value: T, index: KeyToString<K>) => void,\n\tmakeKey?: (value: T, index: KeyToString<K>) => SortKeyType,\n): void;\n\n/**\n * Reactively iterates over the items of an observable array or object, optionally rendering content for each item.\n *\n * Automatically updates when items are added, removed, or modified.\n *\n * @param target The observable array or object to iterate over. Values that are `undefined` are skipped.\n * @param render A function called for each item in the array. It receives the item's (observable) value and its index/key. Any DOM elements created within this function will be associated with the item, placed at the right spot in the DOM, and cleaned up when redrawing/removing the item.\n * @param makeKey An optional function to generate a sort key for each item. This controls the order in which items are rendered in the DOM. If omitted, items are rendered in array index order. The returned key can be a number, string, or an array of numbers/strings for composite sorting. Use {@link invertString} on string keys for descending order. Returning `null` or `undefined` from `makeKey` will prevent the item from being rendered.\n *\n * @example Iterating an array\n * ```typescript\n * const items = proxy(['apple', 'banana', 'cherry']);\n *\n * // Basic iteration\n * onEach(items, (item, index) => $(`li#${item} (#${index})`));\n *\n * // Add a new item - the list updates automatically\n * setTimeout(() => items.push('durian'), 2000);\n * // Same for updates and deletes\n * setTimeout(() => items[1] = 'berry', 4000);\n * setTimeout(() => delete items[2], 6000);\n * ```\n *\n * @example Iterating an array with custom ordering\n * ```typescript\n * const users = proxy([\n * { id: 3, group: 1, name: 'Charlie' },\n * { id: 1, group: 1, name: 'Alice' },\n * { id: 2, group: 2, name: 'Bob' },\n * ]);\n *\n * // Sort by name alphabetically\n * onEach(users, (user) => {\n * $(`p#${user.name} (id=${user.id})`);\n * }, (user) => [user.group, user.name]); // Sort by group, and within each group sort by name\n * ```\n *\n * @example Iterating an object\n * ```javascript\n * const config = proxy({ theme: 'dark', fontSize: 14, showTips: true });\n *\n * // Display configuration options\n * $('dl', () => {\n * onEach(config, (value, key) => {\n * if (key === 'showTips') return; // Don't render this one\n * $('dt#'+key);\n * $('dd#'+value);\n * });\n * });\n *\n * // Change a value - the display updates automatically\n * setTimeout(() => config.fontSize = 16, 2000);\n * ```\n * @see {@link invertString} To easily create keys for reverse sorting.\n */\nexport function onEach(\n\ttarget: TargetType,\n\trender: (value: any, index: any) => void,\n\tmakeKey?: (value: any, key: any) => SortKeyType,\n): void {\n\tif (!target || typeof target !== \"object\")\n\t\tthrow new Error(\"onEach requires an object\");\n\ttarget = (target as any)[TARGET_SYMBOL] || target;\n\n\tnew OnEachScope(target, render, makeKey);\n}\n\nfunction isObjEmpty(obj: object): boolean {\n\tfor (const k of Object.keys(obj)) return false;\n\treturn true;\n}\n\nconst EMPTY = Symbol(\"empty\");\n\n/**\n * Reactively checks if an observable array or object is empty.\n *\n * This function not only returns the current emptiness state but also establishes\n * a reactive dependency. If the emptiness state of the `proxied` object or array\n * changes later (e.g., an item is added to an empty array, or the last property\n * is deleted from an object), the scope that called `isEmpty` will be automatically\n * scheduled for re-evaluation.\n *\n * @param proxied The observable array or object to check.\n * @returns `true` if the array has length 0 or the object has no own enumerable properties, `false` otherwise.\n *\n * @example\n * ```typescript\n * const items = proxy([]);\n *\n * // Reactively display a message if the items array is empty\n * $('div', () => {\n * if (isEmpty(items)) {\n * $('p', 'i#No items yet!');\n * } else {\n * \t\t onEach(items, item=>$('p#'+item));\n * }\n * });\n *\n * // Adding an item will automatically remove the \"No items yet!\" message\n * setInterval(() => {\n * if (!items.length || Math.random()>0.5) items.push('Item');\n * else items.length = 0;\n * }, 1000)\n * ```\n */\nexport function isEmpty(proxied: TargetType): boolean {\n\tconst target = (proxied as any)[TARGET_SYMBOL] || proxied;\n\tconst scope = currentScope;\n\n\tif (target instanceof Array) {\n\t\tsubscribe(target, \"length\", (index: any, newData: any, oldData: any) => {\n\t\t\tif (!newData !== !oldData) queue(scope);\n\t\t});\n\t\treturn !target.length;\n\t}\n\t\n\tif (target instanceof Map) {\n\t\tsubscribe(target, MAP_SIZE_SYMBOL, (index: any, newData: any, oldData: any) => {\n\t\t\tif (!newData !== !oldData) queue(scope);\n\t\t});\n\t\treturn !target.size;\n\t}\n\t\n\tconst result = isObjEmpty(target);\n\tsubscribe(target, ANY_SYMBOL, (index: any, newData: any, oldData: any) => {\n\t\tif (result ? oldData === EMPTY : newData === EMPTY) queue(scope);\n\t});\n\treturn result;\n}\n\n/** @private */\nexport interface ValueRef<T> {\n\tvalue: T;\n}\n\n/**\n * Reactively counts the number of properties in an objects.\n *\n * @param proxied The observable object to count. In case an `array` is passed in, a {@link ref} to its `.length` will be returned.\n * @returns an observable object for which the `value` property reflects the number of properties in `proxied` with a value other than `undefined`.\n * \n * @example\n * ```typescript\n * const items = proxy({x: 3, y: 7} as any);\n * const cnt = count(items);\n *\n * // Create a DOM text node for the count:\n * $('div', {text: cnt});\n * // <div>2</div>\n\n * // Or we can use it in an {@link derive} function:\n * $(() => console.log(\"The count is now\", cnt.value));\n * // The count is now 2\n * \n * // Adding/removing items will update the count\n * items.z = 12;\n * // Asynchronously, after 0ms:\n * // <div>3</div>\n * // The count is now 3\n * ```\n */\nexport function count(proxied: TargetType): ValueRef<number> {\n\tif (proxied instanceof Array) return ref(proxied, \"length\");\n\tif (proxied instanceof Map) return ref(proxied, \"size\");\n\n\tconst target = (proxied as any)[TARGET_SYMBOL] || proxied;\n\tlet cnt = 0;\n\tfor (const k of Object.keys(target)) if (target[k] !== undefined) cnt++;\n\n\tconst result = proxy(cnt);\n\tsubscribe(\n\t\ttarget,\n\t\tANY_SYMBOL,\n\t\t(index: any, newData: any, oldData: any) => {\n\t\t\tif (oldData === newData) {\n\t\t\t} else if (oldData === EMPTY) result.value = ++cnt;\n\t\t\telse if (newData === EMPTY) result.value = --cnt;\n\t\t},\n\t);\n\n\treturn result;\n}\n\n/** @internal */\nexport function defaultEmitHandler(\n\ttarget: TargetType,\n\tindex: string | symbol | number,\n\tnewData: any,\n\toldData: any,\n) {\n\t// We're triggering for values changing from undefined to undefined, as this *may*\n\t// indicate a change from or to `[empty]` (such as `[,1][0]`).\n\tif (newData === oldData && newData !== undefined) return;\n\n\tconst byTarget = subscribers.get(target);\n\tif (byTarget === undefined) return;\n\n\tfor (const what of [index, ANY_SYMBOL]) {\n\t\tconst byIndex = byTarget.get(what);\n\t\tif (byIndex) {\n\t\t\tfor (const observer of byIndex) {\n\t\t\t\tif (typeof observer === \"function\") observer(index, newData, oldData);\n\t\t\t\telse observer.onChange(index);\n\t\t\t}\n\t\t}\n\t}\n}\nlet emit = defaultEmitHandler;\n\nconst objectHandler: ProxyHandler<any> = {\n\tget(target: any, prop: any) {\n\t\tif (prop === TARGET_SYMBOL) return target;\n\t\tsubscribe(target, prop);\n\t\treturn optProxy(target[prop]);\n\t},\n\tset(target: any, prop: any, newData: any) {\n\t\t// Make sure newData is unproxied\n\t\tif (typeof newData === \"object\" && newData)\n\t\t\tnewData = (newData as any)[TARGET_SYMBOL] || newData;\n\t\tconst oldData = target.hasOwnProperty(prop) ? target[prop] : EMPTY;\n\t\tif (newData !== oldData) {\n\t\t\ttarget[prop] = newData;\n\t\t\temit(target, prop, newData, oldData);\n\t\t}\n\t\treturn true;\n\t},\n\tdeleteProperty(target: any, prop: any) {\n\t\tconst old = target.hasOwnProperty(prop) ? target[prop] : EMPTY;\n\t\tdelete target[prop];\n\t\temit(target, prop, EMPTY, old);\n\t\treturn true;\n\t},\n\thas(target: any, prop: any) {\n\t\tsubscribe(target, prop);\n\t\treturn target.hasOwnProperty(prop);\n\t},\n\townKeys(target: any) {\n\t\tsubscribe(target, ANY_SYMBOL);\n\t\treturn Reflect.ownKeys(target);\n\t},\n};\n\nfunction arraySet(target: any, prop: any, newData: any) {\n\t// Make sure newData is unproxied\n\tif (typeof newData === \"object\" && newData) {\n\t\tnewData = (newData as any)[TARGET_SYMBOL] || newData;\n\t}\n\tlet oldData = target[prop];\n\tif (oldData === undefined && !target.hasOwnProperty(prop)) oldData = EMPTY;\n\tif (newData !== oldData) {\n\t\tconst oldLength = target.length;\n\n\t\tif (prop === \"length\") {\n\t\t\ttarget.length = newData;\n\n\t\t\t// We only need to emit for shrinking, as growing just adds undefineds\n\t\t\tfor (let i = newData; i < oldLength; i++) {\n\t\t\t\temit(target, i, EMPTY, target[i]);\n\t\t\t}\n\t\t} else {\n\t\t\tif (typeof prop === 'string') { // Convert to int when possible\n\t\t\t\tconst n = 0|prop as any;\n\t\t\t\tif (String(n) === prop && n >= 0) prop = n;\n\t\t\t}\n\n\t\t\ttarget[prop] = newData;\n\t\t\temit(target, prop, newData, oldData);\n\t\t}\n\t\tif (target.length !== oldLength) {\n\t\t\temit(target, \"length\", target.length, oldLength);\n\t\t}\n\t}\n\treturn true;\n}\n\nconst arrayHandler: ProxyHandler<any[]> = {\n\tget(target: any, prop: any) {\n\t\tif (prop === TARGET_SYMBOL) return target;\n\t\tif (typeof prop === 'string') { // Convert to int when possible\n\t\t\tconst n = 0|prop as any;\n\t\t\tif (String(n) === prop && n >= 0) prop = n;\n\t\t}\n\t\tsubscribe(target, prop);\n\t\treturn optProxy(target[prop]);\n\t},\n\tset: arraySet,\n\tdeleteProperty(target: any, prop: any) {\n\t\tif (typeof prop === 'string') { // Convert to int when possible\n\t\t\tconst n = 0|prop as any;\n\t\t\tif (String(n) === prop && n >= 0) prop = n;\n\t\t}\n\t\tlet oldData = target[prop];\n\t\tif (oldData === undefined && !target.hasOwnProperty(prop)) oldData = EMPTY;\n\t\tdelete target[prop];\n\t\temit(target, prop, EMPTY, oldData);\n\t\treturn true;\n\t},\n};\n\n/**\n * Helper functions that wrap iterators to proxy values\n */\nfunction wrapIteratorSingle(iterator: IterableIterator<any>): IterableIterator<any> {\n\treturn {\n\t\t[Symbol.iterator]() { return this; },\n\t\tnext() {\n\t\t\tconst result = iterator.next();\n\t\t\tif (result.done) return result;\n\t\t\treturn {\n\t\t\t\tdone: false,\n\t\t\t\tvalue: optProxy(result.value)\n\t\t\t};\n\t\t}\n\t};\n}\nfunction wrapIteratorPair(iterator: IterableIterator<[any, any]>): IterableIterator<[any, any]> {\n\treturn {\n\t\t[Symbol.iterator]() { return this; },\n\t\tnext() {\n\t\t\tconst result = iterator.next();\n\t\t\tif (result.done) return result;\n\t\t\treturn {\n\t\t\t\tdone: false,\n\t\t\t\tvalue: [optProxy(result.value[0]), optProxy(result.value[1])]\n\t\t\t};\n\t\t}\n\t};\n}\n\nconst mapMethodHandlers = {\n\tget(this: any, key: any): any {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\t// Make sure key is unproxied\n\t\tif (typeof key === \"object\" && key)\n\t\t\tkey = (key as any)[TARGET_SYMBOL] || key;\n\t\tsubscribe(target, key);\n\t\treturn optProxy(target.get(key));\n\t},\n\tset(this: any, key: any, newData: any): any {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\t// Make sure key and newData are unproxied\n\t\tif (typeof key === \"object\" && key) {\n\t\t\tkey = (key as any)[TARGET_SYMBOL] || key;\n\t\t}\n\t\tif (typeof newData === \"object\" && newData) {\n\t\t\tnewData = (newData as any)[TARGET_SYMBOL] || newData;\n\t\t}\n\t\tlet oldData = target.get(key);\n\t\tif (oldData === undefined && !target.has(key)) oldData = EMPTY;\n\t\tif (newData !== oldData) {\n\t\t\tconst oldSize = target.size;\n\t\t\ttarget.set(key, newData);\n\t\t\temit(target, key, newData, oldData);\n\t\t\temit(target, MAP_SIZE_SYMBOL, target.size, oldSize);\n\t\t}\n\t\treturn this;\n\t},\n\tdelete(this: any, key: any): boolean {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\t// Make sure key is unproxied\n\t\tif (typeof key === \"object\" && key) {\n\t\t\tkey = (key as any)[TARGET_SYMBOL] || key;\n\t\t}\n\t\tlet oldData = target.get(key);\n\t\tif (oldData === undefined && !target.has(key)) oldData = EMPTY;\n\t\tconst result: boolean = target.delete(key);\n\t\tif (result) {\n\t\t\temit(target, key, EMPTY, oldData);\n\t\t\temit(target, MAP_SIZE_SYMBOL, target.size, target.size + 1);\n\t\t}\n\t\treturn result;\n\t},\n\tclear(this: any): void {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\tconst oldSize = target.size;\n\t\tfor (const key of target.keys()) {\n\t\t\temit(target, key, undefined, target.get(key));\n\t\t}\n\t\ttarget.clear();\n\t\temit(target, MAP_SIZE_SYMBOL, 0, oldSize);\n\t},\n\thas(this: any, key: any): boolean {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\t// Make sure key is unproxied\n\t\tif (typeof key === \"object\" && key) {\n\t\t\tkey = (key as any)[TARGET_SYMBOL] || key;\n\t\t}\n\t\tsubscribe(target, key);\n\t\treturn target.has(key);\n\t},\n\tkeys(this: any): IterableIterator<any> {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\tsubscribe(target, ANY_SYMBOL);\n\t\treturn wrapIteratorSingle(target.keys());\n\t},\n\tvalues(this: any): IterableIterator<any> {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\tsubscribe(target, ANY_SYMBOL);\n\t\treturn wrapIteratorSingle(target.values());\n\t},\n\tentries(this: any): IterableIterator<[any, any]> {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\tsubscribe(target, ANY_SYMBOL);\n\t\treturn wrapIteratorPair(target.entries());\n\t},\n\t[Symbol.iterator](this: any): IterableIterator<[any, any]> {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\tsubscribe(target, ANY_SYMBOL);\n\t\treturn wrapIteratorPair(target[Symbol.iterator]());\n\t}\n};\n\nconst mapHandler: ProxyHandler<Map<any, any>> = {\n\tget(target: Map<any, any>, prop: any) {\n\t\tif (prop === TARGET_SYMBOL) return target;\n\t\t\n\t\t// Handle Map methods using lookup object\n\t\tif (mapMethodHandlers.hasOwnProperty(prop)) {\n\t\t\treturn (mapMethodHandlers as any)[prop];\n\t\t}\n\t\t\n\t\t// Handle size property\n\t\tif (prop === \"size\") {\n\t\t\tsubscribe(target, MAP_SIZE_SYMBOL);\n\t\t\treturn target.size;\n\t\t}\n\t\t\n\t\t// Handle other properties normally\n\t\treturn (target as any)[prop];\n\t},\n};\n\nconst proxyMap = new WeakMap<TargetType, /*Proxy*/ TargetType>();\n\nfunction optProxy(value: any): any {\n\t// If value is a primitive type or already proxied, just return it\n\tif (\n\t\ttypeof value !== \"object\" ||\n\t\t!value ||\n\t\tvalue[TARGET_SYMBOL] !== undefined ||\n\t\tNO_COPY in value\n\t) {\n\t\treturn value;\n\t}\n\tlet proxied = proxyMap.get(value);\n\tif (proxied) return proxied; // Only one proxy per target!\n\n\tlet handler;\n\tif (value instanceof Array) {\n\t\thandler = arrayHandler;\n\t} else if (value instanceof Map) {\n\t\thandler = mapHandler;\n\t} else {\n\t\thandler = objectHandler;\n\t}\n\n\tproxied = new Proxy(value, handler);\n\tproxyMap.set(value, proxied as TargetType);\n\treturn proxied;\n}\n\n/**\n * When `proxy` is called with a Promise, the returned object has this shape.\n */\nexport interface PromiseProxy<T> {\n\t/**\n\t * True if the promise is still pending, false if it has resolved or rejected.\n\t */\n\tbusy: boolean;\n\t/**\n\t * If the promise has resolved, this contains the resolved value.\n\t */\n\tvalue?: T;\n\t/**\n\t * If the promise has rejected, this contains the rejection error.\n\t */\n\terror?: any;\n}\n\nexport function proxy<T extends any>(target: Promise<T>): PromiseProxy<T>;\nexport function proxy<T extends any>(target: Array<T>): Array<T extends number ? number : T extends string ? string : T extends boolean ? boolean : T >;\nexport function proxy<T extends object>(target: T): T;\nexport function proxy<T extends any>(target: T): ValueRef<T extends number ? number : T extends string ? string : T extends boolean ? boolean : T>;\n\n/**\n * Creates a reactive proxy around the given data.\n *\n * Reading properties from the returned proxy within a reactive scope (like one created by\n * {@link $} or {@link derive}) establishes a subscription. Modifying properties *through*\n * the proxy will notify subscribed scopes, causing them to re-execute.\n *\n * - Plain objects and arrays are wrapped in a standard JavaScript `Proxy` that intercepts\n * property access and mutations, but otherwise works like the underlying data.\n * - Primitives (string, number, boolean, null, undefined) are wrapped in an object\n * `{ value: T }` which is then proxied. Access the primitive via the `.value` property.\n * - Promises are represented by proxied objects `{ busy: boolean, value?: T, error?: any }`.\n * Initially, `busy` is `true`. When the promise resolves, `value` is set and `busy`\n * is set to `false`. If the promise is rejected, `error` is set and `busy` is also\n * set to `false`.\n *\n * Use {@link unproxy} to get the original underlying data back.\n *\n * @param target - The object, array, or primitive value to make reactive.\n * @returns A reactive proxy wrapping the target data.\n * @template T - The type of the data being proxied.\n *\n * @example Object\n * ```javascript\n * const state = proxy({ count: 0, message: 'Hello' });\n * $(() => console.log(state.message)); // Subscribes to message\n * setTimeout(() => state.message = 'World', 1000); // Triggers the observing function\n * setTimeout(() => state.count++, 2000); // Triggers nothing\n * ```\n *\n * @example Array\n * ```javascript\n * const items = proxy(['a', 'b']);\n * $(() => console.log(items.length)); // Subscribes to length\n * setTimeout(() => items.push('c'), 2000); // Triggers the observing function\n * ```\n *\n * @example Primitive\n * ```javascript\n * const name = proxy('Aberdeen');\n * $(() => console.log(name.value)); // Subscribes to value\n * setTimeout(() => name.value = 'UI', 2000); // Triggers the observing function\n * ```\n *\n * @example Class instance\n * ```typescript\n * class Widget {\n * constructor(public name: string, public width: number, public height: number) {}\n * grow() { this.width *= 2; }\n * toString() { return `${this.name}Widget (${this.width}x${this.height})`; }\n * }\n * let graph: Widget = proxy(new Widget('Graph', 200, 100));\n * $(() => console.log(''+graph));\n * setTimeout(() => graph.grow(), 2000);\n * setTimeout(() => graph.grow(), 4000);\n * ```\n */\nexport function proxy(target: TargetType): TargetType {\n\tif (target instanceof Promise) {\n\t\tconst result: PromiseProxy<any> = optProxy({\n\t\t\tbusy: true,\n\t\t});\n\t\ttarget\n\t\t\t.then((value) => {\n\t\t\t\tresult.value = value;\n\t\t\t\tresult.busy = false;\n\t\t\t})\n\t\t\t.catch((err) => {\n\t\t\t\tresult.error = err;\n\t\t\t\tresult.busy = false;\n\t\t\t});\n\t\treturn result;\n\t}\n\treturn optProxy(\n\t\ttypeof target === \"object\" && target !== null ? target : { value: target },\n\t);\n}\n\n/**\n * Returns the original, underlying data target from a reactive proxy created by {@link proxy}.\n * If the input `target` is not a proxy, it is returned directly.\n *\n * This is useful when you want to avoid triggering subscriptions during read operations or\n * re-executes during write operations. Using {@link peek} is an alternative way to achieve this.\n *\n * @param target - A proxied object, array, or any other value.\n * @returns The underlying (unproxied) data, or the input value if it wasn't a proxy.\n * @template T - The type of the target.\n *\n * @example\n * ```typescript\n * const userProxy = proxy({ name: 'Frank' });\n * const rawUser = unproxy(userProxy);\n *\n * // Log reactively\n * $(() => console.log('proxied', userProxy.name));\n * // The following will only ever log once, as we're not subscribing to any observable\n * $(() => console.log('unproxied', rawUser.name));\n *\n * // This cause the first log to run again:\n * setTimeout(() => userProxy.name += '!', 1000);\n *\n * // This doesn't cause any new logs:\n * setTimeout(() => rawUser.name += '?', 2000);\n *\n * // Both userProxy and rawUser end up as `{name: 'Frank!?'}`\n * setTimeout(() => {\n * console.log('final proxied', userProxy)\n * console.log('final unproxied', rawUser)\n * }, 3000);\n * ```\n */\nexport function unproxy<T>(target: T): T {\n\treturn target ? (target as any)[TARGET_SYMBOL] || target : target;\n}\n\nconst onDestroyMap: WeakMap<Node, string | ((...args: any[]) => void) | true> =\n\tnew WeakMap();\n\nfunction destroyWithClass(element: Element, cls: string) {\n\tconst classes = cls.split(\".\").filter((c) => c);\n\telement.classList.add(...classes);\n\tsetTimeout(() => element.remove(), 2000);\n}\n\n/**\n * Recursively copies properties or array items from `src` to `dst`.\n * It's designed to work efficiently with reactive proxies created by {@link proxy}.\n *\n * - **Minimizes Updates:** When copying between objects/arrays (proxied or not), if a nested object\n * exists in `dst` with the same constructor as the corresponding object in `src`, `copy`\n * will recursively copy properties into the existing `dst` object instead of replacing it.\n * This minimizes change notifications for reactive updates.\n * - **Handles Proxies:** Can accept proxied or unproxied objects/arrays for both `dst` and `src`.\n * - **Cross-Type Copying:** Supports copying between Maps and objects. When copying from an object\n * to a Map, object properties become Map entries. When copying from a Map to an object, Map entries\n * become object properties (only for Maps with string/number/symbol keys).\n *\n * @param dst - The destination object/array/Map (proxied or unproxied).\n * @param src - The source object/array/Map (proxied or unproxied). It won't be modified.\n * @template T - The type of the objects being copied.\n * @returns `true` if any changes were made to `dst`, or `false` if not.\n * @throws Error if attempting to copy an array into a non-array or vice versa.\n *\n * @example Basic Copy\n * ```typescript\n * const source = proxy({ a: 1, b: { c: 2 } });\n * const dest = proxy({ b: { d: 3 } });\n * copy(dest, source);\n * console.log(dest); // proxy({ a: 1, b: { c: 2 } })\n * copy(dest, 'b', { e: 4 });\n * console.log(dest); // proxy({ a: 1, b: { e: 4 } })\n * ```\n */\n\nexport function copy<T extends object>(dst: T, src: T): boolean;\n/**\n * Like above, but copies `src` into `dst[dstKey]`. This is useful if you're unsure if dst[dstKey]\n * already exists (as the right type of object) or if you don't want to subscribe to dst[dstKey].\n * \n * @param dstKey - Optional key in `dst` to copy into. \n */\nexport function copy<T extends object>(dst: T, dstKey: keyof T, src: T[typeof dstKey]): boolean;\nexport function copy(a: any, b: any, c?: any): boolean {\n\tif (arguments.length > 2) return copySet(a, b, c, 0);\n\treturn copyImpl(a, b, 0);\n}\n\nfunction copySet(dst: any, dstKey: any, src: any, flags: number): boolean {\n\tlet dstVal = peek(dst, dstKey);\n\tif (src === dstVal) return false;\n\tif (typeof dstVal === \"object\" && dstVal && typeof src === \"object\" && src && dstVal.constructor === src.constructor) {\n\t\treturn copyImpl(dstVal, src, flags);\n\t}\n\tsrc = clone(src); \n\tif (dst instanceof Map) dst.set(dstKey, src);\n\telse dst[dstKey] = clone(src);\n\treturn true;\n}\n\n/**\n * Like {@link copy}, but uses merge semantics. Properties in `dst` not present in `src` are kept.\n * `null`/`undefined` in `src` delete properties in `dst`.\n * \n * When the destination is an object and the source is an array, its keys are used as (sparse) array indices.\n * \n * @example Basic merge\n * ```typescript\n * const source = { b: { c: 99 }, d: undefined }; // d: undefined will delete\n * const dest = proxy({ a: 1, b: { x: 5 }, d: 4 });\n * merge(dest, source);\n * merge(dest, 'b', { y: 6 }); // merge into dest.b\n * merge(dest, 'c', { z: 7 }); // merge.c doesn't exist yet, so it will just be assigned\n * console.log(dest); // proxy({ a: 1, b: { c: 99, x: 5, y: 6 }, c: { z: 7 } })\n * ```\n *\n * @example Partial Array Merge\n * ```typescript\n * const messages = proxy(['msg1', 'msg2', 'msg3']);\n * const update = { 1: 'updated msg2' }; // Update using object key as index\n * merge(messages, update);\n * console.log(messages); // proxy(['msg1', 'updated msg2', 'msg3'])\n * ```\n *\n */\nexport function merge<T extends object>(dst: T, value: Partial<T>): boolean;\nexport function merge<T extends object>(dst: T, dstKey: keyof T, value: Partial<T[typeof dstKey]>): boolean;\nexport function merge(a: any, b: any, c?: any) {\n\tif (arguments.length > 2) return copySet(a, b, c, MERGE);\n\treturn copyImpl(a, b, MERGE);\n}\n\nfunction copyImpl(dst: any, src: any, flags: number): boolean {\n\t// We never want to subscribe to reads we do to the target (to find changes). So we'll\n\t// take the unproxied version and `emit` updates ourselve.\n\tlet unproxied = (dst as any)[TARGET_SYMBOL];\n\tif (unproxied) {\n\t\tdst = unproxied;\n\t\tflags |= COPY_EMIT;\n\t}\n\t// For performance, we'll work on the unproxied `src` and manually subscribe to changes.\n\tunproxied = (src as any)[TARGET_SYMBOL];\n\tif (unproxied) {\n\t\tsrc = unproxied;\n\t\t// If we're not in peek mode, we'll manually subscribe to all source reads.\n\t\tif (currentScope !== ROOT_SCOPE && !peeking) flags |= COPY_SUBSCRIBE;\n\t}\n\n\treturn copyRecursive(dst, src, flags);\n}\n\n// The dst and src parameters must be objects. Will throw a friendly message if they're not both the same type.\nfunction copyRecursive<T extends object>(dst: T, src: T, flags: number): boolean {\n\n\tif (flags & COPY_SUBSCRIBE) subscribe(src, ANY_SYMBOL);\n\tlet changed = false;\n\n\t// The following loops are somewhat repetitive, but it keeps performance high by avoiding\n\t// function calls and extra checks within the loops.\n\n\tif (src instanceof Array && dst instanceof Array) {\n\t\tconst dstLen = dst.length;\n\t\tconst srcLen = src.length;\n\t\tfor (let index = 0; index < srcLen; index++) {\n\t\t\t// changed = copyValue(dst, i, src[i], flags) || changed;\n\n\t\t\tlet dstValue = dst[index];\n\t\t\tif (dstValue === undefined && !dst.hasOwnProperty(index)) dstValue = EMPTY;\n\t\t\tlet srcValue = src[index];\n\t\t\tif (srcValue === undefined && !src.hasOwnProperty(index)) {\n\t\t\t\tdelete dst[index];\n\t\t\t\tif (flags & COPY_EMIT) emit(dst, index, EMPTY, dstValue);\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t\telse if (dstValue !== srcValue) {\n\t\t\t\tif (srcValue && typeof srcValue === \"object\") {\n\t\t\t\t\tif (typeof dstValue === \"object\" && dstValue && srcValue.constructor === dstValue.constructor && !(NO_COPY in srcValue)) {\n\t\t\t\t\t\tchanged = copyRecursive(dstValue, srcValue, flags) || changed;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tsrcValue = clone(srcValue);\n\t\t\t\t}\n\t\t\t\tdst[index] = srcValue;\n\n\t\t\t\tif (flags & COPY_EMIT) emit(dst, index, srcValue, dstValue);\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t}\n\n\t\t// Leaving additional values in the old array doesn't make sense, so we'll do this even when MERGE is set:\n\t\tif (srcLen !== dstLen) {\n\t\t\tif (flags & COPY_EMIT) {\n\t\t\t\tfor (let i = srcLen; i < dstLen; i++) {\n\t\t\t\t\tconst old = dst[i];\n\t\t\t\t\tdelete dst[i];\n\t\t\t\t\temit(dst, i, EMPTY, old);\n\t\t\t\t}\n\t\t\t\tdst.length = srcLen;\n\t\t\t\temit(dst, \"length\", srcLen, dstLen);\n\t\t\t} else {\n\t\t\t\tdst.length = srcLen;\n\t\t\t}\n\t\t\tchanged = true;\n\t\t}\n\t} else if (src instanceof Map && dst instanceof Map) {\n\t\tfor (const key of src.keys()) {\n\t\t\t// changed = copyValue(dst, k, src.get(k), flags) || changed;\n\t\t\tlet srcValue = src.get(key);\n\t\t\tlet dstValue = dst.get(key);\n\t\t\tif (dstValue === undefined && !dst.has(key)) dstValue = EMPTY;\n\t\t\tif (dstValue !== srcValue) {\n\t\t\t\tif (srcValue && typeof srcValue === \"object\") {\n\t\t\t\t\tif (typeof dstValue === \"object\" && dstValue && srcValue.constructor === dstValue.constructor && !(NO_COPY in srcValue)) {\n\t\t\t\t\t\tchanged = copyRecursive(dstValue, srcValue, flags) || changed;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tsrcValue = clone(srcValue);\n\t\t\t\t}\n\n\t\t\t\tdst.set(key, srcValue);\n\n\t\t\t\tif (flags & COPY_EMIT) emit(dst, key, srcValue, dstValue);\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t}\n\n\t\tif (!(flags & MERGE)) {\n\t\t\tfor (const k of dst.keys()) {\n\t\t\t\tif (!src.has(k)) {\n\t\t\t\t\tconst old = dst.get(k);\n\t\t\t\t\tdst.delete(k);\n\t\t\t\t\tif (flags & COPY_EMIT) {\n\t\t\t\t\t\temit(dst, k, undefined, old);\n\t\t\t\t\t}\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (src.constructor === dst.constructor) {\n\t\tfor (const key of Object.keys(src) as (keyof typeof src)[]) {\n\t\t\t// changed = copyValue(dst, k, src[k as keyof typeof src], flags) || changed;\n\t\t\tlet srcValue = src[key];\n\t\t\tconst dstValue = dst.hasOwnProperty(key) ? dst[key] : EMPTY;\n\t\t\tif (dstValue !== srcValue) {\n\t\t\t\tif (srcValue && typeof srcValue === \"object\") {\n\t\t\t\t\tif (typeof dstValue === \"object\" && dstValue && srcValue.constructor === dstValue.constructor && !(NO_COPY in srcValue)) {\n\t\t\t\t\t\tchanged = copyRecursive(dstValue as typeof srcValue, srcValue, flags) || changed;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tsrcValue = clone(srcValue);\n\t\t\t\t}\n\n\t\t\t\tdst[key] = srcValue;\n\n\t\t\t\tif (flags & COPY_EMIT) emit(dst, key, srcValue, dstValue);\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t}\n\n\t\tif (!(flags & MERGE)) {\n\t\t\tfor (const k of Object.keys(dst) as (keyof typeof dst)[]) {\n\t\t\t\tif (!src.hasOwnProperty(k)) {\n\t\t\t\t\tconst old = dst[k];\n\t\t\t\t\tdelete dst[k];\n\t\t\t\t\tif (flags & COPY_EMIT && old !== undefined) {\n\t\t\t\t\t\temit(dst, k, undefined, old);\n\t\t\t\t\t}\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tthrow new Error(`Incompatible or non-object types: ${src?.constructor?.name || typeof src} vs ${dst?.constructor?.name || typeof dst}`);\n\t}\n\treturn changed;\n}\n\nconst MERGE = 1;\nconst COPY_SUBSCRIBE = 32;\nconst COPY_EMIT = 64;\n\n/**\n * A symbol that can be added to an object to prevent it from being cloned by {@link clone} or {@link copy}.\n * This is useful for objects that should be shared by reference. That also mean that their contents won't\n * be observed for changes.\n */\nexport const NO_COPY = Symbol(\"NO_COPY\");\n\n// Promises break when proxied, so we'll just mark them as NO_COPY\n(Promise.prototype as any)[NO_COPY] = true;\n\n/**\n * CSS variable lookup table for the `@` value prefix.\n * \n * When a CSS value starts with `@`, the rest is used as a key to look up the actual value.\n * Pre-initialized with keys '1'-'12' mapping to an exponential rem scale (e.g., @1=0.25rem, @3=1rem).\n * \n * @example\n * ```typescript\n * cssVars.primary = '#3b82f6';\n * cssVars[3] = '16px'; // Override @3 to be 16px instead of 1rem\n * $('p color:@primary'); // Sets color to #3b82f6\n * $('div mt:@3'); // Sets margin-top to 16px\n * ```\n */\nexport const cssVars: Record<string, string> = optProxy({});\n\nfor (let i = 1; i <= 12; i++) {\n\tcssVars[i] = 2 ** (i - 3) + \"rem\";\n}\n\n/**\n * Clone an (optionally proxied) object or array.\n *\n * @param src The object or array to clone. If it is proxied, `clone` will subscribe to any changes to the (nested) data structure.\n * @template T - The type of the objects being copied.\n * @returns A new unproxied array or object (of the same type as `src`), containing a deep copy of `src`.\n */\nexport function clone<T extends object>(src: T): T {\n\tif (NO_COPY in src) return src;\n\t// Create an empty object of the same type\n\tconst copied = Array.isArray(src) ? [] : src instanceof Map ? new Map() : Object.create(Object.getPrototypeOf(src));\n\t// Copy all properties to it. This doesn't need to emit anything, and because\n\t// the destination is an empty object, we can just MERGE, which is a bit faster.\n\tcopyImpl(copied, src, MERGE);\n\treturn copied;\n}\n\ninterface RefTarget {\n\tproxy: TargetType;\n\tindex: any;\n}\nconst refHandler: ProxyHandler<RefTarget> = {\n\tget(target: RefTarget, prop: any) {\n\t\tif (prop === TARGET_SYMBOL) {\n\t\t\t// Create a ref to the unproxied version of the target\n\t\t\treturn ref(unproxy(target.proxy), target.index);\n\t\t}\n\t\tif (prop === \"value\") {\n\t\t\treturn (target.proxy as any)[target.index];\n\t\t}\n\t},\n\tset(target: any, prop: any, value: any) {\n\t\tif (prop === \"value\") {\n\t\t\t(target.proxy as any)[target.index] = value;\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t},\n};\n\n/**\n * Creates a reactive reference (`{ value: T }`-like object) to a specific value\n * within a proxied object or array.\n *\n * This is primarily used for the `bind` property in {@link $} to create two-way data bindings\n * with form elements, and for passing a reactive property to any of the {@link $} key-value pairs.\n *\n * Reading `ref.value` accesses the property from the underlying proxy (and subscribes the current scope).\n * Assigning to `ref.value` updates the property in the underlying proxy (triggering reactive updates).\n *\n * @param target - The reactive proxy (created by {@link proxy}) containing the target property.\n * @param index - The key (for objects) or index (for arrays) of the property to reference.\n * @returns A reference object with a `value` property linked to the specified proxy property.\n *\n * @example\n * ```javascript\n * const formData = proxy({ color: 'orange', velocity: 42 });\n *\n * // Usage with `bind`\n * $('input', {\n * type: 'text',\n * // Creates a two-way binding between the input's value and formData.username\n * bind: ref(formData, 'color')\n * });\n *\n * // Usage as a dynamic property, causes a TextNode with just the name to be created and live-updated\n * $('p#Selected color: ', {\n * text: ref(formData, 'color'),\n * $color: ref(formData, 'color')\n * });\n *\n * // Changes are actually stored in formData - this causes logs like `{color: \"Blue\", velocity 42}`\n * $(() => console.log(formData))\n * ```\n */\nexport function ref<T extends TargetType, K extends keyof T>(\n\ttarget: T,\n\tindex: K,\n): ValueRef<T[K]> {\n\treturn new Proxy({ proxy: target, index }, refHandler) as any as ValueRef<\n\t\tT[K]\n\t>;\n}\n\nfunction applyBind(el: HTMLInputElement, target: any) {\n\tlet onProxyChange: () => void;\n\tlet onInputChange: () => void;\n\tconst type = el.getAttribute(\"type\");\n\tconst value = unproxy(target).value;\n\tif (type === \"checkbox\") {\n\t\tif (value === undefined) target.value = el.checked;\n\t\tonProxyChange = () => {\n\t\t\tel.checked = target.value;\n\t\t};\n\t\tonInputChange = () => {\n\t\t\ttarget.value = el.checked;\n\t\t};\n\t} else if (type === \"radio\") {\n\t\tif (value === undefined && el.checked) target.value = el.value;\n\t\tonProxyChange = () => {\n\t\t\tel.checked = target.value === el.value;\n\t\t};\n\t\tonInputChange = () => {\n\t\t\tif (el.checked) target.value = el.value;\n\t\t};\n\t} else {\n\t\tonInputChange = () => {\n\t\t\ttarget.value =\n\t\t\t\ttype === \"number\" || type === \"range\"\n\t\t\t\t\t? el.value === \"\"\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: +el.value\n\t\t\t\t\t: el.value;\n\t\t};\n\t\tif (value === undefined) onInputChange();\n\t\tonProxyChange = () => {\n\t\t\tel.value = target.value;\n\t\t\t// biome-ignore lint/suspicious/noDoubleEquals: it's fine for numbers to be casts to strings here\n\t\t\tif (el.tagName === \"SELECT\" && el.value != target.value) {\n\t\t\t\t// Presumable, OPTIONs haven't been created yet. Try again after all currently queued work has been done.\n\t\t\t\tnew DelayedOneTimeRunner(() => el.value = target.value);\n\t\t\t}\n\t\t};\n\t}\n\tderive(onProxyChange);\n\tel.addEventListener(\"input\", onInputChange);\n\tclean(() => {\n\t\tel.removeEventListener(\"input\", onInputChange);\n\t});\n}\n\nconst SPECIAL_PROPS: { [key: string]: (el: Element, value: any) => void } = {\n\tcreate: (el: Element, value: any) => {\n\t\tif (currentScope !== topRedrawScope) return;\n\t\tif (typeof value === \"function\") {\n\t\t\tvalue(el);\n\t\t} else {\n\t\t\tconst classes = value.split(\".\").filter((c: any) => c);\n\t\t\tel.classList.add(...classes);\n\t\t\t(async () => {\n\t\t\t\t// attempt to prevent layout trashing\n\t\t\t\t(el as HTMLElement).offsetHeight; // trigger layout\n\t\t\t\tel.classList.remove(...classes);\n\t\t\t})();\n\t\t}\n\t},\n\tdestroy: (el: Element, value: any) => {\n\t\tonDestroyMap.set(el, value);\n\t},\n\thtml: (el: Element, value: any) => {\n\t\tconst tmpParent = document.createElement(\n\t\t\tcurrentScope.el.tagName,\n\t\t);\n\t\ttmpParent.innerHTML = `${value}`;\n\t\twhile (tmpParent.firstChild) addNode(el, tmpParent.firstChild);\n\t},\n\ttext: (el: Element, value: any) => {\n\t\taddNode(el, document.createTextNode(value));\n\t},\n};\n\n/**\n * The core function for building reactive user interfaces in Aberdeen. It creates and inserts new DOM elements\n * and sets attributes/properties/event listeners on DOM elements. It does so in a reactive way, meaning that\n * changes will be (mostly) undone when the current *scope* is destroyed or will be re-execute.\n *\n * @param {...(string | function | object | false | undefined | null)} args - Any number of arguments can be given. How they're interpreted depends on their types:\n *\n * - `string`: Strings can be used to create and insert new elements, set classnames for the *current* element, and add text to the current element.\n * The format of a string is: (**tag** | `.` **class** | **key**=**val** | **key**=\"**long val**\")* ('#' **text** | **key**=)?\n * So there can be:\n * - Any number of **tag** element, like `h1` or `div`. These elements are created, added to the *current* element, and become the new *current* element for the rest of this `$` function execution.\n * - Any number of CSS classes prefixed by `.` characters. These classes will be added to the *current* element. Optionally, CSS classes can be appended to a **tag** without a space. So both `div.myclass` and `div .myclass` are valid and do the same thing.\n * - Any number of key/value pairs with string values, like `placeholder=\"Your name\"` or `data-id=123`. These will be handled according to the rules specified for `object`, below, but with the caveat that values can only be strings. The quotes around string values are optional, unless the value contains spaces. It's not possible to escape quotes within the value. If you want to do that, or if you have user-provided values, use the `object` syntax (see below) or end your string with `key=` followed by the data as a separate argument (see below).\n * - The string may end in a '#' followed by text, which will be added as a TextNode to the *current* element. The text ranges til the end of the string, and may contain any characters, including spaces and quotes.\n * - Alternatively, the string may end in a key followed by an '=' character, in which case the value is expected as a separate argument. The key/value pair is set according to the rules specified for `object` below. This is useful when the value is not a string or contains spaces or user data. Example: `$('button text=\"Click me\" click=', () => alert('Clicked!'))` or `$('input.value=', someUserData, \"placeholder=\", \"Type your stuff\")`.\n * - `function`: When a function (without argument nor a return value) is passed in, it will be reactively executed in its own observer scope, preserving the *current element*. So any `$()` invocations within this function will create DOM elements with our *current* element as parent. If the function reads observable data, and that data is changed later on, the function we re-execute (after side effects, such as DOM modifications through `$`, have been cleaned - see also {@link clean}).\n * - `object`: When an object is passed in, its key-value pairs are used to modify the *current* element in the following ways...\n * - `{<attrName>: any}`: The common case is setting the value as an HTML attribute named key. So `{placeholder: \"Your name\"}` would add `placeholder=\"Your name\"` to the current HTML element.\n * - `{<propName>: boolean}` or `{value: any}` or `{selectedIndex: number}`: If the value is a boolean, or if the key is `value` or `selectedIndex`, it is set on the `current` element as a DOM property instead of an HTML attribute. For example `{checked: true}` would do `el.checked = true` for the *current* element.\n * - `{\".class\": boolean}`: If the key starts with a `.` character, its either added to or removed from the *current* element as a CSS class, based on the truthiness of the value. So `{\".hidden\": hide}` would toggle the `hidden` CSS class.\n * - `{<eventName>: function}`: If the value is a `function` it is set as an event listener for the event with the name given by the key. For example: `{click: myClickHandler}`.\n * - `{$<styleProp>: value}`: If the key starts with a `$` character, set a CSS style property with the name of the rest of the key to the given value. Example: `{$backgroundColor: 'red'}`.\n * - `{create: string}`: Add the value string as a CSS class to the *current* element, *after* the browser has finished doing a layout pass. This behavior only triggers when the scope setting the `create` is the top-level scope being (re-)run. This allows for creation transitions, without triggering the transitions for deeply nested elements being drawn as part of a larger component. The string may also contain multiple dot-separated CSS classes, such as `.fade.grow`.\n * - `{destroy: string}`: When the *current* element is a top-level element to be removed (due to reactivity cleanup), actual removal from the DOM is delayed by 2 seconds, and in the mean time the value string is added as a CSS class to the element, allowing for a deletion transition. The string may also contain multiple dot-separated CSS classes, such as `.fade.shrink`.\n * - `{create: function}` and `{destroy: function}`: The function is invoked when the *current* element is the top-level element being created/destroyed. It can be used for more involved creation/deletion animations. In case of `destroy`, the function is responsible for actually removing the element from the DOM (eventually). See `transitions.ts` in the Aberdeen source code for some examples.\n * - `{bind: <obsValue>}`: Create a two-way binding element between the `value` property of the given observable (proxy) variable, and the *current* input element (`<input>`, `<select>` or `<textarea>`). This is often used together with {@link ref}, in order to use properties other than `.value`.\n * - `{<any>: <obsvalue>}`: Create a new observer scope and read the `value` property of the given observable (proxy) variable from within it, and apply the contained value using any of the other rules in this list. Example:\n * ```typescript\n * const myColor = proxy('red');\n * $('p#Test', {$color: myColor, click: () => myColor.value = 'yellow'})\n * // Clicking the text will cause it to change color without recreating the <p> itself\n * ```\n * This is often used together with {@link ref}, in order to use properties other than `.value`.\n * - `{text: string|number}`: Add the value as a `TextNode` to the *current* element.\n * - `{html: string}`: Add the value as HTML to the *current* element. This should only be used in exceptional situations. And of course, beware of XSS.\n - `Node`: If a DOM Node (Element or TextNode) is passed in, it is added as a child to the *current* element. If the Node is an Element, it becomes the new *current* element for the rest of this `$` function execution.\n *\n * @returns The most inner DOM element that was created (not counting text nodes nor elements created by content functions),\n * or undefined if no elements were created.\n *\n * @example Create Element\n * ```typescript\n * $('button.secondary.outline#Submit', {\n * disabled: false,\n * click: () => console.log('Clicked!'),\n * $color: 'red'\n * });\n * ```\n * \n * Which can also be written as:\n * ```typescript\n * $('button.secondary.outline text=Submit $color=red disabled=', false, 'click=', () => console.log('Clicked!'));\n * ```\n * \n * We want to set `disabled` as a property instead of an attribute, so we must use the `key=` syntax in order to provide\n * `false` as a boolean instead of a string.\n *\n * @example Create Nested Elements\n * ```typescript\n * let inputElement: Element = $('label#Click me', 'input', {type: 'checkbox'});\n * // You should usually not touch raw DOM elements, unless when integrating\n * // with non-Aberdeen code.\n * console.log('DOM element:', inputElement);\n * ```\n *\n * @example Content Functions & Reactive Scope\n * ```typescript\n * const state = proxy({ count: 0 });\n * $('div', () => { // Outer element\n * // This scope re-renders when state.count changes\n * $(`p#Count is ${state.count}`);\n * $('button#Increment', { click: () => state.count++ });\n * });\n * ```\n *\n * @example Two-way Binding\n * ```typescript\n * const user = proxy({ name: '' });\n * $('input', { placeholder: 'Name', bind: ref(user, 'name') });\n * $('h3', () => { // Reactive scope\n * $(`#Hello ${user.name || 'stranger'}`);\n * });\n * ```\n *\n * @example Conditional Rendering\n * ```typescript\n * const show = proxy(false);\n * $('button', { click: () => show.value = !show.value }, () => $(show.value ? '#Hide' : '#Show'));\n * $(() => { // Reactive scope\n * if (show.value) {\n * $('p#Details are visible!');\n * }\n * });\n * ```\n */\n\nexport function $(...args: any[]): undefined | Element {\n\tlet el: undefined | Element = currentScope.el;\n\tlet svg: boolean = currentScope.svg\n\n\tconst argCount = args.length;\n\tfor(let argIndex = 0; argIndex < argCount; argIndex++) {\n\t\tconst arg = args[argIndex];\n\t\tif (arg == null || arg === false) {\n\t\t\t// Ignore\n\t\t} else if (typeof arg === \"string\") {\n\t\t\tlet argLen = arg.length;\n\t\t\tlet nextPos = 0;\n\t\t\tfor(let pos=0; pos<argLen; pos=nextPos+1) {\n\t\t\t\tnextPos = findFirst(arg, \" .=:#\", pos);\n\t\t\t\tconst next = arg[nextPos];\n\n\t\t\t\tif (next === \":\" || next === \"=\") {\n\t\t\t\t\tlet key = arg.substring(pos, nextPos);\n\t\t\t\t\tif (next === ':') key = '$' + key; // Style prefix\n\t\t\t\t\tif (nextPos + 1 >= argLen) {\n\t\t\t\t\t\tapplyArg(el, key, args[++argIndex]);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (arg[nextPos+1] === '\"') {\n\t\t\t\t\t\tconst endIndex = findFirst(arg, '\"', nextPos + 2);\n\t\t\t\t\t\tconst value = arg.substring(nextPos+2, endIndex);\n\t\t\t\t\t\tapplyArg(el, key, value);\n\t\t\t\t\t\tnextPos = endIndex;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst endIndex = findFirst(arg, \" \", nextPos + 1);\n\t\t\t\t\t\tconst value = arg.substring(nextPos + 1, endIndex);\n\t\t\t\t\t\tapplyArg(el, key, value);\n\t\t\t\t\t\tnextPos = endIndex;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (nextPos > pos) { // Up til this point if non-empty, is a tag\n\t\t\t\t\t\tconst tag = arg.substring(pos, nextPos);\n\t\t\t\t\t\t// Determine which namespace to use for element creation\n\t\t\t\t\t\tsvg ||= tag === 'svg';\n\t\t\t\t\t\tlet newEl = svg ? document.createElementNS('http://www.w3.org/2000/svg', tag) : document.createElement(tag);\n\t\t\t\t\t\taddNode(el, newEl);\n\t\t\t\t\t\tel = newEl;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (next === \"#\") { // The rest of the string is text (or a text arg follows)\t\n\t\t\t\t\t\tconst text = nextPos + 1 < argLen ? arg.substring(nextPos + 1) : args[++argIndex];\n\t\t\t\t\t\tapplyArg(el, \"text\", text);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (next === \".\") { // Class name\n\t\t\t\t\t\tlet classEnd = findFirst(arg, \" #=.\", nextPos + 1);\n\t\t\t\t\t\tif (arg[classEnd] === '=' && classEnd + 1 >= argLen) {\n\t\t\t\t\t\t\t// Conditional class name. Pass to applyArg including the leading '.'\n\t\t\t\t\t\t\tapplyArg(el, arg.substring(nextPos, classEnd), args[++argIndex]);\n\t\t\t\t\t\t\tnextPos = classEnd;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlet className: any = arg.substring(nextPos + 1, classEnd);\n\t\t\t\t\t\t\tel.classList.add(className || args[++argIndex]);\n\t\t\t\t\t\t\tnextPos = classEnd - 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (typeof arg === \"object\") {\n\t\t\tif (arg.constructor !== Object) {\n\t\t\t\tif (arg instanceof Node) {\n\t\t\t\t\taddNode(el, arg);\n\t\t\t\t\tif (arg instanceof Element) {\n\t\t\t\t\t\tel = arg;\n\t\t\t\t\t\tsvg = arg.namespaceURI === 'http://www.w3.org/2000/svg';\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(`Unexpected argument: ${arg}`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (const key of Object.keys(arg)) {\n\t\t\t\t\tapplyArg(el, key, arg[key]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (typeof arg === \"function\") {\n\t\t\tnew RegularScope(el, svg, arg);\n\t\t} else {\n\t\t\tthrow new Error(`Unexpected argument: ${arg}`);\n\t\t}\n\t}\n\treturn el;\n}\n\nfunction findFirst(str: string, chars: string, startPos: number): number {\n\tif (chars.length === 1) {\n\t\tconst idx = str.indexOf(chars, startPos);\n\t\treturn idx >= 0 ? idx : str.length;\n\t}\n\tconst strLen = str.length;\n\tfor (let i = startPos; i < strLen; i++) {\n\t\tif (chars.indexOf(str[i]) >= 0) return i;\n\t}\n\treturn strLen;\n}\n\nlet cssCount = 0;\n\n/**\n * Inserts CSS rules into the document, scoping them with a unique class name.\n *\n * Takes a JavaScript object representation of CSS rules. camelCased property keys are\n * converted to kebab-case (e.g., `fontSize` becomes `font-size`).\n *\n * @param style - An object where keys are CSS selectors (or camelCased properties) and values are\n * CSS properties or nested rule objects.\n * - Selectors are usually combined as a descendant-relationship (meaning just a space character) with their parent selector.\n * - In case a selector contains a `&`, that character will be replaced by the parent selector.\n * - Selectors will be split on `,` characters, each combining with the parent selector with *or* semantics.\n * - Selector starting with `'@'` define at-rules like media queries. They may be nested within regular selectors.\n * @param global - @deprecated Use {@link insertGlobalCss} instead.\n * @returns The unique class name prefix used for scoping (e.g., `.AbdStl1`). Use this \n * prefix with {@link $} to apply the styles.\n *\n * @example Scoped Styles\n * ```typescript\n * const scopeClass = insertCss({\n * color: 'red',\n * padding: '10px',\n * '&:hover': { // Use '&' for the root scoped selector\n * backgroundColor: '#535'\n * },\n * '.child-element': { // Nested selector\n * fontWeight: 'bold'\n * },\n * '@media (max-width: 600px)': {\n * padding: '5px'\n * }\n * });\n * // scopeClass might be \".AbdStl1\"\n *\n * // Apply the styles\n * $(scopeClass, () => { // Add class to the div\n * $(`#Scoped content`);\n * $('div.child-element#Child'); // .AbdStl1 .child-element rule applies\n * });\n * ```\n */\nexport function insertCss(style: object, global = false): string {\n\tconst prefix = global ? \"\" : `.AbdStl${++cssCount}`;\n\tconst css = styleToCss(style, prefix);\n\tif (css) $(`style#${css}`);\n\treturn prefix;\n}\n\n/**\n * Inserts CSS rules globally.\n * \n * Works exactly like {@link insertCss}, but without prefixing selectors with a unique class name.\n * \n * @example Global Styles\n * ```typescript\n * insertGlobalCss({\n * '*': {\n * fontFamily: 'monospace',\n * m: 0, // Using shortcut for margin\n * },\n * 'a': {\n * textDecoration: 'none',\n * fg: \"@primary\", // Using foreground shortcut and CSS variable\n * }\n * });\n *\n * $('a#Styled link');\n * ```\n */\nexport function insertGlobalCss(style: object): string {\n\treturn insertCss(style, true);\n}\n\nconst CSS_SHORT: Record<string, string | string[]> = {\n\tm: \"margin\",\n\tmt: \"marginTop\",\n\tmb: \"marginBottom\",\n\tml: \"marginLeft\",\n\tmr: \"marginRight\",\n\tmh: [\"marginLeft\", \"marginRight\"],\n\tmv: [\"marginTop\", \"marginBottom\"],\n\tp: \"padding\",\n\tpt: \"paddingTop\",\n\tpb: \"paddingBottom\",\n\tpl: \"paddingLeft\",\n\tpr: \"paddingRight\",\n\tph: [\"paddingLeft\", \"paddingRight\"],\n\tpv: [\"paddingTop\", \"paddingBottom\"],\n\tw: \"width\",\n\th: \"height\",\n\tbg: \"background\",\n\tfg: \"color\",\n\tr: \"borderRadius\",\n};\n\nfunction styleToCss(style: object, prefix: string): string {\n\tlet props = \"\";\n\tlet rules = \"\";\n\tfor (const kOr of Object.keys(style)) {\n\t\tconst v = (style as any)[kOr];\n\t\tfor (const k of kOr.split(/, ?/g)) {\n\t\t\tif (v && typeof v === \"object\") {\n\t\t\t\tif (k.startsWith(\"@\")) {\n\t\t\t\t\t// media queries\n\t\t\t\t\trules += `${k}{\\n${styleToCss(v, prefix)}}\\n`;\n\t\t\t\t} else {\n\t\t\t\t\trules += styleToCss(\n\t\t\t\t\t\tv,\n\t\t\t\t\t\tk.includes(\"&\") ? k.replace(/&/g, prefix) : `${prefix} ${k}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst val = v == null || v === false ? \"\" : typeof v === 'string' ? (v[0] === '@' ? (cssVars as any)[v.substring(1)] || \"\" : v) : String(v);\n\t\t\t\tconst expanded = CSS_SHORT[k] || k;\n\t\t\t\tfor (const prop of (Array.isArray(expanded) ? expanded : [expanded])) {\n\t\t\t\t\tprops += `${prop.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}:${val};`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (props) rules = `${prefix.trimStart() || \"*\"}{${props}}\\n${rules}`;\n\treturn rules;\n}\n\nfunction applyArg(el: Element, key: string, value: any) {\n\tif (typeof value === \"object\" && value !== null && value[TARGET_SYMBOL]) {\n\t\t// Value is a proxy\n\t\tif (key === \"bind\") {\n\t\t\tapplyBind(el as HTMLInputElement, value);\n\t\t} else {\n\t\t\tnew SetArgScope(el, key, value);\n\t\t\t// SetArgScope will (repeatedly) call `applyArg` again with the actual value\n\t\t}\n\t} else if (key[0] === \".\") {\n\t\t// CSS class(es)\n\t\tconst classes = key.substring(1).split(\".\");\n\t\tif (value) el.classList.add(...classes);\n\t\telse el.classList.remove(...classes);\n\t} else if (key[0] === \"$\") {\n\t\t// Style (with shortcuts)\n\t\tkey = key.substring(1);\n\t\tconst val = value == null || value === false ? \"\" : typeof value === 'string' ? (value[0] === '@' ? (cssVars as any)[value.substring(1)] || \"\" : value) : String(value);\n\t\tconst expanded = CSS_SHORT[key] || key;\n\t\tif (typeof expanded === \"string\") {\n\t\t\t(el as any).style[expanded] = val;\n\t\t} else {\n\t\t\tfor (const prop of expanded) (el as any).style[prop] = val;\n\t\t}\n\t} else if (value == null) {\n\t\t// Value left empty\n\t\t// Do nothing\n\t} else if (key in SPECIAL_PROPS) {\n\t\t// Special property\n\t\tSPECIAL_PROPS[key](el, value);\n\t} else if (typeof value === \"function\") {\n\t\t// Event listener\n\t\tel.addEventListener(key, value);\n\t\tif (el === currentScope.el) clean(() => el.removeEventListener(key, value));\n\t} else if (\n\t\tvalue === true ||\n\t\tvalue === false ||\n\t\tkey === \"value\" ||\n\t\tkey === \"selectedIndex\"\n\t) {\n\t\t// DOM property\n\t\t(el as any)[key] = value;\n\t} else {\n\t\t// HTML attribute\n\t\tel.setAttribute(key, value);\n\t}\n}\n\nfunction defaultOnError(error: Error) {\n\tconsole.error(\"Error while in Aberdeen render:\", error);\n\treturn true;\n}\nlet onError: (error: Error) => boolean | undefined = defaultOnError;\n\n/**\n * Sets a custom error handler function for errors that occur asynchronously\n * within reactive scopes (e.g., during updates triggered by proxy changes in\n * {@link derive} or {@link $} render functions).\n *\n * The default handler logs the error to `console.error` and adds a simple\n * 'Error' message div to the DOM at the location where the error occurred (if possible).\n *\n * Your handler can provide custom logging, UI feedback, or suppress the default\n * error message.\n *\n * @param handler - A function that accepts the `Error` object.\n * - Return `false` to prevent adding an error message to the DOM.\n * - Return `true` or `undefined` (or throw) to allow the error messages to be added to the DOM.\n *\n * @example Custom Logging and Suppressing Default Message\n * ```typescript\n * setErrorHandler(error => {\n * console.warn('Aberdeen render error:', error.message);\n * // Log to error reporting service\n * // myErrorReporter.log(error);\n *\n * try {\n * // Attempt to show a custom message in the UI\n * $('div.error-message#Oops, something went wrong!');\n * } catch (e) {\n * // Ignore errors during error handling itself\n * }\n *\n * return false; // Suppress default console log and DOM error message\n * });\n *\n * // Styling for our custom error message\n * insertCss({\n * '.error-message': {\n * backgroundColor: '#e31f00',\n * display: 'inline-block',\n * color: 'white',\n * borderRadius: '3px',\n * padding: '2px 4px',\n * }\n * }, true); // global style\n *\n * // Cause an error within a render scope.\n * $('div.box', () => {\n * // Will cause our error handler to insert an error message within the box\n * noSuchFunction();\n * })\n * ```\n */\nexport function setErrorHandler(\n\thandler?: (error: Error) => boolean | undefined,\n) {\n\tonError = handler || defaultOnError;\n}\n\n/**\n * Gets the parent DOM `Element` where nodes created by {@link $} would currently be inserted.\n *\n * This is context-dependent based on the current reactive scope (e.g., inside a {@link mount}\n * call or a {@link $} element's render function).\n *\n * **Note:** While this provides access to the DOM element, directly manipulating it outside\n * of Aberdeen's control is generally discouraged. Prefer reactive updates using {@link $}.\n *\n * @returns The current parent `Element` for DOM insertion.\n *\n * @example Get parent for attaching a third-party library\n * ```typescript\n * function thirdPartyLibInit(parentElement) {\n * parentElement.innerHTML = \"This element is managed by a <em>third party</em> lib.\"\n * }\n *\n * $('div.box', () => {\n * // Get the div.box element just created\n * const containerElement = getParentElement();\n * thirdPartyLibInit(containerElement);\n * });\n * ```\n */\nexport function getParentElement(): Element {\n\treturn currentScope.el;\n}\n\n/**\n * Registers a cleanup function to be executed just before the current reactive scope\n * is destroyed or redraws.\n *\n * This is useful for releasing resources, removing manual event listeners, or cleaning up\n * side effects associated with the scope. Cleaners are run in reverse order of registration.\n *\n * Scopes are created by functions like {@link derive}, {@link mount}, {@link $} (when given a render function),\n * and internally by constructs like {@link onEach}.\n *\n * @param cleaner - The function to execute during cleanup.\n *\n * @example Maintaing a sum for a changing array\n * ```typescript\n * const myArray = proxy([3, 5, 10]);\n * let sum = proxy(0);\n *\n * // Show the array items and maintain the sum\n * onEach(myArray, (item, index) => {\n * $(`code#${index}→${item}`);\n * // We'll update sum.value using peek, as += first does a read, but\n * // we don't want to subscribe.\n * peek(() => sum.value += item);\n * // Clean gets called before each rerun for a certain item index\n * // No need for peek here, as the clean code doesn't run in an\n * // observer scope.\n * clean(() => sum.value -= item);\n * })\n *\n * // Show the sum\n * $('h1', {text: sum});\n *\n * // Make random changes to the array\n * const rnd = () => 0|(Math.random()*20);\n * setInterval(() => myArray[rnd()] = rnd(), 1000);\n * ```\n */\n\nexport function clean(cleaner: () => void) {\n\tcurrentScope.cleaners.push(cleaner);\n}\n\n/**\n * Creates a reactive scope that automatically re-executes the provided function\n * whenever any proxied data (created by {@link proxy}) read during its last execution changes, storing\n * its return value in an observable.\n *\n * Updates are batched and run asynchronously shortly after the changes occur.\n * Use {@link clean} to register cleanup logic for the scope.\n * Use {@link peek} or {@link unproxy} within the function to read proxied data without subscribing to it.\n *\n * @param func - The function to execute reactively. Any DOM manipulations should typically\n * be done using {@link $} within this function. Its return value will be made available as an\n * observable returned by the `derive()` function.\n * @returns An observable object, with its `value` property containing whatever the last run of `func` returned.\n *\n * @example Observation creating a UI components\n * ```typescript\n * const data = proxy({ user: 'Frank', notifications: 42 });\n *\n * $('main', () => {\n * console.log('Welcome');\n * $('h3#Welcome, ' + data.user); // Reactive text\n *\n * derive(() => {\n * // When data.notifications changes, only this inner scope reruns,\n * // leaving the `<p>Welcome, ..</p>` untouched.\n * console.log('Notifications');\n * $('code.notification-badge#' + data.notifications);\n * $('a#Notify!', {click: () => data.notifications++});\n * });\n * });\n * ```\n *\n * ***Note*** that the above could just as easily be done using `$(func)` instead of `derive(func)`.\n *\n * @example Observation with return value\n * ```typescript\n * const counter = proxy(0);\n * setInterval(() => counter.value++, 1000);\n * const double = derive(() => counter.value * 2);\n *\n * $('h3', () => {\n * $(`#counter=${counter.value} double=${double.value}`);\n * })\n * ```\n *\n * @overload\n * @param func Func without a return value.\n */\nexport function derive<T>(func: () => T): ValueRef<T> {\n\treturn new ResultScope<T>(func).result;\n}\n\n/**\n * Attaches a reactive Aberdeen UI fragment to an existing DOM element. Without the use of\n * this function, {@link $} will assume `document.body` as its root.\n *\n * It creates a top-level reactive scope associated with the `parentElement`. The provided\n * function `func` is executed immediately within this scope. Any proxied data read by `func`\n * will cause it to re-execute when the data changes, updating the DOM elements created within it.\n *\n * Calls to {@link $} inside `func` will append nodes to `parentElement`.\n * You can nest {@link derive} or other {@link $} scopes within `func`.\n * Use {@link unmountAll} to clean up all mounted scopes and their DOM nodes.\n *\n * Mounting scopes happens reactively, meaning that if this function is called from within another\n * ({@link derive} or {@link $} or {@link mount}) scope that gets cleaned up, so will the mount.\n *\n * @param parentElement - The native DOM `Element` to which the UI fragment will be appended.\n * @param func - The function that defines the UI fragment, typically containing calls to {@link $}.\n *\n * @example Basic Mount\n * ```javascript\n * // Create a pre-existing DOM structure (without Aberdeen)\n * document.body.innerHTML = `<h3>Static content <span id=\"title-extra\"></span></h3><div class=\"box\" id=\"app-root\"></div>`;\n *\n * import { mount, $, proxy } from 'aberdeen';\n *\n * const runTime = proxy(0);\n * setInterval(() => runTime.value++, 1000);\n *\n * mount(document.getElementById('app-root'), () => {\n * $('h4#Aberdeen App');\n * $(`p#Run time: ${runTime.value}s`);\n * // Conditionally render some content somewhere else in the static page\n * if (runTime.value&1) {\n * mount(document.getElementById('title-extra'), () =>\n * $(`i#(${runTime.value}s)`)\n * );\n * }\n * });\n * ```\n *\n * Note how the inner mount behaves reactively as well, automatically unmounting when it's parent observer scope re-runs.\n */\n\nexport function mount(parentElement: Element, func: () => void) {\n\tnew MountScope(parentElement, func);\n}\n\n/**\n * Removes all Aberdeen-managed DOM nodes and stops all active reactive scopes\n * (created by {@link mount}, {@link derive}, {@link $} with functions, etc.).\n *\n * This effectively cleans up the entire Aberdeen application state.\n */\nexport function unmountAll() {\n\tROOT_SCOPE.remove();\n\tcssCount = 0;\n}\n\n/**\n * Executes a function or retrieves a value *without* creating subscriptions in the current reactive scope, and returns its result.\n *\n * This is useful when you need to access reactive data inside a reactive scope (like {@link $})\n * but do not want changes to that specific data to trigger a re-execute of the scope.\n * \n * Note: You may also use {@link unproxy} to get to the raw underlying data structure, which can be used to similar effect.\n *\n * @param target - Either a function to execute, or an object (which may also be an Array or a Map) to index.\n * @param key - Optional key/index to use when `target` is an object.\n * @returns The result of the function call, or the value at `target[key]` when `target` is an object or `target.get(key)` when it's a Map.\n *\n * @example Peeking within observer\n * ```typescript\n * const data = proxy({ a: 1, b: 2 });\n * $(() => {\n * // re-executes only when data.a changes, because data.b is peeked.\n * const b = peek(() => data.b);\n * console.log(`A is ${data.a}, B was ${b} when A changed.`);\n * });\n * data.b = 3; // Does not trigger console.log\n * data.a = 2; // Triggers console.log (logs \"A is 2, B was 3 when A changed.\")\n * ```\n *\n */\n\nexport function peek<T extends object>(target: T, key: keyof T): T[typeof key];\nexport function peek<K,V>(target: Map<K,V>, key: K): V | undefined;\nexport function peek<T>(target: T[], key: number): T | undefined;\nexport function peek<T>(target: () => T): T;\n\nexport function peek(target: any, key?: any) {\n\tpeeking++;\n\ttry {\n\t\tif (arguments.length === 1) {\n\t\t\treturn target();\n\t\t} else {\n\t\t\treturn (target instanceof Map) ? target.get(key) : target[key];\n\t\t}\n\t} finally {\n\t\tpeeking--;\n\t}\n}\n\n/** When using a Map as `source`. */\nexport function map<K, IN, OUT>(\n\tsource: Map<K, IN>,\n\tfunc: (value: IN, key: K) => undefined | OUT,\n): Map<K, OUT>;\n/** When using an array as `source`. */\nexport function map<IN, OUT>(\n\tsource: Array<IN>,\n\tfunc: (value: IN, index: number) => undefined | OUT,\n): Array<OUT>;\n/** When using an object as `source`. */\nexport function map<IN, const IN_KEY extends string | number | symbol, OUT>(\n\tsource: Record<IN_KEY, IN>,\n\tfunc: (value: IN, index: KeyToString<IN_KEY>) => undefined | OUT,\n): Record<string | symbol, OUT>;\n/**\n * Reactively maps/filters items from a proxied source array or object to a new proxied array or object.\n *\n * It iterates over the `target` proxy. For each item, it calls `func`.\n * - If `func` returns a value, it's added to the result proxy under the same key/index.\n * - If `func` returns `undefined`, the item is skipped (filtered out).\n *\n * The returned proxy automatically updates when:\n * - Items are added/removed/updated in the `target` proxy.\n * - Any proxied data read *within* the `func` call changes (for a specific item).\n *\n * @param func - A function `(value, key) => mappedValue | undefined` that transforms each item.\n * It receives the item's value and its key/index. Return `undefined` to filter the item out.\n * @returns A new proxied array or object containing the mapped values.\n * @template IN The type of items in the source proxy.\n * @template OUT The type of items in the resulting proxy.\n *\n * @example Map array values\n * ```typescript\n * const numbers = proxy([1, 2, 3]);\n * const doubled = map(numbers, (n) => n * 2);\n * // doubled is proxy([2, 4, 6])\n *\n * $(() => console.log(doubled)); // Logs updates\n * numbers.push(4); // doubled becomes proxy([2, 4, 6, 8])\n * ```\n *\n * @example Filter and map object properties\n * ```typescript\n * const users = proxy({\n * 'u1': { name: 'Alice', active: true },\n * 'u2': { name: 'Bob', active: false },\n * 'u3': { name: 'Charlie', active: true }\n * });\n *\n * const activeUserNames = map(users, (user) => user.active ? user.name : undefined);\n * // activeUserNames is proxy({ u1: 'Alice', u3: 'Charlie' })\n * $(() => console.log(Object.values(activeUserNames)));\n *\n * users.u2.active = true;\n * // activeUserNames becomes proxy({ u1: 'Alice', u2: 'Bob', u3: 'Charlie' })\n * ```\n */\nexport function map(\n\tsource: any,\n\tfunc: (value: any, key: any) => any,\n): any {\n\tlet out;\n\tif (source instanceof Array) {\n\t\tout = optProxy([]);\n\t} else if (source instanceof Map) {\n\t\tout = optProxy(new Map());\n\t} else {\n\t\tout = optProxy({});\n\t}\n\t\n\tonEach(source, (item: any, key: symbol | string | number) => {\n\t\tconst value = func(item, key);\n\t\tif (value !== undefined) {\n\t\t\tif (out instanceof Map) {\n\t\t\t\tout.set(key, value);\n\t\t\t\tclean(() => {\n\t\t\t\t\tout.delete(key);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tout[key] = value;\n\t\t\t\tclean(() => {\n\t\t\t\t\tdelete out[key];\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\treturn out;\n}\n\n/** When using an array as `source`. */\nexport function multiMap<IN, OUT extends { [key: string | symbol]: any }>(\n\tsource: Array<IN>,\n\tfunc: (value: IN, index: number) => OUT | undefined,\n): OUT;\n/** When using an object as `source`. */\nexport function multiMap<\n\tK extends string | number | symbol,\n\tIN,\n\tOUT extends { [key: string | symbol]: any },\n>(source: Record<K, IN>, func: (value: IN, index: KeyToString<K>) => OUT | undefined): OUT;\n/** When using a Map as `source`. */\nexport function multiMap<\n\tK,\n\tIN,\n\tOUT extends { [key: string | symbol]: any },\n>(source: Map<K, IN>, func: (value: IN, key: K) => OUT | undefined): OUT;\n/**\n * Reactively maps items from a source proxy (array or object) to a target proxied object,\n * where each source item can contribute multiple key-value pairs to the target.\n *\n * It iterates over the `target` proxy. For each item, it calls `func`.\n * - If `func` returns an object, all key-value pairs from that object are added to the result proxy.\n * - If `func` returns `undefined`, the item contributes nothing.\n *\n * The returned proxy automatically updates when:\n * - Items are added/removed/updated in the `target` proxy.\n * - Any proxied data read *within* the `func` call changes (for a specific item).\n * - If multiple input items produce the same output key, the last one processed usually \"wins\",\n * but the exact behavior on collision depends on update timing.\n *\n * This is useful for \"flattening\" or \"indexing\" data, or converting an observable array to an observable object.\n *\n * @param source - The source proxied array or object.\n * @param func - A function `(value, key) => ({...pairs} | undefined)` that transforms an item\n * into an object of key-value pairs to add, or `undefined` to add nothing.\n * @returns A new proxied object containing the aggregated key-value pairs.\n * @template IN The type of items in the source proxy.\n * @template OUT The type of the aggregated output object (should encompass all possible key-value pairs).\n *\n * @example Creating an index from an array\n * ```typescript\n * const items = proxy([\n * { id: 'a', value: 10 },\n * { id: 'b', value: 20 },\n * ]);\n * const itemsById = multiMap(items, (item) => ({\n * [item.id]: item.value,\n * [item.id+item.id]: item.value*10,\n * }));\n * // itemsById is proxy({ a: 10, aa: 100, b: 20, bb: 200 })\n *\n * $(() => console.log(itemsById));\n *\n * items.push({ id: 'c', value: 30 });\n * // itemsById becomes proxy({ a: 10, aa: 100, b: 20, bb: 200, c: 30, cc: 300 })\n * ```\n */\nexport function multiMap(\n\tsource: any,\n\tfunc: (value: any, key: any) => Record<string | symbol, any>,\n): any {\n\tconst out = optProxy({});\n\tonEach(source, (item: any, key: symbol | string | number) => {\n\t\tconst pairs = func(item, key);\n\t\tif (pairs) {\n\t\t\tfor (const key of Object.keys(pairs)) out[key] = pairs[key];\n\t\t\tclean(() => {\n\t\t\t\tfor (const key of Object.keys(pairs)) delete out[key];\n\t\t\t});\n\t\t}\n\t});\n\treturn out;\n}\n\n/** When using an object as `array`. */\nexport function partition<OUT_K extends string | number | symbol, IN_V>(\n\tsource: IN_V[],\n\tfunc: (value: IN_V, key: number) => undefined | OUT_K | OUT_K[],\n): Record<OUT_K, Record<number, IN_V>>;\n/** When using an object as `source`. */\nexport function partition<\n\tIN_K extends string | number | symbol,\n\tOUT_K extends string | number | symbol,\n\tIN_V,\n>(\n\tsource: Record<IN_K, IN_V>,\n\tfunc: (value: IN_V, key: IN_K) => undefined | OUT_K | OUT_K[],\n): Record<OUT_K, Record<IN_K, IN_V>>;\n/** When using a Map as `source`. */\nexport function partition<\n\tIN_K extends string | number | symbol,\n\tOUT_K extends string | number | symbol,\n\tIN_V,\n>(\n\tsource: Map<IN_K, IN_V>,\n\tfunc: (value: IN_V, key: IN_K) => undefined | OUT_K | OUT_K[],\n): Record<OUT_K, Record<IN_K, IN_V>>;\n\n/**\n * @overload\n * Reactively partitions items from a source proxy (array or object) into multiple \"bucket\" proxies\n * based on keys determined by a classifier function.\n *\n * This function iterates through the `source` proxy using {@link onEach}. For each item,\n * it calls the classifier `func`, which should return:\n * - A single key (`OUT_K`): The item belongs to the bucket with this key.\n * - An array of keys (`OUT_K[]`): The item belongs to all buckets specified in the array.\n * - `undefined`: The item is not placed in any bucket.\n *\n * The function returns a main proxied object. The keys of this object are the bucket keys (`OUT_K`)\n * returned by `func`. Each value associated with a bucket key is another proxied object (the \"bucket\").\n * This inner bucket object maps the *original* keys/indices from the `source` to the items\n * themselves that were classified into that bucket.\n *\n * The entire structure is reactive. Changes in the `source` proxy (adding/removing/updating items)\n * or changes in dependencies read by the `func` will cause the output partitioning to update automatically.\n * Buckets are created dynamically as needed and removed when they become empty.\n *\n * @param source - The input proxied Array or Record (e.g., created by {@link proxy}) containing the items to partition.\n * @param func - A classifier function `(value: IN_V, key: IN_K | number) => undefined | OUT_K | OUT_K[]`.\n * It receives the item's value and its original key/index from the `source`. It returns the bucket key(s)\n * the item belongs to, or `undefined` to ignore the item.\n * @returns A proxied object where keys are the bucket identifiers (`OUT_K`) and values are proxied Records\n * (`Record<IN_K | number, IN_V>`) representing the buckets. Each bucket maps original source keys/indices\n * to the items belonging to that bucket.\n *\n * @template OUT_K - The type of the keys used for the output buckets (string, number, or symbol).\n * @template IN_V - The type of the values in the source proxy.\n * @template IN_K - The type of the keys in the source proxy (if it's a Record).\n *\n * @example Grouping items by a property\n * ```typescript\n * interface Product { id: string; category: string; name: string; }\n * const products = proxy<Product[]>([\n * { id: 'p1', category: 'Fruit', name: 'Apple' },\n * { id: 'p2', category: 'Veg', name: 'Carrot' },\n * { id: 'p3', category: 'Fruit', name: 'Banana' },\n * ]);\n *\n * // Partition products by category. Output keys are categories (string).\n * // Inner keys are original array indices (number).\n * const productsByCategory = partition(products, (product) => product.category);\n *\n * // Reactively show the data structure\n * dump(productsByCategory);\n *\n * // Make random changes to the categories, to show reactiveness\n * setInterval(() => products[0|(Math.random()*3)].category = ['Snack','Fruit','Veg'][0|(Math.random()*3)], 2000);\n * ```\n *\n * @example Item in multiple buckets\n * ```typescript\n * interface User { id: number; tags: string[]; name: string; }\n * const users = proxy({\n * 'u1': { name: 'Alice', tags: ['active', 'new'] },\n * 'u2': { name: 'Bob', tags: ['active'] }\n * });\n *\n * // Partition users by tag. Output keys are tags (string).\n * // Inner keys are original object keys (string: 'u1', 'u2').\n * const usersByTag = partition(users, (user) => user.tags);\n *\n * console.log(usersByTag);\n * ```\n */\nexport function partition<\n\tIN_K extends string | number | symbol,\n\tOUT_K extends string | number | symbol,\n\tIN_V,\n>(\n\tsource: Record<IN_K, IN_V>,\n\tfunc: (value: IN_V, key: KeyToString<IN_K>) => undefined | OUT_K | OUT_K[],\n): Record<OUT_K, Record<KeyToString<IN_K>, IN_V>> {\n\tconst unproxiedOut = {} as Record<OUT_K, Record<KeyToString<IN_K>, IN_V>>;\n\tconst out = optProxy(unproxiedOut);\n\tonEach(source, (item: IN_V, key: KeyToString<IN_K>) => {\n\t\tconst rsp = func(item, key);\n\t\tif (rsp != null) {\n\t\t\tconst buckets = rsp instanceof Array ? rsp : [rsp];\n\t\t\tif (buckets.length) {\n\t\t\t\tfor (const bucket of buckets) {\n\t\t\t\t\tif (unproxiedOut[bucket]) out[bucket][key] = item;\n\t\t\t\t\telse out[bucket] = { [key]: item } as Record<KeyToString<IN_K>, IN_V>;\n\t\t\t\t}\n\t\t\t\tclean(() => {\n\t\t\t\t\tfor (const bucket of buckets) {\n\t\t\t\t\t\tdelete out[bucket][key];\n\t\t\t\t\t\tif (isObjEmpty(unproxiedOut[bucket])) delete out[bucket];\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\treturn out;\n}\n\n/**\n * Renders a live, recursive dump of a proxied data structure (or any value)\n * into the DOM at the current {@link $} insertion point.\n *\n * Uses `<ul>` and `<li>` elements to display object properties and array items.\n * Updates reactively if the dumped data changes. Primarily intended for debugging purposes.\n *\n * @param data - The proxied data structure (or any value) to display.\n * @returns The original `data` argument, allowing for chaining.\n * @template T - The type of the data being dumped.\n *\n * @example Dumping reactive state\n * ```typescript\n * import { $, proxy, dump } from 'aberdeen';\n *\n * const state = proxy({\n * user: { name: 'Frank', kids: 1 },\n * items: ['a', 'b']\n * });\n *\n * $('h2#Live State Dump');\n * dump(state);\n *\n * // Change state later, the dump in the DOM will update\n * setTimeout(() => { state.user.kids++; state.items.push('c'); }, 2000);\n * ```\n */\nexport function dump<T>(data: T): T {\n\tif (data && typeof data === \"object\") {\n\t\tconst name = data.constructor.name.toLowerCase() || \"unknown object\";\n\t\t$(`#<${name}>`);\n\t\tif (NO_COPY in data ) {\n\t\t\t$(\"# [NO_COPY]\");\n\t\t} else {\n\t\t\t$(\"ul\", () => {\n\t\t\t\tonEach(data as any, (value, key) => {\n\t\t\t\t\t$(\"li\", () => {\n\t\t\t\t\t\t$(`#${JSON.stringify(key)}: `);\n\t\t\t\t\t\tdump(value);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t} else if (data !== undefined) {\n\t\t$(\"#\" + JSON.stringify(data));\n\t}\n\treturn data;\n}\n\n/*\n * Helper functions\n */\n\n/* c8 ignore start */\nfunction internalError(code: number): never {\n\tthrow new Error(`Aberdeen internal error ${code}`);\n}\n/* c8 ignore end */\n\nfunction handleError(e: any, showMessage: boolean) {\n\ttry {\n\t\tif (onError(e) === false) showMessage = false;\n\t} catch (e) {\n\t\tconsole.error(e);\n\t}\n\ttry {\n\t\tif (showMessage) $(\"div.aberdeen-error#Error\");\n\t} catch {\n\t\t// Error while adding the error marker to the DOM. Apparently, we're in\n\t\t// an awkward context. The error should already have been logged by\n\t\t// onError, so let's not confuse things by generating more errors.\n\t}\n}\n\n/** @internal */\nexport function withEmitHandler(\n\thandler: (\n\t\ttarget: TargetType,\n\t\tindex: any,\n\t\tnewData: any,\n\t\toldData: any,\n\t) => void,\n\tfunc: () => void,\n) {\n\tconst oldEmitHandler = emit;\n\temit = handler;\n\ttry {\n\t\tfunc();\n\t} finally {\n\t\temit = oldEmitHandler;\n\t}\n}\n"
6
+ "import { ReverseSortedSet } from \"./helpers/reverseSortedSet.js\";\nimport type { ReverseSortedSetPointer } from \"./helpers/reverseSortedSet.js\";\n\n/*\n * QueueRunner\n *\n * `queue()`d runners are executed on the next timer tick, by order of their\n * `prio` values.\n */\ninterface QueueRunner {\n\tprio: number; // Higher values have higher priority\n\tqueueRun(): void;\n\n\t[ptr: ReverseSortedSetPointer]: QueueRunner;\n}\n\nlet sortedQueue: ReverseSortedSet<QueueRunner, \"prio\"> | undefined; // When set, a runQueue is scheduled or currently running.\nlet runQueueDepth = 0; // Incremented when a queue event causes another queue event to be added. Reset when queue is empty. Throw when >= 42 to break (infinite) recursion.\nlet topRedrawScope: Scope | undefined; // The scope that triggered the current redraw. Elements drawn at this scope level may trigger 'create' animations.\n\n/** @internal */\nexport type TargetType = any[] | { [key: string | symbol]: any } | Map<any, any>;\n\n\nfunction queue(runner: QueueRunner) {\n\tif (!sortedQueue) {\n\t\tsortedQueue = new ReverseSortedSet<QueueRunner, \"prio\">(\"prio\");\n\t\tsetTimeout(runQueue, 0);\n\t} else if (!(runQueueDepth & 1)) {\n\t\trunQueueDepth++; // Make it uneven\n\t\tif (runQueueDepth > 98) {\n\t\t\tthrow new Error(\"Too many recursive updates from observes\");\n\t\t}\n\t}\n\tsortedQueue.add(runner);\n}\n\n/**\n * Forces the immediate and synchronous execution of all pending reactive updates.\n *\n * Normally, changes to observed data sources (like proxied objects or arrays)\n * are processed asynchronously in a batch after a brief timeout (0ms). This function\n * allows you to bypass the timeout and process the update queue immediately.\n *\n * This can be useful in specific scenarios where you need the DOM to be updated\n * synchronously.\n *\n * This function is re-entrant, meaning it is safe to call `runQueue` from within\n * a function that is itself being executed as part of an update cycle triggered\n * by a previous (or the same) `runQueue` call.\n *\n * @example\n * ```typescript\n * const data = proxy(\"before\");\n *\n * $('#'+data);\n * console.log(1, document.body.innerHTML); // before\n *\n * // Make an update that should cause the DOM to change.\n * data.value = \"after\";\n *\n * // Normally, the DOM update would happen after a timeout.\n * // But this causes an immediate update:\n * runQueue();\n *\n * console.log(2, document.body.innerHTML); // after\n * ```\n */\nexport function runQueue(): void {\n\tlet time = Date.now();\n\twhile (sortedQueue) {\n\t\tconst runner = sortedQueue.fetchLast();\n\t\tif (!runner) break;\n\t\tif (runQueueDepth & 1) runQueueDepth++; // Make it even\n\t\trunner.queueRun();\n\t}\n\tsortedQueue = undefined;\n\trunQueueDepth = 0;\n\ttime = Date.now() - time;\n\tif (time > 9) console.debug(`Aberdeen queue took ${time}ms`);\n}\n\n/**\n * A sort key, as used by {@link onEach}, is a value that determines the order of items. It can\n * be a number, string, or an array of numbers/strings. The sort key is used to sort items\n * based on their values. The sort key can also be `undefined`, which indicates that the item\n * should be ignored.\n * @internal\n */\nexport type SortKeyType = number | string | Array<number | string> | undefined | void;\n\n/**\n * Given an integer number or a string, this function returns a string that can be concatenated\n * with other strings to create a composed sort key, that follows natural number ordering.\n */\nfunction partToStr(part: number | string): string {\n\tif (typeof part === \"string\") {\n\t\treturn `${part}\\x01`; // end-of-string\n\t}\n\tlet result = \"\";\n\tlet num = Math.abs(Math.round(part));\n\tconst negative = part < 0;\n\twhile (num > 0) {\n\t\t/*\n\t\t * We're reserving a few character codes:\n\t\t * 0 - for compatibility\n\t\t * 1 - separator between string array items\n\t\t * 65535 - for compatibility\n\t\t */\n\t\tresult = String.fromCharCode(\n\t\t\tnegative ? 65534 - (num % 65533) : 2 + (num % 65533),\n\t\t) + result;\n\t\tnum = Math.floor(num / 65533);\n\t}\n\t// Prefix the number of digits, counting down from 128 for negative and up for positive\n\treturn (\n\t\tString.fromCharCode(128 + (negative ? -result.length : result.length)) +\n\t\tresult\n\t);\n}\n\n/**\n * Creates a new string that has the opposite sort order compared to the input string.\n *\n * This is achieved by flipping the bits of each character code in the input string.\n * The resulting string is intended for use as a sort key, particularly with the\n * `makeKey` function in {@link onEach}, to achieve a descending sort order.\n *\n * **Warning:** The output string will likely contain non-printable characters or\n * appear as gibberish and should not be displayed to the user.\n *\n * @example\n * ```typescript\n * const users = proxy([\n * { id: 1, name: 'Charlie', score: 95 },\n * { id: 2, name: 'Alice', score: 100 },\n * { id: 3, name: 'Bob', score: 90 },\n * ]);\n *\n * onEach(users, (user) => {\n * $(`p#${user.name}: ${user.score}`);\n * }, (user) => invertString(user.name)); // Reverse alphabetic order\n * ```\n *\n * @param input The string whose sort order needs to be inverted.\n * @returns A new string that will sort in the reverse order of the input string.\n * @see {@link onEach} for usage with sorting.\n */\nexport function invertString(input: string): string {\n\tlet result = \"\";\n\tfor (let i = 0; i < input.length; i++) {\n\t\tresult += String.fromCodePoint(65535 - input.charCodeAt(i));\n\t}\n\treturn result;\n}\n\n// Each new scope gets a lower prio than all scopes before it, by decrementing\n// this counter.\nlet lastPrio = 0;\n\nabstract class Scope implements QueueRunner {\n\t// Scopes are to be handled in creation order. This will make sure that parents are\n\t// handled before their children (as they should), and observes are executed in the\n\t// order of the source code.\n\tprio: number = --lastPrio;\n\n\t[ptr: ReverseSortedSetPointer]: this;\n\n\tonChange(index: any): void {\n\t\tqueue(this);\n\t}\n\tabstract queueRun(): void;\n\n\tabstract getLastNode(): Node | undefined;\n\tabstract getPrecedingNode(): Node | undefined;\n\tabstract delete(): void;\n\n\tremove() {\n\t\t// Remove any nodes\n\t\tconst lastNode = this.getLastNode();\n\t\tif (lastNode) removeNodes(lastNode, this.getPrecedingNode());\n\n\t\t// Run any cleaners\n\t\tthis.delete();\n\t}\n\n\t// toString(): string {\n\t// \treturn `${this.constructor.name}`\n\t// }\n}\n\n/**\n * Execute a function once, after all currently scheduled jobs are completed.\n */\nclass DelayedOneTimeRunner implements QueueRunner {\n\tprio: number = --lastPrio;\n\t[ptr: ReverseSortedSetPointer]: this;\n\tconstructor(\n\t\tpublic queueRun: () => void\n\t) {\n\t\tqueue(this);\n\t}\n}\n\n/**\n * All Scopes that can hold nodes and subscopes, including `SimpleScope` and `OnEachItemScope`\n * but *not* `OnEachScope`, are `ContentScope`s.\n */\nabstract class ContentScope extends Scope {\n\t// The list of clean functions to be called when this scope is cleaned. These can\n\t// be for child scopes, subscriptions as well as `clean(..)` hooks.\n\tcleaners: Array<{ delete: (scope: Scope) => void } | (() => void)>;\n\n\tabstract svg: boolean;\n\tabstract el: Element;\n\n\tconstructor(\n\t\tcleaners: Array<{ delete: (scope: Scope) => void } | (() => void)> = [],\n\t) {\n\t\tsuper();\n\t\tthis.cleaners = cleaners;\n\t}\n\n\tlastChild: Node | Scope | undefined;\n\n\t// Should be subclassed in most cases..\n\tredraw() {}\n\n\tgetLastNode(): Node | undefined {\n\t\treturn findLastNodeInPrevSiblings(this.lastChild);\n\t}\n\n\t/**\n\t * Call cleaners and make sure the scope is not queued.\n\t * It is called `delete`, so that the list of cleaners can also contain `Set`s.\n\t */\n\tdelete(/* ignore observer argument */) {\n\t\tfor (const cleaner of this.cleaners) {\n\t\t\tif (typeof cleaner === \"function\") cleaner();\n\t\t\telse cleaner.delete(this); // pass in observer argument, in case `cleaner` is a `Set`\n\t\t}\n\t\tthis.cleaners.length = 0;\n\t\tsortedQueue?.remove(this); // This is very fast and O(1) when not queued\n\n\t\t// To prepare for a redraw or to help GC when we're being removed:\n\t\tthis.lastChild = undefined;\n\t}\n\n\tqueueRun() {\n\t\tthis.remove();\n\n\t\ttopRedrawScope = this;\n\t\tthis.redraw();\n\t\ttopRedrawScope = undefined;\n\t}\n\n\tgetInsertAfterNode() {\n\t\treturn this.getLastNode() || this.getPrecedingNode();\n\t}\n\n\tonChange() {\n\t\tqueue(this);\n\t}\n\n\tgetChildPrevSibling() {\n\t\treturn this.lastChild;\n\t}\n}\n\nclass ChainedScope extends ContentScope {\n\t// The node or scope right before this scope that has the same `parentElement`.\n\tpublic prevSibling: Node | Scope | undefined;\n\n\tconstructor(\n\t\t// The parent DOM element we'll add our child nodes to.\n\t\tpublic el: Element,\n\t\t// Whether this scope is within an SVG namespace context\n\t\tpublic svg: boolean,\n\t\t// When true, we share our 'cleaners' list with the parent scope.\n\t\tuseParentCleaners = false,\n\t) {\n\t\tsuper(useParentCleaners ? currentScope.cleaners : []);\n\t\t\n\t\tif (el === currentScope.el) {\n\t\t\t// If `currentScope` is not actually a ChainedScope, prevSibling will be undefined, as intended\n\t\t\tthis.prevSibling = currentScope.getChildPrevSibling();\n\t\t\tcurrentScope.lastChild = this;\n\t\t} else {\n\t\t\tthis.prevSibling = el.lastChild || undefined;\n\t\t}\n\n\t\t// We're always adding ourselve as a cleaner, in order to run our own cleaners\n\t\t// and to remove ourselve from the queue (if we happen to be in there).\n\t\tif (!useParentCleaners) currentScope.cleaners.push(this);\n\t}\n\n\tgetPrecedingNode(): Node | undefined {\n\t\treturn findLastNodeInPrevSiblings(this.prevSibling);\n\t}\n\n\tgetChildPrevSibling() {\n\t\treturn this.lastChild || this.prevSibling;\n\t}\n}\n\n/**\n * @internal\n * A `RegularScope` is created with a `render` function that is run initially,\n * and again when any of the `Store`s that this function reads are changed. Any\n * DOM elements that is given a `render` function for its contents has its own scope.\n * The `Scope` manages the position in the DOM tree elements created by `render`\n * are inserted at. Before a rerender, all previously created elements are removed\n * and the `clean` functions for the scope and all sub-scopes are called.\n */\nclass RegularScope extends ChainedScope {\n\tconstructor(\n\t\tel: Element,\n\t\tsvg: boolean,\n\t\t// The function that will be reactively called. Elements it creates using `$` are\n\t\t// added to the appropriate position within `parentElement`.\n\t\tpublic renderer: () => any,\n\t) {\n\t\tsuper(el, svg);\n\n\t\t// Do the initial run\n\t\tthis.redraw();\n\t}\n\n\tredraw() {\n\t\tconst savedScope = currentScope;\n\t\tcurrentScope = this;\n\t\ttry {\n\t\t\tthis.renderer();\n\t\t} catch (e) {\n\t\t\t// Throw the error async, so the rest of the rendering can continue\n\t\t\thandleError(e, true);\n\t\t}\n\t\tcurrentScope = savedScope;\n\t}\n}\n\nclass RootScope extends ContentScope {\n\tel = document.body;\n\tsvg = false;\n\tgetPrecedingNode(): Node | undefined {\n\t\treturn undefined;\n\t}\n}\n\nclass MountScope extends ContentScope {\n\tsvg: boolean;\n\tconstructor(\n\t\t// The parent DOM element we'll add our child nodes to\n\t\tpublic el: Element,\n\t\t// The function that\n\t\tpublic renderer: () => any,\n\t) {\n\t\tsuper();\n\t\tthis.svg = el.namespaceURI === 'http://www.w3.org/2000/svg';\n\t\t\n\t\tthis.redraw();\n\t\tcurrentScope.cleaners.push(this);\n\t}\n\n\tredraw() {\n\t\tRegularScope.prototype.redraw.call(this);\n\t}\n\n\tgetPrecedingNode(): Node | undefined {\n\t\treturn undefined;\n\t}\n\n\tdelete() {\n\t\t// We can't rely on our parent scope to remove all our nodes for us, as our parent\n\t\t// probably has a totally different `parentElement`. Therefore, our `delete()` does\n\t\t// what `_remove()` does for regular scopes.\n\t\tremoveNodes(this.getLastNode(), this.getPrecedingNode());\n\t\tsuper.delete();\n\t}\n\n\tremove() {\n\t\tthis.delete();\n\t}\n}\n\n// Remove node and all its preceding siblings (uptil and excluding preNode)\n// from the DOM, using onDestroy if applicable.\nfunction removeNodes(\n\tnode: Node | null | undefined,\n\tpreNode: Node | null | undefined,\n) {\n\twhile (node && node !== preNode) {\n\t\tconst prevNode: Node | null = node.previousSibling;\n\t\tconst onDestroy = onDestroyMap.get(node);\n\t\tif (onDestroy && node instanceof Element) {\n\t\t\tif (onDestroy !== true) {\n\t\t\t\tif (typeof onDestroy === \"function\") {\n\t\t\t\t\tonDestroy(node);\n\t\t\t\t} else {\n\t\t\t\t\tdestroyWithClass(node, onDestroy);\n\t\t\t\t}\n\t\t\t\t// This causes the element to be ignored from this function from now on:\n\t\t\t\tonDestroyMap.set(node, true);\n\t\t\t}\n\t\t\t// Ignore the deleting element\n\t\t} else {\n\t\t\t(node as Element | Text).remove();\n\t\t}\n\t\tnode = prevNode;\n\t}\n}\n\n// Get a reference to the last node within `sibling` or any of its preceding siblings.\n// If a `Node` is given, that node is returned.\nfunction findLastNodeInPrevSiblings(\n\tsibling: Node | Scope | undefined,\n): Node | undefined {\n\tif (!sibling || sibling instanceof Node) return sibling;\n\treturn sibling.getLastNode() || sibling.getPrecedingNode();\n}\n\nclass ResultScope<T> extends ChainedScope {\n\tpublic result: ValueRef<T> = optProxy({ value: undefined });\n\n\tconstructor(\n\t\tpublic renderer: () => T,\n\t) {\n\t\tsuper(currentScope.el, currentScope.svg);\n\t\tthis.redraw();\n\t}\n\n\tredraw() {\n\t\tconst savedScope = currentScope;\n\t\tcurrentScope = this;\n\t\ttry {\n\t\t\tthis.result.value = this.renderer();\n\t\t} catch (e) {\n\t\t\t// Throw the error async, so the rest of the rendering can continue\n\t\t\thandleError(e, true);\n\t\t}\n\t\tcurrentScope = savedScope;\n\t}\n}\n\n/**\n * A `Scope` subclass optimized for reactively setting just a single element property\n * based on a proxied reference.\n */\n\nclass SetArgScope extends ChainedScope {\n\tpublic svg = false;\n\tconstructor(\n\t\tel: Element,\n\t\tprivate key: string,\n\t\tprivate target: { value: any },\n\t) {\n\t\tsuper(el, el.namespaceURI === 'http://www.w3.org/2000/svg');\n\t\tthis.redraw();\n\t}\n\tredraw() {\n\t\tconst savedScope = currentScope;\n\t\tcurrentScope = this;\n\t\tapplyArg(this.el, this.key, this.target.value);\n\t\tcurrentScope = savedScope;\n\t}\n}\n\n/** @internal */\nclass OnEachScope extends Scope {\n\t// biome-ignore lint/correctness/noInvalidUseBeforeDeclaration: circular, as currentScope is initialized with a Scope\n\tparentElement: Element = currentScope.el;\n\tprevSibling: Node | Scope | undefined;\n\n\t/** The data structure we are iterating */\n\ttarget: TargetType;\n\n\t/** All item scopes, by array index or object key. This is used for removing an item scope when its value\n\t * disappears, and calling all subscope cleaners. */\n\tbyIndex: Map<any, OnEachItemScope> = new Map();\n\n\t/** The reverse-ordered list of item scopes, not including those for which makeSortKey returned undefined. */\n\tsortedSet: ReverseSortedSet<OnEachItemScope, \"sortKey\"> =\n\t\tnew ReverseSortedSet(\"sortKey\");\n\n\t/** Indexes that have been created/removed and need to be handled in the next `queueRun`. */\n\tchangedIndexes: Set<any> = new Set();\n\n\tconstructor(\n\t\tproxy: TargetType,\n\t\t/** A function that renders an item */\n\t\tpublic renderer: (value: any, key: any) => void,\n\t\t/** A function returning a number/string/array that defines the position of an item */\n\t\tpublic makeSortKey?: (value: any, key: any) => SortKeyType,\n\t) {\n\t\tsuper();\n\t\tconst target: TargetType = (this.target =\n\t\t\t(proxy as any)[TARGET_SYMBOL] || proxy);\n\n\t\tsubscribe(target, ANY_SYMBOL, this);\n\t\tthis.prevSibling = currentScope.getChildPrevSibling();\n\t\tcurrentScope.lastChild = this;\n\n\t\tcurrentScope.cleaners.push(this);\n\n\t\t// Do _addChild() calls for initial items\n\t\tif (target instanceof Array) {\n\t\t\tfor (let i = 0; i < target.length; i++) {\n\t\t\t\tnew OnEachItemScope(this, i, false);\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const key of (target instanceof Map ? target.keys() : Object.keys(target))) {\n\t\t\t\tnew OnEachItemScope(this, key, false);\n\t\t\t}\n\t\t}\n\t}\n\n\tgetPrecedingNode(): Node | undefined {\n\t\treturn findLastNodeInPrevSiblings(this.prevSibling);\n\t}\n\n\tonChange(index: any) {\n\t\tif (!(this.target instanceof Array) || typeof index === \"number\")\n\t\t\tthis.changedIndexes.add(index);\n\t\tqueue(this);\n\t}\n\n\tqueueRun() {\n\t\tconst indexes = this.changedIndexes;\n\t\tthis.changedIndexes = new Set();\n\t\tfor (const index of indexes) {\n\t\t\tconst oldScope = this.byIndex.get(index);\n\t\t\tif (oldScope) oldScope.remove();\n\n\t\t\tif (this.target instanceof Map ? this.target.has(index) : index in this.target) {\n\t\t\t\t// Item still exists\n\t\t\t\tnew OnEachItemScope(this, index, true);\n\t\t\t} else {\n\t\t\t\t// Item has disappeared\n\t\t\t\tthis.byIndex.delete(index);\n\t\t\t}\n\t\t}\n\t\ttopRedrawScope = undefined;\n\t}\n\n\tdelete() {\n\t\t// Propagate to all our subscopes\n\t\tfor (const scope of this.byIndex.values()) {\n\t\t\tscope.delete();\n\t\t}\n\n\t\tsortedQueue?.remove(this); // This is very fast and O(1) when not queued\n\n\t\t// Help garbage collection:\n\t\tthis.byIndex.clear();\n\t\tsetTimeout(() => {\n\t\t\t// Unsure if this is a good idea. It takes time, but presumably makes things a lot easier for GC...\n\t\t\tthis.sortedSet.clear();\n\t\t}, 1);\n\t}\n\n\tgetLastNode(): Node | undefined {\n\t\tfor (const scope of this.sortedSet) {\n\t\t\t// Iterates starting at last child scope.\n\t\t\tconst node = scope.getActualLastNode();\n\t\t\tif (node) return node;\n\t\t}\n\t}\n}\n\n/** @internal */\nclass OnEachItemScope extends ContentScope {\n\tsortKey: string | number | undefined; // When undefined, this scope is currently not showing in the list\n\tpublic el: Element;\n\tpublic svg: boolean;\n\n\tconstructor(\n\t\tpublic parent: OnEachScope,\n\t\tpublic itemIndex: any,\n\t\ttopRedraw: boolean,\n\t) {\n\t\tsuper();\n\t\tthis.el = parent.parentElement;\n\t\t\n\t\t// Inherit SVG namespace state from current scope\n\t\tthis.svg = currentScope.svg;\n\n\t\tthis.parent.byIndex.set(this.itemIndex, this);\n\n\t\t// Okay, this is hacky. In case our first (actual) child is a ChainedScope, we won't be able\n\t\t// to provide it with a reliable prevSibling. Therefore, we'll pretend to be that sibling,\n\t\t// doing what's need for this case in `getLastNode`.\n\t\t// For performance, we prefer not having to create additional 'fake sibling' objects for each item.\n\t\tthis.lastChild = this;\n\n\t\t// Don't register to be cleaned by parent scope, as the OnEachScope will manage this for us (for efficiency)\n\n\t\tif (topRedraw) topRedrawScope = this;\n\t\tthis.redraw();\n\t}\n\n\tgetPrecedingNode(): Node | undefined {\n\t\t// As apparently we're interested in the node insert position, we'll need to become part\n\t\t// of the sortedSet now (if we weren't already).\n\t\t// This will do nothing and barely take any time of `this` is already part of the set:\n\t\tthis.parent.sortedSet.add(this);\n\n\t\tconst preScope = this.parent.sortedSet.prev(this);\n\t\t// As preScope should have inserted itself as its first child, this should\n\t\t// recursively call getPrecedingNode() on preScope in case it doesn't\n\t\t// have any actual nodes as children yet.\n\t\tif (preScope) return findLastNodeInPrevSiblings(preScope.lastChild);\n\t\treturn this.parent.getPrecedingNode();\n\t}\n\n\tgetLastNode(): Node | undefined {\n\t\t// Hack! As explain in the constructor, this getLastNode method actually\n\t\t// does not return the last node, but the preceding one.\n\t\treturn this.getPrecedingNode();\n\t}\n\n\tgetActualLastNode(): Node | undefined {\n\t\tlet child = this.lastChild;\n\n\t\twhile (child && child !== this) {\n\t\t\tif (child instanceof Node) return child;\n\t\t\tconst node = child.getLastNode();\n\t\t\tif (node) return node;\n\t\t\tchild = child.getPrecedingNode();\n\t\t}\n\t}\n\n\tqueueRun() {\n\t\t/* c8 ignore next */\n\t\tif (currentScope !== ROOT_SCOPE) internalError(4);\n\n\t\t// We're not calling `remove` here, as we don't want to remove ourselves from\n\t\t// the sorted set. `redraw` will take care of that, if needed.\n\t\t// Also, we can't use `getLastNode` here, as we've hacked it to return the\n\t\t// preceding node instead.\n\t\tif (this.sortKey !== undefined) {\n\t\t\tconst lastNode = this.getActualLastNode();\n\t\t\tif (lastNode) removeNodes(lastNode, this.getPrecedingNode());\n\t\t}\n\n\t\tthis.delete();\n\t\tthis.lastChild = this; // apply the hack (see constructor) again\n\n\t\ttopRedrawScope = this;\n\t\tthis.redraw();\n\t\ttopRedrawScope = undefined;\n\t}\n\n\tredraw() {\n\t\t// Have the makeSortKey function return an ordering int/string/array.\n\n\t\t// Note that we're NOT subscribing on target[itemIndex], as the OnEachScope uses\n\t\t// a wildcard subscription to delete/recreate any scopes when that changes.\n\t\t// We ARE creating a proxy around the value though (in case its an object/array),\n\t\t// so we'll have our own scope subscribe to changes on that.\n\t\tlet value: any;\n\t\tconst target = this.parent.target;\n\t\tlet itemIndex = this.itemIndex;\n\t\tif (target instanceof Map) {\n\t\t\tvalue = optProxy(target.get(itemIndex));\n\t\t\t// For Maps, the key may be an object. If so, we'll proxy it as well.\n\t\t\titemIndex = optProxy(itemIndex);\n\t\t} else {\n\t\t\tvalue = optProxy((target as any)[itemIndex]);\n\t\t}\n\n\t\t// Since makeSortKey may get() the Store, we'll need to set currentScope first.\n\t\tconst savedScope = currentScope;\n\t\tcurrentScope = this;\n\n\t\tlet sortKey: undefined | string | number;\n\t\ttry {\n\t\t\tif (this.parent.makeSortKey) {\n\t\t\t\tconst rawSortKey = this.parent.makeSortKey(value, itemIndex);\n\t\t\t\tif (rawSortKey != null)\n\t\t\t\t\tsortKey =\n\t\t\t\t\t\trawSortKey instanceof Array\n\t\t\t\t\t\t\t? rawSortKey.map(partToStr).join(\"\")\n\t\t\t\t\t\t\t: rawSortKey;\n\t\t\t} else {\n\t\t\t\tsortKey = itemIndex;\n\t\t\t}\n\t\t\tif (typeof sortKey === \"number\") sortKey = partToStr(sortKey);\n\n\t\t\tif (this.sortKey !== sortKey) {\n\t\t\t\t// If the sortKey is changed, make sure `this` is removed from the\n\t\t\t\t// set before setting the new sortKey to it.\n\t\t\t\tthis.parent.sortedSet.remove(this); // Very fast if `this` is not in the set\n\t\t\t\tthis.sortKey = sortKey;\n\t\t\t}\n\n\t\t\t// We're not adding `this` to the `sortedSet` (yet), as that may not be needed,\n\t\t\t// in case no nodes are created. We'll do it just-in-time in `getPrecedingNode`.\n\n\t\t\tif (sortKey != null) this.parent.renderer(value, itemIndex);\n\t\t} catch (e) {\n\t\t\thandleError(e, sortKey != null);\n\t\t}\n\n\t\tcurrentScope = savedScope;\n\t}\n\n\tgetInsertAfterNode() {\n\t\tif (this.sortKey == null) internalError(1);\n\t\t// Due to the `this` being the first child for `this` hack, this will look\n\t\t// for the preceding node as well, if we don't have nodes ourselves.\n\t\treturn findLastNodeInPrevSiblings(this.lastChild);\n\t}\n\n\tremove() {\n\t\t// We can't use getLastNode here, as we've hacked it to return the preceding\n\t\t// node instead.\n\t\tif (this.sortKey !== undefined) {\n\t\t\tconst lastNode = this.getActualLastNode();\n\t\t\tif (lastNode) removeNodes(lastNode, this.getPrecedingNode());\n\n\t\t\tthis.parent.sortedSet.remove(this);\n\t\t\tthis.sortKey = undefined;\n\t\t}\n\n\t\tthis.delete();\n\t}\n}\n\nfunction addNode(el: Element, node: Node) {\n\tif (el !== currentScope.el) {\n\t\tel.appendChild(node);\n\t\treturn;\n\t}\n\tconst parentEl = currentScope.el;\n\tconst prevNode = currentScope.getInsertAfterNode();\n\tparentEl.insertBefore(\n\t\tnode,\n\t\tprevNode ? prevNode.nextSibling : parentEl.firstChild,\n\t);\n\tcurrentScope.lastChild = node;\n}\n\n/**\n * This global is set during the execution of a `Scope.render`. It is used by\n * functions like `$` and `clean`.\n */\nconst ROOT_SCOPE = new RootScope();\nlet currentScope: ContentScope = ROOT_SCOPE;\n\n/**\n * Execute a function in a never-cleaned root scope. Even {@link unmountAll} will not\n * clean up observers/nodes created by the function.\n * @param func The function to execute.\n * @returns The return value of the function.\n * @internal\n */\nexport function leakScope<T>(func: () => T): T {\n\tconst savedScope = currentScope;\n\tcurrentScope = new RootScope();\n\ttry {\n\t\treturn func();\n\t} finally {\n\t\tcurrentScope = savedScope;\n\t}\n}\n\n/**\n * A special Node observer index to subscribe to any value in the map changing.\n */\nconst ANY_SYMBOL = Symbol(\"any\");\n\n/**\n * When our proxy objects need to lookup `obj[TARGET_SYMBOL]` it returns its\n * target, to be used in our wrapped methods.\n */\nconst TARGET_SYMBOL = Symbol(\"target\");\n\n/**\n * Symbol used internally to track Map size without clashing with actual Map keys named \"size\".\n */\nconst MAP_SIZE_SYMBOL = Symbol(\"mapSize\");\n\nconst subscribers = new WeakMap<\n\tTargetType,\n\tMap<\n\t\tany,\n\t\tSet<Scope | ((index: any, newData: any, oldData: any) => void)>\n\t>\n>();\nlet peeking = 0; // When > 0, we're not subscribing to any changes\n\nfunction subscribe(\n\ttarget: any,\n\tindex: symbol | string | number,\n\tobserver:\n\t\t| Scope\n\t\t| ((\n\t\t\t\tindex: any,\n\t\t\t\tnewData: any,\n\t\t\t\toldData: any,\n\t\t ) => void) = currentScope,\n) {\n\tif (observer === ROOT_SCOPE || peeking) return;\n\n\tlet byTarget = subscribers.get(target);\n\tif (!byTarget) subscribers.set(target, (byTarget = new Map()));\n\n\t// No need to subscribe to specific keys if we're already subscribed to ANY\n\tif (index !== ANY_SYMBOL && byTarget.get(ANY_SYMBOL)?.has(observer)) return;\n\n\tlet byIndex = byTarget.get(index);\n\tif (!byIndex) byTarget.set(index, (byIndex = new Set()));\n\n\tif (byIndex.has(observer)) return;\n\n\tbyIndex.add(observer);\n\n\tif (observer === currentScope) {\n\t\tcurrentScope.cleaners.push(byIndex);\n\t} else {\n\t\tcurrentScope.cleaners.push(() => {\n\t\t\tbyIndex.delete(observer);\n\t\t});\n\t}\n}\n\n/**\n * Records in TypeScript pretend that they can have number keys, but in reality they are converted to string.\n * This type changes (number | something) types to (string | something) types, maintaining typing precision as much as possible.\n * @internal\n */\ntype KeyToString<K> = K extends number ? string : K extends string | symbol ? K : K extends number | infer U ? string | U : K;\n\nexport function onEach<K, T>(\n\ttarget: Map<K, undefined | T>,\n\trender: (value: T, key: K) => void,\n\tmakeKey?: (value: T, key: K) => SortKeyType,\n): void;\nexport function onEach<T>(\n\ttarget: ReadonlyArray<undefined | T>,\n\trender: (value: T, index: number) => void,\n\tmakeKey?: (value: T, index: number) => SortKeyType,\n): void;\nexport function onEach<K extends string | number | symbol, T>(\n\ttarget: Record<K, undefined | T>,\n\trender: (value: T, index: KeyToString<K>) => void,\n\tmakeKey?: (value: T, index: KeyToString<K>) => SortKeyType,\n): void;\n\n/**\n * Reactively iterates over the items of an observable array or object, optionally rendering content for each item.\n *\n * Automatically updates when items are added, removed, or modified.\n *\n * @param target The observable array or object to iterate over. Values that are `undefined` are skipped.\n * @param render A function called for each item in the array. It receives the item's (observable) value and its index/key. Any DOM elements created within this function will be associated with the item, placed at the right spot in the DOM, and cleaned up when redrawing/removing the item.\n * @param makeKey An optional function to generate a sort key for each item. This controls the order in which items are rendered in the DOM. If omitted, items are rendered in array index order. The returned key can be a number, string, or an array of numbers/strings for composite sorting. Use {@link invertString} on string keys for descending order. Returning `null` or `undefined` from `makeKey` will prevent the item from being rendered.\n *\n * @example Iterating an array\n * ```typescript\n * const items = proxy(['apple', 'banana', 'cherry']);\n *\n * // Basic iteration\n * onEach(items, (item, index) => $(`li#${item} (#${index})`));\n *\n * // Add a new item - the list updates automatically\n * setTimeout(() => items.push('durian'), 2000);\n * // Same for updates and deletes\n * setTimeout(() => items[1] = 'berry', 4000);\n * setTimeout(() => delete items[2], 6000);\n * ```\n *\n * @example Iterating an array with custom ordering\n * ```typescript\n * const users = proxy([\n * { id: 3, group: 1, name: 'Charlie' },\n * { id: 1, group: 1, name: 'Alice' },\n * { id: 2, group: 2, name: 'Bob' },\n * ]);\n *\n * // Sort by name alphabetically\n * onEach(users, (user) => {\n * $(`p#${user.name} (id=${user.id})`);\n * }, (user) => [user.group, user.name]); // Sort by group, and within each group sort by name\n * ```\n *\n * @example Iterating an object\n * ```javascript\n * const config = proxy({ theme: 'dark', fontSize: 14, showTips: true });\n *\n * // Display configuration options\n * $('dl', () => {\n * onEach(config, (value, key) => {\n * if (key === 'showTips') return; // Don't render this one\n * $('dt#'+key);\n * $('dd#'+value);\n * });\n * });\n *\n * // Change a value - the display updates automatically\n * setTimeout(() => config.fontSize = 16, 2000);\n * ```\n * @see {@link invertString} To easily create keys for reverse sorting.\n */\nexport function onEach(\n\ttarget: TargetType,\n\trender: (value: any, index: any) => void,\n\tmakeKey?: (value: any, key: any) => SortKeyType,\n): void {\n\tif (!target || typeof target !== \"object\")\n\t\tthrow new Error(\"onEach requires an object\");\n\ttarget = (target as any)[TARGET_SYMBOL] || target;\n\n\tnew OnEachScope(target, render, makeKey);\n}\n\nfunction isObjEmpty(obj: object): boolean {\n\tfor (const k of Object.keys(obj)) return false;\n\treturn true;\n}\n\nconst EMPTY = Symbol(\"empty\");\n\n/**\n * Reactively checks if an observable array or object is empty.\n *\n * This function not only returns the current emptiness state but also establishes\n * a reactive dependency. If the emptiness state of the `proxied` object or array\n * changes later (e.g., an item is added to an empty array, or the last property\n * is deleted from an object), the scope that called `isEmpty` will be automatically\n * scheduled for re-evaluation.\n *\n * @param proxied The observable array or object to check.\n * @returns `true` if the array has length 0 or the object has no own enumerable properties, `false` otherwise.\n *\n * @example\n * ```typescript\n * const items = proxy([]);\n *\n * // Reactively display a message if the items array is empty\n * $('div', () => {\n * if (isEmpty(items)) {\n * $('p i#No items yet!');\n * } else {\n * onEach(items, item => $('p#'+item));\n * }\n * });\n *\n * // Adding an item will automatically remove the \"No items yet!\" message\n * setInterval(() => {\n * if (!items.length || Math.random()>0.5) items.push('Item');\n * else items.length = 0;\n * }, 1000)\n * ```\n */\nexport function isEmpty(proxied: TargetType): boolean {\n\tconst target = (proxied as any)[TARGET_SYMBOL] || proxied;\n\tconst scope = currentScope;\n\n\tif (target instanceof Array) {\n\t\tsubscribe(target, \"length\", (index: any, newData: any, oldData: any) => {\n\t\t\tif (!newData !== !oldData) queue(scope);\n\t\t});\n\t\treturn !target.length;\n\t}\n\t\n\tif (target instanceof Map) {\n\t\tsubscribe(target, MAP_SIZE_SYMBOL, (index: any, newData: any, oldData: any) => {\n\t\t\tif (!newData !== !oldData) queue(scope);\n\t\t});\n\t\treturn !target.size;\n\t}\n\t\n\tconst result = isObjEmpty(target);\n\tsubscribe(target, ANY_SYMBOL, (index: any, newData: any, oldData: any) => {\n\t\tif (result ? oldData === EMPTY : newData === EMPTY) queue(scope);\n\t});\n\treturn result;\n}\n\n/** @private */\nexport interface ValueRef<T> {\n\tvalue: T;\n}\n\n/**\n * Reactively counts the number of properties in an objects.\n *\n * @param proxied The observable object to count. In case an `array` is passed in, a {@link ref} to its `.length` will be returned.\n * @returns an observable object for which the `value` property reflects the number of properties in `proxied` with a value other than `undefined`.\n * \n * @example\n * ```typescript\n * const items = proxy({x: 3, y: 7} as any);\n * const cnt = count(items);\n *\n * // Create a DOM text node for the count:\n * $('div text=', cnt);\n * // <div>2</div>\n\n * // Or we can use it in an {@link derive} function:\n * $(() => console.log(\"The count is now\", cnt.value));\n * // The count is now 2\n * \n * // Adding/removing items will update the count\n * items.z = 12;\n * // Asynchronously, after 0ms:\n * // <div>3</div>\n * // The count is now 3\n * ```\n */\nexport function count(proxied: TargetType): ValueRef<number> {\n\tif (proxied instanceof Array) return ref(proxied, \"length\");\n\tif (proxied instanceof Map) return ref(proxied, \"size\");\n\n\tconst target = (proxied as any)[TARGET_SYMBOL] || proxied;\n\tlet cnt = 0;\n\tfor (const k of Object.keys(target)) if (target[k] !== undefined) cnt++;\n\n\tconst result = proxy(cnt);\n\tsubscribe(\n\t\ttarget,\n\t\tANY_SYMBOL,\n\t\t(index: any, newData: any, oldData: any) => {\n\t\t\tif (oldData === newData) {\n\t\t\t} else if (oldData === EMPTY) result.value = ++cnt;\n\t\t\telse if (newData === EMPTY) result.value = --cnt;\n\t\t},\n\t);\n\n\treturn result;\n}\n\n/** @internal */\nexport function defaultEmitHandler(\n\ttarget: TargetType,\n\tindex: string | symbol | number,\n\tnewData: any,\n\toldData: any,\n) {\n\t// We're triggering for values changing from undefined to undefined, as this *may*\n\t// indicate a change from or to `[empty]` (such as `[,1][0]`).\n\tif (newData === oldData && newData !== undefined) return;\n\n\tconst byTarget = subscribers.get(target);\n\tif (byTarget === undefined) return;\n\n\tfor (const what of [index, ANY_SYMBOL]) {\n\t\tconst byIndex = byTarget.get(what);\n\t\tif (byIndex) {\n\t\t\tfor (const observer of byIndex) {\n\t\t\t\tif (typeof observer === \"function\") observer(index, newData, oldData);\n\t\t\t\telse observer.onChange(index);\n\t\t\t}\n\t\t}\n\t}\n}\nlet emit = defaultEmitHandler;\n\nconst objectHandler: ProxyHandler<any> = {\n\tget(target: any, prop: any) {\n\t\tif (prop === TARGET_SYMBOL) return target;\n\t\tsubscribe(target, prop);\n\t\treturn optProxy(target[prop]);\n\t},\n\tset(target: any, prop: any, newData: any) {\n\t\t// Make sure newData is unproxied\n\t\tif (typeof newData === \"object\" && newData)\n\t\t\tnewData = (newData as any)[TARGET_SYMBOL] || newData;\n\t\tconst oldData = target.hasOwnProperty(prop) ? target[prop] : EMPTY;\n\t\tif (newData !== oldData) {\n\t\t\ttarget[prop] = newData;\n\t\t\temit(target, prop, newData, oldData);\n\t\t}\n\t\treturn true;\n\t},\n\tdeleteProperty(target: any, prop: any) {\n\t\tconst old = target.hasOwnProperty(prop) ? target[prop] : EMPTY;\n\t\tdelete target[prop];\n\t\temit(target, prop, EMPTY, old);\n\t\treturn true;\n\t},\n\thas(target: any, prop: any) {\n\t\tsubscribe(target, prop);\n\t\treturn target.hasOwnProperty(prop);\n\t},\n\townKeys(target: any) {\n\t\tsubscribe(target, ANY_SYMBOL);\n\t\treturn Reflect.ownKeys(target);\n\t},\n};\n\nfunction arraySet(target: any, prop: any, newData: any) {\n\t// Make sure newData is unproxied\n\tif (typeof newData === \"object\" && newData) {\n\t\tnewData = (newData as any)[TARGET_SYMBOL] || newData;\n\t}\n\tlet oldData = target[prop];\n\tif (oldData === undefined && !target.hasOwnProperty(prop)) oldData = EMPTY;\n\tif (newData !== oldData) {\n\t\tconst oldLength = target.length;\n\n\t\tif (prop === \"length\") {\n\t\t\ttarget.length = newData;\n\n\t\t\t// We only need to emit for shrinking, as growing just adds undefineds\n\t\t\tfor (let i = newData; i < oldLength; i++) {\n\t\t\t\temit(target, i, EMPTY, target[i]);\n\t\t\t}\n\t\t} else {\n\t\t\tif (typeof prop === 'string') { // Convert to int when possible\n\t\t\t\tconst n = 0|prop as any;\n\t\t\t\tif (String(n) === prop && n >= 0) prop = n;\n\t\t\t}\n\n\t\t\ttarget[prop] = newData;\n\t\t\temit(target, prop, newData, oldData);\n\t\t}\n\t\tif (target.length !== oldLength) {\n\t\t\temit(target, \"length\", target.length, oldLength);\n\t\t}\n\t}\n\treturn true;\n}\n\nconst arrayHandler: ProxyHandler<any[]> = {\n\tget(target: any, prop: any) {\n\t\tif (prop === TARGET_SYMBOL) return target;\n\t\tif (typeof prop === 'string') { // Convert to int when possible\n\t\t\tconst n = 0|prop as any;\n\t\t\tif (String(n) === prop && n >= 0) prop = n;\n\t\t}\n\t\tsubscribe(target, prop);\n\t\treturn optProxy(target[prop]);\n\t},\n\tset: arraySet,\n\tdeleteProperty(target: any, prop: any) {\n\t\tif (typeof prop === 'string') { // Convert to int when possible\n\t\t\tconst n = 0|prop as any;\n\t\t\tif (String(n) === prop && n >= 0) prop = n;\n\t\t}\n\t\tlet oldData = target[prop];\n\t\tif (oldData === undefined && !target.hasOwnProperty(prop)) oldData = EMPTY;\n\t\tdelete target[prop];\n\t\temit(target, prop, EMPTY, oldData);\n\t\treturn true;\n\t},\n};\n\n/**\n * Helper functions that wrap iterators to proxy values\n */\nfunction wrapIteratorSingle(iterator: IterableIterator<any>): IterableIterator<any> {\n\treturn {\n\t\t[Symbol.iterator]() { return this; },\n\t\tnext() {\n\t\t\tconst result = iterator.next();\n\t\t\tif (result.done) return result;\n\t\t\treturn {\n\t\t\t\tdone: false,\n\t\t\t\tvalue: optProxy(result.value)\n\t\t\t};\n\t\t}\n\t};\n}\nfunction wrapIteratorPair(iterator: IterableIterator<[any, any]>): IterableIterator<[any, any]> {\n\treturn {\n\t\t[Symbol.iterator]() { return this; },\n\t\tnext() {\n\t\t\tconst result = iterator.next();\n\t\t\tif (result.done) return result;\n\t\t\treturn {\n\t\t\t\tdone: false,\n\t\t\t\tvalue: [optProxy(result.value[0]), optProxy(result.value[1])]\n\t\t\t};\n\t\t}\n\t};\n}\n\nconst mapMethodHandlers = {\n\tget(this: any, key: any): any {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\t// Make sure key is unproxied\n\t\tif (typeof key === \"object\" && key)\n\t\t\tkey = (key as any)[TARGET_SYMBOL] || key;\n\t\tsubscribe(target, key);\n\t\treturn optProxy(target.get(key));\n\t},\n\tset(this: any, key: any, newData: any): any {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\t// Make sure key and newData are unproxied\n\t\tif (typeof key === \"object\" && key) {\n\t\t\tkey = (key as any)[TARGET_SYMBOL] || key;\n\t\t}\n\t\tif (typeof newData === \"object\" && newData) {\n\t\t\tnewData = (newData as any)[TARGET_SYMBOL] || newData;\n\t\t}\n\t\tlet oldData = target.get(key);\n\t\tif (oldData === undefined && !target.has(key)) oldData = EMPTY;\n\t\tif (newData !== oldData) {\n\t\t\tconst oldSize = target.size;\n\t\t\ttarget.set(key, newData);\n\t\t\temit(target, key, newData, oldData);\n\t\t\temit(target, MAP_SIZE_SYMBOL, target.size, oldSize);\n\t\t}\n\t\treturn this;\n\t},\n\tdelete(this: any, key: any): boolean {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\t// Make sure key is unproxied\n\t\tif (typeof key === \"object\" && key) {\n\t\t\tkey = (key as any)[TARGET_SYMBOL] || key;\n\t\t}\n\t\tlet oldData = target.get(key);\n\t\tif (oldData === undefined && !target.has(key)) oldData = EMPTY;\n\t\tconst result: boolean = target.delete(key);\n\t\tif (result) {\n\t\t\temit(target, key, EMPTY, oldData);\n\t\t\temit(target, MAP_SIZE_SYMBOL, target.size, target.size + 1);\n\t\t}\n\t\treturn result;\n\t},\n\tclear(this: any): void {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\tconst oldSize = target.size;\n\t\tfor (const key of target.keys()) {\n\t\t\temit(target, key, undefined, target.get(key));\n\t\t}\n\t\ttarget.clear();\n\t\temit(target, MAP_SIZE_SYMBOL, 0, oldSize);\n\t},\n\thas(this: any, key: any): boolean {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\t// Make sure key is unproxied\n\t\tif (typeof key === \"object\" && key) {\n\t\t\tkey = (key as any)[TARGET_SYMBOL] || key;\n\t\t}\n\t\tsubscribe(target, key);\n\t\treturn target.has(key);\n\t},\n\tkeys(this: any): IterableIterator<any> {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\tsubscribe(target, ANY_SYMBOL);\n\t\treturn wrapIteratorSingle(target.keys());\n\t},\n\tvalues(this: any): IterableIterator<any> {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\tsubscribe(target, ANY_SYMBOL);\n\t\treturn wrapIteratorSingle(target.values());\n\t},\n\tentries(this: any): IterableIterator<[any, any]> {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\tsubscribe(target, ANY_SYMBOL);\n\t\treturn wrapIteratorPair(target.entries());\n\t},\n\t[Symbol.iterator](this: any): IterableIterator<[any, any]> {\n\t\tconst target: Map<any, any> = this[TARGET_SYMBOL];\n\t\tsubscribe(target, ANY_SYMBOL);\n\t\treturn wrapIteratorPair(target[Symbol.iterator]());\n\t}\n};\n\nconst mapHandler: ProxyHandler<Map<any, any>> = {\n\tget(target: Map<any, any>, prop: any) {\n\t\tif (prop === TARGET_SYMBOL) return target;\n\t\t\n\t\t// Handle Map methods using lookup object\n\t\tif (mapMethodHandlers.hasOwnProperty(prop)) {\n\t\t\treturn (mapMethodHandlers as any)[prop];\n\t\t}\n\t\t\n\t\t// Handle size property\n\t\tif (prop === \"size\") {\n\t\t\tsubscribe(target, MAP_SIZE_SYMBOL);\n\t\t\treturn target.size;\n\t\t}\n\t\t\n\t\t// Handle other properties normally\n\t\treturn (target as any)[prop];\n\t},\n};\n\nconst proxyMap = new WeakMap<TargetType, /*Proxy*/ TargetType>();\n\nfunction optProxy(value: any): any {\n\t// If value is a primitive type or already proxied, just return it\n\tif (\n\t\ttypeof value !== \"object\" ||\n\t\t!value ||\n\t\tvalue[TARGET_SYMBOL] !== undefined ||\n\t\tNO_COPY in value\n\t) {\n\t\treturn value;\n\t}\n\tlet proxied = proxyMap.get(value);\n\tif (proxied) return proxied; // Only one proxy per target!\n\n\tlet handler;\n\tif (value instanceof Array) {\n\t\thandler = arrayHandler;\n\t} else if (value instanceof Map) {\n\t\thandler = mapHandler;\n\t} else {\n\t\thandler = objectHandler;\n\t}\n\n\tproxied = new Proxy(value, handler);\n\tproxyMap.set(value, proxied as TargetType);\n\treturn proxied;\n}\n\n/**\n * When `proxy` is called with a Promise, the returned object has this shape.\n */\nexport interface PromiseProxy<T> {\n\t/**\n\t * True if the promise is still pending, false if it has resolved or rejected.\n\t */\n\tbusy: boolean;\n\t/**\n\t * If the promise has resolved, this contains the resolved value.\n\t */\n\tvalue?: T;\n\t/**\n\t * If the promise has rejected, this contains the rejection error.\n\t */\n\terror?: any;\n}\n\nexport function proxy<T extends any>(target: Promise<T>): PromiseProxy<T>;\nexport function proxy<T extends any>(target: Array<T>): Array<T extends number ? number : T extends string ? string : T extends boolean ? boolean : T >;\nexport function proxy<T extends object>(target: T): T;\nexport function proxy<T extends any>(target: T): ValueRef<T extends number ? number : T extends string ? string : T extends boolean ? boolean : T>;\n\n/**\n * Creates a reactive proxy around the given data.\n *\n * Reading properties from the returned proxy within a reactive scope (like one created by\n * {@link $} or {@link derive}) establishes a subscription. Modifying properties *through*\n * the proxy will notify subscribed scopes, causing them to re-execute.\n *\n * - Plain objects and arrays are wrapped in a standard JavaScript `Proxy` that intercepts\n * property access and mutations, but otherwise works like the underlying data.\n * - Primitives (string, number, boolean, null, undefined) are wrapped in an object\n * `{ value: T }` which is then proxied. Access the primitive via the `.value` property.\n * - Promises are represented by proxied objects `{ busy: boolean, value?: T, error?: any }`.\n * Initially, `busy` is `true`. When the promise resolves, `value` is set and `busy`\n * is set to `false`. If the promise is rejected, `error` is set and `busy` is also\n * set to `false`.\n *\n * Use {@link unproxy} to get the original underlying data back.\n *\n * @param target - The object, array, or primitive value to make reactive.\n * @returns A reactive proxy wrapping the target data.\n * @template T - The type of the data being proxied.\n *\n * @example Object\n * ```javascript\n * const state = proxy({ count: 0, message: 'Hello' });\n * $(() => console.log(state.message)); // Subscribes to message\n * setTimeout(() => state.message = 'World', 1000); // Triggers the observing function\n * setTimeout(() => state.count++, 2000); // Triggers nothing\n * ```\n *\n * @example Array\n * ```javascript\n * const items = proxy(['a', 'b']);\n * $(() => console.log(items.length)); // Subscribes to length\n * setTimeout(() => items.push('c'), 2000); // Triggers the observing function\n * ```\n *\n * @example Primitive\n * ```javascript\n * const name = proxy('Aberdeen');\n * $(() => console.log(name.value)); // Subscribes to value\n * setTimeout(() => name.value = 'UI', 2000); // Triggers the observing function\n * ```\n *\n * @example Class instance\n * ```typescript\n * class Widget {\n * constructor(public name: string, public width: number, public height: number) {}\n * grow() { this.width *= 2; }\n * toString() { return `${this.name}Widget (${this.width}x${this.height})`; }\n * }\n * let graph: Widget = proxy(new Widget('Graph', 200, 100));\n * $(() => console.log(''+graph));\n * setTimeout(() => graph.grow(), 2000);\n * setTimeout(() => graph.grow(), 4000);\n * ```\n */\nexport function proxy(target: TargetType): TargetType {\n\tif (target instanceof Promise) {\n\t\tconst result: PromiseProxy<any> = optProxy({\n\t\t\tbusy: true,\n\t\t});\n\t\ttarget\n\t\t\t.then((value) => {\n\t\t\t\tresult.value = value;\n\t\t\t\tresult.busy = false;\n\t\t\t})\n\t\t\t.catch((err) => {\n\t\t\t\tresult.error = err;\n\t\t\t\tresult.busy = false;\n\t\t\t});\n\t\treturn result;\n\t}\n\treturn optProxy(\n\t\ttypeof target === \"object\" && target !== null ? target : { value: target },\n\t);\n}\n\n/**\n * Returns the original, underlying data target from a reactive proxy created by {@link proxy}.\n * If the input `target` is not a proxy, it is returned directly.\n *\n * This is useful when you want to avoid triggering subscriptions during read operations or\n * re-executes during write operations. Using {@link peek} is an alternative way to achieve this.\n *\n * @param target - A proxied object, array, or any other value.\n * @returns The underlying (unproxied) data, or the input value if it wasn't a proxy.\n * @template T - The type of the target.\n *\n * @example\n * ```typescript\n * const userProxy = proxy({ name: 'Frank' });\n * const rawUser = unproxy(userProxy);\n *\n * // Log reactively\n * $(() => console.log('proxied', userProxy.name));\n * // The following will only ever log once, as we're not subscribing to any observable\n * $(() => console.log('unproxied', rawUser.name));\n *\n * // This cause the first log to run again:\n * setTimeout(() => userProxy.name += '!', 1000);\n *\n * // This doesn't cause any new logs:\n * setTimeout(() => rawUser.name += '?', 2000);\n *\n * // Both userProxy and rawUser end up as `{name: 'Frank!?'}`\n * setTimeout(() => {\n * console.log('final proxied', userProxy)\n * console.log('final unproxied', rawUser)\n * }, 3000);\n * ```\n */\nexport function unproxy<T>(target: T): T {\n\treturn target ? (target as any)[TARGET_SYMBOL] || target : target;\n}\n\nconst onDestroyMap: WeakMap<Node, string | ((...args: any[]) => void) | true> =\n\tnew WeakMap();\n\nfunction destroyWithClass(element: Element, cls: string) {\n\tconst classes = cls.split(\".\").filter((c) => c);\n\telement.classList.add(...classes);\n\tsetTimeout(() => element.remove(), 2000);\n}\n\n/**\n * Recursively copies properties or array items from `src` to `dst`.\n * It's designed to work efficiently with reactive proxies created by {@link proxy}.\n *\n * - **Minimizes Updates:** When copying between objects/arrays (proxied or not), if a nested object\n * exists in `dst` with the same constructor as the corresponding object in `src`, `copy`\n * will recursively copy properties into the existing `dst` object instead of replacing it.\n * This minimizes change notifications for reactive updates.\n * - **Handles Proxies:** Can accept proxied or unproxied objects/arrays for both `dst` and `src`.\n * - **Cross-Type Copying:** Supports copying between Maps and objects. When copying from an object\n * to a Map, object properties become Map entries. When copying from a Map to an object, Map entries\n * become object properties (only for Maps with string/number/symbol keys).\n *\n * @param dst - The destination object/array/Map (proxied or unproxied).\n * @param src - The source object/array/Map (proxied or unproxied). It won't be modified.\n * @template T - The type of the objects being copied.\n * @returns `true` if any changes were made to `dst`, or `false` if not.\n * @throws Error if attempting to copy an array into a non-array or vice versa.\n *\n * @example Basic Copy\n * ```typescript\n * const source = proxy({ a: 1, b: { c: 2 } });\n * const dest = proxy({ b: { d: 3 } });\n * copy(dest, source);\n * console.log(dest); // proxy({ a: 1, b: { c: 2 } })\n * copy(dest, 'b', { e: 4 });\n * console.log(dest); // proxy({ a: 1, b: { e: 4 } })\n * ```\n */\n\nexport function copy<T extends object>(dst: T, src: T): boolean;\n/**\n * Like above, but copies `src` into `dst[dstKey]`. This is useful if you're unsure if dst[dstKey]\n * already exists (as the right type of object) or if you don't want to subscribe to dst[dstKey].\n * \n * @param dstKey - Optional key in `dst` to copy into. \n */\nexport function copy<T extends object>(dst: T, dstKey: keyof T, src: T[typeof dstKey]): boolean;\nexport function copy(a: any, b: any, c?: any): boolean {\n\tif (arguments.length > 2) return copySet(a, b, c, 0);\n\treturn copyImpl(a, b, 0);\n}\n\nfunction copySet(dst: any, dstKey: any, src: any, flags: number): boolean {\n\tlet dstVal = peek(dst, dstKey);\n\tif (src === dstVal) return false;\n\tif (typeof dstVal === \"object\" && dstVal && typeof src === \"object\" && src && dstVal.constructor === src.constructor) {\n\t\treturn copyImpl(dstVal, src, flags);\n\t}\n\tsrc = clone(src); \n\tif (dst instanceof Map) dst.set(dstKey, src);\n\telse dst[dstKey] = clone(src);\n\treturn true;\n}\n\n/**\n * Like {@link copy}, but uses merge semantics. Properties in `dst` not present in `src` are kept.\n * `null`/`undefined` in `src` delete properties in `dst`.\n * \n * When the destination is an object and the source is an array, its keys are used as (sparse) array indices.\n * \n * @example Basic merge\n * ```typescript\n * const source = { b: { c: 99 }, d: undefined }; // d: undefined will delete\n * const dest = proxy({ a: 1, b: { x: 5 }, d: 4 });\n * merge(dest, source);\n * merge(dest, 'b', { y: 6 }); // merge into dest.b\n * merge(dest, 'c', { z: 7 }); // merge.c doesn't exist yet, so it will just be assigned\n * console.log(dest); // proxy({ a: 1, b: { c: 99, x: 5, y: 6 }, c: { z: 7 } })\n * ```\n *\n * @example Partial Array Merge\n * ```typescript\n * const messages = proxy(['msg1', 'msg2', 'msg3']);\n * const update = { 1: 'updated msg2' }; // Update using object key as index\n * merge(messages, update);\n * console.log(messages); // proxy(['msg1', 'updated msg2', 'msg3'])\n * ```\n *\n */\nexport function merge<T extends object>(dst: T, value: Partial<T>): boolean;\nexport function merge<T extends object>(dst: T, dstKey: keyof T, value: Partial<T[typeof dstKey]>): boolean;\nexport function merge(a: any, b: any, c?: any) {\n\tif (arguments.length > 2) return copySet(a, b, c, MERGE);\n\treturn copyImpl(a, b, MERGE);\n}\n\nfunction copyImpl(dst: any, src: any, flags: number): boolean {\n\t// We never want to subscribe to reads we do to the target (to find changes). So we'll\n\t// take the unproxied version and `emit` updates ourselve.\n\tlet unproxied = (dst as any)[TARGET_SYMBOL];\n\tif (unproxied) {\n\t\tdst = unproxied;\n\t\tflags |= COPY_EMIT;\n\t}\n\t// For performance, we'll work on the unproxied `src` and manually subscribe to changes.\n\tunproxied = (src as any)[TARGET_SYMBOL];\n\tif (unproxied) {\n\t\tsrc = unproxied;\n\t\t// If we're not in peek mode, we'll manually subscribe to all source reads.\n\t\tif (currentScope !== ROOT_SCOPE && !peeking) flags |= COPY_SUBSCRIBE;\n\t}\n\n\treturn copyRecursive(dst, src, flags);\n}\n\n// The dst and src parameters must be objects. Will throw a friendly message if they're not both the same type.\nfunction copyRecursive<T extends object>(dst: T, src: T, flags: number): boolean {\n\n\tif (flags & COPY_SUBSCRIBE) subscribe(src, ANY_SYMBOL);\n\tlet changed = false;\n\n\t// The following loops are somewhat repetitive, but it keeps performance high by avoiding\n\t// function calls and extra checks within the loops.\n\n\tif (src instanceof Array && dst instanceof Array) {\n\t\tconst dstLen = dst.length;\n\t\tconst srcLen = src.length;\n\t\tfor (let index = 0; index < srcLen; index++) {\n\t\t\t// changed = copyValue(dst, i, src[i], flags) || changed;\n\n\t\t\tlet dstValue = dst[index];\n\t\t\tif (dstValue === undefined && !dst.hasOwnProperty(index)) dstValue = EMPTY;\n\t\t\tlet srcValue = src[index];\n\t\t\tif (srcValue === undefined && !src.hasOwnProperty(index)) {\n\t\t\t\tdelete dst[index];\n\t\t\t\tif (flags & COPY_EMIT) emit(dst, index, EMPTY, dstValue);\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t\telse if (dstValue !== srcValue) {\n\t\t\t\tif (srcValue && typeof srcValue === \"object\") {\n\t\t\t\t\tif (typeof dstValue === \"object\" && dstValue && srcValue.constructor === dstValue.constructor && !(NO_COPY in srcValue)) {\n\t\t\t\t\t\tchanged = copyRecursive(dstValue, srcValue, flags) || changed;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tsrcValue = clone(srcValue);\n\t\t\t\t}\n\t\t\t\tdst[index] = srcValue;\n\n\t\t\t\tif (flags & COPY_EMIT) emit(dst, index, srcValue, dstValue);\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t}\n\n\t\t// Leaving additional values in the old array doesn't make sense, so we'll do this even when MERGE is set:\n\t\tif (srcLen !== dstLen) {\n\t\t\tif (flags & COPY_EMIT) {\n\t\t\t\tfor (let i = srcLen; i < dstLen; i++) {\n\t\t\t\t\tconst old = dst[i];\n\t\t\t\t\tdelete dst[i];\n\t\t\t\t\temit(dst, i, EMPTY, old);\n\t\t\t\t}\n\t\t\t\tdst.length = srcLen;\n\t\t\t\temit(dst, \"length\", srcLen, dstLen);\n\t\t\t} else {\n\t\t\t\tdst.length = srcLen;\n\t\t\t}\n\t\t\tchanged = true;\n\t\t}\n\t} else if (src instanceof Map && dst instanceof Map) {\n\t\tfor (const key of src.keys()) {\n\t\t\t// changed = copyValue(dst, k, src.get(k), flags) || changed;\n\t\t\tlet srcValue = src.get(key);\n\t\t\tlet dstValue = dst.get(key);\n\t\t\tif (dstValue === undefined && !dst.has(key)) dstValue = EMPTY;\n\t\t\tif (dstValue !== srcValue) {\n\t\t\t\tif (srcValue && typeof srcValue === \"object\") {\n\t\t\t\t\tif (typeof dstValue === \"object\" && dstValue && srcValue.constructor === dstValue.constructor && !(NO_COPY in srcValue)) {\n\t\t\t\t\t\tchanged = copyRecursive(dstValue, srcValue, flags) || changed;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tsrcValue = clone(srcValue);\n\t\t\t\t}\n\n\t\t\t\tdst.set(key, srcValue);\n\n\t\t\t\tif (flags & COPY_EMIT) emit(dst, key, srcValue, dstValue);\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t}\n\n\t\tif (!(flags & MERGE)) {\n\t\t\tfor (const k of dst.keys()) {\n\t\t\t\tif (!src.has(k)) {\n\t\t\t\t\tconst old = dst.get(k);\n\t\t\t\t\tdst.delete(k);\n\t\t\t\t\tif (flags & COPY_EMIT) {\n\t\t\t\t\t\temit(dst, k, undefined, old);\n\t\t\t\t\t}\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (src.constructor === dst.constructor) {\n\t\tfor (const key of Object.keys(src) as (keyof typeof src)[]) {\n\t\t\t// changed = copyValue(dst, k, src[k as keyof typeof src], flags) || changed;\n\t\t\tlet srcValue = src[key];\n\t\t\tconst dstValue = dst.hasOwnProperty(key) ? dst[key] : EMPTY;\n\t\t\tif (dstValue !== srcValue) {\n\t\t\t\tif (srcValue && typeof srcValue === \"object\") {\n\t\t\t\t\tif (typeof dstValue === \"object\" && dstValue && srcValue.constructor === dstValue.constructor && !(NO_COPY in srcValue)) {\n\t\t\t\t\t\tchanged = copyRecursive(dstValue as typeof srcValue, srcValue, flags) || changed;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tsrcValue = clone(srcValue);\n\t\t\t\t}\n\n\t\t\t\tdst[key] = srcValue;\n\n\t\t\t\tif (flags & COPY_EMIT) emit(dst, key, srcValue, dstValue);\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t}\n\n\t\tif (!(flags & MERGE)) {\n\t\t\tfor (const k of Object.keys(dst) as (keyof typeof dst)[]) {\n\t\t\t\tif (!src.hasOwnProperty(k)) {\n\t\t\t\t\tconst old = dst[k];\n\t\t\t\t\tdelete dst[k];\n\t\t\t\t\tif (flags & COPY_EMIT && old !== undefined) {\n\t\t\t\t\t\temit(dst, k, undefined, old);\n\t\t\t\t\t}\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tthrow new Error(`Incompatible or non-object types: ${src?.constructor?.name || typeof src} vs ${dst?.constructor?.name || typeof dst}`);\n\t}\n\treturn changed;\n}\n\nconst MERGE = 1;\nconst COPY_SUBSCRIBE = 32;\nconst COPY_EMIT = 64;\n\n/**\n * A symbol that can be added to an object to prevent it from being cloned by {@link clone} or {@link copy}.\n * This is useful for objects that should be shared by reference. That also mean that their contents won't\n * be observed for changes.\n */\nexport const NO_COPY = Symbol(\"NO_COPY\");\n\n// Promises break when proxied, so we'll just mark them as NO_COPY\n(Promise.prototype as any)[NO_COPY] = true;\n\n/**\n * CSS variable lookup table for the `@` value prefix.\n * \n * When a CSS value starts with `@`, the rest is used as a key to look up the actual value.\n * Pre-initialized with keys '1'-'12' mapping to an exponential rem scale (e.g., @1=0.25rem, @3=1rem).\n * \n * @example\n * ```typescript\n * cssVars.primary = '#3b82f6';\n * cssVars[3] = '16px'; // Override @3 to be 16px instead of 1rem\n * $('p color:@primary'); // Sets color to #3b82f6\n * $('div mt:@3'); // Sets margin-top to 16px\n * ```\n */\nexport const cssVars: Record<string, string> = optProxy({});\n\nfor (let i = 1; i <= 12; i++) {\n\tcssVars[i] = 2 ** (i - 3) + \"rem\";\n}\n\n/**\n * Clone an (optionally proxied) object or array.\n *\n * @param src The object or array to clone. If it is proxied, `clone` will subscribe to any changes to the (nested) data structure.\n * @template T - The type of the objects being copied.\n * @returns A new unproxied array or object (of the same type as `src`), containing a deep copy of `src`.\n */\nexport function clone<T extends object>(src: T): T {\n\tif (NO_COPY in src) return src;\n\t// Create an empty object of the same type\n\tconst copied = Array.isArray(src) ? [] : src instanceof Map ? new Map() : Object.create(Object.getPrototypeOf(src));\n\t// Copy all properties to it. This doesn't need to emit anything, and because\n\t// the destination is an empty object, we can just MERGE, which is a bit faster.\n\tcopyImpl(copied, src, MERGE);\n\treturn copied;\n}\n\ninterface RefTarget {\n\tproxy: TargetType;\n\tindex: any;\n}\nconst refHandler: ProxyHandler<RefTarget> = {\n\tget(target: RefTarget, prop: any) {\n\t\tif (prop === TARGET_SYMBOL) {\n\t\t\t// Create a ref to the unproxied version of the target\n\t\t\treturn ref(unproxy(target.proxy), target.index);\n\t\t}\n\t\tif (prop === \"value\") {\n\t\t\treturn (target.proxy as any)[target.index];\n\t\t}\n\t},\n\tset(target: any, prop: any, value: any) {\n\t\tif (prop === \"value\") {\n\t\t\t(target.proxy as any)[target.index] = value;\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t},\n};\n\n/**\n * Creates a reactive reference (`{ value: T }`-like object) to a specific value\n * within a proxied object or array.\n *\n * This is primarily used for the `bind` property in {@link $} to create two-way data bindings\n * with form elements, and for passing a reactive property to any of the {@link $} key-value pairs.\n *\n * Reading `ref.value` accesses the property from the underlying proxy (and subscribes the current scope).\n * Assigning to `ref.value` updates the property in the underlying proxy (triggering reactive updates).\n *\n * @param target - The reactive proxy (created by {@link proxy}) containing the target property.\n * @param index - The key (for objects) or index (for arrays) of the property to reference.\n * @returns A reference object with a `value` property linked to the specified proxy property.\n *\n * @example\n * ```javascript\n * const formData = proxy({ color: 'orange', velocity: 42 });\n *\n * // Usage with `bind`\n * $('input type=text bind=', ref(formData, 'color'));\n *\n * // Usage as a dynamic property, causes a TextNode with just the name to be created and live-updated\n * $('p text=\"Selected color: \" text=', ref(formData, 'color'), 'color:', ref(formData, 'color'));\n *\n * // Changes are actually stored in formData - this causes logs like `{color: \"Blue\", velocity 42}`\n * $(() => console.log(formData))\n * ```\n */\nexport function ref<T extends TargetType, K extends keyof T>(\n\ttarget: T,\n\tindex: K,\n): ValueRef<T[K]> {\n\treturn new Proxy({ proxy: target, index }, refHandler) as any as ValueRef<\n\t\tT[K]\n\t>;\n}\n\nfunction applyBind(el: HTMLInputElement, target: any) {\n\tlet onProxyChange: () => void;\n\tlet onInputChange: () => void;\n\tconst type = el.getAttribute(\"type\");\n\tconst value = unproxy(target).value;\n\tif (type === \"checkbox\") {\n\t\tif (value === undefined) target.value = el.checked;\n\t\tonProxyChange = () => {\n\t\t\tel.checked = target.value;\n\t\t};\n\t\tonInputChange = () => {\n\t\t\ttarget.value = el.checked;\n\t\t};\n\t} else if (type === \"radio\") {\n\t\tif (value === undefined && el.checked) target.value = el.value;\n\t\tonProxyChange = () => {\n\t\t\tel.checked = target.value === el.value;\n\t\t};\n\t\tonInputChange = () => {\n\t\t\tif (el.checked) target.value = el.value;\n\t\t};\n\t} else {\n\t\tonInputChange = () => {\n\t\t\ttarget.value =\n\t\t\t\ttype === \"number\" || type === \"range\"\n\t\t\t\t\t? el.value === \"\"\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: +el.value\n\t\t\t\t\t: el.value;\n\t\t};\n\t\tif (value === undefined) onInputChange();\n\t\tonProxyChange = () => {\n\t\t\tel.value = target.value;\n\t\t\t// biome-ignore lint/suspicious/noDoubleEquals: it's fine for numbers to be casts to strings here\n\t\t\tif (el.tagName === \"SELECT\" && el.value != target.value) {\n\t\t\t\t// Presumable, OPTIONs haven't been created yet. Try again after all currently queued work has been done.\n\t\t\t\tnew DelayedOneTimeRunner(() => el.value = target.value);\n\t\t\t}\n\t\t};\n\t}\n\tderive(onProxyChange);\n\tel.addEventListener(\"input\", onInputChange);\n\tclean(() => {\n\t\tel.removeEventListener(\"input\", onInputChange);\n\t});\n}\n\nconst SPECIAL_PROPS: { [key: string]: (el: Element, value: any) => void } = {\n\tcreate: (el: Element, value: any) => {\n\t\tif (currentScope !== topRedrawScope) return;\n\t\tif (typeof value === \"function\") {\n\t\t\tvalue(el);\n\t\t} else {\n\t\t\tconst classes = value.split(\".\").filter((c: any) => c);\n\t\t\tel.classList.add(...classes);\n\t\t\t(async () => {\n\t\t\t\t// attempt to prevent layout trashing\n\t\t\t\t(el as HTMLElement).offsetHeight; // trigger layout\n\t\t\t\tel.classList.remove(...classes);\n\t\t\t})();\n\t\t}\n\t},\n\tdestroy: (el: Element, value: any) => {\n\t\tonDestroyMap.set(el, value);\n\t},\n\thtml: (el: Element, value: any) => {\n\t\tconst tmpParent = document.createElement(\n\t\t\tcurrentScope.el.tagName,\n\t\t);\n\t\ttmpParent.innerHTML = `${value}`;\n\t\twhile (tmpParent.firstChild) addNode(el, tmpParent.firstChild);\n\t},\n\ttext: (el: Element, value: any) => {\n\t\taddNode(el, document.createTextNode(value));\n\t},\n};\n\n/**\n * The core function for building reactive user interfaces in Aberdeen. It creates and inserts new DOM elements\n * and sets attributes/properties/event listeners on DOM elements. It does so in a reactive way, meaning that\n * changes will be (mostly) undone when the current *scope* is destroyed or will be re-execute.\n *\n * @param {...(string | function | object | false | undefined | null)} args - Any number of arguments can be given. How they're interpreted depends on their types:\n *\n * - `string`: Strings can be used to create and insert new elements, set classnames for the *current* element, and add text to the current element.\n * The format of a string is: (**tag** | `.` **class** | **key**=**val** | **key**=\"**long val**\")* ('#' **text** | **key**=)?\n * So there can be:\n * - Any number of **tag** element, like `h1` or `div`. These elements are created, added to the *current* element, and become the new *current* element for the rest of this `$` function execution.\n * - Any number of CSS classes prefixed by `.` characters. These classes will be added to the *current* element. Optionally, CSS classes can be appended to a **tag** without a space. So both `div.myclass` and `div .myclass` are valid and do the same thing.\n * - Any number of key/value pairs with string values, like `placeholder=\"Your name\"` or `data-id=123`. These will be handled according to the rules specified for `object`, below, but with the caveat that values can only be strings. The quotes around string values are optional, unless the value contains spaces. It's not possible to escape quotes within the value. If you want to do that, or if you have user-provided values, use the `object` syntax (see below) or end your string with `key=` followed by the data as a separate argument (see below).\n * - The string may end in a '#' followed by text, which will be added as a TextNode to the *current* element. The text ranges til the end of the string, and may contain any characters, including spaces and quotes.\n * - Alternatively, the string may end in a key followed by an '=' character, in which case the value is expected as a separate argument. The key/value pair is set according to the rules specified for `object` below. This is useful when the value is not a string or contains spaces or user data. Example: `$('button text=\"Click me\" click=', () => alert('Clicked!'))` or `$('input.value=', someUserData, \"placeholder=\", \"Type your stuff\")`.\n * - `function`: When a function (without argument nor a return value) is passed in, it will be reactively executed in its own observer scope, preserving the *current element*. So any `$()` invocations within this function will create DOM elements with our *current* element as parent. If the function reads observable data, and that data is changed later on, the function we re-execute (after side effects, such as DOM modifications through `$`, have been cleaned - see also {@link clean}).\n * - `object`: When an object is passed in, its key-value pairs are used to modify the *current* element in the following ways...\n * - `{<attrName>: any}`: The common case is setting the value as an HTML attribute named key. So `{placeholder: \"Your name\"}` would add `placeholder=\"Your name\"` to the current HTML element.\n * - `{<propName>: boolean}` or `{value: any}` or `{selectedIndex: number}`: If the value is a boolean, or if the key is `value` or `selectedIndex`, it is set on the `current` element as a DOM property instead of an HTML attribute. For example `{checked: true}` would do `el.checked = true` for the *current* element.\n * - `{\".class\": boolean}`: If the key starts with a `.` character, its either added to or removed from the *current* element as a CSS class, based on the truthiness of the value. So `{\".hidden\": hide}` would toggle the `hidden` CSS class.\n * - `{<eventName>: function}`: If the value is a `function` it is set as an event listener for the event with the name given by the key. For example: `{click: myClickHandler}`.\n * - `{$<styleProp>: value}`: If the key starts with a `$` character, set a CSS style property with the name of the rest of the key to the given value. Example: `{$backgroundColor: 'red'}`.\n * - `{create: string}`: Add the value string as a CSS class to the *current* element, *after* the browser has finished doing a layout pass. This behavior only triggers when the scope setting the `create` is the top-level scope being (re-)run. This allows for creation transitions, without triggering the transitions for deeply nested elements being drawn as part of a larger component. The string may also contain multiple dot-separated CSS classes, such as `.fade.grow`.\n * - `{destroy: string}`: When the *current* element is a top-level element to be removed (due to reactivity cleanup), actual removal from the DOM is delayed by 2 seconds, and in the mean time the value string is added as a CSS class to the element, allowing for a deletion transition. The string may also contain multiple dot-separated CSS classes, such as `.fade.shrink`.\n * - `{create: function}` and `{destroy: function}`: The function is invoked when the *current* element is the top-level element being created/destroyed. It can be used for more involved creation/deletion animations. In case of `destroy`, the function is responsible for actually removing the element from the DOM (eventually). See `transitions.ts` in the Aberdeen source code for some examples.\n * - `{bind: <obsValue>}`: Create a two-way binding element between the `value` property of the given observable (proxy) variable, and the *current* input element (`<input>`, `<select>` or `<textarea>`). This is often used together with {@link ref}, in order to use properties other than `.value`.\n * - `{<any>: <obsvalue>}`: Create a new observer scope and read the `value` property of the given observable (proxy) variable from within it, and apply the contained value using any of the other rules in this list. Example:\n * ```typescript\n * const myColor = proxy('red');\n * $('p#Test', {$color: myColor, click: () => myColor.value = 'yellow'})\n * // Clicking the text will cause it to change color without recreating the <p> itself\n * ```\n * This is often used together with {@link ref}, in order to use properties other than `.value`.\n * - `{text: string|number}`: Add the value as a `TextNode` to the *current* element.\n * - `{html: string}`: Add the value as HTML to the *current* element. This should only be used in exceptional situations. And of course, beware of XSS.\n - `Node`: If a DOM Node (Element or TextNode) is passed in, it is added as a child to the *current* element. If the Node is an Element, it becomes the new *current* element for the rest of this `$` function execution.\n *\n * @returns The most inner DOM element that was created (not counting text nodes nor elements created by content functions),\n * or undefined if no elements were created.\n *\n * @example Create Element\n * ```typescript\n * $('button.secondary.outline text=Submit color:red disabled=', false, 'click=', () => console.log('Clicked!'));\n * ```\n * \n * We want to set `disabled` as a property instead of an attribute, so we must use the `key=` syntax in order to provide\n * `false` as a boolean instead of a string.\n *\n * @example Create Nested Elements\n * ```typescript\n * let inputElement: Element = $('label text=\"Click me\" input type=checkbox');\n * // You should usually not touch raw DOM elements, unless when integrating\n * // with non-Aberdeen code.\n * console.log('DOM element:', inputElement);\n * ```\n *\n * @example Content Functions & Reactive Scope\n * ```typescript\n * const state = proxy({ count: 0 });\n * $('div', () => { // Outer element\n * // This scope re-renders when state.count changes\n * $(`p#Count is ${state.count}`);\n * $('button text=Increment click=', () => state.count++);\n * });\n * ```\n *\n * @example Two-way Binding\n * ```typescript\n * const user = proxy({ name: '' });\n * $('input placeholder=Name bind=', ref(user, 'name'));\n * $('h3', () => { // Reactive scope\n * $(`#Hello ${user.name || 'stranger'}`);\n * });\n * ```\n *\n * @example Conditional Rendering\n * ```typescript\n * const show = proxy(false);\n * $('button click=', () => show.value = !show.value, () => $(show.value ? '#Hide' : '#Show'));\n * $(() => { // Reactive scope\n * if (show.value) {\n * $('p#Details are visible!');\n * }\n * });\n * ```\n */\n\nexport function $(...args: any[]): undefined | Element {\n\tlet el: undefined | Element = currentScope.el;\n\tlet svg: boolean = currentScope.svg\n\n\tconst argCount = args.length;\n\tfor(let argIndex = 0; argIndex < argCount; argIndex++) {\n\t\tconst arg = args[argIndex];\n\t\tif (arg == null || arg === false) {\n\t\t\t// Ignore\n\t\t} else if (typeof arg === \"string\") {\n\t\t\tlet argLen = arg.length;\n\t\t\tlet nextPos = 0;\n\t\t\tfor(let pos=0; pos<argLen; pos=nextPos+1) {\n\t\t\t\tnextPos = findFirst(arg, \" .=:#\", pos);\n\t\t\t\tconst next = arg[nextPos];\n\n\t\t\t\tif (next === \":\" || next === \"=\") {\n\t\t\t\t\tlet key = arg.substring(pos, nextPos);\n\t\t\t\t\tif (next === ':') key = '$' + key; // Style prefix\n\t\t\t\t\tif (nextPos + 1 >= argLen) {\n\t\t\t\t\t\tapplyArg(el, key, args[++argIndex]);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (arg[nextPos+1] === '\"') {\n\t\t\t\t\t\tconst endIndex = findFirst(arg, '\"', nextPos + 2);\n\t\t\t\t\t\tconst value = arg.substring(nextPos+2, endIndex);\n\t\t\t\t\t\tapplyArg(el, key, value);\n\t\t\t\t\t\tnextPos = endIndex;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst endIndex = findFirst(arg, \" \", nextPos + 1);\n\t\t\t\t\t\tconst value = arg.substring(nextPos + 1, endIndex);\n\t\t\t\t\t\tapplyArg(el, key, value);\n\t\t\t\t\t\tnextPos = endIndex;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (nextPos > pos) { // Up til this point if non-empty, is a tag\n\t\t\t\t\t\tconst tag = arg.substring(pos, nextPos);\n\t\t\t\t\t\t// Determine which namespace to use for element creation\n\t\t\t\t\t\tsvg ||= tag === 'svg';\n\t\t\t\t\t\tlet newEl = svg ? document.createElementNS('http://www.w3.org/2000/svg', tag) : document.createElement(tag);\n\t\t\t\t\t\taddNode(el, newEl);\n\t\t\t\t\t\tel = newEl;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (next === \"#\") { // The rest of the string is text (or a text arg follows)\t\n\t\t\t\t\t\tconst text = nextPos + 1 < argLen ? arg.substring(nextPos + 1) : args[++argIndex];\n\t\t\t\t\t\tapplyArg(el, \"text\", text);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (next === \".\") { // Class name\n\t\t\t\t\t\tlet classEnd = findFirst(arg, \" #=.\", nextPos + 1);\n\t\t\t\t\t\tif (arg[classEnd] === '=' && classEnd + 1 >= argLen) {\n\t\t\t\t\t\t\t// Conditional class name. Pass to applyArg including the leading '.'\n\t\t\t\t\t\t\tapplyArg(el, arg.substring(nextPos, classEnd), args[++argIndex]);\n\t\t\t\t\t\t\tnextPos = classEnd;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlet className: any = arg.substring(nextPos + 1, classEnd);\n\t\t\t\t\t\t\tel.classList.add(className || args[++argIndex]);\n\t\t\t\t\t\t\tnextPos = classEnd - 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (typeof arg === \"object\") {\n\t\t\tif (arg.constructor !== Object) {\n\t\t\t\tif (arg instanceof Node) {\n\t\t\t\t\taddNode(el, arg);\n\t\t\t\t\tif (arg instanceof Element) {\n\t\t\t\t\t\tel = arg;\n\t\t\t\t\t\tsvg = arg.namespaceURI === 'http://www.w3.org/2000/svg';\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(`Unexpected argument: ${arg}`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (const key of Object.keys(arg)) {\n\t\t\t\t\tapplyArg(el, key, arg[key]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (typeof arg === \"function\") {\n\t\t\tnew RegularScope(el, svg, arg);\n\t\t} else {\n\t\t\tthrow new Error(`Unexpected argument: ${arg}`);\n\t\t}\n\t}\n\treturn el;\n}\n\nfunction findFirst(str: string, chars: string, startPos: number): number {\n\tif (chars.length === 1) {\n\t\tconst idx = str.indexOf(chars, startPos);\n\t\treturn idx >= 0 ? idx : str.length;\n\t}\n\tconst strLen = str.length;\n\tfor (let i = startPos; i < strLen; i++) {\n\t\tif (chars.indexOf(str[i]) >= 0) return i;\n\t}\n\treturn strLen;\n}\n\nlet cssCount = 0;\n\n/**\n * Inserts CSS rules into the document, scoping them with a unique class name.\n *\n * Takes a JavaScript object representation of CSS rules. camelCased property keys are\n * converted to kebab-case (e.g., `fontSize` becomes `font-size`).\n *\n * @param style - An object where keys are CSS selectors (or camelCased properties) and values are\n * CSS properties or nested rule objects.\n * - Selectors are usually combined as a descendant-relationship (meaning just a space character) with their parent selector.\n * - In case a selector contains a `&`, that character will be replaced by the parent selector.\n * - Selectors will be split on `,` characters, each combining with the parent selector with *or* semantics.\n * - Selector starting with `'@'` define at-rules like media queries. They may be nested within regular selectors.\n * @param global - Deprecated! Use {@link insertGlobalCss} instead.\n * @returns The unique class name prefix used for scoping (e.g., `.AbdStl1`). Use this \n * prefix with {@link $} to apply the styles.\n *\n * @example Scoped Styles\n * ```typescript\n * const scopeClass = insertCss({\n * color: 'red',\n * padding: '10px',\n * '&:hover': { // Use '&' for the root scoped selector\n * backgroundColor: '#535'\n * },\n * '.child-element': { // Nested selector\n * fontWeight: 'bold'\n * },\n * '@media (max-width: 600px)': {\n * padding: '5px'\n * }\n * });\n * // scopeClass might be \".AbdStl1\"\n *\n * // Apply the styles\n * $(scopeClass, () => { // Add class to the div\n * $(`#Scoped content`);\n * $('div.child-element#Child'); // .AbdStl1 .child-element rule applies\n * });\n * ```\n */\nexport function insertCss(style: object, global = false): string {\n\tconst prefix = global ? \"\" : `.AbdStl${++cssCount}`;\n\tconst css = styleToCss(style, prefix);\n\tif (css) $(`style#${css}`);\n\treturn prefix;\n}\n\n/**\n * Inserts CSS rules globally.\n * \n * Works exactly like {@link insertCss}, but without prefixing selectors with a unique class name.\n * \n * @example Global Styles\n * ```typescript\n * insertGlobalCss({\n * '*': {\n * fontFamily: 'monospace',\n * m: 0, // Using shortcut for margin\n * },\n * 'a': {\n * textDecoration: 'none',\n * fg: \"@primary\", // Using foreground shortcut and CSS variable\n * }\n * });\n *\n * $('a#Styled link');\n * ```\n */\nexport function insertGlobalCss(style: object): string {\n\treturn insertCss(style, true);\n}\n\nconst CSS_SHORT: Record<string, string | string[]> = {\n\tm: \"margin\",\n\tmt: \"marginTop\",\n\tmb: \"marginBottom\",\n\tml: \"marginLeft\",\n\tmr: \"marginRight\",\n\tmh: [\"marginLeft\", \"marginRight\"],\n\tmv: [\"marginTop\", \"marginBottom\"],\n\tp: \"padding\",\n\tpt: \"paddingTop\",\n\tpb: \"paddingBottom\",\n\tpl: \"paddingLeft\",\n\tpr: \"paddingRight\",\n\tph: [\"paddingLeft\", \"paddingRight\"],\n\tpv: [\"paddingTop\", \"paddingBottom\"],\n\tw: \"width\",\n\th: \"height\",\n\tbg: \"background\",\n\tfg: \"color\",\n\tr: \"borderRadius\",\n};\n\nfunction styleToCss(style: object, prefix: string): string {\n\tlet props = \"\";\n\tlet rules = \"\";\n\tfor (const kOr of Object.keys(style)) {\n\t\tconst v = (style as any)[kOr];\n\t\tfor (const k of kOr.split(/, ?/g)) {\n\t\t\tif (v && typeof v === \"object\") {\n\t\t\t\tif (k.startsWith(\"@\")) {\n\t\t\t\t\t// media queries\n\t\t\t\t\trules += `${k}{\\n${styleToCss(v, prefix)}}\\n`;\n\t\t\t\t} else {\n\t\t\t\t\trules += styleToCss(\n\t\t\t\t\t\tv,\n\t\t\t\t\t\tk.includes(\"&\") ? k.replace(/&/g, prefix) : `${prefix} ${k}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst val = v == null || v === false ? \"\" : typeof v === 'string' ? (v[0] === '@' ? (cssVars as any)[v.substring(1)] || \"\" : v) : String(v);\n\t\t\t\tconst expanded = CSS_SHORT[k] || k;\n\t\t\t\tfor (const prop of (Array.isArray(expanded) ? expanded : [expanded])) {\n\t\t\t\t\tprops += `${prop.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}:${val};`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (props) rules = `${prefix.trimStart() || \"*\"}{${props}}\\n${rules}`;\n\treturn rules;\n}\n\nfunction applyArg(el: Element, key: string, value: any) {\n\tif (typeof value === \"object\" && value !== null && value[TARGET_SYMBOL]) {\n\t\t// Value is a proxy\n\t\tif (key === \"bind\") {\n\t\t\tapplyBind(el as HTMLInputElement, value);\n\t\t} else {\n\t\t\tnew SetArgScope(el, key, value);\n\t\t\t// SetArgScope will (repeatedly) call `applyArg` again with the actual value\n\t\t}\n\t} else if (key[0] === \".\") {\n\t\t// CSS class(es)\n\t\tconst classes = key.substring(1).split(\".\");\n\t\tif (value) el.classList.add(...classes);\n\t\telse el.classList.remove(...classes);\n\t} else if (key[0] === \"$\") {\n\t\t// Style (with shortcuts)\n\t\tkey = key.substring(1);\n\t\tconst val = value == null || value === false ? \"\" : typeof value === 'string' ? (value[0] === '@' ? (cssVars as any)[value.substring(1)] || \"\" : value) : String(value);\n\t\tconst expanded = CSS_SHORT[key] || key;\n\t\tif (typeof expanded === \"string\") {\n\t\t\t(el as any).style[expanded] = val;\n\t\t} else {\n\t\t\tfor (const prop of expanded) (el as any).style[prop] = val;\n\t\t}\n\t} else if (value == null) {\n\t\t// Value left empty\n\t\t// Do nothing\n\t} else if (key in SPECIAL_PROPS) {\n\t\t// Special property\n\t\tSPECIAL_PROPS[key](el, value);\n\t} else if (typeof value === \"function\") {\n\t\t// Event listener\n\t\tel.addEventListener(key, value);\n\t\tif (el === currentScope.el) clean(() => el.removeEventListener(key, value));\n\t} else if (\n\t\tvalue === true ||\n\t\tvalue === false ||\n\t\tkey === \"value\" ||\n\t\tkey === \"selectedIndex\"\n\t) {\n\t\t// DOM property\n\t\t(el as any)[key] = value;\n\t} else {\n\t\t// HTML attribute\n\t\tel.setAttribute(key, value);\n\t}\n}\n\nfunction defaultOnError(error: Error) {\n\tconsole.error(\"Error while in Aberdeen render:\", error);\n\treturn true;\n}\nlet onError: (error: Error) => boolean | undefined = defaultOnError;\n\n/**\n * Sets a custom error handler function for errors that occur asynchronously\n * within reactive scopes (e.g., during updates triggered by proxy changes in\n * {@link derive} or {@link $} render functions).\n *\n * The default handler logs the error to `console.error` and adds a simple\n * 'Error' message div to the DOM at the location where the error occurred (if possible).\n *\n * Your handler can provide custom logging, UI feedback, or suppress the default\n * error message.\n *\n * @param handler - A function that accepts the `Error` object.\n * - Return `false` to prevent adding an error message to the DOM.\n * - Return `true` or `undefined` (or throw) to allow the error messages to be added to the DOM.\n *\n * @example Custom Logging and Suppressing Default Message\n * ```typescript\n * setErrorHandler(error => {\n * console.warn('Aberdeen render error:', error.message);\n * // Log to error reporting service\n * // myErrorReporter.log(error);\n *\n * try {\n * // Attempt to show a custom message in the UI\n * $('div.error-message#Oops, something went wrong!');\n * } catch (e) {\n * // Ignore errors during error handling itself\n * }\n *\n * return false; // Suppress default console log and DOM error message\n * });\n *\n * // Styling for our custom error message\n * insertCss({\n * '.error-message': {\n * backgroundColor: '#e31f00',\n * display: 'inline-block',\n * color: 'white',\n * borderRadius: '3px',\n * padding: '2px 4px',\n * }\n * }, true); // global style\n *\n * // Cause an error within a render scope.\n * $('div.box', () => {\n * // Will cause our error handler to insert an error message within the box\n * noSuchFunction();\n * })\n * ```\n */\nexport function setErrorHandler(\n\thandler?: (error: Error) => boolean | undefined,\n) {\n\tonError = handler || defaultOnError;\n}\n\n/**\n * Gets the parent DOM `Element` where nodes created by {@link $} would currently be inserted.\n *\n * This is context-dependent based on the current reactive scope (e.g., inside a {@link mount}\n * call or a {@link $} element's render function).\n *\n * **Note:** While this provides access to the DOM element, directly manipulating it outside\n * of Aberdeen's control is generally discouraged. Prefer reactive updates using {@link $}.\n *\n * @returns The current parent `Element` for DOM insertion.\n *\n * @example Get parent for attaching a third-party library\n * ```typescript\n * function thirdPartyLibInit(parentElement) {\n * parentElement.innerHTML = \"This element is managed by a <em>third party</em> lib.\"\n * }\n *\n * $('div.box', () => {\n * // Get the div.box element just created\n * const containerElement = getParentElement();\n * thirdPartyLibInit(containerElement);\n * });\n * ```\n */\nexport function getParentElement(): Element {\n\treturn currentScope.el;\n}\n\n/**\n * Registers a cleanup function to be executed just before the current reactive scope\n * is destroyed or redraws.\n *\n * This is useful for releasing resources, removing manual event listeners, or cleaning up\n * side effects associated with the scope. Cleaners are run in reverse order of registration.\n *\n * Scopes are created by functions like {@link derive}, {@link mount}, {@link $} (when given a render function),\n * and internally by constructs like {@link onEach}.\n *\n * @param cleaner - The function to execute during cleanup.\n *\n * @example Maintaing a sum for a changing array\n * ```typescript\n * const myArray = proxy([3, 5, 10]);\n * let sum = proxy(0);\n *\n * // Show the array items and maintain the sum\n * onEach(myArray, (item, index) => {\n * $(`code#${index}→${item}`);\n * // We'll update sum.value using peek, as += first does a read, but\n * // we don't want to subscribe.\n * peek(() => sum.value += item);\n * // Clean gets called before each rerun for a certain item index\n * // No need for peek here, as the clean code doesn't run in an\n * // observer scope.\n * clean(() => sum.value -= item);\n * })\n *\n * // Show the sum\n * $('h1 text=', sum);\n *\n * // Make random changes to the array\n * const rnd = () => 0|(Math.random()*20);\n * setInterval(() => myArray[rnd()] = rnd(), 1000);\n * ```\n */\n\nexport function clean(cleaner: () => void) {\n\tcurrentScope.cleaners.push(cleaner);\n}\n\n/**\n * Creates a reactive scope that automatically re-executes the provided function\n * whenever any proxied data (created by {@link proxy}) read during its last execution changes, storing\n * its return value in an observable.\n *\n * Updates are batched and run asynchronously shortly after the changes occur.\n * Use {@link clean} to register cleanup logic for the scope.\n * Use {@link peek} or {@link unproxy} within the function to read proxied data without subscribing to it.\n *\n * @param func - The function to execute reactively. Any DOM manipulations should typically\n * be done using {@link $} within this function. Its return value will be made available as an\n * observable returned by the `derive()` function.\n * @returns An observable object, with its `value` property containing whatever the last run of `func` returned.\n *\n * @example Observation creating a UI components\n * ```typescript\n * const data = proxy({ user: 'Frank', notifications: 42 });\n *\n * $('main', () => {\n * console.log('Welcome');\n * $('h3#Welcome, ' + data.user); // Reactive text\n *\n * derive(() => {\n * // When data.notifications changes, only this inner scope reruns,\n * // leaving the `<p>Welcome, ..</p>` untouched.\n * console.log('Notifications');\n * $('code.notification-badge text=', data.notifications);\n * $('a text=Notify! click=', () => data.notifications++);\n * });\n * });\n * ```\n *\n * ***Note*** that the above could just as easily be done using `$(func)` instead of `derive(func)`.\n *\n * @example Observation with return value\n * ```typescript\n * const counter = proxy(0);\n * setInterval(() => counter.value++, 1000);\n * const double = derive(() => counter.value * 2);\n *\n * $('h3', () => {\n * $(`#counter=${counter.value} double=${double.value}`);\n * })\n * ```\n *\n * @overload\n * @param func Func without a return value.\n */\nexport function derive<T>(func: () => T): ValueRef<T> {\n\treturn new ResultScope<T>(func).result;\n}\n\n/**\n * Attaches a reactive Aberdeen UI fragment to an existing DOM element. Without the use of\n * this function, {@link $} will assume `document.body` as its root.\n *\n * It creates a top-level reactive scope associated with the `parentElement`. The provided\n * function `func` is executed immediately within this scope. Any proxied data read by `func`\n * will cause it to re-execute when the data changes, updating the DOM elements created within it.\n *\n * Calls to {@link $} inside `func` will append nodes to `parentElement`.\n * You can nest {@link derive} or other {@link $} scopes within `func`.\n * Use {@link unmountAll} to clean up all mounted scopes and their DOM nodes.\n *\n * Mounting scopes happens reactively, meaning that if this function is called from within another\n * ({@link derive} or {@link $} or {@link mount}) scope that gets cleaned up, so will the mount.\n *\n * @param parentElement - The native DOM `Element` to which the UI fragment will be appended.\n * @param func - The function that defines the UI fragment, typically containing calls to {@link $}.\n *\n * @example Basic Mount\n * ```javascript\n * // Create a pre-existing DOM structure (without Aberdeen)\n * document.body.innerHTML = `<h3>Static content <span id=\"title-extra\"></span></h3><div class=\"box\" id=\"app-root\"></div>`;\n *\n * import { mount, $, proxy } from 'aberdeen';\n *\n * const runTime = proxy(0);\n * setInterval(() => runTime.value++, 1000);\n *\n * mount(document.getElementById('app-root'), () => {\n * $('h4#Aberdeen App');\n * $(`p#Run time: ${runTime.value}s`);\n * // Conditionally render some content somewhere else in the static page\n * if (runTime.value&1) {\n * mount(document.getElementById('title-extra'), () =>\n * $(`i#(${runTime.value}s)`)\n * );\n * }\n * });\n * ```\n *\n * Note how the inner mount behaves reactively as well, automatically unmounting when it's parent observer scope re-runs.\n */\n\nexport function mount(parentElement: Element, func: () => void) {\n\tnew MountScope(parentElement, func);\n}\n\n/**\n * Removes all Aberdeen-managed DOM nodes and stops all active reactive scopes\n * (created by {@link mount}, {@link derive}, {@link $} with functions, etc.).\n *\n * This effectively cleans up the entire Aberdeen application state.\n */\nexport function unmountAll() {\n\tROOT_SCOPE.remove();\n\tcssCount = 0;\n}\n\n/**\n * Executes a function or retrieves a value *without* creating subscriptions in the current reactive scope, and returns its result.\n *\n * This is useful when you need to access reactive data inside a reactive scope (like {@link $})\n * but do not want changes to that specific data to trigger a re-execute of the scope.\n * \n * Note: You may also use {@link unproxy} to get to the raw underlying data structure, which can be used to similar effect.\n *\n * @param target - Either a function to execute, or an object (which may also be an Array or a Map) to index.\n * @param key - Optional key/index to use when `target` is an object.\n * @returns The result of the function call, or the value at `target[key]` when `target` is an object or `target.get(key)` when it's a Map.\n *\n * @example Peeking within observer\n * ```typescript\n * const data = proxy({ a: 1, b: 2 });\n * $(() => {\n * // re-executes only when data.a changes, because data.b is peeked.\n * const b = peek(() => data.b);\n * console.log(`A is ${data.a}, B was ${b} when A changed.`);\n * });\n * data.b = 3; // Does not trigger console.log\n * data.a = 2; // Triggers console.log (logs \"A is 2, B was 3 when A changed.\")\n * ```\n *\n */\n\nexport function peek<T extends object, K extends keyof T>(target: T, key: K): T[K];\nexport function peek<K,V>(target: Map<K,V>, key: K): V | undefined;\nexport function peek<T>(target: T[], key: number): T | undefined;\nexport function peek<T>(target: () => T): T;\n\nexport function peek(target: any, key?: any) {\n\tpeeking++;\n\ttry {\n\t\tif (arguments.length === 1) {\n\t\t\treturn target();\n\t\t} else {\n\t\t\treturn (target instanceof Map) ? target.get(key) : target[key];\n\t\t}\n\t} finally {\n\t\tpeeking--;\n\t}\n}\n\n/** When using a Map as `source`. */\nexport function map<K, IN, OUT>(\n\tsource: Map<K, IN>,\n\tfunc: (value: IN, key: K) => undefined | OUT,\n): Map<K, OUT>;\n/** When using an array as `source`. */\nexport function map<IN, OUT>(\n\tsource: Array<IN>,\n\tfunc: (value: IN, index: number) => undefined | OUT,\n): Array<OUT>;\n/** When using an object as `source`. */\nexport function map<IN, const IN_KEY extends string | number | symbol, OUT>(\n\tsource: Record<IN_KEY, IN>,\n\tfunc: (value: IN, index: KeyToString<IN_KEY>) => undefined | OUT,\n): Record<string | symbol, OUT>;\n/**\n * Reactively maps/filters items from a proxied source array or object to a new proxied array or object.\n *\n * It iterates over the `target` proxy. For each item, it calls `func`.\n * - If `func` returns a value, it's added to the result proxy under the same key/index.\n * - If `func` returns `undefined`, the item is skipped (filtered out).\n *\n * The returned proxy automatically updates when:\n * - Items are added/removed/updated in the `target` proxy.\n * - Any proxied data read *within* the `func` call changes (for a specific item).\n *\n * @param func - A function `(value, key) => mappedValue | undefined` that transforms each item.\n * It receives the item's value and its key/index. Return `undefined` to filter the item out.\n * @returns A new proxied array or object containing the mapped values.\n * @template IN The type of items in the source proxy.\n * @template OUT The type of items in the resulting proxy.\n *\n * @example Map array values\n * ```typescript\n * const numbers = proxy([1, 2, 3]);\n * const doubled = map(numbers, (n) => n * 2);\n * // doubled is proxy([2, 4, 6])\n *\n * $(() => console.log(doubled)); // Logs updates\n * numbers.push(4); // doubled becomes proxy([2, 4, 6, 8])\n * ```\n *\n * @example Filter and map object properties\n * ```typescript\n * const users = proxy({\n * 'u1': { name: 'Alice', active: true },\n * 'u2': { name: 'Bob', active: false },\n * 'u3': { name: 'Charlie', active: true }\n * });\n *\n * const activeUserNames = map(users, (user) => user.active ? user.name : undefined);\n * // activeUserNames is proxy({ u1: 'Alice', u3: 'Charlie' })\n * $(() => console.log(Object.values(activeUserNames)));\n *\n * users.u2.active = true;\n * // activeUserNames becomes proxy({ u1: 'Alice', u2: 'Bob', u3: 'Charlie' })\n * ```\n */\nexport function map(\n\tsource: any,\n\tfunc: (value: any, key: any) => any,\n): any {\n\tlet out;\n\tif (source instanceof Array) {\n\t\tout = optProxy([]);\n\t} else if (source instanceof Map) {\n\t\tout = optProxy(new Map());\n\t} else {\n\t\tout = optProxy({});\n\t}\n\t\n\tonEach(source, (item: any, key: symbol | string | number) => {\n\t\tconst value = func(item, key);\n\t\tif (value !== undefined) {\n\t\t\tif (out instanceof Map) {\n\t\t\t\tout.set(key, value);\n\t\t\t\tclean(() => {\n\t\t\t\t\tout.delete(key);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tout[key] = value;\n\t\t\t\tclean(() => {\n\t\t\t\t\tdelete out[key];\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\treturn out;\n}\n\n/** When using an array as `source`. */\nexport function multiMap<IN, OUT extends { [key: string | symbol]: any }>(\n\tsource: Array<IN>,\n\tfunc: (value: IN, index: number) => OUT | undefined,\n): OUT;\n/** When using an object as `source`. */\nexport function multiMap<\n\tK extends string | number | symbol,\n\tIN,\n\tOUT extends { [key: string | symbol]: any },\n>(source: Record<K, IN>, func: (value: IN, index: KeyToString<K>) => OUT | undefined): OUT;\n/** When using a Map as `source`. */\nexport function multiMap<\n\tK,\n\tIN,\n\tOUT extends { [key: string | symbol]: any },\n>(source: Map<K, IN>, func: (value: IN, key: K) => OUT | undefined): OUT;\n/**\n * Reactively maps items from a source proxy (array or object) to a target proxied object,\n * where each source item can contribute multiple key-value pairs to the target.\n *\n * It iterates over the `target` proxy. For each item, it calls `func`.\n * - If `func` returns an object, all key-value pairs from that object are added to the result proxy.\n * - If `func` returns `undefined`, the item contributes nothing.\n *\n * The returned proxy automatically updates when:\n * - Items are added/removed/updated in the `target` proxy.\n * - Any proxied data read *within* the `func` call changes (for a specific item).\n * - If multiple input items produce the same output key, the last one processed usually \"wins\",\n * but the exact behavior on collision depends on update timing.\n *\n * This is useful for \"flattening\" or \"indexing\" data, or converting an observable array to an observable object.\n *\n * @param source - The source proxied array or object.\n * @param func - A function `(value, key) => ({...pairs} | undefined)` that transforms an item\n * into an object of key-value pairs to add, or `undefined` to add nothing.\n * @returns A new proxied object containing the aggregated key-value pairs.\n * @template IN The type of items in the source proxy.\n * @template OUT The type of the aggregated output object (should encompass all possible key-value pairs).\n *\n * @example Creating an index from an array\n * ```typescript\n * const items = proxy([\n * { id: 'a', value: 10 },\n * { id: 'b', value: 20 },\n * ]);\n * const itemsById = multiMap(items, (item) => ({\n * [item.id]: item.value,\n * [item.id+item.id]: item.value*10,\n * }));\n * // itemsById is proxy({ a: 10, aa: 100, b: 20, bb: 200 })\n *\n * $(() => console.log(itemsById));\n *\n * items.push({ id: 'c', value: 30 });\n * // itemsById becomes proxy({ a: 10, aa: 100, b: 20, bb: 200, c: 30, cc: 300 })\n * ```\n */\nexport function multiMap(\n\tsource: any,\n\tfunc: (value: any, key: any) => Record<string | symbol, any>,\n): any {\n\tconst out = optProxy({});\n\tonEach(source, (item: any, key: symbol | string | number) => {\n\t\tconst pairs = func(item, key);\n\t\tif (pairs) {\n\t\t\tfor (const key of Object.keys(pairs)) out[key] = pairs[key];\n\t\t\tclean(() => {\n\t\t\t\tfor (const key of Object.keys(pairs)) delete out[key];\n\t\t\t});\n\t\t}\n\t});\n\treturn out;\n}\n\n/** When using an object as `array`. */\nexport function partition<OUT_K extends string | number | symbol, IN_V>(\n\tsource: IN_V[],\n\tfunc: (value: IN_V, key: number) => undefined | OUT_K | OUT_K[],\n): Record<OUT_K, Record<number, IN_V>>;\n/** When using an object as `source`. */\nexport function partition<\n\tIN_K extends string | number | symbol,\n\tOUT_K extends string | number | symbol,\n\tIN_V,\n>(\n\tsource: Record<IN_K, IN_V>,\n\tfunc: (value: IN_V, key: IN_K) => undefined | OUT_K | OUT_K[],\n): Record<OUT_K, Record<IN_K, IN_V>>;\n/** When using a Map as `source`. */\nexport function partition<\n\tIN_K extends string | number | symbol,\n\tOUT_K extends string | number | symbol,\n\tIN_V,\n>(\n\tsource: Map<IN_K, IN_V>,\n\tfunc: (value: IN_V, key: IN_K) => undefined | OUT_K | OUT_K[],\n): Record<OUT_K, Record<IN_K, IN_V>>;\n\n/**\n * @overload\n * Reactively partitions items from a source proxy (array or object) into multiple \"bucket\" proxies\n * based on keys determined by a classifier function.\n *\n * This function iterates through the `source` proxy using {@link onEach}. For each item,\n * it calls the classifier `func`, which should return:\n * - A single key (`OUT_K`): The item belongs to the bucket with this key.\n * - An array of keys (`OUT_K[]`): The item belongs to all buckets specified in the array.\n * - `undefined`: The item is not placed in any bucket.\n *\n * The function returns a main proxied object. The keys of this object are the bucket keys (`OUT_K`)\n * returned by `func`. Each value associated with a bucket key is another proxied object (the \"bucket\").\n * This inner bucket object maps the *original* keys/indices from the `source` to the items\n * themselves that were classified into that bucket.\n *\n * The entire structure is reactive. Changes in the `source` proxy (adding/removing/updating items)\n * or changes in dependencies read by the `func` will cause the output partitioning to update automatically.\n * Buckets are created dynamically as needed and removed when they become empty.\n *\n * @param source - The input proxied Array or Record (e.g., created by {@link proxy}) containing the items to partition.\n * @param func - A classifier function `(value: IN_V, key: IN_K | number) => undefined | OUT_K | OUT_K[]`.\n * It receives the item's value and its original key/index from the `source`. It returns the bucket key(s)\n * the item belongs to, or `undefined` to ignore the item.\n * @returns A proxied object where keys are the bucket identifiers (`OUT_K`) and values are proxied Records\n * (`Record<IN_K | number, IN_V>`) representing the buckets. Each bucket maps original source keys/indices\n * to the items belonging to that bucket.\n *\n * @template OUT_K - The type of the keys used for the output buckets (string, number, or symbol).\n * @template IN_V - The type of the values in the source proxy.\n * @template IN_K - The type of the keys in the source proxy (if it's a Record).\n *\n * @example Grouping items by a property\n * ```typescript\n * interface Product { id: string; category: string; name: string; }\n * const products = proxy<Product[]>([\n * { id: 'p1', category: 'Fruit', name: 'Apple' },\n * { id: 'p2', category: 'Veg', name: 'Carrot' },\n * { id: 'p3', category: 'Fruit', name: 'Banana' },\n * ]);\n *\n * // Partition products by category. Output keys are categories (string).\n * // Inner keys are original array indices (number).\n * const productsByCategory = partition(products, (product) => product.category);\n *\n * // Reactively show the data structure\n * dump(productsByCategory);\n *\n * // Make random changes to the categories, to show reactiveness\n * setInterval(() => products[0|(Math.random()*3)].category = ['Snack','Fruit','Veg'][0|(Math.random()*3)], 2000);\n * ```\n *\n * @example Item in multiple buckets\n * ```typescript\n * interface User { id: number; tags: string[]; name: string; }\n * const users = proxy({\n * 'u1': { name: 'Alice', tags: ['active', 'new'] },\n * 'u2': { name: 'Bob', tags: ['active'] }\n * });\n *\n * // Partition users by tag. Output keys are tags (string).\n * // Inner keys are original object keys (string: 'u1', 'u2').\n * const usersByTag = partition(users, (user) => user.tags);\n *\n * console.log(usersByTag);\n * ```\n */\nexport function partition<\n\tIN_K extends string | number | symbol,\n\tOUT_K extends string | number | symbol,\n\tIN_V,\n>(\n\tsource: Record<IN_K, IN_V>,\n\tfunc: (value: IN_V, key: KeyToString<IN_K>) => undefined | OUT_K | OUT_K[],\n): Record<OUT_K, Record<KeyToString<IN_K>, IN_V>> {\n\tconst unproxiedOut = {} as Record<OUT_K, Record<KeyToString<IN_K>, IN_V>>;\n\tconst out = optProxy(unproxiedOut);\n\tonEach(source, (item: IN_V, key: KeyToString<IN_K>) => {\n\t\tconst rsp = func(item, key);\n\t\tif (rsp != null) {\n\t\t\tconst buckets = rsp instanceof Array ? rsp : [rsp];\n\t\t\tif (buckets.length) {\n\t\t\t\tfor (const bucket of buckets) {\n\t\t\t\t\tif (unproxiedOut[bucket]) out[bucket][key] = item;\n\t\t\t\t\telse out[bucket] = { [key]: item } as Record<KeyToString<IN_K>, IN_V>;\n\t\t\t\t}\n\t\t\t\tclean(() => {\n\t\t\t\t\tfor (const bucket of buckets) {\n\t\t\t\t\t\tdelete out[bucket][key];\n\t\t\t\t\t\tif (isObjEmpty(unproxiedOut[bucket])) delete out[bucket];\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\treturn out;\n}\n\n/**\n * Renders a live, recursive dump of a proxied data structure (or any value)\n * into the DOM at the current {@link $} insertion point.\n *\n * Uses `<ul>` and `<li>` elements to display object properties and array items.\n * Updates reactively if the dumped data changes. Primarily intended for debugging purposes.\n *\n * @param data - The proxied data structure (or any value) to display.\n * @returns The original `data` argument, allowing for chaining.\n * @template T - The type of the data being dumped.\n *\n * @example Dumping reactive state\n * ```typescript\n * import { $, proxy, dump } from 'aberdeen';\n *\n * const state = proxy({\n * user: { name: 'Frank', kids: 1 },\n * items: ['a', 'b']\n * });\n *\n * $('h2#Live State Dump');\n * dump(state);\n *\n * // Change state later, the dump in the DOM will update\n * setTimeout(() => { state.user.kids++; state.items.push('c'); }, 2000);\n * ```\n */\nexport function dump<T>(data: T): T {\n\tif (data && typeof data === \"object\") {\n\t\tconst name = data.constructor.name.toLowerCase() || \"unknown object\";\n\t\t$(`#<${name}>`);\n\t\tif (NO_COPY in data ) {\n\t\t\t$(\"# [NO_COPY]\");\n\t\t} else {\n\t\t\t$(\"ul\", () => {\n\t\t\t\tonEach(data as any, (value, key) => {\n\t\t\t\t\t$(\"li\", () => {\n\t\t\t\t\t\t$(`#${JSON.stringify(key)}: `);\n\t\t\t\t\t\tdump(value);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t} else if (data !== undefined) {\n\t\t$(\"#\" + JSON.stringify(data));\n\t}\n\treturn data;\n}\n\n/*\n * Helper functions\n */\n\n/* c8 ignore start */\nfunction internalError(code: number): never {\n\tthrow new Error(`Aberdeen internal error ${code}`);\n}\n/* c8 ignore end */\n\nfunction handleError(e: any, showMessage: boolean) {\n\ttry {\n\t\tif (onError(e) === false) showMessage = false;\n\t} catch (e) {\n\t\tconsole.error(e);\n\t}\n\ttry {\n\t\tif (showMessage) $(\"div.aberdeen-error#Error\");\n\t} catch {\n\t\t// Error while adding the error marker to the DOM. Apparently, we're in\n\t\t// an awkward context. The error should already have been logged by\n\t\t// onError, so let's not confuse things by generating more errors.\n\t}\n}\n\n/** @internal */\nexport function withEmitHandler(\n\thandler: (\n\t\ttarget: TargetType,\n\t\tindex: any,\n\t\tnewData: any,\n\t\toldData: any,\n\t) => void,\n\tfunc: () => void,\n) {\n\tconst oldEmitHandler = emit;\n\temit = handler;\n\ttry {\n\t\tfunc();\n\t} finally {\n\t\temit = oldEmitHandler;\n\t}\n}\n"
7
7
  ],
8
- "mappings": ";AAeO,MAAM,iBAAkE;AAAA,EAa1D;AAAA,EAXZ;AAAA,EAEA;AAAA,EASR,WAAW,CAAS,SAAmB;AAAA,IAAnB;AAAA,IACnB,KAAK,OAAO,CAAC;AAAA,IACb,KAAK,UAAU,CAAC,OAAO,CAAC,CAAC;AAAA;AAAA,EAoB1B,GAAG,CAAC,MAAkB;AAAA,IACrB,IAAI,KAAK,QAAQ,MAAM;AAAA,MAAM,OAAO;AAAA,IAGpC,MAAM,QAAQ,KAAK,KAAK,MAAM,KAAK,OAAO,IAAI,UAAU,KAAK;AAAA,IAC7D,SAAS,IAAI,KAAK,QAAQ,OAAQ,IAAI,OAAO;AAAA,MAC5C,KAAK,QAAQ,KAAK,OAAO,CAAC,CAAC;AAAA,IAE5B,MAAM,UAAU,KAAK;AAAA,IACrB,MAAM,MAAM,KAAK;AAAA,IAGjB,IAAI;AAAA,IACJ,IAAI,UAAuB,KAAK;AAAA,IAChC,SAAS,IAAI,KAAK,QAAQ,SAAS,EAAG,KAAK,GAAG,KAAK;AAAA,MAClD,MAAM,SAA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