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,EAAI,IAAK,GAAW,GAC5B,EAAQ,EAAI,IAAK,GAAY,GAC7B,EAAI,cAAW,GAGT,GACN,EACA,EAAU,OACT,EAAU,MAEb,CASA,SAAS,GACR,EACA,EACA,GAEA,MAAM,EAAS,EAAI,OACnB,IAAK,EACJ,MAAM,EAGP,IAAI,EACJ,IACC,EAAO,GAAiB,EAAQ,EACjC,CAAE,MAAO,GACR,OAAO,GAAe,EAAQ,EAAK,EACpC,CAEA,GAAI,EAAc,GACjB,OAAO,EAAK,MACX,KAAW,GAAgB,EAAQ,EAAiB,IACnD,GAAQ,GAAe,EAAQ,EAAK,KAIvC,GAAgB,EAAQ,EACzB,CA2EA,IAAA,GAAe,CAAC,gBAAe,mB","file":"/npm/@b9g/crank@0.7.5/crank.js/+esm","sourceRoot":"","sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.\n * Original file: /npm/@b9g/crank@0.7.5/crank.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","// EVENT PHASE CONSTANTS\n// https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase\nconst NONE = 0;\nconst CAPTURING_PHASE = 1;\nconst AT_TARGET = 2;\nconst BUBBLING_PHASE = 3;\n\nexport function isEventTarget(value: any): value is EventTarget {\n\treturn (\n\t\tvalue != null &&\n\t\ttypeof value.addEventListener === \"function\" &&\n\t\ttypeof value.removeEventListener === \"function\" &&\n\t\ttypeof value.dispatchEvent === \"function\"\n\t);\n}\n\nfunction setEventProperty<T extends keyof Event>(\n\tev: Event,\n\tkey: T,\n\tvalue: Event[T],\n): void {\n\tObject.defineProperty(ev, key, {value, writable: false, configurable: true});\n}\n\nfunction isListenerOrListenerObject(\n\tvalue: unknown,\n): value is EventListenerOrEventListenerObject {\n\treturn (\n\t\ttypeof value === \"function\" ||\n\t\t(value !== null &&\n\t\t\ttypeof value === \"object\" &&\n\t\t\ttypeof (value as any).handleEvent === \"function\")\n\t);\n}\n\nfunction normalizeListenerOptions(\n\toptions: AddEventListenerOptions | boolean | null | undefined,\n): AddEventListenerOptions {\n\tif (typeof options === \"boolean\") {\n\t\treturn {capture: options};\n\t} else if (options == null) {\n\t\treturn {};\n\t}\n\n\treturn options;\n}\n\nconst _parent = Symbol.for(\"CustomEventTarget.parent\");\nconst _listeners = Symbol.for(\"CustomEventTarget.listeners\");\nconst _delegates = Symbol.for(\"CustomEventTarget.delegates\");\nconst _dispatchEventOnSelf = Symbol.for(\"CustomEventTarget.dispatchSelf\");\n\ninterface EventListenerRecord {\n\ttype: string;\n\t// listener is the original value passed to addEventListener, callback is the\n\t// actual function we call\n\tlistener: EventListenerOrEventListenerObject;\n\tcallback: EventListener;\n\toptions: AddEventListenerOptions;\n}\n\nexport class CustomEventTarget<\n\tTParent extends CustomEventTarget<TParent> = any,\n> implements EventTarget {\n\tdeclare static dispatchEventOnSelf: typeof _dispatchEventOnSelf;\n\tdeclare [_parent]: TParent | null;\n\tdeclare [_listeners]: Array<EventListenerRecord>;\n\tdeclare [_delegates]: Set<EventTarget>;\n\tconstructor(parent: TParent | null = null) {\n\t\tthis[_parent] = parent;\n\t\tthis[_listeners] = [];\n\t\tthis[_delegates] = new Set<EventTarget>();\n\t}\n\n\taddEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject | null,\n\t\toptions?: boolean | AddEventListenerOptions,\n\t): void {\n\t\tif (!isListenerOrListenerObject(listener)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst listeners = this[_listeners];\n\t\toptions = normalizeListenerOptions(options);\n\t\tlet callback: EventListener;\n\t\tif (typeof listener === \"function\") {\n\t\t\tcallback = listener;\n\t\t} else {\n\t\t\tcallback = (ev: Event) => listener.handleEvent(ev);\n\t\t}\n\t\tconst record: EventListenerRecord = {type, listener, callback, options};\n\n\t\tif (options.once) {\n\t\t\trecord.callback = function (this: any) {\n\t\t\t\tconst i = listeners.indexOf(record);\n\t\t\t\tif (i !== -1) {\n\t\t\t\t\tlisteners.splice(i, 1);\n\t\t\t\t}\n\n\t\t\t\treturn callback.apply(this, arguments as any);\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tlisteners.some(\n\t\t\t\t(record1) =>\n\t\t\t\t\trecord.type === record1.type &&\n\t\t\t\t\trecord.listener === record1.listener &&\n\t\t\t\t\t!record.options.capture === !record1.options.capture,\n\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tlisteners.push(record);\n\n\t\tfor (const delegate of this[_delegates]) {\n\t\t\tdelegate.addEventListener(type, record.callback, record.options);\n\t\t}\n\t}\n\n\tremoveEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject | null,\n\t\toptions?: EventListenerOptions | boolean,\n\t): void {\n\t\tconst listeners = this[_listeners];\n\t\tif (listeners == null || !isListenerOrListenerObject(listener)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst options1 = normalizeListenerOptions(options);\n\t\tconst i = listeners.findIndex(\n\t\t\t(record) =>\n\t\t\t\trecord.type === type &&\n\t\t\t\trecord.listener === listener &&\n\t\t\t\t!record.options.capture === !options1.capture,\n\t\t);\n\n\t\tif (i === -1) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst record = listeners[i];\n\t\tlisteners.splice(i, 1);\n\n\t\tfor (const delegate of this[_delegates]) {\n\t\t\tdelegate.removeEventListener(\n\t\t\t\trecord.type,\n\t\t\t\trecord.callback,\n\t\t\t\trecord.options,\n\t\t\t);\n\t\t}\n\t}\n\n\tdispatchEvent(ev: Event): boolean {\n\t\tconst path: Array<CustomEventTarget> = [];\n\t\tfor (let parent = this[_parent]; parent; parent = parent[_parent]) {\n\t\t\tpath.push(parent);\n\t\t}\n\n\t\tlet cancelBubble = false;\n\t\tlet immediateCancelBubble = false;\n\t\tconst stopPropagation = ev.stopPropagation;\n\t\tsetEventProperty(ev, \"stopPropagation\", () => {\n\t\t\tcancelBubble = true;\n\t\t\treturn stopPropagation.call(ev);\n\t\t});\n\n\t\tconst stopImmediatePropagation = ev.stopImmediatePropagation;\n\t\tsetEventProperty(ev, \"stopImmediatePropagation\", () => {\n\t\t\timmediateCancelBubble = true;\n\t\t\treturn stopImmediatePropagation.call(ev);\n\t\t});\n\t\tsetEventProperty(ev, \"target\", this);\n\n\t\t// The only possible errors in this block are errors thrown by callbacks,\n\t\t// and dispatchEvent will only log these errors rather than throwing them.\n\t\t// Therefore, we place all code in a try block, log errors in the catch\n\t\t// block, and use an unsafe return statement in the finally block.\n\t\t//\n\t\t// Each early return within the try block returns true because while the\n\t\t// return value is overridden in the finally block, TypeScript\n\t\t// (justifiably) does not recognize the unsafe return statement.\n\t\ttry {\n\t\t\tsetEventProperty(ev, \"eventPhase\", CAPTURING_PHASE);\n\t\t\tfor (let i = path.length - 1; i >= 0; i--) {\n\t\t\t\tconst target = path[i];\n\t\t\t\tconst listeners = target[_listeners];\n\t\t\t\tsetEventProperty(ev, \"currentTarget\", target);\n\t\t\t\tfor (let i = 0; i < listeners.length; i++) {\n\t\t\t\t\tconst record = listeners[i];\n\t\t\t\t\tif (record.type === ev.type && record.options.capture) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\trecord.callback.call(target, ev);\n\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\tconsole.error(err);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (immediateCancelBubble) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (cancelBubble) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t{\n\t\t\t\tsetEventProperty(ev, \"eventPhase\", AT_TARGET);\n\t\t\t\tsetEventProperty(ev, \"currentTarget\", this);\n\n\t\t\t\tthis[_dispatchEventOnSelf](ev);\n\t\t\t\tif (immediateCancelBubble) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tconst listeners = this[_listeners];\n\t\t\t\tfor (let i = 0; i < listeners.length; i++) {\n\t\t\t\t\tconst record = listeners[i];\n\t\t\t\t\tif (record.type === ev.type) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\trecord.callback.call(this, ev);\n\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\tconsole.error(err);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (immediateCancelBubble) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (cancelBubble) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (ev.bubbles) {\n\t\t\t\tsetEventProperty(ev, \"eventPhase\", BUBBLING_PHASE);\n\t\t\t\tfor (let i = 0; i < path.length; i++) {\n\t\t\t\t\tconst target = path[i];\n\t\t\t\t\tsetEventProperty(ev, \"currentTarget\", target);\n\t\t\t\t\tconst listeners = target[_listeners];\n\t\t\t\t\tfor (let i = 0; i < listeners.length; i++) {\n\t\t\t\t\t\tconst record = listeners[i];\n\t\t\t\t\t\tif (record.type === ev.type && !record.options.capture) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\trecord.callback.call(target, ev);\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\tconsole.error(err);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (immediateCancelBubble) {\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (cancelBubble) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tsetEventProperty(ev, \"eventPhase\", NONE);\n\t\t\tsetEventProperty(ev, \"currentTarget\", null);\n\t\t\t// eslint-disable-next-line no-unsafe-finally\n\t\t\treturn !ev.defaultPrevented;\n\t\t}\n\t}\n\n\t[_dispatchEventOnSelf](_ev: Event): void {}\n}\n\nCustomEventTarget.dispatchEventOnSelf = _dispatchEventOnSelf;\n\nexport function addEventTargetDelegates<T extends CustomEventTarget>(\n\ttarget: T,\n\tdelegates: Array<unknown>,\n\tinclude: (target1: T) => boolean = (target1) => target === target1,\n): void {\n\tconst delegates1 = delegates.filter(isEventTarget);\n\tfor (\n\t\tlet target1: T | null = target;\n\t\ttarget1 && include(target1);\n\t\ttarget1 = target1[_parent]\n\t) {\n\t\tfor (let i = 0; i < delegates1.length; i++) {\n\t\t\tconst delegate = delegates1[i];\n\t\t\tif (target1[_delegates].has(delegate)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\ttarget1[_delegates].add(delegate);\n\t\t\tfor (const record of target1[_listeners]) {\n\t\t\t\tdelegate.addEventListener(record.type, record.callback, record.options);\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function removeEventTargetDelegates<T extends CustomEventTarget>(\n\ttarget: T,\n\tdelegates: Array<unknown>,\n\tinclude: (target1: T) => boolean = (target1) => target === target1,\n): void {\n\tconst delegates1 = delegates.filter(isEventTarget);\n\tfor (\n\t\tlet target1: T | null = target;\n\t\ttarget1 && include(target1);\n\t\ttarget1 = target1[_parent]\n\t) {\n\t\tfor (let i = 0; i < delegates1.length; i++) {\n\t\t\tconst delegate = delegates1[i];\n\t\t\tif (!target1[_delegates].has(delegate)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\ttarget1[_delegates].delete(delegate);\n\t\t\tfor (const record of target1[_listeners]) {\n\t\t\t\tdelegate.removeEventListener(\n\t\t\t\t\trecord.type,\n\t\t\t\t\trecord.callback,\n\t\t\t\t\trecord.options,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function clearEventListeners(target: CustomEventTarget): void {\n\tconst listeners = target[_listeners];\n\tconst delegates = target[_delegates];\n\tfor (let i = 0; i < listeners.length; i++) {\n\t\tconst record = listeners[i];\n\t\tfor (const delegate of delegates) {\n\t\t\tdelegate.removeEventListener(\n\t\t\t\trecord.type,\n\t\t\t\trecord.callback,\n\t\t\t\trecord.options,\n\t\t\t);\n\t\t}\n\t}\n\n\tlisteners.length = 0;\n\tdelegates.clear();\n}\n","export function wrap<T>(value: Array<T> | T | undefined): Array<T> {\n\treturn value === undefined ? [] : Array.isArray(value) ? value : [value];\n}\n\nexport function unwrap<T>(arr: Array<T>): Array<T> | T | undefined {\n\treturn arr.length === 0 ? undefined : arr.length === 1 ? arr[0] : arr;\n}\n\nexport type NonStringIterable<T> = Iterable<T> & object;\n\n/**\n * Ensures a value is an array.\n *\n * This function does the same thing as wrap() above except it handles nulls\n * and iterables, so it is appropriate for wrapping user-provided element\n * children.\n */\nexport function arrayify<T>(\n\tvalue: NonStringIterable<T> | T | null | undefined,\n): Array<T> {\n\treturn value == null\n\t\t? []\n\t\t: Array.isArray(value)\n\t\t\t? value\n\t\t\t: typeof value === \"string\" ||\n\t\t\t\t  typeof (value as any)[Symbol.iterator] !== \"function\"\n\t\t\t\t? [value as T]\n\t\t\t\t: [...(value as NonStringIterable<T>)];\n}\n\nexport function isIteratorLike(\n\tvalue: any,\n): value is Iterator<unknown> | AsyncIterator<unknown> {\n\treturn value != null && typeof value.next === \"function\";\n}\n\nexport function isPromiseLike(value: any): value is PromiseLike<unknown> {\n\treturn value != null && typeof value.then === \"function\";\n}\n\ntype Deferred<T = unknown> = {\n\tresolve: (value: T | PromiseLike<T>) => void;\n\treject: (reason?: unknown) => void;\n};\n\ntype RaceRecord = {\n\tdeferreds: Set<Deferred>;\n\tsettled: boolean;\n};\n\nfunction createRaceRecord(contender: PromiseLike<unknown>): RaceRecord {\n\tconst deferreds = new Set<Deferred>();\n\tconst record = {deferreds, settled: false};\n\n\t// This call to `then` happens once for the lifetime of the value.\n\tPromise.resolve(contender).then(\n\t\t(value) => {\n\t\t\tfor (const {resolve} of deferreds) {\n\t\t\t\tresolve(value);\n\t\t\t}\n\n\t\t\tdeferreds.clear();\n\t\t\trecord.settled = true;\n\t\t},\n\t\t(err) => {\n\t\t\tfor (const {reject} of deferreds) {\n\t\t\t\treject(err);\n\t\t\t}\n\n\t\t\tdeferreds.clear();\n\t\t\trecord.settled = true;\n\t\t},\n\t);\n\treturn record;\n}\n\n// Promise.race is memory unsafe. This is alternative which is. See:\n// https://github.com/nodejs/node/issues/17469#issuecomment-685235106\n// Keys are the values passed to race.\n// Values are a record of data containing a set of deferreds and whether the\n// value has settled.\nconst wm = new WeakMap<object, RaceRecord>();\nexport function safeRace<T>(\n\tcontenders: Iterable<T | PromiseLike<T>>,\n): Promise<Awaited<T>> {\n\tlet deferred: Deferred;\n\tconst result = new Promise((resolve, reject) => {\n\t\tdeferred = {resolve, reject};\n\t\tfor (const contender of contenders) {\n\t\t\tif (!isPromiseLike(contender)) {\n\t\t\t\t// If the contender is a not a then-able, attempting to use it as a key\n\t\t\t\t// in the weakmap would throw an error. Luckily, it is safe to call\n\t\t\t\t// `Promise.resolve(contender).then` on regular values multiple\n\t\t\t\t// times because the promise fulfills immediately.\n\t\t\t\tPromise.resolve(contender).then(resolve, reject);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet record = wm.get(contender);\n\t\t\tif (record === undefined) {\n\t\t\t\trecord = createRaceRecord(contender);\n\t\t\t\trecord.deferreds.add(deferred);\n\t\t\t\twm.set(contender, record);\n\t\t\t} else if (record.settled) {\n\t\t\t\t// If the value has settled, it is safe to call\n\t\t\t\t// `Promise.resolve(contender).then` on it.\n\t\t\t\tPromise.resolve(contender).then(resolve, reject);\n\t\t\t} else {\n\t\t\t\trecord.deferreds.add(deferred);\n\t\t\t}\n\t\t}\n\t});\n\n\t// The finally callback executes when any value settles, preventing any of\n\t// the unresolved values from retaining a reference to the resolved value.\n\treturn result.finally(() => {\n\t\tfor (const contender of contenders) {\n\t\t\tif (isPromiseLike(contender)) {\n\t\t\t\tconst record = wm.get(contender);\n\t\t\t\tif (record) {\n\t\t\t\t\trecord.deferreds.delete(deferred);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}) as Promise<Awaited<T>>;\n}\n","import {\n\tCustomEventTarget,\n\taddEventTargetDelegates,\n\tclearEventListeners,\n\tremoveEventTargetDelegates,\n} from \"./event-target.js\";\nimport {\n\tarrayify,\n\tisIteratorLike,\n\tisPromiseLike,\n\tsafeRace,\n\tunwrap,\n\twrap,\n} from \"./_utils.js\";\n\nconst NOOP = (): undefined => {};\n\n/**\n * A type which represents all valid values for an element tag.\n */\nexport type Tag = string | symbol | Component;\n\nfunction getTagName(tag: Tag): string {\n\treturn typeof tag === \"function\"\n\t\t? tag.name || \"Anonymous\"\n\t\t: typeof tag === \"string\"\n\t\t\t? tag\n\t\t\t: // tag is symbol, using else branch to avoid typeof tag === \"symbol\"\n\t\t\t\ttag.description || \"Anonymous\";\n}\n\n/**\n * A helper type to map the tag of an element to its expected props.\n *\n * @template TTag - The tag associated with the props. Can be a string, symbol\n * or a component function.\n */\nexport type TagProps<TTag extends Tag> = TTag extends string\n\t? JSX.IntrinsicElements[TTag]\n\t: TTag extends Component<infer TProps>\n\t\t? TProps & JSX.IntrinsicAttributes\n\t\t: Record<string, unknown> & JSX.IntrinsicAttributes;\n\n/**\n * Describes all valid values of an element tree, excluding iterables.\n *\n * Arbitrary objects can also be safely rendered, but will be converted to a\n * string using the toString() method. We exclude them from this type to catch\n * potential mistakes.\n */\nexport type Child = Element | string | number | boolean | null | undefined;\n\n/**\n * An arbitrarily nested iterable of Child values.\n *\n * We use a recursive interface here rather than making the Children type\n * directly recursive because recursive type aliases were added in TypeScript\n * 3.7.\n *\n * You should avoid referencing this type directly, as it is mainly exported to\n * prevent TypeScript errors.\n */\nexport interface ChildIterable extends Iterable<Child | ChildIterable> {}\n\n/**\n * Describes all valid values for an element tree, including arbitrarily nested\n * iterables of such values.\n *\n * This type can be used to represent the type of the children prop for an\n * element or the return/yield type of a component.\n */\nexport type Children = Child | ChildIterable;\n\n/**\n * Represents all functions which can be used as a component.\n *\n * @template [TProps=*] - The expected props for the component.\n */\nexport type Component<TProps extends Record<string, unknown> = any> = (\n\tthis: Context<TProps>,\n\tprops: TProps,\n\tctx: Context<TProps>,\n) =>\n\t| Children\n\t| PromiseLike<Children>\n\t// The return type of iterators must include void because TypeScript will\n\t// infer generators which return implicitly as having a void return type.\n\t| Iterator<Children, Children | void, any>\n\t| AsyncIterator<Children, Children | void, any>;\n\n/*** SPECIAL TAGS ***/\n/**\n * A special tag for grouping multiple children within the same parent.\n *\n * All non-string iterables which appear in the element tree are implicitly\n * wrapped in a fragment element.\n *\n * This tag is just the empty string, and you can use the empty string in\n * createElement calls or transpiler options directly to avoid having to\n * reference this export.\n */\nexport const Fragment = \"\";\nexport type Fragment = typeof Fragment;\n\n// TODO: We assert the following symbol tags as Components because TypeScript\n// support for symbol tags in JSX doesn't exist yet.\n// https://github.com/microsoft/TypeScript/issues/38367\n\n/**\n * A special tag for rendering into a new root node via a root prop.\n *\n * This tag is useful for creating element trees with multiple roots, for\n * things like modals or tooltips.\n *\n * Renderer.prototype.render() implicitly wraps top-level in a Portal element\n * with the root set to the second argument passed in.\n */\nexport const Portal = Symbol.for(\"crank.Portal\") as unknown as Component<{\n\troot?: object;\n}> &\n\tsymbol;\nexport type Portal = typeof Portal;\n\n/**\n * A special tag which preserves whatever was previously rendered in the\n * element's position.\n *\n * Copy elements are useful for when you want to prevent a subtree from\n * rerendering as a performance optimization. Copy elements can also be keyed,\n * in which case the previously rendered keyed element will be copied.\n */\nexport const Copy = Symbol.for(\"crank.Copy\") as unknown as Component<{}> &\n\tsymbol;\nexport type Copy = typeof Copy;\n\n/**\n * A special tag for rendering text nodes.\n *\n * Strings in the element tree are implicitly wrapped in a Text element with\n * value set to the string.\n */\nexport const Text = Symbol.for(\"crank.Text\") as unknown as Component<{\n\tvalue: string;\n}> &\n\tsymbol;\nexport type Text = typeof Text;\n\n/** A special tag for injecting raw nodes or strings via a value prop. */\nexport const Raw = Symbol.for(\"crank.Raw\") as unknown as Component<{\n\tvalue: string | object;\n}> &\n\tsymbol;\nexport type Raw = typeof Raw;\n\n/**\n * A type to keep track of keys. Any value can be a key, though null and\n * undefined are ignored.\n */\ntype Key = unknown;\n\ntype ChildrenIteratorResult = IteratorResult<Children, Children | void>;\n\nconst ElementSymbol = Symbol.for(\"crank.Element\");\n\n// To maximize compatibility between Crank versions, starting with 0.2.0, any\n// changes to the Element properties will be considered a breaking change.\nexport interface Element<TTag extends Tag = Tag> {\n\t/**\n\t * @internal\n\t * A unique symbol to identify elements as elements across versions and\n\t * realms, and to protect against basic injection attacks.\n\t * https://overreacted.io/why-do-react-elements-have-typeof-property/\n\t *\n\t * This property is defined on the element prototype rather than per\n\t * instance, because it is the same for every Element.\n\t */\n\t$$typeof: typeof ElementSymbol;\n\n\t/**\n\t * The tag of the element. Can be a string, symbol or function.\n\t */\n\ttag: TTag;\n\n\t/**\n\t * An object containing the \"properties\" of an element. These correspond to\n\t * the attribute syntax from JSX.\n\t */\n\tprops: TagProps<TTag>;\n}\n\n/**\n * Elements are the basic building blocks of Crank applications. They are\n * JavaScript objects which are interpreted by special classes called renderers\n * to produce and manage stateful nodes.\n *\n * @template {Tag} [TTag=Tag] - The type of the tag of the element.\n *\n * @example\n * // specific element types\n * let div: Element<\"div\">;\n * let portal: Element<Portal>;\n * let myEl: Element<MyComponent>;\n *\n * // general element types\n * let host: Element<string | symbol>;\n * let component: Element<Component>;\n *\n * Typically, you use a helper function like createElement to create elements\n * rather than instatiating this class directly.\n */\nexport class Element<TTag extends Tag = Tag> {\n\tconstructor(tag: TTag, props: TagProps<TTag>) {\n\t\tthis.tag = tag;\n\t\tthis.props = props;\n\t}\n}\n\n// See Element interface\nElement.prototype.$$typeof = ElementSymbol;\n\nexport function isElement(value: any): value is Element {\n\treturn value != null && value.$$typeof === ElementSymbol;\n}\n\nconst DEPRECATED_PROP_PREFIXES = [\"crank-\", \"c-\", \"$\"];\n\nconst DEPRECATED_SPECIAL_PROP_BASES = [\"key\", \"ref\", \"static\", \"copy\"];\n/**\n * Creates an element with the specified tag, props and children.\n *\n * This function is usually used as a transpilation target for JSX transpilers,\n * but it can also be called directly. It additionally extracts special props so\n * they aren't accessible to renderer methods or components, and assigns the\n * children prop according to any additional arguments passed to the function.\n */\nexport function createElement<TTag extends Tag>(\n\ttag: TTag,\n\tprops?: TagProps<TTag> | null | undefined,\n\t...children: Array<unknown>\n): Element<TTag> {\n\tif (props == null) {\n\t\tprops = {} as TagProps<TTag>;\n\t}\n\n\tif (\"static\" in (props as TagProps<TTag>)) {\n\t\tconsole.error(`The \\`static\\` prop is deprecated. Use \\`copy\\` instead.`);\n\t\t(props as TagProps<TTag>)[\"copy\"] = (props as TagProps<TTag>)[\"static\"];\n\t\tdelete (props as any)[\"static\"];\n\t}\n\n\tfor (let i = 0; i < DEPRECATED_PROP_PREFIXES.length; i++) {\n\t\tconst propPrefix = DEPRECATED_PROP_PREFIXES[i];\n\t\tfor (let j = 0; j < DEPRECATED_SPECIAL_PROP_BASES.length; j++) {\n\t\t\tconst propBase = DEPRECATED_SPECIAL_PROP_BASES[j];\n\t\t\tconst deprecatedPropName = propPrefix + propBase;\n\t\t\tif (deprecatedPropName in (props as TagProps<TTag>)) {\n\t\t\t\tconst targetPropBase = propBase === \"static\" ? \"copy\" : propBase;\n\t\t\t\tconsole.error(\n\t\t\t\t\t`The \\`${deprecatedPropName}\\` prop is deprecated. Use \\`${targetPropBase}\\` instead.`,\n\t\t\t\t);\n\t\t\t\t(props as TagProps<TTag>)[targetPropBase] = (props as TagProps<TTag>)[\n\t\t\t\t\tdeprecatedPropName\n\t\t\t\t];\n\t\t\t\tdelete (props as any)[deprecatedPropName];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (children.length > 1) {\n\t\t(props as TagProps<TTag>).children = children;\n\t} else if (children.length === 1) {\n\t\t(props as TagProps<TTag>).children = children[0];\n\t}\n\n\treturn new Element(tag, props as TagProps<TTag>);\n}\n\n/** Clones a given element, shallowly copying the props object. */\nexport function cloneElement<TTag extends Tag>(\n\tel: Element<TTag>,\n): Element<TTag> {\n\tif (!isElement(el)) {\n\t\tthrow new TypeError(`Cannot clone non-element: ${String(el)}`);\n\t}\n\n\treturn new Element(el.tag, {...el.props});\n}\n\n/*** ELEMENT UTILITIES ***/\n\n// WHAT ARE WE DOING TO THE CHILDREN???\n/**\n * All values in the element tree are narrowed from the union in Child to\n * NarrowedChild during rendering, to simplify element diffing.\n */\ntype NarrowedChild = Element | string | undefined;\n\nfunction narrow(value: Children): NarrowedChild {\n\tif (typeof value === \"boolean\" || value == null) {\n\t\treturn;\n\t} else if (typeof value === \"string\" || isElement(value)) {\n\t\treturn value;\n\t} else if (typeof (value as any)[Symbol.iterator] === \"function\") {\n\t\treturn createElement(Fragment, null, value);\n\t}\n\n\treturn value.toString();\n}\n\n/**\n * A helper type which repesents all possible rendered values of an element.\n *\n * @template TNode - The type of node produced by the associated renderer.\n *\n * When asking the question, what is the \"value\" of a specific element, the\n * answer varies depending on the tag:\n *\n * For intrinsic elements, the value is the node created for the element, e.g.\n * the DOM node in the case of the DOMRenderer.\n *\n * For portals, the value is undefined, because a Portal element's root and\n * children are opaque to its parent.\n *\n * For component or fragment elements the value can be a node or an array of\n * nodes, depending on how many children they have.\n */\nexport type ElementValue<TNode> = Array<TNode> | TNode | undefined;\n\n/*** RETAINER FLAGS ***/\nconst DidDiff = 1 << 0;\nconst DidCommit = 1 << 1;\nconst IsCopied = 1 << 2;\nconst IsUpdating = 1 << 3;\nconst IsExecuting = 1 << 4;\nconst IsRefreshing = 1 << 5;\nconst IsScheduling = 1 << 6;\nconst IsSchedulingFallback = 1 << 7;\nconst IsUnmounted = 1 << 8;\n// TODO: Is this flag still necessary or can we use IsUnmounted?\nconst IsErrored = 1 << 9;\nconst IsResurrecting = 1 << 10;\n// TODO: Maybe we can get rid of IsSyncGen and IsAsyncGen\nconst IsSyncGen = 1 << 11;\nconst IsAsyncGen = 1 << 12;\nconst IsInForOfLoop = 1 << 13;\nconst IsInForAwaitOfLoop = 1 << 14;\nconst NeedsToYield = 1 << 15;\nconst PropsAvailable = 1 << 16;\nconst IsSchedulingRefresh = 1 << 17;\n\nfunction getFlag(ret: Retainer<unknown>, flag: number): boolean {\n\treturn !!(ret.f & flag);\n}\n\nfunction setFlag(ret: Retainer<unknown>, flag: number, value = true): void {\n\tif (value) {\n\t\tret.f |= flag;\n\t} else {\n\t\tret.f &= ~flag;\n\t}\n}\n\n/**\n * @internal\n * Retainers are objects which act as the internal representation of elements,\n * mirroring the element tree.\n */\nclass Retainer<TNode, TScope = unknown> {\n\t/** A bitmask. See RETAINER FLAGS above. */\n\tdeclare f: number;\n\tdeclare el: Element;\n\tdeclare ctx: ContextState<TNode, TScope, any> | undefined;\n\tdeclare children:\n\t\t| Array<Retainer<TNode, TScope> | undefined>\n\t\t| Retainer<TNode, TScope>\n\t\t| undefined;\n\tdeclare fallback: Retainer<TNode, TScope> | undefined;\n\t// This is only assigned for host, text and raw elements.\n\tdeclare value: ElementValue<TNode> | undefined;\n\tdeclare scope: TScope | undefined;\n\t// This is only assigned for host and raw elements.\n\tdeclare oldProps: Record<string, any> | undefined;\n\tdeclare pendingDiff: Promise<undefined> | undefined;\n\tdeclare onNextDiff: Function | undefined;\n\tdeclare graveyard: Array<Retainer<TNode, TScope>> | undefined;\n\tdeclare lingerers:\n\t\t| Array<Set<Retainer<TNode, TScope>> | undefined>\n\t\t| undefined;\n\n\tconstructor(el: Element) {\n\t\tthis.f = 0;\n\t\tthis.el = el;\n\t\tthis.ctx = undefined;\n\t\tthis.children = undefined;\n\t\tthis.fallback = undefined;\n\t\tthis.value = undefined;\n\t\tthis.oldProps = undefined;\n\t\tthis.pendingDiff = undefined;\n\t\tthis.onNextDiff = undefined;\n\t\tthis.graveyard = undefined;\n\t\tthis.lingerers = undefined;\n\t}\n}\n\nfunction cloneRetainer<TNode, TScope>(\n\tret: Retainer<TNode, TScope>,\n): Retainer<TNode, TScope> {\n\tconst clone = new Retainer<TNode, TScope>(ret.el);\n\tclone.f = ret.f;\n\tclone.ctx = ret.ctx;\n\tclone.children = ret.children;\n\tclone.fallback = ret.fallback;\n\tclone.value = ret.value;\n\tclone.scope = ret.scope;\n\tclone.oldProps = ret.oldProps;\n\tclone.pendingDiff = ret.pendingDiff;\n\tclone.onNextDiff = ret.onNextDiff;\n\tclone.graveyard = ret.graveyard;\n\tclone.lingerers = ret.lingerers;\n\n\treturn clone;\n}\n\n/**\n * Finds the value of the element according to its type.\n *\n * @returns A node, an array of nodes or undefined.\n */\nfunction getValue<TNode>(\n\tret: Retainer<TNode>,\n\tisNested = false,\n\tindex?: number,\n): ElementValue<TNode> {\n\tif (getFlag(ret, IsScheduling) && isNested) {\n\t\treturn ret.fallback ? getValue(ret.fallback, isNested, index) : undefined;\n\t} else if (ret.fallback && !getFlag(ret, DidDiff)) {\n\t\treturn ret.fallback\n\t\t\t? getValue(ret.fallback, isNested, index)\n\t\t\t: ret.fallback;\n\t} else if (ret.el.tag === Portal) {\n\t\treturn;\n\t} else if (ret.el.tag === Fragment || typeof ret.el.tag === \"function\") {\n\t\tif (index != null && ret.ctx) {\n\t\t\tret.ctx.index = index;\n\t\t}\n\t\treturn unwrap(getChildValues(ret, index));\n\t}\n\n\treturn ret.value;\n}\n\n/**\n * Walks an element's children to find its child values.\n *\n * @param ret - The retainer whose child values we are reading.\n * @param startIndex - Starting index to thread through for context index updates.\n *\n * @returns An array of nodes.\n */\nfunction getChildValues<TNode>(\n\tret: Retainer<TNode>,\n\tstartIndex?: number,\n): Array<TNode> {\n\tconst values: Array<TNode> = [];\n\tconst lingerers = ret.lingerers;\n\tconst children = wrap(ret.children);\n\tlet currentIndex = startIndex;\n\n\tfor (let i = 0; i < children.length; i++) {\n\t\tif (lingerers != null && lingerers[i] != null) {\n\t\t\tconst rets = lingerers[i]!;\n\t\t\tfor (const ret of rets) {\n\t\t\t\tconst value = getValue(ret, true, currentIndex);\n\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\tfor (let j = 0; j < value.length; j++) {\n\t\t\t\t\t\tvalues.push(value[j]);\n\t\t\t\t\t}\n\t\t\t\t\tif (currentIndex != null) {\n\t\t\t\t\t\tcurrentIndex += value.length;\n\t\t\t\t\t}\n\t\t\t\t} else if (value) {\n\t\t\t\t\tvalues.push(value);\n\t\t\t\t\tif (currentIndex != null) {\n\t\t\t\t\t\tcurrentIndex++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst child = children[i];\n\t\tif (child) {\n\t\t\tconst value = getValue(child, true, currentIndex);\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tfor (let j = 0; j < value.length; j++) {\n\t\t\t\t\tvalues.push(value[j]);\n\t\t\t\t}\n\t\t\t\tif (currentIndex != null) {\n\t\t\t\t\tcurrentIndex += value.length;\n\t\t\t\t}\n\t\t\t} else if (value) {\n\t\t\t\tvalues.push(value);\n\t\t\t\tif (currentIndex != null) {\n\t\t\t\t\tcurrentIndex++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (lingerers != null && lingerers.length > children.length) {\n\t\tfor (let i = children.length; i < lingerers.length; i++) {\n\t\t\tconst rets = lingerers[i];\n\t\t\tif (rets != null) {\n\t\t\t\tfor (const ret of rets) {\n\t\t\t\t\tconst value = getValue(ret, true, currentIndex);\n\t\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\t\tfor (let j = 0; j < value.length; j++) {\n\t\t\t\t\t\t\tvalues.push(value[j]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (currentIndex != null) {\n\t\t\t\t\t\t\tcurrentIndex += value.length;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (value) {\n\t\t\t\t\t\tvalues.push(value);\n\t\t\t\t\t\tif (currentIndex != null) {\n\t\t\t\t\t\t\tcurrentIndex++;\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}\n\t}\n\n\treturn values;\n}\n\nfunction stripSpecialProps(props: Record<string, any>): Record<string, any> {\n\tlet _: unknown;\n\tlet result: Record<string, any>;\n\t({key: _, ref: _, copy: _, hydrate: _, children: _, ...result} = props);\n\treturn result;\n}\n\n/**\n * Interface for adapting the rendering process to a specific target environment.\n *\n * The RenderAdapter defines how Crank elements are mapped to nodes in your target\n * rendering environment (DOM, Canvas, WebGL, Terminal, etc.). Each method handles\n * a specific part of the element lifecycle, from creation to removal.\n *\n * @template TNode - The type representing a node in your target environment\n * @template TScope - Additional context data passed down the component tree\n * @template TRoot - The type of the root container (defaults to TNode)\n * @template TResult - The type returned when reading element values (defaults to ElementValue<TNode>)\n *\n * @example\n * ```typescript\n * const adapter: RenderAdapter<MyNode, MyScope> = {\n *   create: ({ tag, props }) => new MyNode(tag, props),\n *   patch: ({ node, props }) => node.update(props),\n *   arrange: ({ node, children }) => node.replaceChildren(children),\n *   // ... other methods\n * };\n * ```\n */\nexport interface RenderAdapter<\n\tTNode,\n\tTScope,\n\tTRoot extends TNode | undefined = TNode,\n\tTResult = ElementValue<TNode>,\n> {\n\t/**\n\t * Creates a new node for the given element tag and props.\n\t *\n\t * This method is called when Crank encounters a new element that needs to be\n\t * rendered for the first time. You should create and return a node appropriate\n\t * for your target environment.\n\t *\n\t * @param data.tag - The element tag (e.g., \"div\", \"sprite\", or a symbol)\n\t * @param data.tagName - String representation of the tag for debugging\n\t * @param data.props - The element's props object\n\t * @param data.scope - Current scope context (can be undefined)\n\t * @returns A new node instance\n\t *\n\t * @example\n\t * ```typescript\n\t * create: ({ tag, props, scope }) => {\n\t *   if (tag === \"sprite\") {\n\t *     return new PIXI.Sprite(props.texture);\n\t *   }\n\t *   throw new Error(`Unknown tag: ${tag}`);\n\t * }\n\t * ```\n\t */\n\tcreate(data: {\n\t\ttag: string | symbol;\n\t\ttagName: string;\n\t\tprops: Record<string, any>;\n\t\tscope: TScope | undefined;\n\t\troot: TRoot | undefined;\n\t}): TNode;\n\n\t/**\n\t * Adopts existing nodes during hydration.\n\t *\n\t * Called when hydrating server-rendered content or reusing existing nodes.\n\t * Should return an array of child nodes if the provided node matches the\n\t * expected tag, or undefined if hydration should fail.\n\t *\n\t * @param data.tag - The element tag being hydrated\n\t * @param data.tagName - String representation of the tag\n\t * @param data.props - The element's props\n\t * @param data.node - The existing node to potentially adopt\n\t * @param data.scope - Current scope context\n\t * @returns Array of child nodes to hydrate, or undefined if adoption fails\n\t *\n\t * @example\n\t * ```typescript\n\t * adopt: ({ tag, node }) => {\n\t *   if (node && node.tagName.toLowerCase() === tag) {\n\t *     return Array.from(node.children);\n\t *   }\n\t *   return undefined; // Hydration mismatch\n\t * }\n\t * ```\n\t */\n\tadopt(data: {\n\t\ttag: string | symbol;\n\t\ttagName: string;\n\t\tprops: Record<string, any>;\n\t\tnode: TNode | undefined;\n\t\tscope: TScope | undefined;\n\t\troot: TRoot | undefined;\n\t}): Array<TNode> | undefined;\n\n\t/**\n\t * Creates or updates a text node.\n\t *\n\t * Called when rendering text content. Should create a new text node or\n\t * update an existing one with the provided value.\n\t *\n\t * @param data.value - The text content to render\n\t * @param data.scope - Current scope context\n\t * @param data.oldNode - Previous text node to potentially reuse\n\t * @param data.hydrationNodes - Nodes available during hydration\n\t * @returns A text node containing the given value\n\t *\n\t * @example\n\t * ```typescript\n\t * text: ({ value, oldNode }) => {\n\t *   if (oldNode && oldNode.text !== value) {\n\t *     oldNode.text = value;\n\t *     return oldNode;\n\t *   }\n\t *   return new TextNode(value);\n\t * }\n\t * ```\n\t */\n\ttext(data: {\n\t\tvalue: string;\n\t\tscope: TScope | undefined;\n\t\toldNode: TNode | undefined;\n\t\thydrationNodes: Array<TNode> | undefined;\n\t\troot: TRoot | undefined;\n\t}): TNode;\n\n\t/**\n\t * Computes scope context for child elements.\n\t *\n\t * Called to determine what scope context should be passed to child elements.\n\t * The scope can be used to pass rendering context like theme, coordinate systems,\n\t * or namespaces down the component tree.\n\t *\n\t * @param data.tag - The element tag\n\t * @param data.tagName - String representation of the tag\n\t * @param data.props - The element's props\n\t * @param data.scope - Current scope context\n\t * @returns New scope for children, or undefined to inherit current scope\n\t *\n\t * @example\n\t * ```typescript\n\t * scope: ({ tag, props, scope }) => {\n\t *   if (tag === \"svg\") {\n\t *     return { ...scope, namespace: \"http://www.w3.org/2000/svg\" };\n\t *   }\n\t *   return scope;\n\t * }\n\t * ```\n\t */\n\tscope(data: {\n\t\ttag: string | symbol;\n\t\ttagName: string;\n\t\tprops: Record<string, any>;\n\t\tscope: TScope | undefined;\n\t\troot: TRoot | undefined;\n\t}): TScope | undefined;\n\n\t/**\n\t * Handles raw values (strings or nodes) that bypass normal element processing.\n\t *\n\t * Called when rendering Raw elements or other direct node insertions.\n\t * Should convert string values to appropriate nodes for your environment.\n\t *\n\t * @param data.value - Raw string or node value to render\n\t * @param data.scope - Current scope context\n\t * @param data.hydrationNodes - Nodes available during hydration\n\t * @returns ElementValue that can be handled by arrange()\n\t *\n\t * @example\n\t * ```typescript\n\t * raw: ({ value, scope }) => {\n\t *   if (typeof value === \"string\") {\n\t *     const container = new Container();\n\t *     container.innerHTML = value;\n\t *     return Array.from(container.children);\n\t *   }\n\t *   return value;\n\t * }\n\t * ```\n\t */\n\traw(data: {\n\t\tvalue: string | TNode;\n\t\tscope: TScope | undefined;\n\t\thydrationNodes: Array<TNode> | undefined;\n\t\troot: TRoot | undefined;\n\t}): ElementValue<TNode>;\n\n\t/**\n\t * Updates a node's properties.\n\t *\n\t * Called when element props change. Should efficiently update only the\n\t * properties that have changed. This is where you implement prop-to-attribute\n\t * mapping, event listener binding, and other property synchronization.\n\t *\n\t * @param data.tag - The element tag\n\t * @param data.tagName - String representation of the tag\n\t * @param data.node - The node to update\n\t * @param data.props - New props object\n\t * @param data.oldProps - Previous props object (undefined for initial render)\n\t * @param data.scope - Current scope context\n\t * @param data.copyProps - Props to skip (used for copying between renderers)\n\t * @param data.isHydrating - Whether currently hydrating\n\t * @param data.quietProps - Props to not warn about during hydration\n\t *\n\t * @example\n\t * ```typescript\n\t * patch: ({ node, props, oldProps }) => {\n\t *   for (const [key, value] of Object.entries(props)) {\n\t *     if (oldProps?.[key] !== value) {\n\t *       if (key.startsWith(\"on\")) {\n\t *         node.addEventListener(key.slice(2), value);\n\t *       } else {\n\t *         node[key] = value;\n\t *       }\n\t *     }\n\t *   }\n\t * }\n\t * ```\n\t */\n\tpatch(data: {\n\t\ttag: string | symbol;\n\t\ttagName: string;\n\t\tnode: TNode;\n\t\tprops: Record<string, any>;\n\t\toldProps: Record<string, any> | undefined;\n\t\tscope: TScope | undefined;\n\t\troot: TRoot | undefined;\n\t\tcopyProps: Set<string> | undefined;\n\t\tisHydrating: boolean;\n\t\tquietProps: Set<string> | undefined;\n\t}): void;\n\n\t/**\n\t * Arranges child nodes within their parent.\n\t *\n\t * Called after child elements are rendered to organize them within their\n\t * parent node. Should efficiently insert, move, or remove child nodes to\n\t * match the provided children array.\n\t *\n\t * @param data.tag - The parent element tag\n\t * @param data.tagName - String representation of the tag\n\t * @param data.node - The parent node\n\t * @param data.props - The parent element's props\n\t * @param data.children - Array of child nodes in correct order\n\t * @param data.oldProps - Previous props (for reference)\n\t *\n\t * @example\n\t * ```typescript\n\t * arrange: ({ node, children }) => {\n\t *   // Remove existing children\n\t *   node.removeChildren();\n\t *   // Add new children in order\n\t *   for (const child of children) {\n\t *     node.addChild(child);\n\t *   }\n\t * }\n\t * ```\n\t */\n\tarrange(data: {\n\t\ttag: string | symbol;\n\t\ttagName: string;\n\t\tnode: TNode;\n\t\tprops: Record<string, any>;\n\t\tchildren: Array<TNode>;\n\t\toldProps: Record<string, any> | undefined;\n\t\troot: TRoot | undefined;\n\t}): void;\n\n\t/**\n\t * Removes a node from its parent.\n\t *\n\t * Called when an element is being unmounted. Should clean up the node\n\t * and remove it from its parent if appropriate.\n\t *\n\t * @param data.node - The node to remove\n\t * @param data.parentNode - The parent node\n\t * @param data.isNested - Whether this is a nested removal (child of removed element)\n\t *\n\t * @example\n\t * ```typescript\n\t * remove: ({ node, parentNode, isNested }) => {\n\t *   // Clean up event listeners, resources, etc.\n\t *   node.cleanup?.();\n\t *   // Remove from parent unless it's a nested removal\n\t *   if (!isNested && parentNode.contains(node)) {\n\t *     parentNode.removeChild(node);\n\t *   }\n\t * }\n\t * ```\n\t */\n\tremove(data: {\n\t\tnode: TNode;\n\t\tparentNode: TNode;\n\t\tisNested: boolean;\n\t\troot: TRoot | undefined;\n\t}): void;\n\n\t/**\n\t * Reads the final rendered value from an ElementValue.\n\t *\n\t * Called to extract the final result from rendered elements. This allows\n\t * you to transform the internal node representation into the public API\n\t * that users of your renderer will see.\n\t *\n\t * @param value - The ElementValue to read (array, single node, or undefined)\n\t * @returns The public representation of the rendered value\n\t *\n\t * @example\n\t * ```typescript\n\t * read: (value) => {\n\t *   if (Array.isArray(value)) {\n\t *     return value.map(node => node.publicAPI);\n\t *   }\n\t *   return value?.publicAPI;\n\t * }\n\t * ```\n\t */\n\tread(value: ElementValue<TNode>): TResult;\n\n\t/**\n\t * Performs final rendering to the root container.\n\t *\n\t * Called after the entire render cycle is complete. This is where you\n\t * trigger the actual rendering/presentation in your target environment\n\t * (e.g., calling render() on a canvas, flushing to the screen, etc.).\n\t *\n\t * @param root - The root container\n\t *\n\t * @example\n\t * ```typescript\n\t * finalize: (root) => {\n\t *   // Trigger actual rendering\n\t *   if (root instanceof PIXIApplication) {\n\t *     root.render();\n\t *   }\n\t * }\n\t * ```\n\t */\n\tfinalize(root: TRoot): void;\n}\n\nconst defaultAdapter: RenderAdapter<any, any, any, any> = {\n\tcreate() {\n\t\tthrow new Error(\"adapter must implement create\");\n\t},\n\tadopt() {\n\t\tthrow new Error(\"adapter must implement adopt() for hydration\");\n\t},\n\tscope: ({scope}) => scope,\n\tread: (value) => value,\n\ttext: ({value}) => value,\n\traw: ({value}) => value,\n\tpatch: NOOP,\n\tarrange: NOOP,\n\tremove: NOOP,\n\tfinalize: NOOP,\n};\n\n/**\n * An abstract class which is subclassed to render to different target\n * environments. Subclasses call super() with a custom RenderAdapter object.\n * This class is responsible for kicking off the rendering process and caching\n * previous trees by root.\n *\n * @template TNode - The type of the node for a rendering environment.\n * @template TScope - Data which is passed down the tree.\n * @template TRoot - The type of the root for a rendering environment.\n * @template TResult - The type of exposed values.\n */\nexport class Renderer<\n\tTNode extends object,\n\tTScope,\n\tTRoot extends TNode | undefined = TNode,\n\tTResult = ElementValue<TNode>,\n> {\n\t/**\n\t * @internal\n\t * A weakmap which stores element trees by root.\n\t */\n\tdeclare cache: WeakMap<object, Retainer<TNode, TScope>>;\n\tdeclare adapter: RenderAdapter<TNode, TScope, TRoot, TResult>;\n\tconstructor(adapter: Partial<RenderAdapter<TNode, TScope, TRoot, TResult>>) {\n\t\tthis.cache = new WeakMap();\n\t\tthis.adapter = {...defaultAdapter, ...adapter};\n\t}\n\n\t/**\n\t * Renders an element tree into a specific root.\n\t *\n\t * @param children - An element tree. Rendering null deletes cached renders.\n\t * @param root - The root to be rendered into. The renderer caches renders\n\t * per root.\n\t * @param bridge - An optional context that will be the ancestor context of\n\t * all elements in the tree. Useful for connecting different renderers so\n\t * that events/provisions/errors properly propagate. The context for a given\n\t * root must be the same between renders.\n\t *\n\t * @returns The result of rendering the children, or a possible promise of\n\t * the result if the element tree renders asynchronously.\n\t */\n\trender(\n\t\tchildren: Children,\n\t\troot?: TRoot | undefined,\n\t\tbridge?: Context | undefined,\n\t): Promise<TResult> | TResult {\n\t\tconst ret = getRootRetainer(this, bridge, {children, root});\n\t\treturn renderRoot(this.adapter, root, ret, children) as\n\t\t\t| Promise<TResult>\n\t\t\t| TResult;\n\t}\n\n\thydrate(\n\t\tchildren: Children,\n\t\troot: TRoot,\n\t\tbridge?: Context | undefined,\n\t): Promise<TResult> | TResult {\n\t\tconst ret = getRootRetainer(this, bridge, {\n\t\t\tchildren,\n\t\t\troot,\n\t\t\thydrate: true,\n\t\t});\n\t\treturn renderRoot(this.adapter, root, ret, children) as\n\t\t\t| Promise<TResult>\n\t\t\t| TResult;\n\t}\n}\n\n/*** PRIVATE RENDERER FUNCTIONS ***/\nfunction getRootRetainer<\n\tTNode extends object,\n\tTScope,\n\tTRoot extends TNode | undefined,\n>(\n\trenderer: Renderer<TNode, TScope, TRoot, unknown>,\n\tbridge: Context | undefined,\n\t{\n\t\tchildren,\n\t\troot,\n\t\thydrate,\n\t}: {\n\t\tchildren: Children;\n\t\troot: TRoot | undefined;\n\t\thydrate?: boolean;\n\t},\n): Retainer<TNode, TScope> {\n\tlet ret: Retainer<TNode, TScope> | undefined;\n\tconst bridgeCtx = bridge && bridge[_ContextState];\n\tif (typeof root === \"object\" && root !== null) {\n\t\tret = renderer.cache.get(root);\n\t}\n\n\tconst adapter = renderer.adapter;\n\tif (ret === undefined) {\n\t\tret = new Retainer(createElement(Portal, {children, root, hydrate}));\n\t\tret.value = root;\n\t\tret.ctx = bridgeCtx as ContextState<any, any> | undefined;\n\t\tret.scope = adapter.scope({\n\t\t\ttag: Portal,\n\t\t\ttagName: getTagName(Portal),\n\t\t\tprops: stripSpecialProps(ret.el.props),\n\t\t\tscope: undefined,\n\t\t\troot,\n\t\t});\n\t\t// remember that typeof null === \"object\"\n\t\tif (typeof root === \"object\" && root !== null && children != null) {\n\t\t\trenderer.cache.set(root, ret);\n\t\t}\n\t} else if (ret.ctx !== bridgeCtx) {\n\t\tthrow new Error(\n\t\t\t\"A previous call to render() was passed a different context\",\n\t\t);\n\t} else {\n\t\tret.el = createElement(Portal, {children, root, hydrate});\n\t\tif (typeof root === \"object\" && root !== null && children == null) {\n\t\t\trenderer.cache.delete(root);\n\t\t}\n\t}\n\n\treturn ret;\n}\n\nfunction renderRoot<TNode, TScope, TRoot extends TNode | undefined, TResult>(\n\tadapter: RenderAdapter<TNode, TScope, TRoot, TResult>,\n\troot: TRoot | undefined,\n\tret: Retainer<TNode, TScope>,\n\tchildren: Children,\n): Promise<TResult> | TResult {\n\tconst diff = diffChildren(\n\t\tadapter,\n\t\troot,\n\t\tret,\n\t\tret.ctx,\n\t\tret.scope,\n\t\tret,\n\t\tchildren,\n\t);\n\n\tconst schedulePromises: Array<PromiseLike<unknown>> = [];\n\tif (isPromiseLike(diff)) {\n\t\treturn diff.then(() => {\n\t\t\tcommit(\n\t\t\t\tadapter,\n\t\t\t\tret,\n\t\t\t\tret,\n\t\t\t\tret.ctx,\n\t\t\t\tret.scope,\n\t\t\t\troot,\n\t\t\t\t0,\n\t\t\t\tschedulePromises,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tif (schedulePromises.length > 0) {\n\t\t\t\treturn Promise.all(schedulePromises).then(() => {\n\t\t\t\t\tif (typeof root !== \"object\" || root === null) {\n\t\t\t\t\t\tunmount(adapter, ret, ret.ctx, root, ret, false);\n\t\t\t\t\t}\n\t\t\t\t\treturn adapter.read(unwrap(getChildValues(ret)));\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (typeof root !== \"object\" || root === null) {\n\t\t\t\tunmount(adapter, ret, ret.ctx, root, ret, false);\n\t\t\t}\n\t\t\treturn adapter.read(unwrap(getChildValues(ret)));\n\t\t});\n\t}\n\n\tcommit(\n\t\tadapter,\n\t\tret,\n\t\tret,\n\t\tret.ctx,\n\t\tret.scope,\n\t\troot,\n\t\t0,\n\t\tschedulePromises,\n\t\tundefined,\n\t);\n\tif (schedulePromises.length > 0) {\n\t\treturn Promise.all(schedulePromises).then(() => {\n\t\t\tif (typeof root !== \"object\" || root === null) {\n\t\t\t\tunmount(adapter, ret, ret.ctx, root, ret, false);\n\t\t\t}\n\t\t\treturn adapter.read(unwrap(getChildValues(ret)));\n\t\t});\n\t}\n\n\tif (typeof root !== \"object\" || root === null) {\n\t\tunmount(adapter, ret, ret.ctx, root, ret, false);\n\t}\n\treturn adapter.read(unwrap(getChildValues(ret)));\n}\n\nfunction diffChildren<TNode, TScope, TRoot extends TNode | undefined, TResult>(\n\tadapter: RenderAdapter<TNode, TScope, TRoot, TResult>,\n\troot: TRoot | undefined,\n\thost: Retainer<TNode, TScope>,\n\tctx: ContextState<TNode, TScope, TRoot, TResult> | undefined,\n\tscope: TScope | undefined,\n\tparent: Retainer<TNode, TScope>,\n\tnewChildren: Children,\n): Promise<undefined> | undefined {\n\tconst oldRetained = wrap(parent.children);\n\tconst newRetained: typeof oldRetained = [];\n\tconst newChildren1 = arrayify(newChildren);\n\tconst diffs: Array<Promise<undefined> | undefined> = [];\n\tlet childrenByKey: Map<Key, Retainer<TNode, TScope>> | undefined;\n\tlet seenKeys: Set<Key> | undefined;\n\tlet isAsync = false;\n\tlet oi = 0;\n\tlet oldLength = oldRetained.length;\n\tlet graveyard: Array<Retainer<TNode, TScope>> | undefined;\n\tfor (let ni = 0, newLength = newChildren1.length; ni < newLength; ni++) {\n\t\t// length checks to prevent index out of bounds deoptimizations.\n\t\tlet ret = oi >= oldLength ? undefined : oldRetained[oi];\n\t\tlet child = narrow(newChildren1[ni]);\n\t\t{\n\t\t\t// aligning new children with old retainers\n\t\t\tlet oldKey = typeof ret === \"object\" ? ret.el.props.key : undefined;\n\t\t\tlet newKey = typeof child === \"object\" ? child.props.key : undefined;\n\t\t\tif (newKey !== undefined && seenKeys && seenKeys.has(newKey)) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`Duplicate key found in <${getTagName(parent.el.tag)}>`,\n\t\t\t\t\tnewKey,\n\t\t\t\t);\n\t\t\t\tchild = cloneElement(child as Element);\n\t\t\t\tnewKey = child.props.key = undefined;\n\t\t\t}\n\n\t\t\tif (oldKey === newKey) {\n\t\t\t\tif (childrenByKey !== undefined && newKey !== undefined) {\n\t\t\t\t\tchildrenByKey.delete(newKey);\n\t\t\t\t}\n\n\t\t\t\toi++;\n\t\t\t} else {\n\t\t\t\tchildrenByKey = childrenByKey || createChildrenByKey(oldRetained, oi);\n\t\t\t\tif (newKey === undefined) {\n\t\t\t\t\twhile (ret !== undefined && oldKey !== undefined) {\n\t\t\t\t\t\toi++;\n\t\t\t\t\t\tret = oldRetained[oi];\n\t\t\t\t\t\toldKey = typeof ret === \"object\" ? ret.el.props.key : undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\toi++;\n\t\t\t\t} else {\n\t\t\t\t\tret = childrenByKey.get(newKey);\n\t\t\t\t\tif (ret !== undefined) {\n\t\t\t\t\t\tchildrenByKey.delete(newKey);\n\t\t\t\t\t}\n\n\t\t\t\t\t(seenKeys = seenKeys || new Set()).add(newKey);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet diff: Promise<undefined> | undefined = undefined;\n\t\tif (typeof child === \"object\") {\n\t\t\tlet childCopied = false;\n\t\t\tif (child.tag === Copy) {\n\t\t\t\tchildCopied = true;\n\t\t\t} else if (\n\t\t\t\ttypeof ret === \"object\" &&\n\t\t\t\tret.el === child &&\n\t\t\t\tgetFlag(ret, DidCommit)\n\t\t\t) {\n\t\t\t\t// If the child is the same as the retained element, we skip\n\t\t\t\t// re-rendering.\n\t\t\t\tchildCopied = true;\n\t\t\t} else {\n\t\t\t\tif (ret && ret.el.tag === child.tag) {\n\t\t\t\t\tret.el = child;\n\t\t\t\t\tif (child.props.copy && typeof child.props.copy !== \"string\") {\n\t\t\t\t\t\tchildCopied = true;\n\t\t\t\t\t}\n\t\t\t\t} else if (ret) {\n\t\t\t\t\tlet candidateFound = false;\n\t\t\t\t\t// we do not need to add the retainer to the graveyard if it is the\n\t\t\t\t\t// fallback of another retainer\n\t\t\t\t\t// search for the tag in fallback chain\n\t\t\t\t\tfor (\n\t\t\t\t\t\tlet predecessor = ret, candidate = ret.fallback;\n\t\t\t\t\t\tcandidate;\n\t\t\t\t\t\tpredecessor = candidate, candidate = candidate.fallback\n\t\t\t\t\t) {\n\t\t\t\t\t\tif (candidate.el.tag === child.tag) {\n\t\t\t\t\t\t\t// If we find a retainer in the fallback chain with the same tag,\n\t\t\t\t\t\t\t// we reuse it rather than creating a new retainer to preserve\n\t\t\t\t\t\t\t// state. This behavior is useful for when a Suspense component\n\t\t\t\t\t\t\t// re-renders and the children are re-rendered quickly.\n\t\t\t\t\t\t\tconst clone = cloneRetainer(candidate);\n\t\t\t\t\t\t\tsetFlag(clone, IsResurrecting);\n\t\t\t\t\t\t\tpredecessor.fallback = clone;\n\t\t\t\t\t\t\tconst fallback = ret;\n\t\t\t\t\t\t\tret = candidate;\n\t\t\t\t\t\t\tret.el = child;\n\t\t\t\t\t\t\tret.fallback = fallback;\n\t\t\t\t\t\t\tsetFlag(ret, DidDiff, false);\n\t\t\t\t\t\t\tcandidateFound = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!candidateFound) {\n\t\t\t\t\t\tconst fallback = ret;\n\t\t\t\t\t\tret = new Retainer<TNode, TScope>(child);\n\t\t\t\t\t\tret.fallback = fallback;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tret = new Retainer<TNode, TScope>(child);\n\t\t\t\t}\n\n\t\t\t\tif (childCopied && getFlag(ret, DidCommit)) {\n\t\t\t\t\t// pass\n\t\t\t\t} else if (child.tag === Raw || child.tag === Text) {\n\t\t\t\t\t// pass\n\t\t\t\t} else if (child.tag === Fragment) {\n\t\t\t\t\tdiff = diffChildren(\n\t\t\t\t\t\tadapter,\n\t\t\t\t\t\troot,\n\t\t\t\t\t\thost,\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tret,\n\t\t\t\t\t\tret.el.props.children as Children,\n\t\t\t\t\t);\n\t\t\t\t} else if (typeof child.tag === \"function\") {\n\t\t\t\t\tdiff = diffComponent(adapter, root, host, ctx, scope, ret);\n\t\t\t\t} else {\n\t\t\t\t\tdiff = diffHost(adapter, root, ctx, scope, ret);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof ret === \"object\") {\n\t\t\t\tif (childCopied) {\n\t\t\t\t\tsetFlag(ret, IsCopied);\n\t\t\t\t\tdiff = getInflightDiff(ret);\n\t\t\t\t} else {\n\t\t\t\t\tsetFlag(ret, IsCopied, false);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isPromiseLike(diff)) {\n\t\t\t\tisAsync = true;\n\t\t\t}\n\t\t} else if (typeof child === \"string\") {\n\t\t\tif (typeof ret === \"object\" && ret.el.tag === Text) {\n\t\t\t\tret.el.props.value = child;\n\t\t\t} else {\n\t\t\t\tif (typeof ret === \"object\") {\n\t\t\t\t\t(graveyard = graveyard || []).push(ret);\n\t\t\t\t}\n\n\t\t\t\tret = new Retainer<TNode, TScope>(createElement(Text, {value: child}));\n\t\t\t}\n\t\t} else {\n\t\t\tif (typeof ret === \"object\") {\n\t\t\t\t(graveyard = graveyard || []).push(ret);\n\t\t\t}\n\n\t\t\tret = undefined;\n\t\t}\n\n\t\tdiffs[ni] = diff;\n\t\tnewRetained[ni] = ret;\n\t}\n\n\t// cleanup remaining retainers\n\tfor (; oi < oldLength; oi++) {\n\t\tconst ret = oldRetained[oi];\n\t\tif (\n\t\t\ttypeof ret === \"object\" &&\n\t\t\t(typeof ret.el.props.key === \"undefined\" ||\n\t\t\t\t!seenKeys ||\n\t\t\t\t!seenKeys.has(ret.el.props.key))\n\t\t) {\n\t\t\t(graveyard = graveyard || []).push(ret);\n\t\t}\n\t}\n\n\tif (childrenByKey !== undefined && childrenByKey.size > 0) {\n\t\tgraveyard = graveyard || [];\n\t\tfor (const ret of childrenByKey.values()) {\n\t\t\tgraveyard.push(ret);\n\t\t}\n\t}\n\n\tparent.children = unwrap(newRetained);\n\tif (isAsync) {\n\t\tconst diffs1 = Promise.all(diffs)\n\t\t\t.then(() => undefined)\n\t\t\t.finally(() => {\n\t\t\t\tsetFlag(parent, DidDiff);\n\t\t\t\tif (graveyard) {\n\t\t\t\t\tif (parent.graveyard) {\n\t\t\t\t\t\tfor (let i = 0; i < graveyard.length; i++) {\n\t\t\t\t\t\t\tparent.graveyard.push(graveyard[i]);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparent.graveyard = graveyard;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\tlet onNextDiffs!: Function;\n\t\tconst diffs2 = (parent.pendingDiff = safeRace([\n\t\t\tdiffs1,\n\t\t\tnew Promise<any>((resolve) => (onNextDiffs = resolve)),\n\t\t]));\n\n\t\tif (parent.onNextDiff) {\n\t\t\tparent.onNextDiff(diffs2);\n\t\t}\n\n\t\tparent.onNextDiff = onNextDiffs;\n\t\treturn diffs2;\n\t} else {\n\t\tsetFlag(parent, DidDiff);\n\t\tif (graveyard) {\n\t\t\tif (parent.graveyard) {\n\t\t\t\tfor (let i = 0; i < graveyard.length; i++) {\n\t\t\t\t\tparent.graveyard.push(graveyard[i]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tparent.graveyard = graveyard;\n\t\t\t}\n\t\t}\n\n\t\tif (parent.onNextDiff) {\n\t\t\tparent.onNextDiff(diffs);\n\t\t\tparent.onNextDiff = undefined;\n\t\t}\n\n\t\tparent.pendingDiff = undefined;\n\t}\n}\n\nfunction getInflightDiff(\n\tret: Retainer<unknown>,\n): Promise<undefined> | undefined {\n\t// It is not enough to check pendingDiff because pendingDiff is the diff for\n\t// children, but not the diff of an async component retainer's current run.\n\t// For the latter we check ctx.inflight.\n\tif (ret.ctx && ret.ctx.inflight) {\n\t\treturn ret.ctx.inflight[1];\n\t} else if (ret.pendingDiff) {\n\t\treturn ret.pendingDiff;\n\t}\n}\n\nfunction createChildrenByKey<TNode, TScope>(\n\tchildren: Array<Retainer<TNode, TScope> | undefined>,\n\toffset: number,\n): Map<Key, Retainer<TNode, TScope>> {\n\tconst childrenByKey = new Map<Key, Retainer<TNode, TScope>>();\n\tfor (let i = offset; i < children.length; i++) {\n\t\tconst child = children[i];\n\t\tif (\n\t\t\ttypeof child === \"object\" &&\n\t\t\ttypeof child.el.props.key !== \"undefined\"\n\t\t) {\n\t\t\tchildrenByKey.set(child.el.props.key, child);\n\t\t}\n\t}\n\n\treturn childrenByKey;\n}\n\nfunction diffHost<TNode, TScope, TRoot extends TNode | undefined>(\n\tadapter: RenderAdapter<TNode, TScope, TRoot, unknown>,\n\troot: TRoot,\n\tctx: ContextState<TNode, TScope, TRoot> | undefined,\n\tscope: TScope | undefined,\n\tret: Retainer<TNode, TScope>,\n): Promise<undefined> | undefined {\n\tconst el = ret.el;\n\tconst tag = el.tag as string | symbol;\n\tif (el.tag === Portal) {\n\t\troot = ret.value = el.props.root;\n\t}\n\n\tif (getFlag(ret, DidCommit)) {\n\t\tscope = ret.scope;\n\t} else {\n\t\tscope = ret.scope = adapter.scope({\n\t\t\ttag,\n\t\t\ttagName: getTagName(tag),\n\t\t\tprops: el.props,\n\t\t\tscope,\n\t\t\troot,\n\t\t});\n\t}\n\n\treturn diffChildren(\n\t\tadapter,\n\t\troot,\n\t\tret,\n\t\tctx,\n\t\tscope,\n\t\tret,\n\t\tret.el.props.children,\n\t);\n}\n\nfunction commit<TNode, TScope, TRoot extends TNode | undefined, TResult>(\n\tadapter: RenderAdapter<TNode, TScope, TRoot, TResult>,\n\thost: Retainer<TNode, TScope>,\n\tret: Retainer<TNode, TScope>,\n\tctx: ContextState<TNode, TScope, TRoot, TResult> | undefined,\n\tscope: TScope | undefined,\n\troot: TRoot | undefined,\n\tindex: number,\n\tschedulePromises: Array<PromiseLike<unknown>>,\n\thydrationNodes: Array<TNode> | undefined,\n): ElementValue<TNode> {\n\tif (getFlag(ret, IsCopied) && getFlag(ret, DidCommit)) {\n\t\treturn getValue(ret);\n\t}\n\n\tconst el = ret.el;\n\tconst tag = el.tag;\n\tif (\n\t\ttypeof tag === \"function\" ||\n\t\ttag === Fragment ||\n\t\ttag === Portal ||\n\t\ttag === Raw ||\n\t\ttag === Text\n\t) {\n\t\tif (typeof el.props.copy === \"string\") {\n\t\t\tconsole.error(\n\t\t\t\t`String copy prop ignored for <${getTagName(tag)}>. Use booleans instead.`,\n\t\t\t);\n\t\t}\n\t\tif (typeof el.props.hydrate === \"string\") {\n\t\t\tconsole.error(\n\t\t\t\t`String hydrate prop ignored for <${getTagName(tag)}>. Use booleans instead.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tlet value: ElementValue<TNode>;\n\tlet skippedHydrationNodes: Array<TNode> | undefined;\n\tif (\n\t\thydrationNodes &&\n\t\tel.props.hydrate != null &&\n\t\t!el.props.hydrate &&\n\t\ttypeof el.props.hydrate !== \"string\"\n\t) {\n\t\tskippedHydrationNodes = hydrationNodes;\n\t\thydrationNodes = undefined;\n\t}\n\n\tif (typeof tag === \"function\") {\n\t\tret.ctx!.index = index;\n\t\tvalue = commitComponent(ret.ctx!, schedulePromises, hydrationNodes);\n\t} else {\n\t\tif (tag === Fragment) {\n\t\t\tvalue = commitChildren(\n\t\t\t\tadapter,\n\t\t\t\thost,\n\t\t\t\tctx,\n\t\t\t\tscope,\n\t\t\t\troot,\n\t\t\t\tret,\n\t\t\t\tindex,\n\t\t\t\tschedulePromises,\n\t\t\t\thydrationNodes,\n\t\t\t);\n\t\t} else if (tag === Text) {\n\t\t\tvalue = commitText(\n\t\t\t\tadapter,\n\t\t\t\tret,\n\t\t\t\tel as Element<Text>,\n\t\t\t\tscope,\n\t\t\t\thydrationNodes,\n\t\t\t\troot,\n\t\t\t);\n\t\t} else if (tag === Raw) {\n\t\t\tvalue = commitRaw(adapter, host, ret, scope, hydrationNodes, root);\n\t\t} else {\n\t\t\tvalue = commitHost(\n\t\t\t\tadapter,\n\t\t\t\tret,\n\t\t\t\tctx,\n\t\t\t\troot,\n\t\t\t\tschedulePromises,\n\t\t\t\thydrationNodes,\n\t\t\t);\n\t\t}\n\n\t\tif (ret.fallback) {\n\t\t\tunmount(adapter, host, ctx, root, ret.fallback, false);\n\t\t\tret.fallback = undefined;\n\t\t}\n\t}\n\n\tif (skippedHydrationNodes) {\n\t\tskippedHydrationNodes.splice(0, wrap(value).length);\n\t}\n\n\tif (!getFlag(ret, DidCommit)) {\n\t\tsetFlag(ret, DidCommit);\n\t\tif (\n\t\t\ttypeof tag !== \"function\" &&\n\t\t\ttag !== Fragment &&\n\t\t\ttag !== Portal &&\n\t\t\ttypeof el.props.ref === \"function\"\n\t\t) {\n\t\t\tel.props.ref(adapter.read(value));\n\t\t}\n\t}\n\n\treturn value;\n}\n\nfunction commitChildren<\n\tTNode,\n\tTScope,\n\tTRoot extends TNode | undefined,\n\tTResult,\n>(\n\tadapter: RenderAdapter<TNode, unknown, TRoot, TResult>,\n\thost: Retainer<TNode, TScope>,\n\tctx: ContextState<TNode, TScope, TRoot, TResult> | undefined,\n\tscope: TScope | undefined,\n\troot: TRoot | undefined,\n\tparent: Retainer<TNode, TScope>,\n\tindex: number,\n\tschedulePromises: Array<PromiseLike<unknown>>,\n\thydrationNodes: Array<TNode> | undefined,\n): Array<TNode> {\n\tlet values: Array<TNode> = [];\n\tfor (let i = 0, children = wrap(parent.children); i < children.length; i++) {\n\t\tlet child = children[i];\n\t\tlet schedulePromises1: Array<unknown> | undefined;\n\t\tlet isSchedulingFallback = false;\n\t\twhile (\n\t\t\tchild &&\n\t\t\t((!getFlag(child, DidDiff) && child.fallback) ||\n\t\t\t\tgetFlag(child, IsScheduling))\n\t\t) {\n\t\t\t// If the child is scheduling, it is a component retainer so ctx will be\n\t\t\t// defined.\n\t\t\tif (getFlag(child, IsScheduling) && child.ctx!.schedule) {\n\t\t\t\t(schedulePromises1 = schedulePromises1 || []).push(\n\t\t\t\t\tchild.ctx!.schedule.promise,\n\t\t\t\t);\n\t\t\t\tisSchedulingFallback = true;\n\t\t\t}\n\n\t\t\tif (!getFlag(child, DidDiff) && getFlag(child, DidCommit)) {\n\t\t\t\t// If this child has not diffed but has committed, it means it is a\n\t\t\t\t// fallback that is being resurrected.\n\t\t\t\tfor (const node of getChildValues(child)) {\n\t\t\t\t\tadapter.remove({\n\t\t\t\t\t\tnode,\n\t\t\t\t\t\tparentNode: host.value as TNode,\n\t\t\t\t\t\tisNested: false,\n\t\t\t\t\t\troot,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tchild = child.fallback;\n\t\t\t// When a scheduling component is mounting asynchronously but diffs\n\t\t\t// immediately, it will cause previous async diffs to settle due to the\n\t\t\t// chasing mechanism. This would cause earlier renders to resolve sooner\n\t\t\t// than expected, because the render would be missing both its usual\n\t\t\t// children and the children of the scheduling render. Therefore, we need\n\t\t\t// to defer the settling of previous renders until either that render\n\t\t\t// settles, or the scheduling component finally finishes scheduling.\n\t\t\t//\n\t\t\t// To do this, we take advantage of the fact that commits for aborted\n\t\t\t// renders will still fire and walk the tree. During that commit walk,\n\t\t\t// when we encounter a scheduling element, we push a race of the\n\t\t\t// scheduling promise with the inflight diff of the async fallback\n\t\t\t// fallback to schedulePromises to delay the initiator.\n\t\t\t//\n\t\t\t// However, we need to make sure we only use the inflight diffs for the\n\t\t\t// fallback which we are trying to delay, in the case of multiple renders\n\t\t\t// and fallbacks. To do this, we take advantage of the fact that when\n\t\t\t// multiple renders race (e.g., render1->render2->render3->scheduling\n\t\t\t// component), the chasing mechanism will call stale commits in reverse\n\t\t\t// order.\n\t\t\t//\n\t\t\t// We can use this ordering to delay to find which fallbacks we need to\n\t\t\t// add to the race. Each commit call progressively marks an additional\n\t\t\t// fallback as a scheduling fallback, and does not contribute to the\n\t\t\t// scheduling promises if it is further than the last seen level.\n\t\t\t//\n\t\t\t// This prevents promise contamination where newer renders settle early\n\t\t\t// due to diffs from older renders.\n\t\t\tif (schedulePromises1 && isSchedulingFallback && child) {\n\t\t\t\tif (!getFlag(child, DidDiff)) {\n\t\t\t\t\tconst inflightDiff = getInflightDiff(child);\n\t\t\t\t\tschedulePromises1.push(inflightDiff);\n\t\t\t\t} else {\n\t\t\t\t\t// If a scheduling component's fallback has already diffed, we do not\n\t\t\t\t\t// need delay the render.\n\t\t\t\t\tschedulePromises1 = undefined;\n\t\t\t\t}\n\n\t\t\t\tif (getFlag(child, IsSchedulingFallback)) {\n\t\t\t\t\t// This fallback was marked by a more recent commit - keep processing\n\t\t\t\t\t// deeper levels\n\t\t\t\t\tisSchedulingFallback = true;\n\t\t\t\t} else {\n\t\t\t\t\t// First unmarked fallback we've encountered - mark it and stop\n\t\t\t\t\t// contributing to schedulePromises1 for deeper levels.\n\t\t\t\t\tsetFlag(child, IsSchedulingFallback, true);\n\t\t\t\t\tisSchedulingFallback = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (schedulePromises1 && schedulePromises1.length > 1) {\n\t\t\tschedulePromises.push(safeRace(schedulePromises1));\n\t\t}\n\n\t\tif (child) {\n\t\t\tconst value = commit(\n\t\t\t\tadapter,\n\t\t\t\thost,\n\t\t\t\tchild,\n\t\t\t\tctx,\n\t\t\t\tscope,\n\t\t\t\troot,\n\t\t\t\tindex,\n\t\t\t\tschedulePromises,\n\t\t\t\thydrationNodes,\n\t\t\t);\n\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tfor (let j = 0; j < value.length; j++) {\n\t\t\t\t\tvalues.push(value[j]);\n\t\t\t\t}\n\t\t\t\tindex += value.length;\n\t\t\t} else if (value) {\n\t\t\t\tvalues.push(value);\n\t\t\t\tindex++;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (parent.graveyard) {\n\t\tfor (let i = 0; i < parent.graveyard.length; i++) {\n\t\t\tconst child = parent.graveyard[i];\n\t\t\tunmount(adapter, host, ctx, root, child, false);\n\t\t}\n\n\t\tparent.graveyard = undefined;\n\t}\n\n\tif (parent.lingerers) {\n\t\t// if parent.lingerers is set, a descendant component is unmounting\n\t\t// asynchronously, so we overwrite values to include lingerering DOM nodes.\n\t\tvalues = getChildValues(parent);\n\t}\n\n\treturn values;\n}\n\nfunction commitText<TNode, TScope, TRoot extends TNode | undefined>(\n\tadapter: RenderAdapter<TNode, TScope, TRoot, unknown>,\n\tret: Retainer<TNode, TScope>,\n\tel: Element<Text>,\n\tscope: TScope | undefined,\n\thydrationNodes: Array<TNode> | undefined,\n\troot: TRoot | undefined,\n): TNode {\n\tconst value = adapter.text({\n\t\tvalue: el.props.value,\n\t\tscope,\n\t\toldNode: ret.value as TNode,\n\t\thydrationNodes,\n\t\troot,\n\t});\n\n\tret.value = value;\n\treturn value;\n}\n\nfunction commitRaw<TNode, TScope, TRoot extends TNode | undefined>(\n\tadapter: RenderAdapter<TNode, TScope, TRoot, unknown>,\n\thost: Retainer<TNode>,\n\tret: Retainer<TNode>,\n\tscope: TScope | undefined,\n\thydrationNodes: Array<TNode> | undefined,\n\troot: TRoot | undefined,\n): ElementValue<TNode> {\n\tif (!ret.oldProps || ret.oldProps.value !== ret.el.props.value) {\n\t\tconst oldNodes = wrap(ret.value);\n\t\tfor (let i = 0; i < oldNodes.length; i++) {\n\t\t\tconst oldNode = oldNodes[i];\n\t\t\tadapter.remove({\n\t\t\t\tnode: oldNode,\n\t\t\t\tparentNode: host.value as TNode,\n\t\t\t\tisNested: false,\n\t\t\t\troot,\n\t\t\t});\n\t\t}\n\t\tret.value = adapter.raw({\n\t\t\tvalue: ret.el.props.value as any,\n\t\t\tscope,\n\t\t\thydrationNodes,\n\t\t\troot,\n\t\t});\n\t}\n\n\tret.oldProps = stripSpecialProps(ret.el.props);\n\treturn ret.value;\n}\n\nfunction commitHost<TNode, TScope, TRoot extends TNode | undefined>(\n\tadapter: RenderAdapter<TNode, TScope, TRoot, unknown>,\n\tret: Retainer<TNode, TScope>,\n\tctx: ContextState<TNode, TScope, TRoot, unknown> | undefined,\n\troot: TRoot | undefined,\n\tschedulePromises: Array<PromiseLike<unknown>>,\n\thydrationNodes: Array<TNode> | undefined,\n): ElementValue<TNode> {\n\tif (getFlag(ret, IsCopied) && getFlag(ret, DidCommit)) {\n\t\treturn getValue(ret);\n\t}\n\n\tconst tag = ret.el.tag as string | symbol;\n\tconst props = stripSpecialProps(ret.el.props);\n\tconst oldProps = ret.oldProps;\n\tlet node = ret.value as TNode;\n\n\tlet copyProps: Set<string> | undefined;\n\tlet copyChildren = false;\n\tif (oldProps) {\n\t\tfor (const propName in props) {\n\t\t\tif (props[propName] === Copy) {\n\t\t\t\t// The Copy tag can be used to skip the patching of a prop.\n\t\t\t\t//   <div class={shouldPatchClass ? \"class-name\" : Copy} />\n\t\t\t\tprops[propName] = oldProps[propName];\n\t\t\t\t(copyProps = copyProps || new Set()).add(propName);\n\t\t\t}\n\t\t}\n\n\t\tif (typeof ret.el.props.copy === \"string\") {\n\t\t\tconst copyMetaProp = new MetaProp(\"copy\", ret.el.props.copy);\n\t\t\tif (copyMetaProp.include) {\n\t\t\t\tfor (const propName of copyMetaProp.props) {\n\t\t\t\t\tif (propName in oldProps) {\n\t\t\t\t\t\tprops[propName] = oldProps[propName];\n\t\t\t\t\t\t(copyProps = copyProps || new Set()).add(propName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (const propName in oldProps) {\n\t\t\t\t\tif (!copyMetaProp.props.has(propName)) {\n\t\t\t\t\t\tprops[propName] = oldProps[propName];\n\t\t\t\t\t\t(copyProps = copyProps || new Set()).add(propName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcopyChildren = copyMetaProp.includes(\"children\");\n\t\t}\n\t}\n\n\tconst scope = ret.scope;\n\tlet childHydrationNodes: Array<TNode> | undefined;\n\tlet quietProps: Set<string> | undefined;\n\tlet hydrationMetaProp: MetaProp | undefined;\n\tif (!getFlag(ret, DidCommit)) {\n\t\tif (tag === Portal) {\n\t\t\tif (ret.el.props.hydrate && typeof ret.el.props.hydrate !== \"string\") {\n\t\t\t\tchildHydrationNodes = adapter.adopt({\n\t\t\t\t\ttag,\n\t\t\t\t\ttagName: getTagName(tag),\n\t\t\t\t\tnode,\n\t\t\t\t\tprops,\n\t\t\t\t\tscope,\n\t\t\t\t\troot,\n\t\t\t\t});\n\n\t\t\t\tif (childHydrationNodes) {\n\t\t\t\t\tfor (let i = 0; i < childHydrationNodes.length; i++) {\n\t\t\t\t\t\tadapter.remove({\n\t\t\t\t\t\t\tnode: childHydrationNodes[i],\n\t\t\t\t\t\t\tparentNode: node,\n\t\t\t\t\t\t\tisNested: false,\n\t\t\t\t\t\t\troot,\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 {\n\t\t\tif (!node && hydrationNodes) {\n\t\t\t\tconst nextChild = hydrationNodes.shift();\n\t\t\t\tif (typeof ret.el.props.hydrate === \"string\") {\n\t\t\t\t\thydrationMetaProp = new MetaProp(\"hydration\", ret.el.props.hydrate);\n\t\t\t\t\tif (hydrationMetaProp.include) {\n\t\t\t\t\t\t// if we're in inclusive mode, we add all props to quietProps and\n\t\t\t\t\t\t// remove props specified in the metaprop\n\t\t\t\t\t\tquietProps = new Set(Object.keys(props));\n\t\t\t\t\t\tfor (const propName of hydrationMetaProp.props) {\n\t\t\t\t\t\t\tquietProps.delete(propName);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tquietProps = hydrationMetaProp.props;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tchildHydrationNodes = adapter.adopt({\n\t\t\t\t\ttag,\n\t\t\t\t\ttagName: getTagName(tag),\n\t\t\t\t\tnode: nextChild!,\n\t\t\t\t\tprops,\n\t\t\t\t\tscope,\n\t\t\t\t\troot,\n\t\t\t\t});\n\n\t\t\t\tif (childHydrationNodes) {\n\t\t\t\t\tnode = nextChild!;\n\t\t\t\t\tfor (let i = 0; i < childHydrationNodes.length; i++) {\n\t\t\t\t\t\tadapter.remove({\n\t\t\t\t\t\t\tnode: childHydrationNodes[i],\n\t\t\t\t\t\t\tparentNode: node,\n\t\t\t\t\t\t\tisNested: false,\n\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// TODO: For some reason, there are cases where the node is already set\n\t\t\t// and the DidCommit flag is false. Not checking for node fails a test\n\t\t\t// where a child dispatches an event in a schedule callback, the parent\n\t\t\t// listens for this event and refreshes.\n\t\t\tif (!node) {\n\t\t\t\tnode = adapter.create({\n\t\t\t\t\ttag,\n\t\t\t\t\ttagName: getTagName(tag),\n\t\t\t\t\tprops,\n\t\t\t\t\tscope,\n\t\t\t\t\troot,\n\t\t\t\t});\n\t\t\t}\n\t\t\tret.value = node;\n\t\t}\n\t}\n\n\tif (tag !== Portal) {\n\t\tadapter.patch({\n\t\t\ttag,\n\t\t\ttagName: getTagName(tag),\n\t\t\tnode,\n\t\t\tprops,\n\t\t\toldProps,\n\t\t\tscope,\n\t\t\troot,\n\t\t\tcopyProps,\n\t\t\tisHydrating: !!childHydrationNodes,\n\t\t\tquietProps,\n\t\t});\n\t}\n\n\tif (!copyChildren) {\n\t\tconst children = commitChildren(\n\t\t\tadapter,\n\t\t\tret,\n\t\t\tctx,\n\t\t\tscope,\n\t\t\ttag === Portal ? (node as TRoot) : root,\n\t\t\tret,\n\t\t\t0,\n\t\t\tschedulePromises,\n\t\t\thydrationMetaProp && !hydrationMetaProp.includes(\"children\")\n\t\t\t\t? undefined\n\t\t\t\t: childHydrationNodes,\n\t\t);\n\n\t\tadapter.arrange({\n\t\t\ttag,\n\t\t\ttagName: getTagName(tag),\n\t\t\tnode: node,\n\t\t\tprops,\n\t\t\tchildren,\n\t\t\toldProps,\n\t\t\troot,\n\t\t});\n\t}\n\n\tret.oldProps = props;\n\tif (tag === Portal) {\n\t\tflush(adapter, ret.value as TRoot);\n\t\t// The root passed to Portal elements are opaque to parents so we return\n\t\t// undefined here.\n\t\treturn;\n\t}\n\n\treturn node;\n}\n\nclass MetaProp {\n\tdeclare include: boolean;\n\tdeclare props: Set<string>;\n\n\tconstructor(propName: string, propValue: string) {\n\t\tthis.include = true;\n\t\tthis.props = new Set<string>();\n\t\tlet noBangs = true;\n\t\tlet allBangs = true;\n\t\tconst tokens = propValue.split(/[,\\s]+/);\n\t\tfor (let i = 0; i < tokens.length; i++) {\n\t\t\tconst token = tokens[i].trim();\n\t\t\tif (!token) {\n\t\t\t\tcontinue;\n\t\t\t} else if (token.startsWith(\"!\")) {\n\t\t\t\tnoBangs = false;\n\t\t\t\tthis.props.add(token.slice(1));\n\t\t\t} else {\n\t\t\t\tallBangs = false;\n\t\t\t\tthis.props.add(token);\n\t\t\t}\n\t\t}\n\n\t\tif (!allBangs && !noBangs) {\n\t\t\tconsole.error(\n\t\t\t\t`Invalid ${propName} prop \"${propValue}\".\\nUse prop or !prop but not both.`,\n\t\t\t);\n\t\t\tthis.include = true;\n\t\t\tthis.props.clear();\n\t\t} else {\n\t\t\tthis.include = noBangs;\n\t\t}\n\t}\n\n\tincludes(propName: string): boolean {\n\t\tif (this.include) {\n\t\t\treturn this.props.has(propName);\n\t\t} else {\n\t\t\treturn !this.props.has(propName);\n\t\t}\n\t}\n}\n\nfunction contextContains(parent: ContextState, child: ContextState): boolean {\n\tfor (\n\t\tlet current: ContextState | undefined = child;\n\t\tcurrent !== undefined;\n\t\tcurrent = current.parent\n\t) {\n\t\tif (current === parent) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n// When rendering is done without a root, we use this special anonymous root to\n// make sure after callbacks are still called.\nconst ANONYMOUS_ROOT: any = {};\nfunction flush<TRoot>(\n\tadapter: RenderAdapter<unknown, unknown, TRoot>,\n\troot: TRoot | undefined,\n\tinitiator?: ContextState,\n) {\n\tif (root != null) {\n\t\tadapter.finalize(root);\n\t}\n\n\tif (typeof root !== \"object\" || root === null) {\n\t\troot = ANONYMOUS_ROOT;\n\t}\n\n\t// The initiator is the context which initiated the rendering process. If\n\t// initiator is defined we call and clear all flush callbacks which are\n\t// registered with the initiator or with a child context of the initiator,\n\t// because they are fully rendered.\n\t//\n\t// If no initiator is provided, we can call and clear all flush callbacks\n\t// which are not scheduling.\n\tconst afterMap = afterMapByRoot.get(root as any);\n\tif (afterMap) {\n\t\tconst afterMap1 = new Map<ContextState, Set<Function>>();\n\t\tfor (const [ctx, callbacks] of afterMap) {\n\t\t\tif (\n\t\t\t\tgetFlag(ctx.ret, IsScheduling) ||\n\t\t\t\t(initiator && !contextContains(initiator, ctx))\n\t\t\t) {\n\t\t\t\t// copy over callbacks to the new map (defer them)\n\t\t\t\tafterMap.delete(ctx);\n\t\t\t\tafterMap1.set(ctx, callbacks);\n\t\t\t}\n\t\t}\n\n\t\tif (afterMap1.size) {\n\t\t\tafterMapByRoot.set(root as any, afterMap1);\n\t\t} else {\n\t\t\tafterMapByRoot.delete(root as any);\n\t\t}\n\n\t\tfor (const [ctx, callbacks] of afterMap) {\n\t\t\tconst value = adapter.read(getValue(ctx.ret));\n\t\t\tfor (const callback of callbacks) {\n\t\t\t\tcallback(value);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction unmount<TNode, TScope, TRoot extends TNode | undefined, TResult>(\n\tadapter: RenderAdapter<TNode, TScope, TRoot, TResult>,\n\thost: Retainer<TNode>,\n\tctx: ContextState<TNode, TScope, TRoot, TResult> | undefined,\n\troot: TRoot | undefined,\n\tret: Retainer<TNode>,\n\tisNested: boolean,\n): void {\n\t// TODO: set the IsUnmounted flag consistently for all retainers\n\tif (ret.fallback) {\n\t\tunmount(adapter, host, ctx, root, ret.fallback, isNested);\n\t\tret.fallback = undefined;\n\t}\n\n\tif (getFlag(ret, IsResurrecting)) {\n\t\treturn;\n\t}\n\n\tif (ret.lingerers) {\n\t\tfor (let i = 0; i < ret.lingerers.length; i++) {\n\t\t\tconst lingerers = ret.lingerers[i];\n\t\t\tif (lingerers) {\n\t\t\t\tfor (const lingerer of lingerers) {\n\t\t\t\t\tunmount(adapter, host, ctx, root, lingerer, isNested);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tret.lingerers = undefined;\n\t}\n\n\tif (typeof ret.el.tag === \"function\") {\n\t\tunmountComponent(ret.ctx!, isNested);\n\t} else if (ret.el.tag === Fragment) {\n\t\tunmountChildren(adapter, host, ctx, root, ret, isNested);\n\t} else if (ret.el.tag === Portal) {\n\t\tunmountChildren(adapter, ret, ctx, ret.value as TRoot, ret, false);\n\t\tif (ret.value != null) {\n\t\t\tadapter.finalize(ret.value as TRoot);\n\t\t}\n\t} else {\n\t\tunmountChildren(adapter, ret, ctx, root, ret, true);\n\n\t\tif (getFlag(ret, DidCommit)) {\n\t\t\tif (ctx) {\n\t\t\t\t// Remove the value from every context which shares the same host.\n\t\t\t\tremoveEventTargetDelegates(\n\t\t\t\t\tctx.ctx,\n\t\t\t\t\t[ret.value],\n\t\t\t\t\t(ctx1) => ctx1[_ContextState].host === host,\n\t\t\t\t);\n\t\t\t}\n\t\t\tadapter.remove({\n\t\t\t\tnode: ret.value as TNode,\n\t\t\t\tparentNode: host.value as TNode,\n\t\t\t\tisNested,\n\t\t\t\troot,\n\t\t\t});\n\t\t}\n\t}\n}\n\nfunction unmountChildren<\n\tTNode,\n\tTScope,\n\tTRoot extends TNode | undefined,\n\tTResult,\n>(\n\tadapter: RenderAdapter<TNode, TScope, TRoot, TResult>,\n\thost: Retainer<TNode>,\n\tctx: ContextState<TNode, TScope, TRoot, TResult> | undefined,\n\troot: TRoot | undefined,\n\tret: Retainer<TNode>,\n\tisNested: boolean,\n): void {\n\tif (ret.graveyard) {\n\t\tfor (let i = 0; i < ret.graveyard.length; i++) {\n\t\t\tconst child = ret.graveyard[i];\n\t\t\tunmount(adapter, host, ctx, root, child, isNested);\n\t\t}\n\n\t\tret.graveyard = undefined;\n\t}\n\n\tfor (let i = 0, children = wrap(ret.children); i < children.length; i++) {\n\t\tconst child = children[i];\n\t\tif (typeof child === \"object\") {\n\t\t\tunmount(adapter, host, ctx, root, child, isNested);\n\t\t}\n\t}\n}\nconst provisionMaps = new WeakMap<ContextState, Map<unknown, unknown>>();\n\nconst scheduleMap = new WeakMap<ContextState, Set<Function>>();\n\nconst cleanupMap = new WeakMap<ContextState, Set<Function>>();\n\n// keys are roots\nconst afterMapByRoot = new WeakMap<object, Map<ContextState, Set<Function>>>();\n\ninterface PullController {\n\titerationP: Promise<ChildrenIteratorResult> | undefined;\n\tdiff: Promise<undefined> | undefined;\n\tonChildError: ((err: unknown) => void) | undefined;\n}\n\ninterface ScheduleController {\n\tpromise: Promise<unknown>;\n\tonAbort: () => void;\n}\n\n// TODO: allow ContextState to be initialized for testing purposes\n/**\n * @internal\n * The internal class which holds context data.\n */\nclass ContextState<\n\tTNode = unknown,\n\tTScope = unknown,\n\tTRoot extends TNode | undefined = TNode | undefined,\n\tTResult = unknown,\n> {\n\t/** The adapter of the renderer which created this context. */\n\tdeclare adapter: RenderAdapter<TNode, TScope, TRoot, TResult>;\n\n\t/** The root node as set by the nearest ancestor portal. */\n\tdeclare root: TRoot | undefined;\n\n\t/**\n\t * The nearest ancestor host or portal retainer.\n\t *\n\t * When refresh is called, the host element will be arranged as the last step\n\t * of the commit, to make sure the parent's children properly reflects the\n\t * components's childrenk\n\t */\n\tdeclare host: Retainer<TNode>;\n\n\t/** The parent context state. */\n\tdeclare parent: ContextState | undefined;\n\n\t/** The actual context associated with this state. */\n\tdeclare ctx: Context<unknown, TResult>;\n\n\t/** The value of the scope at the point of element's creation. */\n\tdeclare scope: TScope | undefined;\n\n\t/** The internal node associated with this context. */\n\tdeclare ret: Retainer<TNode>;\n\n\t/**\n\t * Any iterator returned by a component function.\n\t *\n\t * Existence of this property implies that the component is a generator\n\t * component. It is deleted when a component is returned.\n\t */\n\tdeclare iterator:\n\t\t| Iterator<Children, Children | void, unknown>\n\t\t| AsyncIterator<Children, Children | void, unknown>\n\t\t| undefined;\n\n\t// See runComponent() for a description of these properties.\n\tdeclare inflight: [Promise<undefined>, Promise<undefined>] | undefined;\n\tdeclare enqueued: [Promise<undefined>, Promise<undefined>] | undefined;\n\n\tdeclare pull: PullController | undefined;\n\n\t// The onPropsProvided callback is set when a component requests props via\n\t// the for await...of loop and props are not available. It is called when\n\t// the component is updated or refreshed.\n\tdeclare onPropsProvided: ((props: unknown) => unknown) | undefined;\n\t// The onPropsRequested callback is set when a component is updated or\n\t// refreshed but the new props are not consumed. It is called when the new\n\t// props are requested.\n\tdeclare onPropsRequested: (() => unknown) | undefined;\n\n\t// The last known index of the component's children, relative to its nearest\n\t// ancestor host or portal.\n\tdeclare index: number;\n\n\tdeclare schedule: ScheduleController | undefined;\n\n\tconstructor(\n\t\tadapter: RenderAdapter<TNode, TScope, TRoot, TResult>,\n\t\troot: TRoot,\n\t\thost: Retainer<TNode>,\n\t\tparent: ContextState | undefined,\n\t\tscope: TScope | undefined,\n\t\tret: Retainer<TNode>,\n\t) {\n\t\tthis.adapter = adapter;\n\t\tthis.root = root;\n\t\tthis.host = host;\n\t\tthis.parent = parent;\n\t\t// This property must be set after this.parent is set because the Context\n\t\t// constructor reads this.parent.\n\t\tthis.ctx = new Context(this);\n\t\tthis.scope = scope;\n\t\tthis.ret = ret;\n\n\t\tthis.iterator = undefined;\n\t\tthis.inflight = undefined;\n\t\tthis.enqueued = undefined;\n\n\t\tthis.onPropsProvided = undefined;\n\t\tthis.onPropsRequested = undefined;\n\n\t\tthis.pull = undefined;\n\t\tthis.index = 0;\n\t\tthis.schedule = undefined;\n\t}\n}\n\n// Public type that only extracts props from component functions\nexport type ComponentProps<T> = T extends () => unknown\n\t? {}\n\t: T extends (props: infer U) => unknown\n\t\t? U\n\t\t: never;\n\n// Public helper type that handles both component functions and regular objects\nexport type ComponentPropsOrProps<T> = T extends Function\n\t? ComponentProps<T>\n\t: T;\n\nconst _ContextState = Symbol.for(\"crank.ContextState\");\n\n/**\n * A class which is instantiated and passed to every component as its this\n * value/second parameter. Contexts form a tree just like elements and all\n * components in the element tree are connected via contexts. Components can\n * use this tree to communicate data upwards via events and downwards via\n * provisions.\n *\n * @template [T=*] - The expected shape of the props passed to the component,\n * or a component function. Used to strongly type the Context iterator methods.\n * @template [TResult=*] - The readable element value type. It is used in\n * places such as the return value of refresh and the argument passed to\n * schedule and cleanup callbacks.\n */\nexport class Context<\n\tT = any,\n\tTResult = any,\n> extends CustomEventTarget<Context> {\n\t/**\n\t * @internal\n\t * DO NOT USE READ THIS PROPERTY.\n\t */\n\tdeclare [_ContextState]: ContextState<unknown, unknown, unknown, TResult>;\n\n\t// TODO: If we could make the constructor function take a nicer value, it\n\t// would be useful for testing purposes.\n\tconstructor(state: ContextState<unknown, unknown, unknown, TResult>) {\n\t\tsuper(state.parent ? state.parent.ctx : null);\n\t\tthis[_ContextState] = state;\n\t}\n\n\t/**\n\t * The current props of the associated element.\n\t */\n\tget props(): ComponentPropsOrProps<T> {\n\t\treturn this[_ContextState].ret.el.props as ComponentPropsOrProps<T>;\n\t}\n\n\t/**\n\t * The current value of the associated element.\n\t *\n\t * @deprecated\n\t */\n\tget value(): TResult {\n\t\tconsole.warn(\"Context.value is deprecated.\");\n\t\treturn this[_ContextState].adapter.read(getValue(this[_ContextState].ret));\n\t}\n\n\tget isExecuting(): boolean {\n\t\treturn getFlag(this[_ContextState].ret, IsExecuting);\n\t}\n\n\tget isUnmounted(): boolean {\n\t\treturn getFlag(this[_ContextState].ret, IsUnmounted);\n\t}\n\n\t*[Symbol.iterator](): Generator<ComponentPropsOrProps<T>, undefined> {\n\t\tconst ctx = this[_ContextState];\n\t\tsetFlag(ctx.ret, IsInForOfLoop);\n\t\ttry {\n\t\t\twhile (!getFlag(ctx.ret, IsUnmounted) && !getFlag(ctx.ret, IsErrored)) {\n\t\t\t\tif (getFlag(ctx.ret, NeedsToYield)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`<${getTagName(ctx.ret.el.tag)}> context iterated twice without a yield`,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tsetFlag(ctx.ret, NeedsToYield);\n\t\t\t\t}\n\n\t\t\t\tyield ctx.ret.el.props as ComponentPropsOrProps<T>;\n\t\t\t}\n\t\t} finally {\n\t\t\tsetFlag(ctx.ret, IsInForOfLoop, false);\n\t\t}\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<\n\t\tComponentPropsOrProps<T>,\n\t\tundefined\n\t> {\n\t\tconst ctx = this[_ContextState];\n\t\tsetFlag(ctx.ret, IsInForAwaitOfLoop);\n\t\ttry {\n\t\t\twhile (!getFlag(ctx.ret, IsUnmounted) && !getFlag(ctx.ret, IsErrored)) {\n\t\t\t\tif (getFlag(ctx.ret, NeedsToYield)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`<${getTagName(ctx.ret.el.tag)}> context iterated twice without a yield`,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tsetFlag(ctx.ret, NeedsToYield);\n\t\t\t\t}\n\n\t\t\t\tif (getFlag(ctx.ret, PropsAvailable)) {\n\t\t\t\t\tsetFlag(ctx.ret, PropsAvailable, false);\n\t\t\t\t\tyield ctx.ret.el.props;\n\t\t\t\t} else {\n\t\t\t\t\tconst props = await new Promise<ComponentPropsOrProps<T>>(\n\t\t\t\t\t\t(resolve) =>\n\t\t\t\t\t\t\t(ctx.onPropsProvided = resolve as (props: unknown) => unknown),\n\t\t\t\t\t);\n\t\t\t\t\tif (getFlag(ctx.ret, IsUnmounted) || getFlag(ctx.ret, IsErrored)) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tyield props;\n\t\t\t\t}\n\n\t\t\t\tif (ctx.onPropsRequested) {\n\t\t\t\t\tctx.onPropsRequested();\n\t\t\t\t\tctx.onPropsRequested = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tsetFlag(ctx.ret, IsInForAwaitOfLoop, false);\n\t\t\tif (ctx.onPropsRequested) {\n\t\t\t\tctx.onPropsRequested();\n\t\t\t\tctx.onPropsRequested = undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Re-executes a component.\n\t *\n\t * @param callback - Optional callback to execute before refresh\n\t * @returns The rendered result of the component or a promise thereof if the\n\t * component or its children execute asynchronously.\n\t */\n\trefresh(callback?: () => unknown): Promise<TResult> | TResult {\n\t\tconst ctx = this[_ContextState];\n\t\tif (getFlag(ctx.ret, IsUnmounted)) {\n\t\t\tconsole.error(\n\t\t\t\t`Component <${getTagName(ctx.ret.el.tag)}> is unmounted. Check the isUnmounted property if necessary.`,\n\t\t\t);\n\t\t\treturn ctx.adapter.read(getValue(ctx.ret));\n\t\t} else if (getFlag(ctx.ret, IsExecuting)) {\n\t\t\tconsole.error(\n\t\t\t\t`Component <${getTagName(ctx.ret.el.tag)}> is already executing Check the isExecuting property if necessary.`,\n\t\t\t);\n\t\t\treturn ctx.adapter.read(getValue(ctx.ret));\n\t\t}\n\n\t\tif (callback) {\n\t\t\tconst result = callback();\n\t\t\tif (isPromiseLike(result)) {\n\t\t\t\treturn Promise.resolve(result).then(() => {\n\t\t\t\t\tif (!getFlag(ctx.ret, IsUnmounted)) {\n\t\t\t\t\t\treturn this.refresh();\n\t\t\t\t\t}\n\t\t\t\t\treturn ctx.adapter.read(getValue(ctx.ret));\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (getFlag(ctx.ret, IsScheduling)) {\n\t\t\tsetFlag(ctx.ret, IsSchedulingRefresh);\n\t\t}\n\n\t\tlet diff: Promise<undefined> | undefined;\n\t\tconst schedulePromises: Array<PromiseLike<unknown>> = [];\n\t\ttry {\n\t\t\tsetFlag(ctx.ret, IsRefreshing);\n\t\t\tdiff = enqueueComponent(ctx);\n\t\t\tif (isPromiseLike(diff)) {\n\t\t\t\treturn diff\n\t\t\t\t\t.then(() => ctx.adapter.read(commitComponent(ctx, schedulePromises)))\n\t\t\t\t\t.then((result) => {\n\t\t\t\t\t\tif (schedulePromises.length) {\n\t\t\t\t\t\t\treturn Promise.all(schedulePromises).then(() => {\n\t\t\t\t\t\t\t\treturn ctx.adapter.read(getValue(ctx.ret));\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t})\n\t\t\t\t\t.catch((err) => {\n\t\t\t\t\t\tconst diff = propagateError(ctx, err, schedulePromises);\n\t\t\t\t\t\tif (diff) {\n\t\t\t\t\t\t\treturn diff.then(() => {\n\t\t\t\t\t\t\t\tif (schedulePromises.length) {\n\t\t\t\t\t\t\t\t\treturn Promise.all(schedulePromises).then(() => {\n\t\t\t\t\t\t\t\t\t\treturn ctx.adapter.read(getValue(ctx.ret));\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn ctx.adapter.read(getValue(ctx.ret));\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (schedulePromises.length) {\n\t\t\t\t\t\t\treturn Promise.all(schedulePromises).then(() => {\n\t\t\t\t\t\t\t\treturn ctx.adapter.read(getValue(ctx.ret));\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn ctx.adapter.read(getValue(ctx.ret));\n\t\t\t\t\t})\n\t\t\t\t\t.finally(() => setFlag(ctx.ret, IsRefreshing, false));\n\t\t\t}\n\n\t\t\tconst result = ctx.adapter.read(commitComponent(ctx, schedulePromises));\n\t\t\tif (schedulePromises.length) {\n\t\t\t\treturn Promise.all(schedulePromises).then(() => {\n\t\t\t\t\treturn ctx.adapter.read(getValue(ctx.ret));\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\t// TODO: await schedulePromises\n\t\t\tconst diff = propagateError(ctx, err, schedulePromises);\n\t\t\tif (diff) {\n\t\t\t\treturn diff\n\t\t\t\t\t.then(() => {\n\t\t\t\t\t\tif (schedulePromises.length) {\n\t\t\t\t\t\t\treturn Promise.all(schedulePromises).then(() => {\n\t\t\t\t\t\t\t\treturn ctx.adapter.read(getValue(ctx.ret));\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.then(() => ctx.adapter.read(getValue(ctx.ret)));\n\t\t\t}\n\n\t\t\tif (schedulePromises.length) {\n\t\t\t\treturn Promise.all(schedulePromises).then(() => {\n\t\t\t\t\treturn ctx.adapter.read(getValue(ctx.ret));\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn ctx.adapter.read(getValue(ctx.ret));\n\t\t} finally {\n\t\t\tif (!isPromiseLike(diff)) {\n\t\t\t\tsetFlag(ctx.ret, IsRefreshing, false);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Registers a callback which fires when the component's children are\n\t * created. Will only fire once per callback and update.\n\t */\n\tschedule(): Promise<TResult>;\n\tschedule(callback: (value: TResult) => unknown): void;\n\tschedule(callback?: (value: TResult) => unknown): Promise<TResult> | void {\n\t\tif (!callback) {\n\t\t\treturn new Promise<TResult>((resolve) => this.schedule(resolve));\n\t\t}\n\n\t\tconst ctx = this[_ContextState];\n\t\tlet callbacks = scheduleMap.get(ctx);\n\t\tif (!callbacks) {\n\t\t\tcallbacks = new Set<Function>();\n\t\t\tscheduleMap.set(ctx, callbacks);\n\t\t}\n\n\t\tcallbacks.add(callback);\n\t}\n\n\t/**\n\t * Registers a callback which fires when the component's children are fully\n\t * rendered. Will only fire once per callback and update.\n\t */\n\tafter(): Promise<TResult>;\n\tafter(callback: (value: TResult) => unknown): void;\n\tafter(callback?: (value: TResult) => unknown): Promise<TResult> | void {\n\t\tif (!callback) {\n\t\t\treturn new Promise<TResult>((resolve) => this.after(resolve));\n\t\t}\n\t\tconst ctx = this[_ContextState];\n\t\tconst root = ctx.root || ANONYMOUS_ROOT;\n\t\tlet afterMap = afterMapByRoot.get(root);\n\t\tif (!afterMap) {\n\t\t\tafterMap = new Map<ContextState, Set<Function>>();\n\t\t\tafterMapByRoot.set(root, afterMap);\n\t\t}\n\n\t\tlet callbacks = afterMap.get(ctx);\n\t\tif (!callbacks) {\n\t\t\tcallbacks = new Set<Function>();\n\t\t\tafterMap.set(ctx, callbacks);\n\t\t}\n\n\t\tcallbacks.add(callback);\n\t}\n\n\t/**\n\t * @deprecated the flush() method has been renamed to after().\n\t */\n\tflush(): Promise<TResult>;\n\tflush(callback: (value: TResult) => unknown): void;\n\tflush(callback?: (value: TResult) => unknown): Promise<TResult> | void {\n\t\tconsole.error(\"Context.flush() method has been renamed to after()\");\n\t\tthis.after(callback!);\n\t}\n\n\t/**\n\t * Registers a callback which fires when the component unmounts.\n\t *\n\t * The callback can be async to defer the unmounting of a component's children.\n\t */\n\tcleanup(): Promise<TResult>;\n\tcleanup(callback: (value: TResult) => unknown): void;\n\tcleanup(callback?: (value: TResult) => unknown): Promise<TResult> | void {\n\t\tif (!callback) {\n\t\t\treturn new Promise<TResult>((resolve) => this.cleanup(resolve));\n\t\t}\n\t\tconst ctx = this[_ContextState];\n\n\t\tif (getFlag(ctx.ret, IsUnmounted)) {\n\t\t\tconst value = ctx.adapter.read(getValue(ctx.ret));\n\t\t\tcallback(value);\n\t\t\treturn;\n\t\t}\n\n\t\tlet callbacks = cleanupMap.get(ctx);\n\t\tif (!callbacks) {\n\t\t\tcallbacks = new Set<Function>();\n\t\t\tcleanupMap.set(ctx, callbacks);\n\t\t}\n\n\t\tcallbacks.add(callback);\n\t}\n\n\tconsume<TKey extends keyof ProvisionMap>(key: TKey): ProvisionMap[TKey];\n\tconsume(key: unknown): any;\n\tconsume(key: unknown): any {\n\t\tfor (\n\t\t\tlet ctx = this[_ContextState].parent;\n\t\t\tctx !== undefined;\n\t\t\tctx = ctx.parent\n\t\t) {\n\t\t\tconst provisions = provisionMaps.get(ctx);\n\t\t\tif (provisions && provisions.has(key)) {\n\t\t\t\treturn provisions.get(key)!;\n\t\t\t}\n\t\t}\n\t}\n\n\tprovide<TKey extends keyof ProvisionMap>(\n\t\tkey: TKey,\n\t\tvalue: ProvisionMap[TKey],\n\t): void;\n\tprovide(key: unknown, value: any): void;\n\tprovide(key: unknown, value: any): void {\n\t\tconst ctx = this[_ContextState];\n\t\tlet provisions = provisionMaps.get(ctx);\n\t\tif (!provisions) {\n\t\t\tprovisions = new Map();\n\t\t\tprovisionMaps.set(ctx, provisions);\n\t\t}\n\n\t\tprovisions.set(key, value);\n\t}\n\n\t[CustomEventTarget.dispatchEventOnSelf](ev: Event): void {\n\t\tconst ctx = this[_ContextState];\n\t\t// dispatchEvent calls the prop callback if it exists\n\t\tlet propCallback = ctx.ret.el.props[\"on\" + ev.type] as unknown;\n\t\tif (typeof propCallback === \"function\") {\n\t\t\tpropCallback(ev);\n\t\t} else {\n\t\t\tfor (const propName in ctx.ret.el.props) {\n\t\t\t\tif (propName.toLowerCase() === \"on\" + ev.type.toLowerCase()) {\n\t\t\t\t\tpropCallback = ctx.ret.el.props[propName] as unknown;\n\t\t\t\t\tif (typeof propCallback === \"function\") {\n\t\t\t\t\t\tpropCallback(ev);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction diffComponent<TNode, TScope, TRoot extends TNode | undefined, TResult>(\n\tadapter: RenderAdapter<TNode, TScope, TRoot, TResult>,\n\troot: TRoot | undefined,\n\thost: Retainer<TNode, TScope>,\n\tparent: ContextState | undefined,\n\tscope: TScope | undefined,\n\tret: Retainer<TNode>,\n): Promise<undefined> | undefined {\n\tlet ctx: ContextState<TNode>;\n\tif (ret.ctx) {\n\t\tctx = ret.ctx;\n\t\tif (getFlag(ctx.ret, IsExecuting)) {\n\t\t\tconsole.error(\n\t\t\t\t`Component <${getTagName(ctx.ret.el.tag)}> is already executing`,\n\t\t\t);\n\t\t\treturn;\n\t\t} else if (ctx.schedule) {\n\t\t\treturn ctx.schedule.promise.then(() => {\n\t\t\t\treturn diffComponent(adapter, root, host, parent, scope, ret);\n\t\t\t});\n\t\t}\n\t} else {\n\t\tctx = ret.ctx = new ContextState(adapter, root, host, parent, scope, ret);\n\t}\n\n\tsetFlag(ctx.ret, IsUpdating);\n\treturn enqueueComponent(ctx);\n}\n\nfunction diffComponentChildren<TNode, TResult>(\n\tctx: ContextState<TNode, unknown, TNode | undefined, TResult>,\n\tchildren: Children,\n\tisYield: boolean,\n): Promise<undefined> | undefined {\n\tif (getFlag(ctx.ret, IsUnmounted) || getFlag(ctx.ret, IsErrored)) {\n\t\treturn;\n\t} else if (children === undefined) {\n\t\tconsole.error(\n\t\t\t`Component <${getTagName(ctx.ret.el.tag)}> has ${isYield ? \"yielded\" : \"returned\"} undefined. If this was intentional, ${isYield ? \"yield\" : \"return\"} null instead.`,\n\t\t);\n\t}\n\n\tlet diff: Promise<undefined> | undefined;\n\ttry {\n\t\t// TODO: Use a different flag here to indicate the component is\n\t\t// synchronously rendering children\n\n\t\t// We set the isExecuting flag in case a child component dispatches an event\n\t\t// which bubbles to this component and causes a synchronous refresh().\n\t\tsetFlag(ctx.ret, IsExecuting);\n\t\tdiff = diffChildren(\n\t\t\tctx.adapter,\n\t\t\tctx.root,\n\t\t\tctx.host,\n\t\t\tctx,\n\t\t\tctx.scope,\n\t\t\tctx.ret,\n\t\t\tnarrow(children),\n\t\t);\n\t\tif (diff) {\n\t\t\tdiff = diff.catch((err) => handleChildError(ctx, err));\n\t\t}\n\t} catch (err) {\n\t\tdiff = handleChildError(ctx, err);\n\t} finally {\n\t\tsetFlag(ctx.ret, IsExecuting, false);\n\t}\n\n\treturn diff;\n}\n\n/** Enqueues and executes the component associated with the context. */\nfunction enqueueComponent<TNode, TResult>(\n\tctx: ContextState<TNode, unknown, TNode | undefined, TResult>,\n): Promise<undefined> | undefined {\n\tif (!ctx.inflight) {\n\t\tconst [block, diff] = runComponent<TNode, TResult>(ctx);\n\t\tif (block) {\n\t\t\t// if block is a promise, diff is a promise\n\t\t\tctx.inflight = [block.finally(() => advanceComponent(ctx)), diff!];\n\t\t}\n\n\t\treturn diff;\n\t} else if (!ctx.enqueued) {\n\t\t// The enqueuedBlock and enqueuedDiff properties must be set\n\t\t// simultaneously, hence the usage of the Promise constructor.\n\t\tlet resolve: Function;\n\t\tctx.enqueued = [\n\t\t\tnew Promise<undefined>((resolve1) => (resolve = resolve1)).finally(() =>\n\t\t\t\tadvanceComponent(ctx),\n\t\t\t),\n\t\t\tctx.inflight[0]!.finally(() => {\n\t\t\t\tconst [block, diff] = runComponent<TNode, TResult>(ctx);\n\t\t\t\tresolve(block);\n\t\t\t\treturn diff;\n\t\t\t}),\n\t\t];\n\t}\n\n\treturn ctx.enqueued[1];\n}\n\n/** Called when the inflight block promise settles. */\nfunction advanceComponent(ctx: ContextState): void {\n\tctx.inflight = ctx.enqueued;\n\tctx.enqueued = undefined;\n}\n\n/**\n * This function is responsible for executing components, and handling the\n * different component types.\n *\n * @returns {[block, diff]} A tuple where:\n * - block is a promise or undefined which represents the duration during which\n *   the component is blocked.\n * - diff is a promise or undefined which represents the duration for diffing\n *   of children.\n *\n * While a component is blocked, further updates to the component are enqueued.\n *\n * Each component type blocks according to its implementation:\n * - Sync function components never block; when props or state change,\n *   updates are immediately passed to children.\n * - Async function components block only while awaiting their own async work\n *   (e.g., during an await), but do not block while their async children are rendering.\n * - Sync generator components block while their children are rendering;\n *   they only resume once their children have finished.\n * - Async generator components can block in two different ways:\n *   - By default, they behave like sync generator components, blocking while\n *     the component or its children are rendering.\n *   - Within a for await...of loop, they block only while waiting for new\n *     props to be requested, and not while children are rendering.\n */\nfunction runComponent<TNode, TResult>(\n\tctx: ContextState<TNode, unknown, TNode | undefined, TResult>,\n): [Promise<undefined> | undefined, Promise<undefined> | undefined] {\n\tif (getFlag(ctx.ret, IsUnmounted)) {\n\t\treturn [undefined, undefined];\n\t}\n\n\tconst ret = ctx.ret;\n\tconst initial = !ctx.iterator;\n\tif (initial) {\n\t\tsetFlag(ctx.ret, IsExecuting);\n\t\tclearEventListeners(ctx.ctx);\n\t\tlet returned: ReturnType<Component>;\n\t\ttry {\n\t\t\treturned = (ret.el.tag as Component).call(ctx.ctx, ret.el.props, ctx.ctx);\n\t\t} catch (err) {\n\t\t\tsetFlag(ctx.ret, IsErrored);\n\t\t\tthrow err;\n\t\t} finally {\n\t\t\tsetFlag(ctx.ret, IsExecuting, false);\n\t\t}\n\n\t\tif (isIteratorLike(returned)) {\n\t\t\tctx.iterator = returned;\n\t\t} else if (!isPromiseLike(returned)) {\n\t\t\t// sync function component\n\t\t\treturn [\n\t\t\t\tundefined,\n\t\t\t\tdiffComponentChildren<TNode, TResult>(ctx, returned, false),\n\t\t\t];\n\t\t} else {\n\t\t\t// async function component\n\t\t\tconst returned1 =\n\t\t\t\treturned instanceof Promise ? returned : Promise.resolve(returned);\n\t\t\treturn [\n\t\t\t\treturned1.catch(NOOP),\n\t\t\t\treturned1.then(\n\t\t\t\t\t(returned) =>\n\t\t\t\t\t\tdiffComponentChildren<TNode, TResult>(ctx, returned, false),\n\t\t\t\t\t(err) => {\n\t\t\t\t\t\tsetFlag(ctx.ret, IsErrored);\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\t}\n\n\tlet iteration!: Promise<ChildrenIteratorResult> | ChildrenIteratorResult;\n\tif (initial) {\n\t\ttry {\n\t\t\tsetFlag(ctx.ret, IsExecuting);\n\t\t\titeration = ctx.iterator!.next();\n\t\t} catch (err) {\n\t\t\tsetFlag(ctx.ret, IsErrored);\n\t\t\tthrow err;\n\t\t} finally {\n\t\t\tsetFlag(ctx.ret, IsExecuting, false);\n\t\t}\n\n\t\tif (isPromiseLike(iteration)) {\n\t\t\tsetFlag(ctx.ret, IsAsyncGen);\n\t\t} else {\n\t\t\tsetFlag(ctx.ret, IsSyncGen);\n\t\t}\n\t}\n\n\tif (getFlag(ctx.ret, IsSyncGen)) {\n\t\t// sync generator component\n\t\tif (!initial) {\n\t\t\ttry {\n\t\t\t\tsetFlag(ctx.ret, IsExecuting);\n\t\t\t\tconst oldResult = ctx.adapter.read(getValue(ctx.ret));\n\t\t\t\titeration = ctx.iterator!.next(oldResult);\n\t\t\t} catch (err) {\n\t\t\t\tsetFlag(ctx.ret, IsErrored);\n\t\t\t\tthrow err;\n\t\t\t} finally {\n\t\t\t\tsetFlag(ctx.ret, IsExecuting, false);\n\t\t\t}\n\t\t}\n\n\t\tif (isPromiseLike(iteration)) {\n\t\t\tthrow new Error(\"Mixed generator component\");\n\t\t}\n\n\t\tif (\n\t\t\tgetFlag(ctx.ret, IsInForOfLoop) &&\n\t\t\t!getFlag(ctx.ret, NeedsToYield) &&\n\t\t\t!getFlag(ctx.ret, IsUnmounted) &&\n\t\t\t!getFlag(ctx.ret, IsSchedulingRefresh)\n\t\t) {\n\t\t\tconsole.error(\n\t\t\t\t`Component <${getTagName(ctx.ret.el.tag)}> yielded/returned more than once in for...of loop`,\n\t\t\t);\n\t\t}\n\n\t\tsetFlag(ctx.ret, NeedsToYield, false);\n\t\tsetFlag(ctx.ret, IsSchedulingRefresh, false);\n\t\tif (iteration.done) {\n\t\t\tsetFlag(ctx.ret, IsSyncGen, false);\n\t\t\tctx.iterator = undefined;\n\t\t}\n\n\t\tconst diff = diffComponentChildren<TNode, TResult>(\n\t\t\tctx,\n\t\t\titeration.value as Children,\n\t\t\t!iteration.done,\n\t\t);\n\t\tconst block = isPromiseLike(diff) ? diff.catch(NOOP) : undefined;\n\t\treturn [block, diff];\n\t} else {\n\t\tif (getFlag(ctx.ret, IsInForAwaitOfLoop)) {\n\t\t\t// initializes the async generator loop\n\t\t\tpullComponent(ctx, iteration);\n\t\t\tconst block = resumePropsAsyncIterator(ctx);\n\t\t\treturn [block, ctx.pull && ctx.pull.diff];\n\t\t} else {\n\t\t\t// We call resumePropsAsyncIterator in case the component exits the\n\t\t\t// for...of loop\n\t\t\tresumePropsAsyncIterator(ctx);\n\t\t\tif (!initial) {\n\t\t\t\ttry {\n\t\t\t\t\tsetFlag(ctx.ret, IsExecuting);\n\t\t\t\t\tconst oldResult = ctx.adapter.read(getValue(ctx.ret));\n\t\t\t\t\titeration = ctx.iterator!.next(oldResult);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tsetFlag(ctx.ret, IsErrored);\n\t\t\t\t\tthrow err;\n\t\t\t\t} finally {\n\t\t\t\t\tsetFlag(ctx.ret, IsExecuting, false);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!isPromiseLike(iteration)) {\n\t\t\t\tthrow new Error(\"Mixed generator component\");\n\t\t\t}\n\n\t\t\tconst diff = iteration.then(\n\t\t\t\t(iteration) => {\n\t\t\t\t\tif (getFlag(ctx.ret, IsInForAwaitOfLoop)) {\n\t\t\t\t\t\t// We have entered a for await...of loop, so we start pulling\n\t\t\t\t\t\tpullComponent(ctx, iteration);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tgetFlag(ctx.ret, IsInForOfLoop) &&\n\t\t\t\t\t\t\t!getFlag(ctx.ret, NeedsToYield) &&\n\t\t\t\t\t\t\t!getFlag(ctx.ret, IsUnmounted) &&\n\t\t\t\t\t\t\t!getFlag(ctx.ret, IsSchedulingRefresh)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\t`Component <${getTagName(ctx.ret.el.tag)}> yielded/returned more than once in for...of loop`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tsetFlag(ctx.ret, NeedsToYield, false);\n\t\t\t\t\tsetFlag(ctx.ret, IsSchedulingRefresh, false);\n\t\t\t\t\tif (iteration.done) {\n\t\t\t\t\t\tsetFlag(ctx.ret, IsAsyncGen, false);\n\t\t\t\t\t\tctx.iterator = undefined;\n\t\t\t\t\t}\n\t\t\t\t\treturn diffComponentChildren<TNode, TResult>(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\t// Children can be void so we eliminate that here\n\t\t\t\t\t\titeration.value as Children,\n\t\t\t\t\t\t!iteration.done,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\t(err) => {\n\t\t\t\t\tsetFlag(ctx.ret, IsErrored);\n\t\t\t\t\tthrow err;\n\t\t\t\t},\n\t\t\t);\n\n\t\t\treturn [diff.catch(NOOP), diff];\n\t\t}\n\t}\n}\n\n/**\n * Called to resume the props async iterator for async generator components.\n *\n * @returns {Promise<undefined> | undefined} A possible promise which\n * represents the duration during which the component is blocked.\n */\nfunction resumePropsAsyncIterator(\n\tctx: ContextState,\n): Promise<undefined> | undefined {\n\tif (ctx.onPropsProvided) {\n\t\tctx.onPropsProvided(ctx.ret.el.props);\n\t\tctx.onPropsProvided = undefined;\n\t\tsetFlag(ctx.ret, PropsAvailable, false);\n\t} else {\n\t\tsetFlag(ctx.ret, PropsAvailable);\n\t\tif (getFlag(ctx.ret, IsInForAwaitOfLoop)) {\n\t\t\treturn new Promise<undefined>(\n\t\t\t\t(resolve) => (ctx.onPropsRequested = resolve as () => unknown),\n\t\t\t);\n\t\t}\n\t}\n\n\treturn (\n\t\tctx.pull && ctx.pull.iterationP && ctx.pull.iterationP.then(NOOP, NOOP)\n\t);\n}\n\n/**\n * The logic for pulling from async generator components when they are in a for\n * await...of loop is implemented here.\n *\n * It makes sense to group this logic in a single async loop to prevent race\n * conditions caused by calling next(), throw() and return() concurrently.\n */\nasync function pullComponent<TNode, TResult>(\n\tctx: ContextState<TNode, unknown, TNode, TResult>,\n\titerationP:\n\t\t| Promise<ChildrenIteratorResult>\n\t\t| ChildrenIteratorResult\n\t\t| undefined,\n): Promise<void> {\n\tif (!iterationP || ctx.pull) {\n\t\treturn;\n\t}\n\n\tctx.pull = {iterationP: undefined, diff: undefined, onChildError: undefined};\n\n\t// TODO: replace done with iteration\n\t//let iteration: ChildrenIteratorResult | undefined;\n\tlet done = false;\n\ttry {\n\t\tlet childError: any;\n\t\twhile (!done) {\n\t\t\tif (isPromiseLike(iterationP)) {\n\t\t\t\tctx.pull.iterationP = iterationP;\n\t\t\t}\n\n\t\t\tlet onDiff!: Function;\n\t\t\tctx.pull.diff = new Promise((resolve) => (onDiff = resolve)).then(\n\t\t\t\t(): undefined => {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!(getFlag(ctx.ret, IsUpdating) || getFlag(ctx.ret, IsRefreshing))\n\t\t\t\t\t) {\n\t\t\t\t\t\tcommitComponent(ctx, []);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t(err) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!(getFlag(ctx.ret, IsUpdating) || getFlag(ctx.ret, IsRefreshing)) ||\n\t\t\t\t\t\t// TODO: is this flag necessary?\n\t\t\t\t\t\t!getFlag(ctx.ret, NeedsToYield)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn propagateError(ctx, err, []);\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow err;\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tlet iteration: ChildrenIteratorResult;\n\t\t\ttry {\n\t\t\t\titeration = await iterationP;\n\t\t\t} catch (err) {\n\t\t\t\tdone = true;\n\t\t\t\tsetFlag(ctx.ret, IsErrored);\n\t\t\t\tsetFlag(ctx.ret, NeedsToYield, false);\n\t\t\t\tonDiff(Promise.reject(err));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// this must be set after iterationP is awaited\n\t\t\tlet oldResult: Promise<TResult>;\n\t\t\t{\n\t\t\t\t// The 'floating' flag tracks whether the promise passed to the generator\n\t\t\t\t// is handled (via await, then, or catch). If handled, we reject the\n\t\t\t\t// promise so the user can catch errors. If not, we inject the error back\n\t\t\t\t// into the generator using throw, like for sync generator components.\n\t\t\t\tlet floating = true;\n\t\t\t\tconst oldResult1 = new Promise<TResult>((resolve, reject) => {\n\t\t\t\t\tctx.ctx.schedule(resolve);\n\t\t\t\t\tctx.pull!.onChildError = (err: any) => {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t\tif (floating) {\n\t\t\t\t\t\t\tchildError = err;\n\t\t\t\t\t\t\tresumePropsAsyncIterator(ctx);\n\t\t\t\t\t\t\treturn ctx.pull!.diff;\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\toldResult1.catch(NOOP);\n\t\t\t\t// We use Object.create() to clone the promise for float detection\n\t\t\t\t// because modern JS engines skip calling .then() on promises awaited\n\t\t\t\t// with await.\n\t\t\t\toldResult = Object.create(oldResult1);\n\t\t\t\toldResult.then = function (\n\t\t\t\t\tonfulfilled?: ((value: TResult) => any) | null,\n\t\t\t\t\tonrejected?: ((reason: any) => any) | null,\n\t\t\t\t): Promise<any> {\n\t\t\t\t\tfloating = false;\n\t\t\t\t\treturn oldResult1.then(onfulfilled, onrejected);\n\t\t\t\t};\n\n\t\t\t\toldResult.catch = function (\n\t\t\t\t\tonrejected?: ((reason: any) => any) | null,\n\t\t\t\t): Promise<any> {\n\t\t\t\t\tfloating = false;\n\t\t\t\t\treturn oldResult1.catch(onrejected);\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (childError != null) {\n\t\t\t\ttry {\n\t\t\t\t\tsetFlag(ctx.ret, IsExecuting);\n\t\t\t\t\tif (typeof ctx.iterator!.throw !== \"function\") {\n\t\t\t\t\t\tthrow childError;\n\t\t\t\t\t}\n\t\t\t\t\titeration = await ctx.iterator!.throw(childError);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tdone = true;\n\t\t\t\t\tsetFlag(ctx.ret, IsErrored);\n\t\t\t\t\tsetFlag(ctx.ret, NeedsToYield, false);\n\t\t\t\t\tonDiff(Promise.reject(err));\n\t\t\t\t\tbreak;\n\t\t\t\t} finally {\n\t\t\t\t\tchildError = undefined;\n\t\t\t\t\tsetFlag(ctx.ret, IsExecuting, false);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// this makes sure we pause before entering a loop if we yield before it\n\t\t\tif (!getFlag(ctx.ret, IsInForAwaitOfLoop)) {\n\t\t\t\tsetFlag(ctx.ret, PropsAvailable, false);\n\t\t\t}\n\n\t\t\tdone = !!iteration.done;\n\n\t\t\tlet diff: Promise<undefined> | undefined;\n\t\t\ttry {\n\t\t\t\tif (!isPromiseLike(iterationP)) {\n\t\t\t\t\t// if iterationP is an iteration and not a promise, the component was\n\t\t\t\t\t// not in a for await...of loop when the iteration started, so we can\n\t\t\t\t\t// skip the diffing of children as it is handled elsewhere.\n\t\t\t\t\tdiff = undefined;\n\t\t\t\t} else if (\n\t\t\t\t\t!getFlag(ctx.ret, NeedsToYield) &&\n\t\t\t\t\tgetFlag(ctx.ret, PropsAvailable) &&\n\t\t\t\t\tgetFlag(ctx.ret, IsInForAwaitOfLoop)\n\t\t\t\t) {\n\t\t\t\t\t// logic to skip yielded children in a stale for await of iteration.\n\t\t\t\t\tdiff = undefined;\n\t\t\t\t} else {\n\t\t\t\t\tdiff = diffComponentChildren<TNode, TResult>(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\titeration.value!,\n\t\t\t\t\t\t!iteration.done,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tonDiff(Promise.reject(err));\n\t\t\t} finally {\n\t\t\t\tonDiff(diff);\n\t\t\t\tsetFlag(ctx.ret, NeedsToYield, false);\n\t\t\t}\n\n\t\t\tif (getFlag(ctx.ret, IsUnmounted)) {\n\t\t\t\t// TODO: move this unmounted branch outside the loop\n\t\t\t\twhile (\n\t\t\t\t\t(!iteration || !iteration.done) &&\n\t\t\t\t\tctx.iterator &&\n\t\t\t\t\tgetFlag(ctx.ret, IsInForAwaitOfLoop)\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsetFlag(ctx.ret, IsExecuting);\n\t\t\t\t\t\titeration = await ctx.iterator.next(oldResult);\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tsetFlag(ctx.ret, IsErrored);\n\t\t\t\t\t\t// we throw the error here to cause an unhandled rejection because\n\t\t\t\t\t\t// the promise returned from pullComponent is never awaited\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tsetFlag(ctx.ret, IsExecuting, false);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t(!iteration || !iteration.done) &&\n\t\t\t\t\tctx.iterator &&\n\t\t\t\t\ttypeof ctx.iterator.return === \"function\"\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsetFlag(ctx.ret, IsExecuting);\n\t\t\t\t\t\tawait ctx.iterator.return();\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tsetFlag(ctx.ret, IsErrored);\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tsetFlag(ctx.ret, IsExecuting, false);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t} else if (!getFlag(ctx.ret, IsInForAwaitOfLoop)) {\n\t\t\t\t// we have exited the for...await of, so updates will be handled by the\n\t\t\t\t// regular runComponent/enqueueComponent logic.\n\t\t\t\tbreak;\n\t\t\t} else if (!iteration.done) {\n\t\t\t\ttry {\n\t\t\t\t\tsetFlag(ctx.ret, IsExecuting);\n\t\t\t\t\titerationP = ctx.iterator!.next(\n\t\t\t\t\t\toldResult,\n\t\t\t\t\t) as Promise<ChildrenIteratorResult>;\n\t\t\t\t} finally {\n\t\t\t\t\tsetFlag(ctx.ret, IsExecuting, false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} finally {\n\t\tif (done) {\n\t\t\tsetFlag(ctx.ret, IsAsyncGen, false);\n\t\t\tctx.iterator = undefined;\n\t\t}\n\n\t\tctx.pull = undefined;\n\t}\n}\n\nfunction commitComponent<TNode>(\n\tctx: ContextState<TNode>,\n\tschedulePromises: Array<PromiseLike<unknown>>,\n\thydrationNodes?: Array<TNode> | undefined,\n): ElementValue<TNode> {\n\tif (ctx.schedule) {\n\t\tctx.schedule.promise.then(() => {\n\t\t\tcommitComponent(ctx, []);\n\t\t\tpropagateComponent(ctx);\n\t\t});\n\t\treturn getValue(ctx.ret);\n\t}\n\n\tconst values = commitChildren(\n\t\tctx.adapter,\n\t\tctx.host,\n\t\tctx,\n\t\tctx.scope,\n\t\tctx.root,\n\t\tctx.ret,\n\t\tctx.index,\n\t\tschedulePromises,\n\t\thydrationNodes,\n\t);\n\n\tif (getFlag(ctx.ret, IsUnmounted)) {\n\t\treturn;\n\t}\n\n\taddEventTargetDelegates(ctx.ctx, values);\n\n\t// Execute schedule callbacks early to check for async deferral\n\tconst wasScheduling = getFlag(ctx.ret, IsScheduling);\n\tlet schedulePromises1: Array<PromiseLike<unknown>> | undefined;\n\tconst callbacks = scheduleMap.get(ctx);\n\tif (callbacks) {\n\t\tscheduleMap.delete(ctx);\n\t\tsetFlag(ctx.ret, IsScheduling);\n\t\tconst result = ctx.adapter.read(unwrap(values));\n\t\tfor (const callback of callbacks) {\n\t\t\tconst scheduleResult = callback(result);\n\t\t\tif (isPromiseLike(scheduleResult)) {\n\t\t\t\t(schedulePromises1 = schedulePromises1 || []).push(scheduleResult);\n\t\t\t}\n\t\t}\n\n\t\tif (schedulePromises1 && !getFlag(ctx.ret, DidCommit)) {\n\t\t\tconst scheduleCallbacksP = Promise.all(schedulePromises1).then(() => {\n\t\t\t\tsetFlag(ctx.ret, IsScheduling, wasScheduling);\n\t\t\t\tpropagateComponent(ctx);\n\t\t\t\tif (ctx.ret.fallback) {\n\t\t\t\t\tunmount(\n\t\t\t\t\t\tctx.adapter,\n\t\t\t\t\t\tctx.host,\n\t\t\t\t\t\tctx.parent,\n\t\t\t\t\t\tctx.root,\n\t\t\t\t\t\tctx.ret.fallback,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tctx.ret.fallback = undefined;\n\t\t\t});\n\n\t\t\tlet onAbort!: () => void;\n\t\t\tconst scheduleP = safeRace([\n\t\t\t\tscheduleCallbacksP,\n\t\t\t\tnew Promise<void>((resolve) => (onAbort = resolve)),\n\t\t\t]).finally(() => {\n\t\t\t\tctx.schedule = undefined;\n\t\t\t});\n\n\t\t\tctx.schedule = {promise: scheduleP, onAbort};\n\t\t\tschedulePromises.push(scheduleP);\n\t\t} else {\n\t\t\tsetFlag(ctx.ret, IsScheduling, wasScheduling);\n\t\t}\n\t} else {\n\t\tsetFlag(ctx.ret, IsScheduling, wasScheduling);\n\t}\n\n\tif (!getFlag(ctx.ret, IsScheduling)) {\n\t\tif (!getFlag(ctx.ret, IsUpdating)) {\n\t\t\tpropagateComponent(ctx);\n\t\t}\n\n\t\tif (ctx.ret.fallback) {\n\t\t\tunmount(\n\t\t\t\tctx.adapter,\n\t\t\t\tctx.host,\n\t\t\t\tctx.parent,\n\t\t\t\tctx.root,\n\t\t\t\tctx.ret.fallback,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t}\n\n\t\tctx.ret.fallback = undefined;\n\t\tsetFlag(ctx.ret, IsUpdating, false);\n\t}\n\n\tsetFlag(ctx.ret, DidCommit);\n\t// We always use getValue() instead of the unwrapping values because there\n\t// are various ways in which the values could have been updated, especially\n\t// if schedule callbacks call refresh() or async mounting is happening.\n\treturn getValue(ctx.ret, true);\n}\n\n/**\n * Checks if a target retainer is active (contributing) in the host's retainer tree.\n * Performs a downward traversal from host to find if target is in the active path.\n */\nfunction isRetainerActive<TNode>(\n\ttarget: Retainer<TNode>,\n\thost: Retainer<TNode>,\n): boolean {\n\tconst stack: Retainer<TNode>[] = [host];\n\n\twhile (stack.length > 0) {\n\t\tconst current = stack.pop()!;\n\n\t\tif (current === target) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Add direct children to stack (skip if this is a host boundary)\n\t\t// Host boundaries are: DOM elements (string tags) or Portal, but NOT Fragment\n\t\tconst isHostBoundary =\n\t\t\tcurrent !== host &&\n\t\t\t((typeof current.el.tag === \"string\" && current.el.tag !== Fragment) ||\n\t\t\t\tcurrent.el.tag === Portal);\n\t\tif (current.children && !isHostBoundary) {\n\t\t\tconst children = wrap(current.children);\n\t\t\tfor (const child of children) {\n\t\t\t\tif (child) {\n\t\t\t\t\tstack.push(child);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Add fallback chains (only if current retainer is using fallback)\n\t\tif (current.fallback && !getFlag(current, DidDiff)) {\n\t\t\tstack.push(current.fallback);\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Propagates component changes up to ancestors when rendering starts from a\n * component via refresh() or multiple for await...of renders. This handles\n * event listeners and DOM arrangement that would normally happen during\n * top-down rendering.\n */\nfunction propagateComponent<TNode>(ctx: ContextState<TNode>): void {\n\tconst values = getChildValues(ctx.ret, ctx.index);\n\taddEventTargetDelegates(\n\t\tctx.ctx,\n\t\tvalues,\n\t\t(ctx1) => ctx1[_ContextState].host === ctx.host,\n\t);\n\tconst host = ctx.host;\n\tconst initiator = ctx.ret;\n\n\t// Check if initiator is active in the host's tree\n\tif (!isRetainerActive(initiator, host)) {\n\t\treturn;\n\t}\n\n\t// Check if host has been committed (has a node)\n\t// Fixes #334: refresh() called before component yields\n\tif (!getFlag(host, DidCommit)) {\n\t\treturn;\n\t}\n\n\tconst props = stripSpecialProps(host.el.props);\n\tconst hostChildren = getChildValues(host, 0);\n\n\tctx.adapter.arrange({\n\t\ttag: host.el.tag as string | symbol,\n\t\ttagName: getTagName(host.el.tag),\n\t\tnode: host.value as TNode,\n\t\tprops,\n\t\toldProps: props,\n\t\tchildren: hostChildren,\n\t\troot: ctx.root,\n\t});\n\n\tflush(ctx.adapter, ctx.root, ctx);\n}\n\nasync function unmountComponent(\n\tctx: ContextState,\n\tisNested: boolean,\n): Promise<undefined> {\n\tif (getFlag(ctx.ret, IsUnmounted)) {\n\t\treturn;\n\t}\n\n\tlet cleanupPromises: Array<PromiseLike<unknown>> | undefined;\n\t// TODO: think about errror handling for callbacks\n\tconst callbacks = cleanupMap.get(ctx);\n\tif (callbacks) {\n\t\tconst oldResult = ctx.adapter.read(getValue(ctx.ret));\n\t\tcleanupMap.delete(ctx);\n\t\tfor (const callback of callbacks) {\n\t\t\tconst cleanup = callback(oldResult);\n\t\t\tif (isPromiseLike(cleanup)) {\n\t\t\t\t(cleanupPromises = cleanupPromises || []).push(cleanup);\n\t\t\t}\n\t\t}\n\t}\n\n\tlet didLinger = false;\n\tif (!isNested && cleanupPromises && getChildValues(ctx.ret).length > 0) {\n\t\tdidLinger = true;\n\t\tconst index = ctx.index;\n\t\tconst lingerers = ctx.host.lingerers || (ctx.host.lingerers = []);\n\t\tlet set = lingerers[index];\n\t\tif (set == null) {\n\t\t\tset = new Set<Retainer<unknown>>();\n\t\t\tlingerers[index] = set;\n\t\t}\n\n\t\tset.add(ctx.ret);\n\t\tawait Promise.all(cleanupPromises);\n\t\tset!.delete(ctx.ret);\n\t\tif (set!.size === 0) {\n\t\t\tlingerers[index] = undefined;\n\t\t}\n\n\t\tif (!lingerers.some(Boolean)) {\n\t\t\t// If there are no lingerers remaining, we can remove the lingerers array\n\t\t\tctx.host.lingerers = undefined;\n\t\t}\n\t}\n\n\tif (getFlag(ctx.ret, IsUnmounted)) {\n\t\t// If the component was unmounted while awaiting the cleanup callbacks,\n\t\t// we do not need to continue unmounting.\n\t\treturn;\n\t}\n\n\tsetFlag(ctx.ret, IsUnmounted);\n\n\t// If component has pending schedule promises, resolve them since component\n\t// is unmounting\n\tif (ctx.schedule) {\n\t\tctx.schedule.onAbort();\n\t\tctx.schedule = undefined;\n\t}\n\n\tclearEventListeners(ctx.ctx);\n\tunmountChildren(ctx.adapter, ctx.host, ctx, ctx.root, ctx.ret, isNested);\n\tif (didLinger) {\n\t\t// If we lingered, we call finalize to ensure rendering is finalized\n\t\tif (ctx.root != null) {\n\t\t\tctx.adapter.finalize(ctx.root);\n\t\t}\n\t}\n\n\tif (ctx.iterator) {\n\t\tif (ctx.pull) {\n\t\t\t// we let pullComponent handle unmounting\n\t\t\tresumePropsAsyncIterator(ctx);\n\t\t\treturn;\n\t\t}\n\n\t\t// we wait for inflight value so yields resume with the most up to date\n\t\t// props\n\t\tif (ctx.inflight) {\n\t\t\tawait ctx.inflight[1];\n\t\t}\n\n\t\tlet iteration: ChildrenIteratorResult | undefined;\n\t\tif (getFlag(ctx.ret, IsInForOfLoop)) {\n\t\t\ttry {\n\t\t\t\tsetFlag(ctx.ret, IsExecuting);\n\t\t\t\tconst oldResult = ctx.adapter.read(getValue(ctx.ret));\n\t\t\t\tconst iterationP = ctx.iterator!.next(oldResult);\n\t\t\t\tif (isPromiseLike(iterationP)) {\n\t\t\t\t\tif (!getFlag(ctx.ret, IsAsyncGen)) {\n\t\t\t\t\t\tthrow new Error(\"Mixed generator component\");\n\t\t\t\t\t}\n\n\t\t\t\t\titeration = await iterationP;\n\t\t\t\t} else {\n\t\t\t\t\tif (!getFlag(ctx.ret, IsSyncGen)) {\n\t\t\t\t\t\tthrow new Error(\"Mixed generator component\");\n\t\t\t\t\t}\n\n\t\t\t\t\titeration = iterationP;\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tsetFlag(ctx.ret, IsErrored);\n\t\t\t\tthrow err;\n\t\t\t} finally {\n\t\t\t\tsetFlag(ctx.ret, IsExecuting, false);\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\t(!iteration || !iteration.done) &&\n\t\t\tctx.iterator &&\n\t\t\ttypeof ctx.iterator.return === \"function\"\n\t\t) {\n\t\t\ttry {\n\t\t\t\tsetFlag(ctx.ret, IsExecuting);\n\t\t\t\tconst iterationP = ctx.iterator.return();\n\t\t\t\tif (isPromiseLike(iterationP)) {\n\t\t\t\t\tif (!getFlag(ctx.ret, IsAsyncGen)) {\n\t\t\t\t\t\tthrow new Error(\"Mixed generator component\");\n\t\t\t\t\t}\n\n\t\t\t\t\titeration = await iterationP;\n\t\t\t\t} else {\n\t\t\t\t\tif (!getFlag(ctx.ret, IsSyncGen)) {\n\t\t\t\t\t\tthrow new Error(\"Mixed generator component\");\n\t\t\t\t\t}\n\n\t\t\t\t\titeration = iterationP;\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tsetFlag(ctx.ret, IsErrored);\n\t\t\t\tthrow err;\n\t\t\t} finally {\n\t\t\t\tsetFlag(ctx.ret, IsExecuting, false);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*** ERROR HANDLING UTILITIES ***/\nfunction handleChildError<TNode>(\n\tctx: ContextState<TNode, unknown, TNode>,\n\terr: unknown,\n): Promise<undefined> | undefined {\n\tif (!ctx.iterator) {\n\t\tthrow err;\n\t}\n\n\tif (ctx.pull) {\n\t\t// we let pullComponent handle child errors\n\t\tctx.pull.onChildError!(err);\n\t\treturn ctx.pull.diff;\n\t}\n\n\tif (!ctx.iterator.throw) {\n\t\tthrow err;\n\t}\n\n\tresumePropsAsyncIterator(ctx);\n\tlet iteration: ChildrenIteratorResult | Promise<ChildrenIteratorResult>;\n\ttry {\n\t\tsetFlag(ctx.ret, IsExecuting);\n\t\titeration = ctx.iterator.throw(err);\n\t} catch (err) {\n\t\tsetFlag(ctx.ret, IsErrored);\n\t\tthrow err;\n\t} finally {\n\t\tsetFlag(ctx.ret, IsExecuting, false);\n\t}\n\n\tif (isPromiseLike(iteration)) {\n\t\treturn iteration.then(\n\t\t\t(iteration) => {\n\t\t\t\tif (iteration.done) {\n\t\t\t\t\tsetFlag(ctx.ret, IsSyncGen, false);\n\t\t\t\t\tsetFlag(ctx.ret, IsAsyncGen, false);\n\t\t\t\t\tctx.iterator = undefined;\n\t\t\t\t}\n\n\t\t\t\treturn diffComponentChildren(\n\t\t\t\t\tctx,\n\t\t\t\t\titeration.value as Children,\n\t\t\t\t\t!iteration.done,\n\t\t\t\t);\n\t\t\t},\n\t\t\t(err) => {\n\t\t\t\tsetFlag(ctx.ret, IsErrored);\n\t\t\t\tthrow err;\n\t\t\t},\n\t\t);\n\t}\n\n\tif (iteration.done) {\n\t\tsetFlag(ctx.ret, IsSyncGen, false);\n\t\tsetFlag(ctx.ret, IsAsyncGen, false);\n\t\tctx.iterator = undefined;\n\t}\n\n\treturn diffComponentChildren(\n\t\tctx,\n\t\titeration.value as Children,\n\t\t!iteration.done,\n\t);\n}\n\n/**\n * Propagates an error up the context tree by calling handleChildError with\n * each parent.\n *\n * @returns A promise which resolves to undefined when the error has been\n * handled, or undefined if the error was handled synchronously.\n */\nfunction propagateError<TNode>(\n\tctx: ContextState<TNode>,\n\terr: unknown,\n\tschedulePromises: Array<PromiseLike<unknown>>,\n): Promise<undefined> | undefined {\n\tconst parent = ctx.parent;\n\tif (!parent) {\n\t\tthrow err;\n\t}\n\n\tlet diff: Promise<undefined> | undefined;\n\ttry {\n\t\tdiff = handleChildError(parent, err);\n\t} catch (err) {\n\t\treturn propagateError(parent, err, schedulePromises);\n\t}\n\n\tif (isPromiseLike(diff)) {\n\t\treturn diff.then(\n\t\t\t() => void commitComponent(parent, schedulePromises),\n\t\t\t(err) => propagateError(parent, err, schedulePromises),\n\t\t);\n\t}\n\n\tcommitComponent(parent, schedulePromises);\n}\n\n/**\n * An interface which can be extended to provide strongly typed provisions.\n * See Context.prototype.consume and Context.prototype.provide.\n */\nexport interface ProvisionMap extends Crank.ProvisionMap {}\n\nexport interface EventMap extends Crank.EventMap {}\n\ntype MappedEventListener<T extends string> = (ev: Crank.EventMap[T]) => unknown;\n\ntype MappedEventListenerOrEventListenerObject<T extends string> =\n\t| MappedEventListener<T>\n\t| {handleEvent: MappedEventListener<T>};\n\nexport interface Context extends Crank.Context {\n\taddEventListener<T extends string>(\n\t\ttype: T,\n\t\tlistener: MappedEventListenerOrEventListenerObject<T> | null,\n\t\toptions?: boolean | AddEventListenerOptions,\n\t): void;\n\n\tremoveEventListener<T extends string>(\n\t\ttype: T,\n\t\tlistener: MappedEventListenerOrEventListenerObject<T> | null,\n\t\toptions?: EventListenerOptions | boolean,\n\t): void;\n\n\tdispatchEvent<T extends string>(ev: EventMap[T] | Event): boolean;\n}\n\n// TODO: uncomment and use in the Element interface below\n// type CrankElement = Element;\ndeclare global {\n\tnamespace Crank {\n\t\texport interface EventMap {\n\t\t\t[tag: string]: Event;\n\t\t}\n\n\t\texport interface ProvisionMap {}\n\n\t\texport interface Context {}\n\t}\n\n\tnamespace JSX {\n\t\t// TODO: JSX Element type (the result of JSX expressions) don't work\n\t\t// because TypeScript demands that all Components return JSX elements for\n\t\t// some reason.\n\t\t// interface Element extends CrankElement {}\n\n\t\texport interface IntrinsicElements {\n\t\t\t[tag: string]: any;\n\t\t}\n\n\t\texport interface IntrinsicAttributes {\n\t\t\tchildren?: unknown;\n\t\t\tkey?: unknown;\n\t\t\tref?: unknown;\n\t\t\tcopy?: unknown;\n\t\t\thydrate?: unknown;\n\t\t}\n\n\t\texport interface ElementChildrenAttribute {\n\t\t\tchildren: {};\n\t\t}\n\t}\n}\n\n/**\n * A re-export of some Crank exports as the default export.\n *\n * Some JSX tools expect things like createElement/Fragment to be defined on\n * the default export. Prefer using the named exports directly.\n */\nexport default {createElement, Fragment};\n"]}