@bgub/fig-dom 0.1.0-alpha.1 → 0.1.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,46 @@
1
+ ## @bgub/fig-dom@0.1.0-alpha.3
2
+
3
+ ### Renderers now install their reconciler implementation
4
+
5
+ Fig DOM and Fast Refresh now depend on their exact reconciler version directly.
6
+ Applications no longer need to install `@bgub/fig-reconciler` alongside Fig DOM;
7
+ the reconciler remains a direct dependency only for custom-renderer authors.
8
+
9
+ Fast Refresh connects to Fig DOM through a renderer-owned adapter, ensuring its
10
+ family resolver and scheduled updates always reach the same reconciler instance
11
+ even when development tooling resolves through a separate package graph.
12
+
13
+ ### Let Fig's Vite integration own runtime configuration
14
+
15
+ The new `fig()` Vite integration defines Fig's development gate and installs
16
+ Fast Refresh. TanStack Start composes it automatically, so applications no
17
+ longer need to configure Fig's compile-time mode or SSR package bundling
18
+ themselves.
19
+
20
+ `@bgub/fig-vite` now uses the application's Fig DOM renderer as a peer instead
21
+ of installing a private renderer copy.
22
+
23
+ The development gate follows Vite's command rather than its mode: serving
24
+ enables development behavior, while builds—including `--mode development`—strip
25
+ it from production output.
26
+
27
+ Published npm packages now expose development artifacts through a Fig-owned
28
+ condition, allowing the Vite integration to enable diagnostics and Fast Refresh
29
+ for ordinary installs while explicit static overrides remain authoritative and
30
+ default production imports retain their previous dead-code elimination. A
31
+ static `false` override also disables Fast Refresh instrumentation.
32
+
33
+ ## @bgub/fig-dom@0.1.0-alpha.2
34
+
35
+ ### Keep empty children and document assets hydration-safe
36
+
37
+ Empty string children now normalize away on both the server and client, so a
38
+ rendered empty token cannot force hydration to recover the root.
39
+
40
+ When full-document hydration does recover, declarative stylesheets, titles,
41
+ and metadata now acquire against the replacement head instead of disappearing
42
+ with the server document.
43
+
1
44
  ## @bgub/fig-dom@0.1.0-alpha.1
2
45
 
3
46
  ### Asset descriptors use native names and preserve native ordering
package/dist/refresh.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- import { RefreshFamily, RefreshUpdate, RefreshUpdate as RefreshUpdate$1 } from "@bgub/fig-reconciler/refresh";
1
+ import { RefreshAdapter, RefreshFamily, RefreshUpdate, RefreshUpdate as RefreshUpdate$1 } from "@bgub/fig-reconciler/refresh";
2
2
  //#region src/refresh-internal.d.ts
3
3
  declare function scheduleRefresh(update: RefreshUpdate$1): void;
4
4
  //#endregion
5
- export { type RefreshFamily, type RefreshUpdate, scheduleRefresh };
5
+ //#region src/refresh.d.ts
6
+ declare const domRefreshAdapter: RefreshAdapter;
7
+ //#endregion
8
+ export { type RefreshFamily, type RefreshUpdate, domRefreshAdapter, scheduleRefresh };
package/dist/refresh.js CHANGED
@@ -1 +1,2 @@
1
- import{n as e}from"./refresh-internal-B05aFp_T.js";export{e as scheduleRefresh};
1
+ import{n as e}from"./refresh-internal-B05aFp_T.js";import{setRefreshHandler as t}from"@bgub/fig-reconciler/refresh";const n={scheduleRefresh:e,setRefreshHandler:t};export{n as domRefreshAdapter,e as scheduleRefresh};
2
+ //# sourceMappingURL=refresh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refresh.js","names":[],"sources":["../src/refresh.ts"],"sourcesContent":["import {\n type RefreshAdapter,\n type RefreshFamily,\n type RefreshUpdate,\n setRefreshHandler,\n} from \"@bgub/fig-reconciler/refresh\";\nimport { scheduleRefresh } from \"./refresh-internal.ts\";\n\nexport type { RefreshFamily, RefreshUpdate };\nexport { scheduleRefresh };\n\nexport const domRefreshAdapter: RefreshAdapter = {\n scheduleRefresh,\n setRefreshHandler,\n};\n"],"mappings":"oHAWA,MAAa,EAAoC,CAC/C,kBACA,mBACF"}
@@ -0,0 +1 @@
1
+ import{act as e}from"@bgub/fig-reconciler/test-utils";export{e as act};
@@ -0,0 +1,2 @@
1
+ import{a as e,i as t,n,o as r,r as i,t as a}from"./renderer-C0R0O1QP.js";import{assertPayloadCodecMatches as o,createPortalNode as s,jsonPayloadCodec as c,loadContextCapabilities as l}from"@bgub/fig/internal";import{dataResource as u,readData as d}from"@bgub/fig";import{decodePayloadStream as f}from"@bgub/fig/payload";const p=()=>void 0;async function m(e,t,r={}){let{signal:i}=t;if(i.aborted)throw await e.body?.cancel().catch(p),h(i);if(!e.ok)throw await e.body?.cancel().catch(p),Error(`Payload request failed with status ${e.status}.`);let a=e.body;if(a===null)throw Error(`Payload response did not include a body.`);try{o(c,e.headers.get(`content-type`))}catch(e){throw await a.cancel().catch(p),e}let s=l(t);return f(a,{hydrate:s?.hydrate,onHoleError:s?.attributeError,onStreamDone:e=>{e.status===`failed`&&console.error(`Payload decode failed after its root value published:`,e.error)},prepareAssets:r.prepareAssets??(e=>n(e)),retainAssets:r.retainAssets,resolveClientReference:r.resolveClientReference,signal:i})}function h(e){return e.reason??Error(`Payload request aborted.`)}function g(e){let t=new WeakMap,n=1;function r(e){if(e===null)return null;if(e===void 0)return[`undefined`];if(typeof e==`string`||typeof e==`boolean`)return e;if(typeof e==`number`)return Number.isNaN(e)?[`number`,`NaN`]:e===1/0?[`number`,`Infinity`]:e===-1/0?[`number`,`-Infinity`]:Object.is(e,-0)?[`number`,`-0`]:e;if(typeof e==`bigint`)return[`bigint`,e.toString()];if(typeof e==`symbol`){let t=Symbol.keyFor(e);if(t===void 0)throw Error(`Only global Symbol.for symbols can be serialized.`);return[`symbol`,t]}if(typeof e==`function`)throw Error(`Functions cannot be serialized into the payload.`);if(e instanceof Date){let t=e.toJSON();if(t===null)throw Error(`Invalid Date values cannot be serialized.`);return[`date`,t]}let i=t.get(e);if(i!==void 0)return[`ref`,i];let a=n++;if(t.set(e,a),Array.isArray(e))return[`array`,a,e.map(r)];if(e instanceof Map)return[`map`,a,Array.from(e,([e,t])=>[r(e),r(t)])];if(e instanceof Set)return[`set`,a,Array.from(e,r)];let o=Object.getPrototypeOf(e);if(o!==Object.prototype&&o!==null)throw Error(`Cannot serialize ${o?.constructor?.name??`object`} into the payload.`);let s=e;return[`object`,a,Object.keys(s).sort().map(e=>[e,r(s[e])])]}return r(e)}function _(e){let t=t=>{let n=v(t);return[...e.key,e.cacheKey===void 0?n:e.cacheKey(t)]},n=u({debugArgs:e.cacheKey===void 0?void 0:v,key:t,load:async(n,r)=>{let i=await e.load(n,{key:l(r)?.key??t(n),signal:r.signal});return m(i instanceof Response?i:new Response(i.stream,{headers:{"content-type":i.contentType}}),r,{prepareAssets:e.prepareAssets??e.load.prepareAssets,resolveClientReference:e.resolveClientReference??e.load.resolveClientReference,retainAssets:e.retainAssets??e.load.retainAssets})}}),r=Object.assign(function(e){return y(e),d(r,e)},n);return Object.defineProperty(r,"displayName",{configurable:!0,value:`Payload(${e.key[0]})`}),r}function v(e){return y(e),g(e)}function y(e){if(Object.hasOwn(e,`children`))throw Error(`Payload components do not accept children.`)}const b=a.flushSync;function x(e,t){let n=a.createRoot(e,t);return i(e,{run:e=>n.data.run(e)}),w(n,e)}function S(e,t,n){let r=a.hydrateRoot(e,t,n);return i(e,{hydrate:(t,n)=>a.hydrateTarget(e,t,n),run:e=>r.data.run(e)}),w(r,e)}function C(e,t,n=null){return s(e,t,n)}function w(e,n){return{...e,unmount:()=>{e.unmount(),t(n)}}}export{r as composeBind,_ as createPayloadComponent,C as createPortal,x as createRoot,b as flushSync,S as hydrateRoot,n as insertAssetResources,e as on};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/payload-decoder.ts","../src/payload-key.ts","../src/payload-component.ts","../src/index.ts"],"sourcesContent":["import type { AwaitedFigNode, DataResourceLoadContext } from \"@bgub/fig\";\nimport {\n assertPayloadCodecMatches,\n jsonPayloadCodec,\n loadContextCapabilities,\n} from \"@bgub/fig/internal\";\nimport {\n decodePayloadStream,\n type PayloadDecodeOptions,\n} from \"@bgub/fig/payload\";\nimport { insertAssetResources } from \"./asset-resources.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\nconst noop = (): void => undefined;\n\nexport type PayloadDecoderOptions = Pick<\n PayloadDecodeOptions,\n \"prepareAssets\" | \"resolveClientReference\" | \"retainAssets\"\n>;\n\n/**\n * Decodes a validated Payload response within one data-resource generation.\n * The root becomes the entry value, streamed holes keep filling for the\n * generation's lifetime, `data` rows hydrate through its guarded capability,\n * and discovered assets enter the document with dependent reveal gates.\n */\nexport async function decodePayloadResponse(\n response: Response,\n context: DataResourceLoadContext,\n options: PayloadDecoderOptions = {},\n): Promise<AwaitedFigNode> {\n const { signal } = context;\n if (signal.aborted) {\n await response.body?.cancel().catch(noop);\n throw abortReason(signal);\n }\n if (!response.ok) {\n await response.body?.cancel().catch(noop);\n throw new Error(`Payload request failed with status ${response.status}.`);\n }\n const body = response.body;\n if (body === null) {\n throw new Error(\"Payload response did not include a body.\");\n }\n try {\n assertPayloadCodecMatches(\n jsonPayloadCodec,\n response.headers.get(\"content-type\"),\n );\n } catch (error) {\n await body.cancel().catch(noop);\n throw error;\n }\n\n const capabilities = loadContextCapabilities(context);\n return decodePayloadStream(body, {\n // Absent outside a data store: data rows are ignored rather than hydrated.\n hydrate: capabilities?.hydrate,\n onHoleError: capabilities?.attributeError,\n // Post-root failures surface through the rejected holes they strand;\n // observing the stream end keeps a failure that no longer has a pending\n // slot from being silently discarded in development.\n onStreamDone: (result) => {\n if (__DEV__ && result.status === \"failed\") {\n console.error(\n \"Payload decode failed after its root value published:\",\n result.error,\n );\n }\n },\n prepareAssets:\n options.prepareAssets ?? ((assets) => insertAssetResources(assets)),\n retainAssets: options.retainAssets,\n resolveClientReference: options.resolveClientReference,\n signal,\n });\n}\n\nfunction abortReason(signal: AbortSignal): unknown {\n return signal.reason ?? new Error(\"Payload request aborted.\");\n}\n","import type { DataResourceKeyInput } from \"@bgub/fig\";\n\nexport function encodePayloadKey(value: unknown): DataResourceKeyInput {\n const ids = new WeakMap<object, number>();\n let nextId = 1;\n\n function encode(value: unknown): DataResourceKeyInput {\n if (value === null) return null;\n if (value === undefined) return [\"undefined\"];\n if (typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") {\n if (Number.isNaN(value)) return [\"number\", \"NaN\"];\n if (value === Infinity) return [\"number\", \"Infinity\"];\n if (value === -Infinity) return [\"number\", \"-Infinity\"];\n return Object.is(value, -0) ? [\"number\", \"-0\"] : value;\n }\n if (typeof value === \"bigint\") return [\"bigint\", value.toString()];\n if (typeof value === \"symbol\") {\n const key = Symbol.keyFor(value);\n if (key === undefined) {\n throw new Error(\"Only global Symbol.for symbols can be serialized.\");\n }\n return [\"symbol\", key];\n }\n if (typeof value === \"function\") {\n throw new Error(\"Functions cannot be serialized into the payload.\");\n }\n if (value instanceof Date) {\n const json = value.toJSON();\n if (json === null) {\n throw new Error(\"Invalid Date values cannot be serialized.\");\n }\n return [\"date\", json];\n }\n\n const existing = ids.get(value);\n if (existing !== undefined) return [\"ref\", existing];\n const id = nextId++;\n ids.set(value, id);\n\n if (Array.isArray(value)) {\n return [\"array\", id, value.map(encode)];\n }\n if (value instanceof Map) {\n return [\n \"map\",\n id,\n Array.from(value, ([key, item]) => [encode(key), encode(item)]),\n ];\n }\n if (value instanceof Set) {\n return [\"set\", id, Array.from(value, encode)];\n }\n\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n throw new Error(\n `Cannot serialize ${prototype?.constructor?.name ?? \"object\"} into the payload.`,\n );\n }\n const record = value as Record<string, unknown>;\n return [\n \"object\",\n id,\n Object.keys(record)\n .sort()\n .map((key) => [key, encode(record[key])]),\n ];\n }\n\n return encode(value);\n}\n","import {\n type AwaitedFigNode,\n dataResource,\n type DataResource,\n type DataResourceKey,\n type DataResourceKeyInput,\n type FigNode,\n readData,\n} from \"@bgub/fig\";\nimport { loadContextCapabilities } from \"@bgub/fig/internal\";\nimport {\n decodePayloadResponse,\n type PayloadDecoderOptions,\n} from \"./payload-decoder.ts\";\nimport { encodePayloadKey } from \"./payload-key.ts\";\n\nexport type PayloadSource =\n | Response\n | {\n contentType: string;\n stream: ReadableStream<Uint8Array>;\n };\n\nexport interface PayloadComponentLoadContext {\n key: DataResourceKey;\n signal: AbortSignal;\n}\n\nexport interface PayloadComponentLoader<\n TProps extends object,\n> extends PayloadDecoderOptions {\n (\n props: TProps,\n context: PayloadComponentLoadContext,\n ): PayloadSource | PromiseLike<PayloadSource>;\n}\n\nexport interface PayloadComponentOptions<\n TProps extends object,\n> extends PayloadDecoderOptions {\n cacheKey?: (props: TProps) => DataResourceKeyInput;\n key: DataResourceKey;\n load: PayloadComponentLoader<TProps>;\n}\n\nexport interface PayloadComponent<TProps extends object> extends DataResource<\n [TProps],\n AwaitedFigNode\n> {\n (props: TProps & { children?: FigNode }): FigNode;\n}\n\n/**\n * Creates a renderable Payload tree backed by Fig's ordinary data store.\n */\nexport function createPayloadComponent<TProps extends object>(\n options: PayloadComponentOptions<TProps>,\n): PayloadComponent<TProps> {\n const key = (props: TProps): DataResourceKey => {\n const serialized = serializedProps(props);\n return [\n ...options.key,\n options.cacheKey === undefined ? serialized : options.cacheKey(props),\n ];\n };\n const resource = dataResource<[TProps], AwaitedFigNode>({\n debugArgs: options.cacheKey === undefined ? undefined : serializedProps,\n key,\n load: async (props, context) => {\n const source = await options.load(props, {\n key: loadContextCapabilities(context)?.key ?? key(props),\n signal: context.signal,\n });\n const response =\n source instanceof Response\n ? source\n : new Response(source.stream, {\n headers: { \"content-type\": source.contentType },\n });\n return decodePayloadResponse(response, context, {\n prepareAssets: options.prepareAssets ?? options.load.prepareAssets,\n resolveClientReference:\n options.resolveClientReference ?? options.load.resolveClientReference,\n retainAssets: options.retainAssets ?? options.load.retainAssets,\n });\n },\n });\n\n const component: PayloadComponent<TProps> = Object.assign(\n function PayloadComponent(props: TProps & { children?: FigNode }): FigNode {\n rejectChildren(props);\n return readData(component, props);\n },\n resource,\n );\n Object.defineProperty(component, \"displayName\", {\n configurable: true,\n value: `Payload(${options.key[0]})`,\n });\n\n return component;\n}\n\nfunction serializedProps<TProps extends object>(\n props: TProps,\n): DataResourceKeyInput {\n rejectChildren(props);\n return encodePayloadKey(props);\n}\n\nfunction rejectChildren(props: object): void {\n if (Object.hasOwn(props, \"children\")) {\n throw new Error(\"Payload components do not accept children.\");\n }\n}\n","import type { FigNode, FigPortal, Key } from \"@bgub/fig\";\nimport { createPortalNode } from \"@bgub/fig/internal\";\nimport type {\n FigRoot,\n FigRootOptions,\n RecoverableErrorInfo,\n} from \"@bgub/fig-reconciler\";\nimport { composeBind } from \"./bind.ts\";\nimport {\n type EventCallback,\n type EventOptions,\n on,\n} from \"./event-descriptor.ts\";\nimport { type Container, registerRoot, unregisterRoot } from \"./events.ts\";\nimport { domRenderer } from \"./renderer.ts\";\n\nexport { insertAssetResources } from \"./asset-resources.ts\";\nexport type { Bind } from \"./bind.ts\";\nexport { composeBind };\nexport { type EventCallback, type EventOptions, on };\nexport type {\n EmptyPropValue,\n HostIntrinsicElements,\n HostProps,\n HostStyle,\n} from \"./jsx.ts\";\nexport {\n createPayloadComponent,\n type PayloadComponent,\n type PayloadComponentLoadContext,\n type PayloadComponentLoader,\n type PayloadComponentOptions,\n type PayloadSource,\n} from \"./payload-component.ts\";\n\nexport type { Container, FigRoot, FigRootOptions, RecoverableErrorInfo };\n\nexport const flushSync = domRenderer.flushSync;\n\nexport function createRoot(\n container: Container,\n options?: FigRootOptions,\n): FigRoot {\n const root = domRenderer.createRoot(container, options);\n registerRoot(container, { run: (callback) => root.data.run(callback) });\n return withEventTeardown(root, container);\n}\n\nexport function hydrateRoot(\n container: Container,\n children: FigNode,\n options?: FigRootOptions,\n): FigRoot {\n const root = domRenderer.hydrateRoot(container, children, options);\n registerRoot(container, {\n hydrate: (target, priority) =>\n domRenderer.hydrateTarget(container, target, priority),\n run: (callback) => root.data.run(callback),\n });\n return withEventTeardown(root, container);\n}\n\nexport function createPortal(\n children: FigNode,\n container: Container,\n key: Key | null = null,\n): FigPortal<Container> {\n return createPortalNode(children, container, key);\n}\n\n// Event routing lives outside the reconciler, so root teardown owns both.\nfunction withEventTeardown(root: FigRoot, container: Container): FigRoot {\n return {\n ...root,\n unmount: () => {\n root.unmount();\n unregisterRoot(container);\n },\n };\n}\n"],"mappings":"gUAeA,MAAM,MAAmB,IAAA,GAazB,eAAsB,EACpB,EACA,EACA,EAAiC,CAAC,EACT,CACzB,GAAM,CAAE,UAAW,EACnB,GAAI,EAAO,QAET,MADA,MAAM,EAAS,MAAM,OAAO,CAAC,CAAC,MAAM,CAAI,EAClC,EAAY,CAAM,EAE1B,GAAI,CAAC,EAAS,GAEZ,MADA,MAAM,EAAS,MAAM,OAAO,CAAC,CAAC,MAAM,CAAI,EAC9B,MAAM,sCAAsC,EAAS,OAAO,EAAE,EAE1E,IAAM,EAAO,EAAS,KACtB,GAAI,IAAS,KACX,MAAU,MAAM,0CAA0C,EAE5D,GAAI,CACF,EACE,EACA,EAAS,QAAQ,IAAI,cAAc,CACrC,CACF,OAAS,EAAO,CAEd,MADA,MAAM,EAAK,OAAO,CAAC,CAAC,MAAM,CAAI,EACxB,CACR,CAEA,IAAM,EAAe,EAAwB,CAAO,EACpD,OAAO,EAAoB,EAAM,CAE/B,QAAS,GAAc,QACvB,YAAa,GAAc,eAI3B,aAAe,GAAW,CACT,EAAO,SAAW,UAC/B,QAAQ,MACN,wDACA,EAAO,KACT,CAEJ,EACA,cACE,EAAQ,gBAAmB,GAAW,EAAqB,CAAM,GACnE,aAAc,EAAQ,aACtB,uBAAwB,EAAQ,uBAChC,QACF,CAAC,CACH,CAEA,SAAS,EAAY,EAA8B,CACjD,OAAO,EAAO,QAAc,MAAM,0BAA0B,CAC9D,CChFA,SAAgB,EAAiB,EAAsC,CACrE,IAAM,EAAM,IAAI,QACZ,EAAS,EAEb,SAAS,EAAO,EAAsC,CACpD,GAAI,IAAU,KAAM,OAAO,KAC3B,GAAI,IAAU,IAAA,GAAW,MAAO,CAAC,WAAW,EAC5C,GAAI,OAAO,GAAU,UAAY,O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CAA4C,CAEhE,CC7EA,MAAa,EAAY,EAAY,UAErC,SAAgB,EACd,EACA,EACS,CACT,IAAM,EAAO,EAAY,WAAW,EAAW,CAAO,EAEtD,OADA,EAAa,EAAW,CAAE,IAAM,GAAa,EAAK,KAAK,IAAI,CAAQ,CAAE,CAAC,EAC/D,EAAkB,EAAM,CAAS,CAC1C,CAEA,SAAgB,EACd,EACA,EACA,EACS,CACT,IAAM,EAAO,EAAY,YAAY,EAAW,EAAU,CAAO,EAMjE,OALA,EAAa,EAAW,CACtB,SAAU,EAAQ,IAChB,EAAY,cAAc,EAAW,EAAQ,CAAQ,EACvD,IAAM,GAAa,EAAK,KAAK,IAAI,CAAQ,CAC3C,CAAC,EACM,EAAkB,EAAM,CAAS,CAC1C,CAEA,SAAgB,EACd,EACA,EACA,EAAkB,KACI,CACtB,OAAO,EAAiB,EAAU,EAAW,CAAG,CAClD,CAGA,SAAS,EAAkB,EAAe,EAA+B,CACvE,MAAO,CACL,GAAG,EACH,YAAe,CACb,EAAK,QAAQ,EACb,EAAe,CAAS,CAC1B,CACF,CACF"}
@@ -0,0 +1 @@
1
+ import{Fragment as e,jsx as t,jsxDEV as n,jsxs as r}from"@bgub/fig/jsx-runtime";export{e as Fragment,t as jsx,n as jsxDEV,r as jsxs};
@@ -0,0 +1,2 @@
1
+ let e=null,t=null;function n(n){if(e=n,t!==null){let e=t;t=null;for(let t of e)n(t)}}function r(n){if(e===null){(t??=[]).push(n);return}e(n)}export{r as n,n as t};
2
+ //# sourceMappingURL=refresh-internal-B05aFp_T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refresh-internal-B05aFp_T.js","names":[],"sources":["../src/refresh-internal.ts"],"sourcesContent":["import type { RefreshUpdate } from \"@bgub/fig-reconciler/refresh\";\n\nlet scheduleDomRefresh: ((update: RefreshUpdate) => void) | null = null;\n\n// Updates that arrive before the @bgub/fig-dom main entry has evaluated (it\n// configures the scheduler as a module side effect). A code-split app can load\n// this entry first, and dropping those updates would silently skip a refresh.\nlet pendingUpdates: RefreshUpdate[] | null = null;\n\nexport function configureDomRefreshScheduler(\n scheduleRefresh: (update: RefreshUpdate) => void,\n): void {\n scheduleDomRefresh = scheduleRefresh;\n\n if (pendingUpdates !== null) {\n const updates = pendingUpdates;\n pendingUpdates = null;\n for (const update of updates) scheduleRefresh(update);\n }\n}\n\nexport function scheduleRefresh(update: RefreshUpdate): void {\n if (scheduleDomRefresh === null) {\n (pendingUpdates ??= []).push(update);\n return;\n }\n\n scheduleDomRefresh(update);\n}\n"],"mappings":"AAEA,IAAI,EAA+D,KAK/D,EAAyC,KAE7C,SAAgB,EACd,EACM,CAGN,GAFA,EAAqB,EAEjB,IAAmB,KAAM,CAC3B,IAAM,EAAU,EAChB,EAAiB,KACjB,IAAK,IAAM,KAAU,EAAS,EAAgB,CAAM,CACtD,CACF,CAEA,SAAgB,EAAgB,EAA6B,CAC3D,GAAI,IAAuB,KAAM,EAC9B,IAAmB,CAAC,EAAA,CAAG,KAAK,CAAM,EACnC,MACF,CAEA,EAAmB,CAAM,CAC3B"}
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./refresh-internal-B05aFp_T.js";import{setRefreshHandler as t}from"@bgub/fig-reconciler/refresh";const n={scheduleRefresh:e,setRefreshHandler:t};export{n as domRefreshAdapter,e as scheduleRefresh};
2
+ //# sourceMappingURL=refresh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refresh.js","names":[],"sources":["../src/refresh.ts"],"sourcesContent":["import {\n type RefreshAdapter,\n type RefreshFamily,\n type RefreshUpdate,\n setRefreshHandler,\n} from \"@bgub/fig-reconciler/refresh\";\nimport { scheduleRefresh } from \"./refresh-internal.ts\";\n\nexport type { RefreshFamily, RefreshUpdate };\nexport { scheduleRefresh };\n\nexport const domRefreshAdapter: RefreshAdapter = {\n scheduleRefresh,\n setRefreshHandler,\n};\n"],"mappings":"oHAWA,MAAa,EAAoC,CAC/C,kBACA,mBACF"}
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./refresh-internal-B05aFp_T.js";import{ACTIVITY_TEMPLATE_ATTRIBUTE as t,EARLY_EVENT_HANDLER_PROPERTY as n,EARLY_EVENT_QUEUE_PROPERTY as r,HYDRATION_SKIP_ATTRIBUTE as i,REPLAYABLE_EVENT_TYPES as a,SUSPENSE_CLIENT_MARKER as o,SUSPENSE_COMPLETED_MARKER as s,SUSPENSE_END_MARKER as c,SUSPENSE_PENDING_PREFIX as l,TEXT_SEPARATOR_DATA as u,assetResourceFromHostAttributes as ee,assetResourceFromHostProps as d,assetResourceHostAttributes as f,assetResourceKey as p,isFigAssetResource as te,markClientOnlyHostBehavior as ne,mixinSlot as re,validateInstanceNesting as ie,validateTextNesting as ae}from"@bgub/fig/internal";import{createMixin as oe}from"@bgub/fig";import{createRenderer as se,runWithEventPriority as ce}from"@bgub/fig-reconciler";function le(e,t){if(!m(e))return;let n=[];ue(e,n);for(let e of n)t(e)}function ue(e,t){t.push(e);for(let n=e.firstChild;n!==null;n=n.nextSibling)m(n)&&ue(n,t)}function m(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===1}function h(e){return m(e)?`localName`in e&&typeof e.localName==`string`?e.localName.toLowerCase():`tagName`in e&&typeof e.tagName==`string`?e.tagName.toLowerCase():``:``}function de(e){return e.namespaceURI===null||e.namespaceURI===`http://www.w3.org/1999/xhtml`}function g(e){return typeof e==`object`&&e&&`parentNode`in e?e.parentNode:null}function _(e){return e==null||e===!1}const v=new WeakMap,y=new WeakSet;function fe(...e){let t=e.filter(e=>typeof e==`function`);return(e,n)=>{for(let r of t)r(e,n)}}function pe(e,t){let n=ve(t),r=v.get(e);if(n===null){r!==void 0&&x(r),v.delete(e);return}if(r===void 0){let t={callback:n,controller:null,strictRan:!1};v.set(e,t),b(e,t)}else r.callback!==n&&(x(r),r.callback=n,b(e,r))}function me(e){let t=v.get(e);t!==void 0&&b(e,t)}function he(e){y.add(e);let t=v.get(e);t!==void 0&&x(t)}function ge(e){y.delete(e);let t=v.get(e);t!==void 0&&b(e,t)}function _e(e){let t=v.get(e);t!==void 0&&(x(t),v.delete(e))}function b(e,t){if(t.controller!==null||e.parentNode===null||y.has(e))return;let n=!1;n=!t.strictRan,t.strictRan=!0,t.controller=new AbortController,t.callback(e,t.controller.signal),n&&(x(t),t.controller=new AbortController,t.callback(e,t.controller.signal))}function x(e){e.controller?.abort(),e.controller=null}function ve(e){if(_(e))return null;if(typeof e==`function`)return e;throw Error(`The bind prop must be a function.`)}const S=Symbol.for(`fig.native-event-descriptors`),ye=oe((e,t,n,r)=>{ne(e,`on()`);let i=e.props,a=i[S];a===void 0&&(a=[],Object.defineProperty(i,S,{configurable:!0,value:a})),a.push({callback:n,options:r,slot:re(e),type:t})});function be(e,t,n){return ye(e,t,n)}const xe=[];function Se(e){return e[S]??xe}function Ce(e,t,n){let r=Ee(e,`currentTarget`,{value:t});try{return n(e)}finally{r()}}function we(e,t,n){let r={immediateStopped:!1,stopped:!t&&e.cancelBubble===!0},i=Te(e,`stopPropagation`,()=>{r.stopped=!0}),a=Te(e,`stopImmediatePropagation`,()=>{r.stopped=!0,r.immediateStopped=!0}),o=Ee(e,`cancelBubble`,{get:()=>r.stopped,set(e){e===!0&&(r.stopped=!0)}});try{return n(r)}finally{o(),a(),i(),r.stopped&&(e.cancelBubble=!0)}}function Te(e,t,n){let r=Reflect.get(e,t);return typeof r==`function`?Ee(e,t,{value(){n(),r.call(e)}}):De}function Ee(e,t,n){let r=Object.getOwnPropertyDescriptor(e,t);return Reflect.defineProperty(e,t,{configurable:!0,...n})?r===void 0?()=>{Reflect.deleteProperty(e,t)}:()=>{Reflect.defineProperty(e,t,r)}:De}function De(){}const C=new WeakMap,w=new WeakMap,Oe=new WeakMap,T=[],ke=new Set(a),Ae=new Set([`beforeinput`,`blur`,`change`,`click`,`contextmenu`,`dblclick`,`focus`,`focusin`,`focusout`,`input`,`keydown`,`keyup`,`mousedown`,`mouseup`,`pointerdown`,`pointerup`,`submit`,`touchend`,`touchstart`]),E=new Set([`drag`,`dragover`,`mousemove`,`pointermove`,`scroll`,`touchmove`,`wheel`]),je=new Set([...Ae,...E,`mouseenter`,`mouseleave`]),Me=new Set(`abort.blur.cancel.canplay.canplaythrough.close.durationchange.emptied.encrypted.ended.error.focus.invalid.load.loadeddata.loadedmetadata.loadstart.mouseenter.mouseleave.pause.play.playing.pointerenter.pointerleave.progress.ratechange.resize.scroll.scrollend.seeked.seeking.stalled.suspend.timeupdate.toggle.volumechange.waiting`.split(`.`));let Ne=e=>e();function Pe(e){Ne=e}function Fe(e,t){let n=D(e);n.run=t.run,t.hydrate!==void 0&&(n.hydrate=t.hydrate,Je(e,n),Le(e))}const Ie=new WeakMap;function Le(e){let t=e.ownerDocument??e,i=Ie.get(t);if(i===void 0){let e=t[r];if(!Array.isArray(e))return;let o=t[n];if(typeof o==`function`&&typeof t.removeEventListener==`function`)for(let e of a)t.removeEventListener(e,o,!0);delete t[r],delete t[n],i=e,Ie.set(t,i)}let o=!1;for(let t=0;t<i.length;){let n=i[t];if(ke.has(n.type)&&F(e,n.target)){i.splice(t,1),Xe(e,n.type,n),o=!0;continue}t+=1}o&&queueMicrotask(k)}function Re(e){let t=w.get(e);if(t!==void 0){ze(e);for(let n of t.listeners.values())e.removeEventListener(n.type,n.listener,n.capture);Be(e),w.delete(e);for(let t=T.length-1;t>=0;--t)T[t].root===e&&T.splice(t,1)}}function ze(e){let t=w.get(e);if(!(t===void 0||t.run===null)){t.hydrate=null;for(let[n,r]of t.hydrationListeners??[])e.removeEventListener(n,r,!0);t.hydrationListeners=null}}function Be(e){for(let t of w.get(e)?.portals??[])Be(t),O(t)}function D(e){let t=w.get(e);return t===void 0&&(t={hydrate:null,hydrationListeners:null,listeners:new Map,portalOwner:null,portals:null,run:null},w.set(e,t)),t}function Ve(e,t){let n=C.get(e)??[];if(n.length===0&&t.length===0)return;let r=new Map;for(let e of n)r.set(e.slot,e);let i=[],a=null;for(let n of t){let t=n.options?.capture===!0,o=n.options?.passive===!0,s=r.get(n.slot);r.delete(n.slot),s===void 0||s.type!==n.type||s.capture!==t||s.passive!==o?(a??=We(e),s!==void 0&&A(s),s=Ke(e,a.root,a.listenerTarget,n,t,o)):s.callback!==n.callback&&(s.callback=n.callback),i.push(s)}for(let e of r.values())A(e);i.length===0?C.delete(e):C.set(e,i)}function He(e){let t=C.get(e);if(t===void 0)return;let{listenerTarget:n,root:r}=We(e);for(let i of t)tt(e,r,n,i)}function Ue(e){let t=C.get(e);if(t!==void 0){for(let e of t)A(e);C.delete(e)}}function We(e){let t=I(e);if(t===null)return{listenerTarget:null,root:null};let n=w.get(t);return n===void 0?{listenerTarget:null,root:null}:{listenerTarget:t,root:n.portalOwner?.root??(n.run===null?null:t)}}function Ge(e,t,n){let r=D(e),i=I(n)??t;if(r.portalOwner!==null){if(r.portalOwner.root===t&&r.portalOwner.parentTarget===i){r.portalOwner={logicalParent:n,parentTarget:i,root:t};return}O(e)}r.portalOwner={logicalParent:n,parentTarget:i,root:t};let a=D(i);(a.portals??=new Set).add(e);for(let n of a.listeners.values())it(t,e,n.type,n.capture,n.passive)}function O(e){let t=w.get(e);if(!t?.portalOwner)return;let n=t.portalOwner;t.portalOwner=null;let r=w.get(n.parentTarget);if(r!==void 0){r.portals?.delete(e);for(let t of r.listeners.keys())at(e,t)}}function k(){let e=new Set;for(let t=0;t<T.length;){let n=T[t];if(!F(n.listenerTarget??n.root,n.event.target)){T.splice(t,1);continue}if(Ze(n)===`blocked`){e.add(n.root),t+=1;continue}if(e.has(n.root)){t+=1;continue}T.splice(t,1),Qe(n)}}function Ke(e,t,n,r,i,a){let o={attachment:null,capture:i,callback:r.callback,controller:null,passive:a,slot:r.slot,type:r.type};return tt(e,t,n,o),o}function A(e){P(e),N(e)}function qe(e,t,n,r,i,a){let o=I(a.target);if(o!==t&&((o===null?null:w.get(o)??null)?.portalOwner?.root===e||!F(t,a.target))||Ye(e,n,a)===`blocked`)return;let s=j(e,t,n,r,i,a);s.length!==0&&we(a,!1,e=>M(s,a,e))}function Je(e,t){if(t.hydrationListeners===null){t.hydrationListeners=[];for(let n of je){let r=t=>Ye(e,n,t);t.hydrationListeners.push([n,r]),e.addEventListener(n,r,{capture:!0,passive:lt(n)})}}}function Ye(e,t,n){let r=w.get(e)?.hydrate??null;if(r===null)return`none`;let i=Oe.get(n),a=i?.get(e);if(a!==void 0)return a;let o=L(t),s=ce(o,()=>r(n.target,o));return i===void 0&&(i=new WeakMap,Oe.set(n,i)),i.set(e,s),s===`blocked`&&ke.has(t)&&Xe(e,t,n),s}function Xe(e,t,n){T.push({event:n,listenerTarget:I(n.target),root:e,type:t})}function Ze(e){let t=w.get(e.root)?.hydrate??null;if(t===null)return`none`;let n=L(e.type);return ce(n,()=>t(e.event.target,n))}function Qe(e){let{event:t,root:n,type:r}=e,i=e.listenerTarget??e.root;we(t,!0,e=>{M(j(n,i,r,!0,null,t),t,e),!(e.immediateStopped||e.stopped)&&M(j(n,i,r,!1,null,t),t,e)})}function j(e,t,n,r,i,a){let o=st(e,t,a),s=[],c=r?-1:1;for(let t=r?o.length-1:0;t>=0&&t<o.length;t+=c){let a=o[t],c=C.get(a);if(c!==void 0)for(let t of c){let o=ot(t);o!==e||t.type!==n||t.capture!==r||i!==null&&t.passive!==i||s.push({callback:t.callback,element:a,root:o,slot:t})}}return s}function M(e,t,n){let r=null;for(let i of e){if(n.immediateStopped)return;if(i.element!==r){if(r!==null&&n.stopped)return;r=i.element}try{$e(i,t)}finally{let e=i.slot;e.attachment===null&&N(e)}}}function $e(e,t){let n=e.slot;N(n),n.controller=new AbortController;let r=n.controller.signal;Ne(()=>{et(e.root,()=>ce(L(n.type),()=>{Ce(t,e.element,t=>{e.callback(t,r)})}))})}function et(e,t){let n=e===null?null:w.get(e)?.run??null;return n===null?t():n(t)}function N(e){e.controller?.abort(),e.controller=null}function tt(e,t,n,r){Me.has(r.type)?nt(e,t,r):rt(t,n,r)}function nt(e,t,n){let r=n.attachment;if(r!==null){if(`element`in r&&r.element===e){t!==null&&(r.root=t);return}P(n)}let i=t=>{try{$e({callback:n.callback,element:e,root:ot(n),slot:n},t)}finally{n.attachment===null&&N(n)}};n.attachment={element:e,listener:i,root:t},e.addEventListener(n.type,i,{capture:n.capture,passive:n.passive})}function rt(e,t,n){if(e===null||t===null)return;let r=n.attachment;r!==null&&`listenerTarget`in r&&r.root===e&&r.listenerTarget===t||(P(n),n.attachment={listenerTarget:t,root:e},it(e,t,n.type,n.capture,n.passive))}function it(e,t,n,r,i){let a=D(t).listeners,o=`${n}:${r}:${i}`,s=a.get(o);if(s===void 0){s={capture:r,count:0,listener:a=>qe(e,t,n,r,i,a),passive:i,type:n},t.addEventListener(n,s.listener,{capture:r,passive:i}),a.set(o,s);for(let a of w.get(t)?.portals??[])it(e,a,n,r,i)}s.count+=1}function at(e,t){let n=w.get(e)?.listeners,r=n?.get(t);if(!(n===void 0||r===void 0)&&(--r.count,!(r.count>0))){e.removeEventListener(r.type,r.listener,r.capture),n.delete(t);for(let n of w.get(e)?.portals??[])at(n,t)}}function P(e){let t=e.attachment;t!==null&&(e.attachment=null,`element`in t?t.element.removeEventListener(e.type,t.listener,e.capture):at(t.listenerTarget,`${e.type}:${e.capture}:${e.passive}`))}function ot(e){return e.attachment?.root??null}function st(e,t,n){let r=[],i=n.composedPath?.();if(i!==void 0){let n=i.indexOf(t);if(n!==-1){for(let e=0;e<n;e+=1){let t=i[e];m(t)&&r.push(t)}return ct(r,e,t),r}}for(let e=n.target;e!==t&&(m(e)&&r.push(e),e=g(e),e!==null););return ct(r,e,t),r}function ct(e,t,n){let r=w.get(n)?.portalOwner??null;if(r===null||r.root!==t)return;let i=r.logicalParent;for(;i!==null&&i!==t;){if(ut(i)){let e=w.get(i)?.portalOwner??null;if(e!==null&&e.root===t){i=e.logicalParent;continue}}m(i)&&e.push(i),i=g(i)}}function F(e,t){for(let n=t;n!==null;){if(n===e)return!0;n=g(n)}return!1}function I(e){for(let t=e;t!==null;){if(ut(t)){let e=w.get(t);if(e!==void 0&&(e.portalOwner!==null||e.run!==null))return t}t=g(t)}return null}function L(e){return Ae.has(e)?`discrete`:E.has(e)?`continuous`:`default`}function lt(e){return E.has(e)||e===`touchstart`||e===`touchend`}function ut(e){return typeof e==`object`&&!!e&&`addEventListener`in e&&`childNodes`in e}function dt(e){le(e,e=>{me(e),He(e)})}function R(e){le(e,e=>{_e(e),Ue(e)})}const z=new WeakMap;function ft(e){return H(e)||e===`checked`||e===`defaultChecked`}function pt(e,t,n,r,i,a){if(t===`select`&&H(n))return;if(t===`option`&&n===`value`){U(e,`value`,V(r));return}let o=a.initial===!0&&a.hydrating!==!0;n===`value`?_(r)||vt(e,r):n===`defaultValue`?_t(e,r,t,o&&i.value===void 0):n===`checked`?r!==void 0&&xt(e,r):n===`defaultChecked`&&bt(e,r,o&&i.checked===void 0)}function mt(e,t,n,r){if(t!==`select`)return;let i=n.value!==void 0,a=i?n.value:n.defaultValue;if(_(a)){z.delete(e);return}let o=!i&&r.hydrating===!0,s={appliedDefault:z.get(e)?.appliedDefault===!0||!i,applyDefaultToInsertedOptions:!o&&!i&&r.initial===!0,controlled:i,selectedValues:Array.isArray(a)?new Set(a.map(String)):String(a)};z.set(e,s),!o&&(i||r.initial===!0)&&St(e,s.selectedValues)}function B(e,t=!1){let n=wt(e);if(n===null)return;let r=z.get(n);r!==void 0&&(!r.controlled&&r.appliedDefault&&!t||!r.controlled&&t&&!r.applyDefaultToInsertedOptions||(St(e,r.selectedValues),r.controlled||(r.appliedDefault=!0)))}function ht(e,t){return(e===`input`||e===`textarea`||e===`select`)&&(t.value!==void 0||t.checked!==void 0)}function gt(e,t){if(ft(t))return(e===`textarea`||e===`select`)&&H(t)?null:t===`defaultValue`?`value`:t===`defaultChecked`?`checked`:t}function _t(e,t,n,r){let i=V(t),a=i??``;`defaultValue`in e&&(e.defaultValue=a),n===`textarea`?e.textContent=a:U(e,`value`,i),r&&`value`in e&&yt(e,a)}function vt(e,t){let n=V(t);n!==null&&(`value`in e?yt(e,n):U(e,`value`,n))}function yt(e,t){let n=e;n.value!==t&&(n.value=t)}function bt(e,t,n){let r=t===!0;`defaultChecked`in e&&(e.defaultChecked=r),U(e,`checked`,r),n&&xt(e,t)}function xt(e,t){let n=t===!0;`checked`in e?e.checked=n:U(e,`checked`,n)}function V(e){return _(e)?null:String(e)}function St(e,t){if(h(e)===`option`){Ct(e,t);return}Tt(e,e=>{Ct(e,t)})}function Ct(e,t){let n=e.getAttribute(`value`)??(e.textContent??``).replace(/\s+/g,` `).trim();e.selected=typeof t==`string`?n===t:t.has(n)}function wt(e){let t=e.parentNode;for(;t!==null;){if(m(t)&&h(t)===`select`)return t;t=t.parentNode}return null}function Tt(e,t){for(let n=e.firstChild;n!==null;){let e=n.nextSibling;m(n)&&(h(n)===`option`?t(n):Tt(n,t)),n=e}}function H(e){return e===`value`||e===`defaultValue`}function U(e,t,n){_(n)?e.removeAttribute(t):e.setAttribute(t,String(n))}const Et=new Set;function Dt(e,t,n){typeof n==`string`&&n!==``&&Nt(`string`,`The style prop must be an object of properties; string styles are ignored.`);let r=e.style;if(r===void 0)return;let i=At(t),a=At(n);for(let e of Object.keys(i))e in a||Mt(r,e);for(let[e,t]of Object.entries(a))_(t)?Mt(r,e):jt(r,e,t)}function Ot(e,t){if(e.length===0)return[];let n=document.createElement(`div`);Dt(n,{},t);let r=new Set(kt(n));return e.filter(e=>!r.has(e)).map(e=>`style.${e}`)}function kt(e){let t=e.style;if(t===void 0)return[];if(typeof t.length==`number`&&typeof t.item==`function`){let e=[];for(let n=0;n<t.length;n+=1){let r=t.item(n);r!==``&&e.push(r)}return e}return Object.keys(t).filter(e=>t[e]!==``)}function At(e){return typeof e==`object`&&e?e:{}}function jt(e,t,n){if(typeof n==`number`||typeof n==`bigint`){Nt(`${t}:${typeof n}`,`The style property "${t}" received a ${typeof n} (${String(n)}); Fig style values must be strings, so this style is ignored.`);return}t.startsWith(`--`)&&typeof e.setProperty==`function`?e.setProperty(t,String(n)):e[t]=n}function Mt(e,t){t.startsWith(`--`)&&typeof e.removeProperty==`function`?e.removeProperty(t):e[t]=``}function Nt(e,t){Et.has(e)||(Et.add(e),console.error(t))}const Pt=`http://www.w3.org/1999/xlink`;function W(e,t,n,r={}){(`mix`in t||`mix`in n)&&Ve(e,Se(n));let i=h(e),a=de(e),o=Object.keys(t);for(let e in n)Object.hasOwn(n,e)&&!Object.hasOwn(t,e)&&o.push(e);for(let s of o){let o=t[s],c=n[s];if(s!==`mix`){if(s===`bind`){o!==c&&pe(e,c);continue}if(s===`unsafeHTML`){r.hydrating===!0?Wt(c):o!==c&&Ut(e,c);continue}if(qt(s)){Jt(s)&&It(s,Lt(s,i,n));continue}if(ft(s)){(s===`checked`||s===`defaultChecked`)&&c!==void 0&&typeof c!=`boolean`&&c!==null&&It(`${s}:${typeof c}`,`The "${s}" prop received a ${typeof c} (${String(c)}); Fig treats only \`true\` as checked, so this renders unchecked.`),pt(e,i,s,c,n,r);continue}o!==c&&(s===`style`?Dt(e,o,c):Gt(e,G(s,a),c))}}mt(e,i,n,r),(i===`option`||i===`optgroup`)&&B(e)}const Ft=new Set;function It(e,t){Ft.has(e)||(Ft.add(e),console.error(t))}function Lt(e,t,n){let r=e.endsWith(`Capture`)&&e.length>9&&e!==`onGotPointerCapture`&&e!==`onLostPointerCapture`,i=e.slice(2,r?-7:void 0),a=r?`, { capture: true }`:``,o=t=>`Fig has no "${e}" event props; use mix={on("${t}", handler${a})} instead.`;return i===`DoubleClick`?o(`dblclick`):i===`Change`&&Rt(t,n)?o(`input`)+` (React's onChange on text-editing controls fires per change like the native "input" event; on("change") fires only on commit.)`:o(i.toLowerCase())}function Rt(e,t){if(e===`textarea`)return!0;if(e!==`input`)return!1;let n=typeof t.type==`string`?t.type:`text`;return n!==`checkbox`&&n!==`radio`&&n!==`file`}function zt(e,t){let n=kt(e),r=Ht(e);W(e,{},t,{hydrating:!0}),t.suppressHydrationWarning!==!0&&Bt(e,t,n,r)}function Bt(e,t,n,r){if(r.length===0&&n.length===0)return;let i=new Set,a=h(e),o=de(e);for(let e of Object.keys(t)){if(e===`bind`||qt(e))continue;let t=Vt(a,e,o);t!==null&&i.add(t)}let s=[];for(let e of r){let t=G(e,o);t.startsWith(`data-fig-`)||i.has(t)||s.push(e)}s.push(...Ot(n,t.style)),s.length!==0&&console.error(`Hydration preserved extra server attributes or styles on <${a}>: ${s.sort().join(`, `)}. They were preserved, so this element now differs from a pure client render.`)}function Vt(e,t,n){let r=gt(e,t);return r===void 0?G(t,n):r}function Ht(e){let t=e.attributes;if(t===void 0)return[];if(`length`in t&&typeof t.length==`number`&&`item`in t&&typeof t.item==`function`){let e=[];for(let n=0;n<t.length;n+=1){let r=t.item(n);r!==null&&e.push(r.name)}return e}return Symbol.iterator in t?Array.from(t,e=>e.name):Object.keys(t)}function Ut(e,t){let n=Wt(t);`innerHTML`in e&&(e.innerHTML=n??``)}function Wt(e){if(_(e))return null;if(typeof e==`string`)return e;throw Error(`The unsafeHTML prop must be a string.`)}function G(e,t){return t?e.toLowerCase():e}function Gt(e,t,n){if(_(n)){Kt(e,t);return}if(t===`xlink:href`){e.setAttributeNS(Pt,t,String(n));return}e.setAttribute(t,String(n))}function Kt(e,t){if(t===`xlink:href`){e.removeAttributeNS(Pt,`href`);return}e.removeAttribute(t)}function qt(e){return e===`children`||e===`key`||e===`mix`||e===`suppressHydrationWarning`||e===`unsafeHTML`||Jt(e)}function Jt(e){return/^on[A-Z]/.test(e)}var Yt=class{element;resourceKind;kind=`metadata`;byOwner=new Map;rendered=null;winner;constructor(e,t,n,r){this.element=e,this.resourceKind=t,this.winner=n,this.byOwner.set(n,r),this.applyWinner()}acquire(e,t){let n=!this.byOwner.has(e);this.byOwner.set(e,t),n&&(this.winner=e),this.winner===e&&this.applyWinner()}update(e,t){if(!this.byOwner.has(e))throw Error(`Expected a live metadata claim.`);this.byOwner.set(e,t),this.winner===e&&this.applyWinner()}release(e){if(!this.byOwner.delete(e))throw Error(`Expected a live metadata claim.`);if(this.byOwner.size===0)return`empty`;if(this.winner!==e)return`retained`;let t=null;for(let e of this.byOwner.keys())t=e;if(t===null)throw Error(`Expected a live metadata claim.`);return this.winner=t,this.applyWinner(),`retained`}applyWinner(){let e=this.byOwner.get(this.winner);if(e===void 0)throw Error(`Expected a live metadata claim.`);W(this.element,this.rendered??{},e),this.resourceKind===`title`&&(this.element.textContent=Xt(e.children)),this.rendered=e}};function Xt(e){return e==null||typeof e==`boolean`?``:typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(Xt).join(``):``}const Zt=new WeakMap,K=new WeakMap;function Qt(e,t,n){let r=J();if(r===null)return;let i=on(e),a=on(t);for(let[e]of i)a.has(e)||ln(r,e,n);for(let[e,t]of a)i.has(e)?(t.kind===`title`||t.kind===`meta`)&&cn(r,e,t,n):sn(r,t,n)}function $t(e,t){let n=J(),r=d(e,t);if(n===null||r===null)return null;let i=p(r);if(X(r)){let t=document.createElement(e);return K.set(t,{key:i,kind:r.kind}),t}let a=n.entries.get(i);if(a?.kind===`metadata`)throw Error(`Expected a persistent resource entry.`);let o=a?.element??Z(n,i)??document.createElement(e);return a===void 0&&(n.entries.set(i,{count:0,element:o,kind:`persistent`,ready:null}),K.set(o,{key:i,kind:r.kind})),o}function en(e,t,n){let r=J();if(r===null)return e;let i=d(h(e),t);return i!==null&&X(i)?Y(r,i,t,n,e):tn(r,e)}function tn(e,t){let n=K.get(t);if(n===void 0){let e=_n(t);if(e===null)return t;n={key:p(e),kind:e.kind},K.set(t,n)}let r=e.entries.get(n.key);if(r?.kind===`metadata`)throw Error(`Expected a persistent resource entry.`);return r!==void 0&&r.element!==t?(r.count+=1,pn(e,r.element)):(r===void 0?e.entries.set(n.key,{count:1,element:t,kind:`persistent`,ready:null}):r.count+=1,pn(e,t))}function q(e,t){let n=J(),r=K.get(e);if(n===null||r===void 0)return;let i=n.entries.get(r.key);if(i?.kind===`metadata`){un(n,r.key,i,t);return}if(r.kind===`title`||r.kind===`meta`){K.delete(e),vn(e);return}nn(n,e)}function nn(e,t){let n=K.get(t);if(n===void 0)return;let r=e.entries.get(n.key);if(r===void 0||r.element!==t){if(hn(e,t))return;K.delete(t);return}if(r.kind!==`persistent`)throw Error(`Expected a persistent resource entry.`);r.count>0&&--r.count}function rn(e,t,n,r){let i=h(e),a=d(i,n),o=K.get(e);if(a===null){{let e=d(i,t),n=o?.key??(e===null?null:p(e)),r=n===null?``:` (asset "${n}")`;throw Error(`A hoisted <${i}>${r} cannot update into an ordinary in-tree element. Keep its asset classification stable or replace it with a different Fig element key.`)}return e}let s=p(a),c=J();if(c===null)return W(e,t,n),e;let l=o===void 0?void 0:c.entries.get(o.key);if(l?.kind===`metadata`){if(!X(a)||s===o?.key)return l.update(r,X(a)?fn(a,n):n),l.element;q(e,r);let t=document.createElement(i);return W(t,{},n),a.kind===`title`&&(t.textContent=a.value),K.set(t,{key:p(a),kind:a.kind}),Y(c,a,n,r,t)}if(o===void 0||s===o.key)return W(e,t,n),e;q(e,r);let u=c.entries.get(s),ee=u?.kind===`persistent`&&u.count>0?u.element:void 0,f=$t(i,n)??e;return f===e?(W(e,t,n),e):(ee!==f&&W(f,{},n),en(f,n,r))}function an(e){let t=J();if(t===null)return Promise.resolve();let n=[];for(let r of e){if(!te(r)||r.kind===`title`||r.kind===`meta`)continue;let e=bn(r),i=p(e),a=t.entries.get(i)?.element,o=(a?.parentNode===t.head?a:null)??Z(t,i);if(o!==null){let r=t.entries.get(i);if(r?.kind===`metadata`)throw Error(`Expected a persistent resource entry.`);r?.element!==o&&(r={count:1,element:o,kind:`persistent`,ready:null},t.entries.set(i,r),K.set(o,{key:i,kind:e.kind}));let a=gn(t,e,i,r);a!==null&&n.push(a);continue}let s=wn(e),c={count:1,element:s,kind:`persistent`,ready:null};c.ready=xn(e)?Cn(s).then(()=>{t.entries.get(i)===c&&(c.ready=null)}):null,t.entries.set(i,c),K.set(s,{key:i,kind:e.kind}),mn(t,s),c.ready!==null&&n.push(c.ready)}return n.length===0?Promise.resolve():Promise.all(n).then(()=>void 0)}function J(){if(typeof document>`u`||document.head==null)return null;let e=Zt.get(document.head);return e===void 0&&(e={entries:new Map,head:document.head},Zt.set(document.head,e)),e}function on(e){let t=new Map;if(e===null)return t;let n=Array.isArray(e)?e:[e];for(let e of n){if(!te(e))continue;let n=bn(e),r=p(n);(!t.has(r)||X(n))&&t.set(r,n)}return t}function sn(e,t,n){if(X(t)){Y(e,t,dn(t),n);return}let r=p(t),i=e.entries.get(r);if(i?.kind===`metadata`)throw Error(`Expected a persistent resource entry.`);let a=i?.element,o=a??Z(e,r)??wn(t);a===void 0&&(e.entries.set(r,{count:0,element:o,kind:`persistent`,ready:null}),K.set(o,{key:r,kind:t.kind})),tn(e,o)}function cn(e,t,n,r){let i=e.entries.get(t);if(i===void 0){sn(e,n,r);return}if(i.kind!==`metadata`)throw Error(`Expected a metadata resource entry.`);i.update(r,dn(n))}function ln(e,t,n){let r=e.entries.get(t);r!==void 0&&(r.kind===`metadata`?un(e,t,r,n):nn(e,r.element))}function Y(e,t,n,r,i){let a=p(t),o=fn(t,n),s=e.entries.get(a);if(s?.kind===`persistent`)throw Error(`Expected a metadata resource entry.`);if(s===void 0){let n=Z(e,a)??i??document.createElement(t.kind);s=new Yt(n,t.kind,r,o),e.entries.set(a,s),K.set(n,{key:a,kind:t.kind})}else s.acquire(r,o);return pn(e,s.element)}function un(e,t,n,r){n.release(r)!==`retained`&&(e.entries.delete(t),K.delete(n.element),vn(n.element))}function dn(e){return e.kind===`title`?{children:e.value}:{charset:e.charset,content:e.content,"data-fig-resource-key":e.key,"http-equiv":e[`http-equiv`],name:e.name,property:e.property}}function fn(e,t){return e.kind===`title`?{...t,children:e.value}:t}function X(e){return e.kind===`title`||e.kind===`meta`}function pn(e,t){return t.parentNode!==e.head&&mn(e,t),dt(t),t}function mn(e,t){let n=yn(t);if(n===null){e.head.appendChild(t);return}let r=!1;for(let i=e.head.firstChild;i!==null;i=i.nextSibling){let a=m(i)?yn(i):null;if(a!==null){if(a===n)r=!0;else if(r){e.head.insertBefore(t,i);return}}}e.head.appendChild(t)}function Z(e,t){for(let n=e.head.firstChild;n!==null;n=n.nextSibling)if(m(n)){let e=_n(n);if(e!==null&&p(e)===t)return n}return null}function hn(e,t){for(let n of e.entries.values())if(n.element===t)return!0;return!1}function gn(e,t,n,r){if(!xn(t))return null;if(r.ready!==null)return r.ready;if(!Sn(r.element))return null;let i=Cn(r.element).then(()=>{e.entries.get(n)===r&&(r.ready=null)});return r.ready=i,i}function _n(e){return ee(h(e),t=>e.getAttribute(t))}function vn(e){R(e),e.parentNode?.removeChild(e)}function yn(e){if(h(e)!==`link`)return null;let t=_n(e);return t?.kind===`stylesheet`?t.precedence??``:null}function bn(e){return e.kind===`font`?{as:`font`,crossorigin:e.crossorigin??`anonymous`,fetchpriority:e.fetchpriority,href:e.href,key:e.key,kind:`preload`,type:e.type}:e}function xn(e){return e.kind!==`stylesheet`||e.blocking===`none`?!1:e.media===void 0||e.media===``||typeof matchMedia!=`function`||matchMedia(e.media).matches}function Sn(e){return h(e)===`link`&&e.getAttribute(`rel`)===`stylesheet`&&`sheet`in e&&e.sheet===null}function Cn(e){return new Promise(t=>{let n=()=>{e.removeEventListener(`load`,n),e.removeEventListener(`error`,n),t()};e.addEventListener(`load`,n),e.addEventListener(`error`,n)})}function wn(e){let t=document.createElement(e.kind===`script`?`script`:`link`);for(let[n,r]of f(e))t.setAttribute(n,r===!0?``:r);return t}function Tn(e){if(!$(e))return null;let t=Q(e);return t===null?null:En(e,t)}function En(e,t){let n=Dn(e);return n===null?null:{end:n,forceClientRender:!1,id:t.id,start:e,get error(){return On(e)},get status(){return Q(e)?.status??t.status}}}function Q(e){if(!$(e))return null;if(e.data===s)return{id:null,status:`completed`};if(e.data===o)return{id:null,status:`client-rendered`};let t=e.data.startsWith(l)?e.data.slice(l.length):null;return t!==null&&t!==``?{id:t,status:`pending`}:null}function Dn(e){let t=0;for(let n=e.nextSibling;n!==null;n=n.nextSibling)if($(n)){if(Q(n)!==null){t+=1;continue}if(n.data===c){if(t===0)return n;--t}}return null}function On(e){let t=e.nextSibling;return Fn(t)?{digest:t.dataset.dgst,message:t.dataset.msg}:null}function kn(e){if(!In(e))return null;for(let t=e;t!==null;t=t.parentNode){let e=0;for(let n=t.previousSibling;n!==null;n=n.previousSibling)if($(n)){if(n.data===c){e+=1;continue}if(Q(n)!==null){if(e===0)return n;--e}}}return null}function An(e,t){if(!In(e))return!1;let n=t.start.parentNode,r=t.end.parentNode;if(n===null&&r===null)return!1;for(let i=e;i!==null;i=i.parentNode){if(i===t.start||i===t.end)return!1;if(n!==null&&i.parentNode===n)return jn(i,t.start,t.end);if(r!==null&&r!==n&&i.parentNode===r)return Mn(i,t.end)}return!1}function jn(e,t,n){for(let r=e;r!==null;r=r.previousSibling){if(r===t)return!0;if(r===n)return!1}return!1}function Mn(e,t){for(let n=e;n!==null;n=n.nextSibling)if(n===t)return!0;return!1}function Nn(e){for(let t=e.start;t!==null;){let n=t.nextSibling;if(Pn(t),t===e.end)return;t=n}}function Pn(e){e.parentNode?.removeChild(e)}function $(e){return typeof e==`object`&&!!e&&`data`in e&&`nodeType`in e&&e.nodeType===8}function Fn(e){return typeof e==`object`&&!!e&&`dataset`in e}function In(e){return typeof e==`object`&&!!e&&`parentNode`in e}function Ln(e){return e.nodeType===9}const Rn=se({createInstance:Hn,createTextInstance:e=>document.createTextNode(e),validateInstanceNesting:(e,t,n)=>{ie(e,n)},validateTextNesting:(e,t)=>{ae(e,t)},containerType:e=>m(e)?h(e):null,appendInitialChild:(e,t)=>{e.appendChild(t),m(t)&&Qn(t)&&B(t,!0)},finalizeInitialInstance:(e,t)=>W(e,{},t,{initial:!0}),setTextContent:(e,t)=>{e.textContent!==t&&(e.textContent=t)},getFirstHydratableChild:Wn,getNextHydratableSibling:e=>Gn(e.nextSibling),canHydrateInstance:Vn,canHydrateTextInstance:(e,t,n)=>Zn(e)&&(n===!0||e.nodeValue===t),canRetainHydrationTail:e=>{let t=h(e);return t===`html`||t===`head`||t===`body`},resolveHoistedInstance:(e,t,n)=>Un(e,n)===`http://www.w3.org/1999/xhtml`?$t(e,t):null,commitHoistedInstance:en,commitAssetResources:Qt,removeHoistedInstance:q,updateHoistedInstance:rn,shouldCommitUpdate:(e,t,n)=>ht(e,n),clearContainer:e=>{let t=e.firstChild;for(;t!==null;){let n=t.nextSibling;t.nodeType!==10&&(R(t),e.removeChild(t)),t=n}queueMicrotask(k)},insertBefore:(e,t,n)=>{e.insertBefore(t,n),m(t)&&Qn(t)&&B(t),dt(t)},removeChild:(e,t)=>{R(t),e.removeChild(t)},commitTextUpdate:(e,t)=>{e.nodeValue!==t&&(e.nodeValue=t)},commitUpdate:W,commitHydratedInstance:zt,getActivityBoundary:Bn,getFirstActivityHydratable:e=>Gn(zn(e).firstChild??null),commitHydratedActivityBoundary:e=>{let t=e.parentNode;if(t===null)return;let n=zn(e);for(;n.firstChild!==null;)t.insertBefore(n.firstChild,e);t.removeChild(e)},hideInstance:e=>{he(e),e.style.setProperty(`display`,`none`,`important`)},unhideInstance:(e,t)=>{let n=t.style?.display;e.style.setProperty(`display`,typeof n==`string`?n:``),ge(e)},hideTextInstance:e=>{e.nodeValue=``},unhideTextInstance:(e,t)=>{e.nodeValue!==t&&(e.nodeValue=t)},getSuspenseBoundary:Tn,getEnclosingSuspenseBoundaryStart:kn,isTargetWithinSuspenseBoundary:An,shouldRecoverSuspenseMismatchAtRoot:(e,t)=>Ln(e)&&An(e.documentElement,t),registerSuspenseBoundaryRetry:(e,t)=>{e.start.__figRetry=t},commitHydratedSuspenseBoundary:e=>{e.status===`completed`&&!e.forceClientRender?(Pn(e.start),Pn(e.end)):Nn(e),queueMicrotask(k)},removeDehydratedSuspenseBoundary:e=>{Nn(e),queueMicrotask(k)},completeRootHydration:e=>{ze(e),queueMicrotask(k)},preparePortalContainer:Ge,removePortalContainer:O});Pe(Rn.batchedUpdates),e(Rn.scheduleRefresh);function zn(e){return`content`in e?e.content:e}function Bn(e){return m(e)&&h(e)===`template`&&e.getAttribute(t)!==null?e:null}function Vn(e,t,n){return!m(e)||!(`setAttribute`in e)||h(e)!==t.toLowerCase()?!1:Xn(e,n)}function Hn(e,t,n){let r=Un(e,n);return r===`http://www.w3.org/1999/xhtml`?document.createElement(e):document.createElementNS(r,e)}function Un(e,t){let n=e.toLowerCase();return n===`svg`?`http://www.w3.org/2000/svg`:n===`math`?`http://www.w3.org/1998/Math/MathML`:`namespaceURI`in t&&h(t)!==`foreignobject`?t.namespaceURI??`http://www.w3.org/1999/xhtml`:`http://www.w3.org/1999/xhtml`}function Wn(e,t){return t!==void 0&&Yn(t)!==null||h(e)===`textarea`&&t!==void 0&&Jn(t)?null:Gn(e.firstChild)}function Gn(e){let t=e;for(;t!==null&&(qn(t)||t.nodeType===10||Kn(t));)t=t.nextSibling;return t}function Kn(e){return m(e)&&e.getAttribute(i)!==null}function qn(e){return e.nodeType===8&&e.nodeValue===u}function Jn(e){return e.value!==void 0||e.defaultValue!==void 0}function Yn(e){return _(e.unsafeHTML)?null:e.unsafeHTML}function Xn(e,t){let n=Yn(t);return n===null||typeof n!=`string`||`innerHTML`in e}function Zn(e){return e.nodeType===3}function Qn(e){let t=h(e);return t===`option`||t===`optgroup`}export{be as a,Re as i,an as n,fe as o,Fe as r,Rn as t};
2
+ //# sourceMappingURL=renderer-C0R0O1QP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer-C0R0O1QP.js","names":["setAttribute","unsafeHTMLValue"],"sources":["../src/tree.ts","../src/bind.ts","../src/event-descriptor.ts","../src/event-propagation.ts","../src/events.ts","../src/attachment.ts","../src/form-controls.ts","../src/styles.ts","../src/props.ts","../src/metadata-claims.ts","../src/asset-resources.ts","../src/suspense-markers.ts","../src/renderer.ts"],"sourcesContent":["export const htmlNamespace = \"http://www.w3.org/1999/xhtml\";\nexport const mathNamespace = \"http://www.w3.org/1998/Math/MathML\";\nexport const svgNamespace = \"http://www.w3.org/2000/svg\";\n\nexport function visitElementSubtree(\n node: Node,\n visitor: (element: Element) => void,\n): void {\n if (!isElementNode(node)) return;\n\n // Visitors run user bind callbacks and abort listeners synchronously.\n // Snapshot the entire original element set before the first callback so a\n // callback cannot hide a later descendant by mutating its parent first.\n const elements: Element[] = [];\n collectElementSubtree(node, elements);\n for (const element of elements) {\n visitor(element);\n }\n}\n\nfunction collectElementSubtree(node: Element, elements: Element[]): void {\n elements.push(node);\n\n for (let child = node.firstChild; child !== null; child = child.nextSibling) {\n if (isElementNode(child)) collectElementSubtree(child, elements);\n }\n}\n\nexport function isElementNode(node: unknown): node is Element {\n return (\n typeof node === \"object\" &&\n node !== null &&\n \"nodeType\" in node &&\n node.nodeType === 1\n );\n}\n\nexport function elementName(node: unknown): string {\n if (!isElementNode(node)) return \"\";\n\n return \"localName\" in node && typeof node.localName === \"string\"\n ? node.localName.toLowerCase()\n : \"tagName\" in node && typeof node.tagName === \"string\"\n ? node.tagName.toLowerCase()\n : \"\";\n}\n\nexport function isHtmlElement(element: Element): boolean {\n return (\n element.namespaceURI === null || element.namespaceURI === htmlNamespace\n );\n}\n\n// Known limitation: the walk follows parentNode only and never hops shadow\n// boundaries (a ShadowRoot's parentNode is null, and there is no `.host`\n// fallback). Fig content rendered inside shadow trees is out of scope for\n// root resolution, delegated dispatch, and replay targeting; register the\n// in-shadow container as a portal target to route events explicitly.\nexport function parentOf(node: unknown): unknown {\n return typeof node === \"object\" && node !== null && \"parentNode\" in node\n ? node.parentNode\n : null;\n}\n\n// The shared \"absent prop\" predicate: null, undefined, and false all mean\n// \"not provided\" for prop-shaped values (bind, mix, unsafeHTML,\n// attributes) — one authority so the prop kinds cannot drift.\nexport function isEmptyPropValue(value: unknown): boolean {\n return value === null || value === undefined || value === false;\n}\n","import { isEmptyPropValue } from \"./tree.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\n\nexport type Bind<T extends Element = Element> = (\n node: T,\n signal: AbortSignal,\n) => undefined;\n\ninterface BindSlot {\n callback: Bind;\n controller: AbortController | null;\n // Persists for the slot's lifetime; gates the dev-only strict re-run to\n // the first attach so callback changes and re-attachments run single.\n strictRan: boolean;\n}\n\nconst bindSlots = new WeakMap<Element, BindSlot>();\n// Elements inside hidden Activity trees: binds must not run while hidden.\n// Keyed by element (not a slot flag) so a bind that first appears while its\n// element is already hidden is covered too.\nconst suspendedBindElements = new WeakSet<Element>();\n\nexport function composeBind<T extends Element = Element>(\n ...binds: Array<Bind<T> | false | null | undefined>\n): Bind<T> {\n const callbacks = binds.filter(\n (bind): bind is Bind<T> => typeof bind === \"function\",\n );\n\n return (node, signal) => {\n for (const bind of callbacks) bind(node, signal);\n };\n}\n\nexport function updateBind(element: Element, value: unknown): void {\n const callback = bindCallback(value);\n const slot = bindSlots.get(element);\n\n if (callback === null) {\n if (slot !== undefined) removeBindSlot(slot);\n bindSlots.delete(element);\n return;\n }\n\n if (slot === undefined) {\n const nextSlot: BindSlot = { callback, controller: null, strictRan: false };\n bindSlots.set(element, nextSlot);\n attachBindSlot(element, nextSlot);\n } else if (slot.callback !== callback) {\n removeBindSlot(slot);\n slot.callback = callback;\n attachBindSlot(element, slot);\n }\n}\n\nexport function attachElementBind(element: Element): void {\n const slot = bindSlots.get(element);\n if (slot !== undefined) attachBindSlot(element, slot);\n}\n\nexport function suspendBind(element: Element): void {\n suspendedBindElements.add(element);\n const slot = bindSlots.get(element);\n if (slot !== undefined) removeBindSlot(slot);\n}\n\nexport function resumeBind(element: Element): void {\n suspendedBindElements.delete(element);\n const slot = bindSlots.get(element);\n if (slot !== undefined) attachBindSlot(element, slot);\n}\n\nexport function detachElementBind(element: Element): void {\n const slot = bindSlots.get(element);\n if (slot !== undefined) {\n removeBindSlot(slot);\n bindSlots.delete(element);\n }\n}\n\nfunction attachBindSlot(element: Element, slot: BindSlot): void {\n if (\n slot.controller !== null ||\n element.parentNode === null ||\n suspendedBindElements.has(element)\n ) {\n return;\n }\n\n let runStrict = false;\n if (__DEV__) {\n // Marked before the callback so re-entrant attaches cannot re-enter the\n // strict cycle.\n runStrict = !slot.strictRan;\n slot.strictRan = true;\n }\n slot.controller = new AbortController();\n slot.callback(element, slot.controller.signal);\n if (__DEV__ && runStrict) {\n // Strict re-run: abort and re-invoke first-time binds so callbacks that\n // ignore their AbortSignal surface in development.\n removeBindSlot(slot);\n slot.controller = new AbortController();\n slot.callback(element, slot.controller.signal);\n }\n}\n\nfunction removeBindSlot(slot: BindSlot): void {\n slot.controller?.abort();\n slot.controller = null;\n}\n\nfunction bindCallback(value: unknown): Bind | null {\n if (isEmptyPropValue(value)) return null;\n if (typeof value === \"function\") return value as Bind;\n throw new Error(\"The bind prop must be a function.\");\n}\n","import {\n createMixin,\n type MixinContext,\n type MixinDescriptor,\n} from \"@bgub/fig\";\nimport { markClientOnlyHostBehavior, mixinSlot } from \"@bgub/fig/internal\";\n\nexport type EventOptions = Pick<AddEventListenerOptions, \"capture\" | \"passive\">;\n\nexport type EventCallback<E extends Event = Event> = (\n event: E,\n signal: AbortSignal,\n) => void;\n\nexport interface NativeEventDescriptor<E extends Event = Event> {\n readonly slot: string;\n readonly type: string;\n readonly callback: EventCallback<E>;\n readonly options?: EventOptions;\n}\n\nconst NativeEventDescriptorsSymbol = Symbol.for(\"fig.native-event-descriptors\");\n\nconst eventMixin = createMixin(\n (\n context: MixinContext,\n type: string,\n callback: EventCallback,\n options?: EventOptions,\n ) => {\n markClientOnlyHostBehavior(context, \"on()\");\n const props = context.props as EventDescriptorProps;\n let descriptors = props[NativeEventDescriptorsSymbol];\n if (descriptors === undefined) {\n descriptors = [];\n // Non-enumerable: a spread copy of resolved host props must not share\n // this array — the copied `mix` re-resolves into a fresh one.\n Object.defineProperty(props, NativeEventDescriptorsSymbol, {\n configurable: true,\n value: descriptors,\n });\n }\n descriptors.push({\n callback,\n options,\n slot: mixinSlot(context),\n type,\n });\n },\n);\n\ninterface EventDescriptorProps {\n [NativeEventDescriptorsSymbol]?: NativeEventDescriptor[];\n}\n\n/**\n * Declares one native listener for an element's `mix` prop. Bubbling\n * events follow the logical Fig tree through portals; non-bubbling events,\n * including `focus` and `blur`, attach directly with native semantics.\n */\nexport function on<K extends keyof HTMLElementEventMap>(\n type: K,\n callback: EventCallback<HTMLElementEventMap[K]>,\n options?: EventOptions,\n): MixinDescriptor;\nexport function on<E extends Event = Event>(\n type: string,\n callback: EventCallback<E>,\n options?: EventOptions,\n): MixinDescriptor;\nexport function on(\n type: string,\n callback: EventCallback,\n options?: EventOptions,\n): MixinDescriptor {\n return eventMixin(type, callback, options);\n}\n\nconst emptyEventDescriptors: readonly never[] = [];\n\nexport function eventDescriptorsFromProps(\n props: object,\n): readonly NativeEventDescriptor[] {\n return (\n (props as EventDescriptorProps)[NativeEventDescriptorsSymbol] ??\n emptyEventDescriptors\n );\n}\n","export interface PropagationState {\n immediateStopped: boolean;\n stopped: boolean;\n}\n\nexport function withCurrentTarget<T>(\n event: Event,\n currentTarget: Element,\n callback: (event: Event) => T,\n): T {\n const restore = patchProperty(event, \"currentTarget\", {\n value: currentTarget,\n });\n\n try {\n return callback(event);\n } finally {\n restore();\n }\n}\n\n// Runs one logical dispatch with isolated propagation state. Live dispatches\n// honor a stop made by an earlier native listener; replays ignore stale state\n// left on the spent native event.\nexport function withPropagationState<T>(\n event: Event,\n replay: boolean,\n callback: (state: PropagationState) => T,\n): T {\n const state: PropagationState = {\n immediateStopped: false,\n stopped: !replay && event.cancelBubble === true,\n };\n\n const restoreStop = patchEventMethod(event, \"stopPropagation\", () => {\n state.stopped = true;\n });\n const restoreImmediate = patchEventMethod(\n event,\n \"stopImmediatePropagation\",\n () => {\n state.stopped = true;\n state.immediateStopped = true;\n },\n );\n const restoreCancelBubble = patchProperty(event, \"cancelBubble\", {\n get: () => state.stopped,\n set(value: unknown) {\n // Per spec, assigning false does nothing.\n if (value === true) state.stopped = true;\n },\n });\n\n try {\n return callback(state);\n } finally {\n restoreCancelBubble();\n restoreImmediate();\n restoreStop();\n // Reflect a logical stop onto the native event after removing the patches.\n if (state.stopped) event.cancelBubble = true;\n }\n}\n\nfunction patchEventMethod(\n event: Event,\n name: \"stopImmediatePropagation\" | \"stopPropagation\",\n onCall: () => void,\n): () => void {\n const native = Reflect.get(event, name);\n if (typeof native !== \"function\") return noop;\n\n return patchProperty(event, name, {\n value() {\n onCall();\n native.call(event);\n },\n });\n}\n\nfunction patchProperty(\n target: object,\n name: PropertyKey,\n descriptor: PropertyDescriptor,\n): () => void {\n const previous = Object.getOwnPropertyDescriptor(target, name);\n const changed = Reflect.defineProperty(target, name, {\n configurable: true,\n ...descriptor,\n });\n if (!changed) return noop;\n\n return previous === undefined\n ? () => {\n Reflect.deleteProperty(target, name);\n }\n : () => {\n Reflect.defineProperty(target, name, previous);\n };\n}\n\nfunction noop(): void {}\n","import {\n EARLY_EVENT_HANDLER_PROPERTY,\n EARLY_EVENT_QUEUE_PROPERTY,\n REPLAYABLE_EVENT_TYPES,\n} from \"@bgub/fig/internal\";\nimport {\n type EventPriority,\n type HydrationTargetResult,\n runWithEventPriority,\n} from \"@bgub/fig-reconciler\";\nimport {\n type EventCallback,\n type NativeEventDescriptor,\n} from \"./event-descriptor.ts\";\nimport {\n type PropagationState,\n withCurrentTarget,\n withPropagationState,\n} from \"./event-propagation.ts\";\nimport { isElementNode, parentOf } from \"./tree.ts\";\n\nexport type Container = Document | DocumentFragment | Element;\ntype Batch = <T>(callback: () => T) => T;\ntype RootRun = <T>(callback: () => T) => T;\n\ninterface EventSlot {\n attachment: EventAttachment | null;\n capture: boolean;\n callback: EventCallback;\n controller: AbortController | null;\n passive: boolean;\n slot: string;\n type: string;\n}\n\ntype EventAttachment =\n | {\n element: Element;\n listener: EventListener;\n root: Container | null;\n }\n | { listenerTarget: Container; root: Container };\n\n// Snapshot of one handler invocation, extracted before any handler runs: a\n// re-entrant commit inside a handler may detach slots or swap callbacks\n// mid-dispatch, and listeners subscribed when the event fired must still\n// run exactly once with the fields they had at extraction.\ninterface DispatchEntry {\n callback: EventCallback;\n element: Element;\n root: Container | null;\n slot: EventSlot;\n}\n\n// type/capture/passive are stored rather than re-parsed from the listener\n// key: event types may themselves contain the key separator (\":\").\ninterface RootListener {\n capture: boolean;\n count: number;\n listener: EventListener;\n passive: boolean;\n type: string;\n}\n\ninterface QueuedReplayableEvent {\n event: Event;\n // The logical dispatch origin (a portal target or the root), captured\n // while the target is still attached so replays keep portal bubbling.\n listenerTarget: Container | null;\n root: Container;\n type: string;\n}\n\ninterface PortalOwner {\n logicalParent: Container | Element;\n // The logical parent's listener target at registration time: the container\n // whose delegated keys this portal mirrors (an enclosing portal target, or\n // the root).\n parentTarget: Container;\n root: Container;\n}\n\ninterface RootOptions {\n hydrate?: HydrationCallback;\n run: RootRun;\n}\n\n// One record per container that participates in event routing — a root, a\n// portal target, or both roles' delegated listener host. Keeping every\n// per-container datum here keeps registration, dispatch, and teardown\n// reading one structure.\ninterface ContainerRecord {\n hydrate: HydrationCallback | null;\n hydrationListeners: Array<readonly [string, EventListener]> | null;\n listeners: Map<string, RootListener>;\n portalOwner: PortalOwner | null;\n // Portal targets whose logical parent resolves to this container: this\n // container's delegated listener keys mirror onto them (cascading down\n // nested portals) so portal-inner events always have a dispatch point for\n // logical bubbling, even when no portal-inner handler shares the key.\n portals: Set<Container> | null;\n // A non-null runner marks this container as a root. Portal-only records\n // leave it null.\n run: RootRun | null;\n}\n\nconst eventSlots = new WeakMap<Element, EventSlot[]>();\nconst containerRecords = new WeakMap<Container, ContainerRecord>();\n// Keyed per (event, root): each root resolves selective hydration against\n// its own tree, so an outer root's \"none\" must not shadow a nested root's\n// \"blocked\". The inner WeakMap avoids retaining other roots' containers\n// while a queued replayable event keeps the native event alive.\nconst eventHydrationResults = new WeakMap<\n Event,\n WeakMap<Container, HydrationTargetResult>\n>();\nconst queuedReplayableEvents: QueuedReplayableEvent[] = [];\n// Shared with the server's inline early-event-capture script: both sides\n// must agree on which events queue for replay.\nconst replayableEvents = new Set<string>(REPLAYABLE_EVENT_TYPES);\nconst discreteEvents = new Set([\n \"beforeinput\",\n \"blur\",\n \"change\",\n \"click\",\n \"contextmenu\",\n \"dblclick\",\n \"focus\",\n \"focusin\",\n \"focusout\",\n \"input\",\n \"keydown\",\n \"keyup\",\n \"mousedown\",\n \"mouseup\",\n \"pointerdown\",\n \"pointerup\",\n \"submit\",\n \"touchend\",\n \"touchstart\",\n]);\nconst continuousEvents = new Set([\n \"drag\",\n \"dragover\",\n \"mousemove\",\n \"pointermove\",\n \"scroll\",\n \"touchmove\",\n \"wheel\",\n]);\nconst hydrationEvents = new Set([\n ...discreteEvents,\n ...continuousEvents,\n \"mouseenter\",\n \"mouseleave\",\n]);\n// Non-bubbling events attach directly to their element with native\n// semantics: a delegated bubble-phase root listener would never fire for\n// them in a real browser. focus/blur included — the platform's bubbling\n// variants are focusin/focusout, which delegate like any bubbling event, so\n// Fig does not emulate bubbling focus the way React does.\nconst nonDelegatedEvents = new Set([\n \"abort\",\n \"blur\",\n \"cancel\",\n \"canplay\",\n \"canplaythrough\",\n \"close\",\n \"durationchange\",\n \"emptied\",\n \"encrypted\",\n \"ended\",\n \"error\",\n \"focus\",\n \"invalid\",\n \"load\",\n \"loadeddata\",\n \"loadedmetadata\",\n \"loadstart\",\n \"mouseenter\",\n \"mouseleave\",\n \"pause\",\n \"play\",\n \"playing\",\n \"pointerenter\",\n \"pointerleave\",\n \"progress\",\n \"ratechange\",\n \"resize\",\n \"scroll\",\n \"scrollend\",\n \"seeked\",\n \"seeking\",\n \"stalled\",\n \"suspend\",\n \"timeupdate\",\n \"toggle\",\n \"volumechange\",\n \"waiting\",\n]);\nlet batch: Batch = (callback) => callback();\n\ntype HydrationCallback = (\n target: EventTarget | null,\n priority: EventPriority,\n) => HydrationTargetResult;\n\nexport function setEventBatching(nextBatch: Batch): void {\n batch = nextBatch;\n}\n\nexport function registerRoot(container: Container, options: RootOptions): void {\n const record = containerRecord(container);\n record.run = options.run;\n if (options.hydrate === undefined) return;\n\n record.hydrate = options.hydrate;\n ensureHydrationListeners(container, record);\n adoptEarlyEvents(container);\n}\n\ntype EarlyEventCarrier = Document & {\n [EARLY_EVENT_QUEUE_PROPERTY]?: Event[];\n [EARLY_EVENT_HANDLER_PROPERTY]?: EventListener;\n};\n\n// Events left over after each root claimed its own, kept per document so\n// later-hydrating roots (multiple containers on one page) still find theirs.\nconst unclaimedEarlyEvents = new WeakMap<Document, Event[]>();\n\n// The server's inline capture script queues replayable events that fired\n// before this bundle executed. Adopt them into the standard replay queue:\n// a discrete replay forces synchronous hydration of its target, so a\n// pre-bundle click on server-rendered content is honored as soon as the\n// drain microtask runs instead of being lost.\nfunction adoptEarlyEvents(root: Container): void {\n const carrier = (root.ownerDocument ?? root) as EarlyEventCarrier;\n let unclaimed = unclaimedEarlyEvents.get(carrier);\n\n if (unclaimed === undefined) {\n const queue = carrier[EARLY_EVENT_QUEUE_PROPERTY];\n if (!Array.isArray(queue)) return;\n\n const handler = carrier[EARLY_EVENT_HANDLER_PROPERTY];\n if (\n typeof handler === \"function\" &&\n typeof carrier.removeEventListener === \"function\"\n ) {\n for (const type of REPLAYABLE_EVENT_TYPES) {\n carrier.removeEventListener(type, handler, true);\n }\n }\n delete carrier[EARLY_EVENT_QUEUE_PROPERTY];\n delete carrier[EARLY_EVENT_HANDLER_PROPERTY];\n\n unclaimed = queue;\n unclaimedEarlyEvents.set(carrier, unclaimed);\n }\n\n let claimed = false;\n for (let index = 0; index < unclaimed.length;) {\n const event = unclaimed[index];\n if (\n replayableEvents.has(event.type) &&\n targetWithinRoot(root, event.target)\n ) {\n unclaimed.splice(index, 1);\n queueReplayableEvent(root, event.type, event);\n claimed = true;\n continue;\n }\n index += 1;\n }\n\n if (claimed) queueMicrotask(replayQueuedEvents);\n}\n\nexport function unregisterRoot(container: Container): void {\n const record = containerRecords.get(container);\n if (record === undefined) return;\n\n disableRootHydration(container);\n\n // Slot teardown normally empties this map before unmount finishes; sweep\n // whatever remains so no delegated listener outlives the root.\n for (const rootListener of record.listeners.values()) {\n container.removeEventListener(\n rootListener.type,\n rootListener.listener,\n rootListener.capture,\n );\n }\n\n // Portal teardown normally clears these during unmount; sweep stragglers\n // (nested portals hang off their parent target's record, so recurse).\n sweepPortals(container);\n\n containerRecords.delete(container);\n\n for (let index = queuedReplayableEvents.length - 1; index >= 0; index -= 1) {\n if (queuedReplayableEvents[index].root === container) {\n queuedReplayableEvents.splice(index, 1);\n }\n }\n}\n\nexport function disableRootHydration(container: Container): void {\n const record = containerRecords.get(container);\n if (record === undefined || record.run === null) return;\n\n record.hydrate = null;\n for (const [type, listener] of record.hydrationListeners ?? []) {\n container.removeEventListener(type, listener, true);\n }\n record.hydrationListeners = null;\n}\n\nfunction sweepPortals(target: Container): void {\n for (const portal of containerRecords.get(target)?.portals ?? []) {\n sweepPortals(portal);\n removePortalContainer(portal);\n }\n}\n\nfunction containerRecord(container: Container): ContainerRecord {\n let record = containerRecords.get(container);\n if (record === undefined) {\n record = {\n hydrate: null,\n hydrationListeners: null,\n listeners: new Map(),\n portalOwner: null,\n portals: null,\n run: null,\n };\n containerRecords.set(container, record);\n }\n return record;\n}\n\nexport function updateEvents(\n element: Element,\n descriptors: readonly NativeEventDescriptor[],\n): void {\n const previousSlots = eventSlots.get(element) ?? [];\n if (previousSlots.length === 0 && descriptors.length === 0) return;\n const previousBySlot = new Map<string, EventSlot>();\n for (const slot of previousSlots) previousBySlot.set(slot.slot, slot);\n const nextSlots: EventSlot[] = [];\n let location: EventLocation | null = null;\n\n for (const descriptor of descriptors) {\n const capture = descriptor.options?.capture === true;\n const passive = descriptor.options?.passive === true;\n let slot = previousBySlot.get(descriptor.slot);\n previousBySlot.delete(descriptor.slot);\n\n if (\n slot === undefined ||\n slot.type !== descriptor.type ||\n slot.capture !== capture ||\n slot.passive !== passive\n ) {\n location ??= eventLocationFor(element);\n if (slot !== undefined) removeEventSlot(slot);\n slot = addEventSlot(\n element,\n location.root,\n location.listenerTarget,\n descriptor,\n capture,\n passive,\n );\n } else if (slot.callback !== descriptor.callback) {\n slot.callback = descriptor.callback as EventCallback;\n }\n nextSlots.push(slot);\n }\n\n for (const slot of previousBySlot.values()) removeEventSlot(slot);\n if (nextSlots.length === 0) eventSlots.delete(element);\n else eventSlots.set(element, nextSlots);\n}\n\nexport function attachElementEvents(element: Element): void {\n const slots = eventSlots.get(element);\n if (slots === undefined) return;\n const { listenerTarget, root } = eventLocationFor(element);\n\n for (const slot of slots) {\n attachEventSlot(element, root, listenerTarget, slot);\n }\n}\n\nexport function detachElementEvents(element: Element): void {\n const slots = eventSlots.get(element);\n if (slots === undefined) return;\n for (const slot of slots) removeEventSlot(slot);\n eventSlots.delete(element);\n}\n\ninterface EventLocation {\n listenerTarget: Container | null;\n root: Container | null;\n}\n\nfunction eventLocationFor(\n node: Element | Text | Comment | Container,\n): EventLocation {\n const listenerTarget = listenerTargetFor(node);\n if (listenerTarget === null) return { listenerTarget: null, root: null };\n\n // listenerTargetFor only returns containers with a live record; fail safe\n // (no root) if that invariant ever breaks rather than treating the node's\n // own container as a root.\n const record = containerRecords.get(listenerTarget);\n if (record === undefined) return { listenerTarget: null, root: null };\n\n return {\n listenerTarget,\n root:\n record.portalOwner?.root ?? (record.run !== null ? listenerTarget : null),\n };\n}\n\nexport function registerPortalContainer(\n container: Container,\n root: Container,\n logicalParent: Container | Element,\n): void {\n const record = containerRecord(container);\n const parentTarget = listenerTargetFor(logicalParent) ?? root;\n\n if (record.portalOwner !== null) {\n // Re-registration on a later commit: refresh the logical position; the\n // mirrors are already in place while the parent target is unchanged.\n if (\n record.portalOwner.root === root &&\n record.portalOwner.parentTarget === parentTarget\n ) {\n record.portalOwner = { logicalParent, parentTarget, root };\n return;\n }\n removePortalContainer(container);\n }\n\n record.portalOwner = {\n logicalParent,\n parentTarget,\n root,\n };\n\n const parentRecord = containerRecord(parentTarget);\n (parentRecord.portals ??= new Set()).add(container);\n // Mirror the logical parent target's active delegated keys (which already\n // include its own ancestors' mirrors) so events inside the portal have a\n // dispatch point for every handler along the logical ancestor chain.\n for (const mirrored of parentRecord.listeners.values()) {\n acquireRootListener(\n root,\n container,\n mirrored.type,\n mirrored.capture,\n mirrored.passive,\n );\n }\n}\n\nexport function removePortalContainer(container: Container): void {\n const record = containerRecords.get(container);\n if (!record?.portalOwner) return;\n const owner = record.portalOwner;\n\n record.portalOwner = null;\n\n const parentRecord = containerRecords.get(owner.parentTarget);\n if (parentRecord === undefined) return;\n parentRecord.portals?.delete(container);\n for (const key of parentRecord.listeners.keys()) {\n releaseRootListener(container, key);\n }\n}\n\nexport function replayQueuedEvents(): void {\n // Replays preserve the user's input order per root: a still-blocked entry\n // stalls later entries of ITS root only, so an independent root's\n // never-completing boundary cannot head-of-line block everyone else.\n const stalledRoots = new Set<Container>();\n\n for (let index = 0; index < queuedReplayableEvents.length;) {\n const queued = queuedReplayableEvents[index];\n\n // Liveness is checked against the logical dispatch origin: a portal\n // target lives outside the root container's DOM.\n const anchor = queued.listenerTarget ?? queued.root;\n if (!targetWithinRoot(anchor, queued.event.target)) {\n queuedReplayableEvents.splice(index, 1);\n continue;\n }\n\n // Attempt hydration even for stalled roots so later boundaries make\n // progress; only dispatch is withheld to keep ordering.\n if (hydrateQueuedEvent(queued) === \"blocked\") {\n stalledRoots.add(queued.root);\n index += 1;\n continue;\n }\n\n if (stalledRoots.has(queued.root)) {\n index += 1;\n continue;\n }\n\n queuedReplayableEvents.splice(index, 1);\n dispatchReplayedEvent(queued);\n }\n}\n\nfunction addEventSlot(\n element: Element,\n root: Container | null,\n listenerTarget: Container | null,\n descriptor: NativeEventDescriptor,\n capture: boolean,\n passive: boolean,\n): EventSlot {\n const slot: EventSlot = {\n attachment: null,\n capture,\n callback: descriptor.callback as EventCallback,\n controller: null,\n passive,\n slot: descriptor.slot,\n type: descriptor.type,\n };\n attachEventSlot(element, root, listenerTarget, slot);\n return slot;\n}\n\nfunction removeEventSlot(slot: EventSlot): void {\n detachEventSlot(slot);\n abortEventSlot(slot);\n}\n\nfunction dispatchRootEvent(\n root: Container,\n listenerTarget: Container,\n type: string,\n capture: boolean,\n passive: boolean,\n event: Event,\n): void {\n const targetListenerTarget = listenerTargetFor(event.target);\n if (targetListenerTarget !== listenerTarget) {\n const targetRecord =\n targetListenerTarget === null\n ? null\n : (containerRecords.get(targetListenerTarget) ?? null);\n if (targetRecord?.portalOwner?.root === root) return;\n if (!targetWithinRoot(listenerTarget, event.target)) return;\n }\n if (hydrateForEvent(root, type, event) === \"blocked\") return;\n\n const entries = extractDispatches(\n root,\n listenerTarget,\n type,\n capture,\n passive,\n event,\n );\n if (entries.length === 0) return;\n\n withPropagationState(event, false, (state) =>\n invokeDispatches(entries, event, state),\n );\n}\n\nfunction ensureHydrationListeners(\n root: Container,\n record: ContainerRecord,\n): void {\n if (record.hydrationListeners !== null) return;\n record.hydrationListeners = [];\n\n for (const type of hydrationEvents) {\n const listener = (event: Event) => hydrateForEvent(root, type, event);\n record.hydrationListeners.push([type, listener]);\n root.addEventListener(type, listener, {\n capture: true,\n passive: passiveHydrationEvent(type),\n });\n }\n}\n\nfunction hydrateForEvent(\n root: Container,\n type: string,\n event: Event,\n): HydrationTargetResult {\n const hydrate = containerRecords.get(root)?.hydrate ?? null;\n if (hydrate === null) return \"none\";\n\n let results = eventHydrationResults.get(event);\n const previousResult = results?.get(root);\n if (previousResult !== undefined) return previousResult;\n\n const priority = eventPriority(type);\n const result = runWithEventPriority(priority, () =>\n hydrate(event.target, priority),\n );\n if (results === undefined) {\n results = new WeakMap();\n eventHydrationResults.set(event, results);\n }\n results.set(root, result);\n\n // Queue only on the fresh computation: the capture hydration listener and\n // the delegated dispatch guard both land here for the same (event, root).\n if (result === \"blocked\" && replayableEvents.has(type)) {\n queueReplayableEvent(root, type, event);\n }\n\n return result;\n}\n\nfunction queueReplayableEvent(\n root: Container,\n type: string,\n event: Event,\n): void {\n queuedReplayableEvents.push({\n event,\n listenerTarget: listenerTargetFor(event.target),\n root,\n type,\n });\n}\n\nfunction hydrateQueuedEvent(\n queued: QueuedReplayableEvent,\n): HydrationTargetResult {\n const hydrate = containerRecords.get(queued.root)?.hydrate ?? null;\n if (hydrate === null) return \"none\";\n\n const priority = eventPriority(queued.type);\n return runWithEventPriority(priority, () =>\n hydrate(queued.event.target, priority),\n );\n}\n\n// Replays a queued event after selective hydration: the spent native event\n// no longer propagates, so one synthetic dispatch stands in for both phases\n// (`passive: null` matches every slot — no live root listener partitions\n// them by key here). The bubble phase extracts after capture handlers ran,\n// mirroring live DOM listener semantics; one propagation state spans both\n// phases, ignoring the spent event's stale cancelBubble.\nfunction dispatchReplayedEvent(queued: QueuedReplayableEvent): void {\n const { event, root, type } = queued;\n const listenerTarget = queued.listenerTarget ?? queued.root;\n\n withPropagationState(event, true, (state) => {\n invokeDispatches(\n extractDispatches(root, listenerTarget, type, true, null, event),\n event,\n state,\n );\n\n if (state.immediateStopped || state.stopped) return;\n\n invokeDispatches(\n extractDispatches(root, listenerTarget, type, false, null, event),\n event,\n state,\n );\n });\n}\n\nfunction extractDispatches(\n root: Container,\n listenerTarget: Container,\n type: string,\n capture: boolean,\n passive: boolean | null,\n event: Event,\n): DispatchEntry[] {\n const path = eventPath(root, listenerTarget, event);\n const entries: DispatchEntry[] = [];\n const step = capture ? -1 : 1;\n\n for (\n let index = capture ? path.length - 1 : 0;\n index >= 0 && index < path.length;\n index += step\n ) {\n const element = path[index];\n const slots = eventSlots.get(element);\n if (slots === undefined) continue;\n\n for (const slot of slots) {\n const slotRoot = attachedRoot(slot);\n if (\n slotRoot !== root ||\n slot.type !== type ||\n slot.capture !== capture ||\n (passive !== null && slot.passive !== passive)\n ) {\n continue;\n }\n\n entries.push({\n callback: slot.callback,\n element,\n root: slotRoot,\n slot,\n });\n }\n }\n\n return entries;\n}\n\nfunction invokeDispatches(\n entries: DispatchEntry[],\n event: Event,\n state: PropagationState,\n): void {\n let currentElement: Element | null = null;\n\n for (const entry of entries) {\n if (state.immediateStopped) return;\n\n // stopPropagation lets remaining handlers on the same element run and\n // skips every later element.\n if (entry.element !== currentElement) {\n if (currentElement !== null && state.stopped) return;\n currentElement = entry.element;\n }\n\n try {\n dispatchEventSlot(entry, event);\n } finally {\n // A slot detached mid-dispatch still ran — it was subscribed when the\n // event fired — but its signal must end aborted per the abort-on-removal\n // contract, even if the handler threw.\n const slot = entry.slot;\n if (slot.attachment === null) {\n abortEventSlot(slot);\n }\n }\n }\n}\n\nfunction dispatchEventSlot(entry: DispatchEntry, event: Event): void {\n const slot = entry.slot;\n abortEventSlot(slot);\n slot.controller = new AbortController();\n const signal = slot.controller.signal;\n\n batch(() => {\n runWithRootScope(entry.root, () =>\n runWithEventPriority(eventPriority(slot.type), () => {\n withCurrentTarget(event, entry.element, (currentEvent) => {\n entry.callback(currentEvent, signal);\n });\n }),\n );\n });\n}\n\nfunction runWithRootScope<T>(root: Container | null, callback: () => T): T {\n const run = root === null ? null : (containerRecords.get(root)?.run ?? null);\n return run === null ? callback() : run(callback);\n}\n\nfunction abortEventSlot(slot: EventSlot): void {\n slot.controller?.abort();\n slot.controller = null;\n}\n\nfunction attachEventSlot(\n element: Element,\n root: Container | null,\n listenerTarget: Container | null,\n slot: EventSlot,\n): void {\n if (nonDelegatedEvents.has(slot.type)) {\n attachDirectEventSlot(element, root, slot);\n } else {\n attachDelegatedEventSlot(root, listenerTarget, slot);\n }\n}\n\nfunction attachDirectEventSlot(\n element: Element,\n root: Container | null,\n slot: EventSlot,\n): void {\n // The root scopes dispatch (root.data.run and friends), same as the\n // delegated path. The first attach can run before insertion, when the\n // element's root lookup still resolves null, so a re-attach on the same\n // element refreshes the root without re-adding the DOM listener.\n const attachment = slot.attachment;\n if (attachment !== null) {\n if (\"element\" in attachment && attachment.element === element) {\n if (root !== null) attachment.root = root;\n return;\n }\n detachEventSlot(slot);\n }\n\n const listener: EventListener = (event) => {\n try {\n dispatchEventSlot(\n {\n callback: slot.callback,\n element,\n root: attachedRoot(slot),\n slot,\n },\n event,\n );\n } finally {\n if (slot.attachment === null) {\n abortEventSlot(slot);\n }\n }\n };\n slot.attachment = { element, listener, root };\n element.addEventListener(slot.type, listener, {\n capture: slot.capture,\n passive: slot.passive,\n });\n}\n\nfunction attachDelegatedEventSlot(\n root: Container | null,\n listenerTarget: Container | null,\n slot: EventSlot,\n): void {\n if (root === null || listenerTarget === null) return;\n\n const attachment = slot.attachment;\n if (\n attachment !== null &&\n \"listenerTarget\" in attachment &&\n attachment.root === root &&\n attachment.listenerTarget === listenerTarget\n ) {\n return;\n }\n\n detachEventSlot(slot);\n slot.attachment = { listenerTarget, root };\n\n acquireRootListener(\n root,\n listenerTarget,\n slot.type,\n slot.capture,\n slot.passive,\n );\n}\n\nfunction acquireRootListener(\n root: Container,\n listenerTarget: Container,\n type: string,\n capture: boolean,\n passive: boolean,\n): void {\n const listeners = containerRecord(listenerTarget).listeners;\n const key = `${type}:${capture}:${passive}`;\n let rootListener = listeners.get(key);\n\n if (rootListener === undefined) {\n rootListener = {\n capture,\n count: 0,\n listener: (event) =>\n dispatchRootEvent(root, listenerTarget, type, capture, passive, event),\n passive,\n type,\n };\n listenerTarget.addEventListener(type, rootListener.listener, {\n capture,\n passive,\n });\n listeners.set(key, rootListener);\n\n // A key newly active on a target mirrors onto its portal targets\n // (cascading through nested portals) so portal-inner events dispatch\n // through the logical tree for it.\n for (const portal of containerRecords.get(listenerTarget)?.portals ?? []) {\n acquireRootListener(root, portal, type, capture, passive);\n }\n }\n\n rootListener.count += 1;\n}\n\nfunction releaseRootListener(listenerTarget: Container, key: string): void {\n const listeners = containerRecords.get(listenerTarget)?.listeners;\n const rootListener = listeners?.get(key);\n if (listeners === undefined || rootListener === undefined) return;\n\n rootListener.count -= 1;\n if (rootListener.count > 0) return;\n\n listenerTarget.removeEventListener(\n rootListener.type,\n rootListener.listener,\n rootListener.capture,\n );\n listeners.delete(key);\n\n // The key died on this target: drop its mirrors from the portal targets.\n for (const portal of containerRecords.get(listenerTarget)?.portals ?? []) {\n releaseRootListener(portal, key);\n }\n}\n\nfunction detachEventSlot(slot: EventSlot): void {\n const attachment = slot.attachment;\n if (attachment === null) return;\n slot.attachment = null;\n\n if (\"element\" in attachment) {\n attachment.element.removeEventListener(\n slot.type,\n attachment.listener,\n slot.capture,\n );\n } else {\n releaseRootListener(\n attachment.listenerTarget,\n `${slot.type}:${slot.capture}:${slot.passive}`,\n );\n }\n}\n\nfunction attachedRoot(slot: EventSlot): Container | null {\n return slot.attachment?.root ?? null;\n}\n\nfunction eventPath(\n root: Container,\n listenerTarget: Container,\n event: Event,\n): Element[] {\n const path: Element[] = [];\n const composedPath = event.composedPath?.();\n\n if (composedPath !== undefined) {\n const index = composedPath.indexOf(listenerTarget);\n if (index !== -1) {\n for (let pathIndex = 0; pathIndex < index; pathIndex += 1) {\n const node = composedPath[pathIndex];\n if (isElementNode(node)) path.push(node);\n }\n appendLogicalPortalPath(path, root, listenerTarget);\n return path;\n }\n }\n\n for (let current: unknown = event.target; current !== listenerTarget;) {\n if (isElementNode(current)) path.push(current);\n current = parentOf(current);\n if (current === null) break;\n }\n\n appendLogicalPortalPath(path, root, listenerTarget);\n return path;\n}\n\nfunction appendLogicalPortalPath(\n path: Element[],\n root: Container,\n listenerTarget: Container,\n): void {\n const owner = containerRecords.get(listenerTarget)?.portalOwner ?? null;\n if (owner === null || owner.root !== root) return;\n\n let cursor: unknown = owner.logicalParent;\n\n while (cursor !== null && cursor !== root) {\n // A portal container in the chain (nested portals): continue from its\n // logical parent; the target element itself is not a logical ancestor.\n if (isContainer(cursor)) {\n const hop = containerRecords.get(cursor)?.portalOwner ?? null;\n if (hop !== null && hop.root === root) {\n cursor = hop.logicalParent;\n continue;\n }\n }\n\n if (isElementNode(cursor)) path.push(cursor);\n cursor = parentOf(cursor);\n }\n}\n\nfunction targetWithinRoot(\n root: Container,\n target: EventTarget | null,\n): boolean {\n for (let current: unknown = target; current !== null;) {\n if (current === root) return true;\n current = parentOf(current);\n }\n\n return false;\n}\n\nfunction listenerTargetFor(node: EventTarget | null): Container | null {\n for (let current: unknown = node; current !== null;) {\n if (isContainer(current)) {\n const record = containerRecords.get(current);\n if (\n record !== undefined &&\n (record.portalOwner !== null || record.run !== null)\n ) {\n return current;\n }\n }\n\n current = parentOf(current);\n }\n\n return null;\n}\n\nfunction eventPriority(type: string): EventPriority {\n if (discreteEvents.has(type)) return \"discrete\";\n if (continuousEvents.has(type)) return \"continuous\";\n return \"default\";\n}\n\nfunction passiveHydrationEvent(type: string): boolean {\n // Hydration listeners never call preventDefault, so scroll-blocking touch\n // events can stay passive alongside the continuous set.\n return (\n continuousEvents.has(type) || type === \"touchstart\" || type === \"touchend\"\n );\n}\n\nfunction isContainer(node: unknown): node is Container {\n return (\n typeof node === \"object\" &&\n node !== null &&\n \"addEventListener\" in node &&\n \"childNodes\" in node\n );\n}\n","import { attachElementBind, detachElementBind } from \"./bind.ts\";\nimport { attachElementEvents, detachElementEvents } from \"./events.ts\";\nimport { visitElementSubtree } from \"./tree.ts\";\n\n// Bind and event state always attach and detach together when DOM moves in\n// or out of the live tree; a single walk keeps that pairing unforgettable\n// (a hook calling one without the other leaks signals or listeners) and\n// halves the traversal per insertion/removal.\n\nexport function attachSubtree(node: Node): void {\n visitElementSubtree(node, (element) => {\n attachElementBind(element);\n attachElementEvents(element);\n });\n}\n\nexport function detachSubtree(node: Node): void {\n visitElementSubtree(node, (element) => {\n detachElementBind(element);\n detachElementEvents(element);\n });\n}\n","import type { Props } from \"@bgub/fig\";\nimport { elementName, isElementNode, isEmptyPropValue } from \"./tree.ts\";\n\nexport interface HostUpdateOptions {\n hydrating?: boolean;\n // The instance's first render: the only time defaultValue/defaultChecked\n // may live-write the element's value/checked state.\n initial?: boolean;\n}\n\ninterface SelectState {\n appliedDefault: boolean;\n applyDefaultToInsertedOptions: boolean;\n controlled: boolean;\n selectedValues: string | ReadonlySet<string>;\n}\n\nconst selectStates = new WeakMap<Element, SelectState>();\n\nexport function isFormProp(name: string): boolean {\n return isValueProp(name) || name === \"checked\" || name === \"defaultChecked\";\n}\n\nexport function updateFormControl(\n element: Element,\n type: string,\n name: string,\n value: unknown,\n props: Props,\n options: HostUpdateOptions,\n): void {\n if (type === \"select\" && isValueProp(name)) return;\n if (type === \"option\" && name === \"value\") {\n setAttribute(element, \"value\", formValue(value));\n return;\n }\n\n // Defaults live-write only on the instance's first client render. A\n // default that appears later must not clobber user-edited state.\n const initial = options.initial === true && options.hydrating !== true;\n\n if (name === \"value\") {\n if (!isEmptyPropValue(value)) setFormValue(element, value);\n } else if (name === \"defaultValue\") {\n setDefaultValue(element, value, type, initial && props.value === undefined);\n } else if (name === \"checked\") {\n if (value !== undefined) setLiveChecked(element, value);\n } else if (name === \"defaultChecked\") {\n setDefaultChecked(element, value, initial && props.checked === undefined);\n }\n}\n\nexport function updateSelect(\n element: Element,\n type: string,\n props: Props,\n options: HostUpdateOptions,\n): void {\n if (type !== \"select\") return;\n\n const controlled = props.value !== undefined;\n const value = controlled ? props.value : props.defaultValue;\n if (isEmptyPropValue(value)) {\n selectStates.delete(element);\n return;\n }\n\n // Hydration trusts an uncontrolled selection that the user may already\n // have changed. Controlled selects always reassert their value.\n const hydratingDefault = !controlled && options.hydrating === true;\n const previous = selectStates.get(element);\n const state: SelectState = {\n appliedDefault: previous?.appliedDefault === true || !controlled,\n applyDefaultToInsertedOptions:\n !hydratingDefault && !controlled && options.initial === true,\n controlled,\n selectedValues: Array.isArray(value)\n ? new Set(value.map(String))\n : String(value),\n };\n selectStates.set(element, state);\n\n if (!hydratingDefault && (controlled || options.initial === true)) {\n applySelectValue(element, state.selectedValues);\n }\n}\n\nexport function updateParentSelect(\n element: Element,\n applyDefault = false,\n): void {\n const select = closestParentSelect(element);\n if (select === null) return;\n\n const state = selectStates.get(select);\n if (state === undefined) return;\n if (!state.controlled && state.appliedDefault && !applyDefault) return;\n if (\n !state.controlled &&\n applyDefault &&\n !state.applyDefaultToInsertedOptions\n ) {\n return;\n }\n\n applySelectValue(element, state.selectedValues);\n if (!state.controlled) state.appliedDefault = true;\n}\n\nexport function shouldRestoreControlledFormState(\n type: string,\n props: Props,\n): boolean {\n return (\n (type === \"input\" || type === \"textarea\" || type === \"select\") &&\n (props.value !== undefined || props.checked !== undefined)\n );\n}\n\nexport function hydratedFormAttributeName(\n type: string,\n name: string,\n): string | null | undefined {\n if (!isFormProp(name)) return undefined;\n if ((type === \"textarea\" || type === \"select\") && isValueProp(name)) {\n return null;\n }\n if (name === \"defaultValue\") return \"value\";\n if (name === \"defaultChecked\") return \"checked\";\n return name;\n}\n\nfunction setDefaultValue(\n element: Element,\n value: unknown,\n type: string,\n live: boolean,\n): void {\n const attributeValue = formValue(value);\n const next = attributeValue ?? \"\";\n if (\"defaultValue\" in element) {\n (element as Element & { defaultValue: string }).defaultValue = next;\n }\n if (type === \"textarea\") element.textContent = next;\n else setAttribute(element, \"value\", attributeValue);\n if (live && \"value\" in element) setLiveValue(element, next);\n}\n\nfunction setFormValue(element: Element, value: unknown): void {\n const next = formValue(value);\n if (next === null) return;\n if (\"value\" in element) setLiveValue(element, next);\n else setAttribute(element, \"value\", next);\n}\n\nfunction setLiveValue(element: Element, value: string): void {\n const target = element as Element & { value: string };\n if (target.value !== value) target.value = value;\n}\n\nfunction setDefaultChecked(\n element: Element,\n value: unknown,\n live: boolean,\n): void {\n const checked = value === true;\n\n if (\"defaultChecked\" in element) {\n (element as Element & { defaultChecked: boolean }).defaultChecked = checked;\n }\n setAttribute(element, \"checked\", checked);\n if (live) setLiveChecked(element, value);\n}\n\nfunction setLiveChecked(element: Element, value: unknown): void {\n const checked = value === true;\n if (\"checked\" in element) {\n (element as Element & { checked: boolean }).checked = checked;\n } else {\n setAttribute(element, \"checked\", checked);\n }\n}\n\nfunction formValue(value: unknown): string | null {\n return isEmptyPropValue(value) ? null : String(value);\n}\n\nfunction applySelectValue(\n element: Element,\n values: string | ReadonlySet<string>,\n): void {\n if (elementName(element) === \"option\") {\n setOptionSelected(element, values);\n return;\n }\n\n visitDescendantOptions(element, (option) => {\n setOptionSelected(option, values);\n });\n}\n\nfunction setOptionSelected(\n option: Element,\n values: string | ReadonlySet<string>,\n): void {\n const explicitValue = option.getAttribute(\"value\");\n const value =\n explicitValue ?? (option.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\n (option as Element & { selected: boolean }).selected =\n typeof values === \"string\" ? value === values : values.has(value);\n}\n\nfunction closestParentSelect(element: Element): Element | null {\n let parent = element.parentNode;\n while (parent !== null) {\n if (isElementNode(parent) && elementName(parent) === \"select\")\n return parent;\n parent = parent.parentNode;\n }\n return null;\n}\n\nfunction visitDescendantOptions(\n element: Element,\n visitor: (option: Element) => void,\n): void {\n for (let child = element.firstChild; child !== null;) {\n const next = child.nextSibling;\n if (isElementNode(child)) {\n if (elementName(child) === \"option\") visitor(child);\n else visitDescendantOptions(child, visitor);\n }\n child = next;\n }\n}\n\nfunction isValueProp(name: string): boolean {\n return name === \"value\" || name === \"defaultValue\";\n}\n\nfunction setAttribute(\n element: Element,\n name: string,\n value: string | boolean | null,\n): void {\n if (isEmptyPropValue(value)) element.removeAttribute(name);\n else element.setAttribute(name, String(value));\n}\n","import { isEmptyPropValue } from \"./tree.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\n\ntype StyleTarget = Record<string, unknown> & {\n readonly length?: number;\n item?: (index: number) => string;\n removeProperty?: (name: string) => void;\n setProperty?: (name: string, value: string) => void;\n};\n\nconst warnedStyles = new Set<string>();\n\nexport function updateStyle(\n element: Element,\n previous: unknown,\n next: unknown,\n): void {\n if (__DEV__ && typeof next === \"string\" && next !== \"\") {\n warnStyle(\n \"string\",\n \"The style prop must be an object of properties; string styles are ignored.\",\n );\n }\n\n const style = (element as Element & { style?: StyleTarget }).style;\n if (style === undefined) return;\n\n const previousStyle = styleProps(previous);\n const nextStyle = styleProps(next);\n\n for (const name of Object.keys(previousStyle)) {\n if (!(name in nextStyle)) clearStyle(style, name);\n }\n\n for (const [name, value] of Object.entries(nextStyle)) {\n if (isEmptyPropValue(value)) {\n clearStyle(style, name);\n } else {\n setStyle(style, name, value);\n }\n }\n}\n\n// CSSOM canonicalizes name casing and shorthand expansion, so hydration\n// compares server and client style names only after both pass through it.\nexport function extraHydratedStyleNames(\n serverStyles: readonly string[],\n next: unknown,\n): string[] {\n if (serverStyles.length === 0) return [];\n\n const scratch = document.createElement(\"div\");\n updateStyle(scratch, {}, next);\n const expected = new Set(hydratedStyleNames(scratch));\n\n return serverStyles\n .filter((name) => !expected.has(name))\n .map((name) => `style.${name}`);\n}\n\nexport function hydratedStyleNames(element: Element): string[] {\n const style = (element as Element & { style?: StyleTarget }).style;\n if (style === undefined) return [];\n\n if (typeof style.length === \"number\" && typeof style.item === \"function\") {\n const names: string[] = [];\n for (let index = 0; index < style.length; index += 1) {\n const name = style.item(index);\n if (name !== \"\") names.push(name);\n }\n return names;\n }\n\n return Object.keys(style).filter((name) => style[name] !== \"\");\n}\n\nfunction styleProps(value: unknown): Record<string, unknown> {\n return typeof value === \"object\" && value !== null\n ? (value as Record<string, unknown>)\n : {};\n}\n\nfunction setStyle(style: StyleTarget, name: string, value: unknown): void {\n if (typeof value === \"number\" || typeof value === \"bigint\") {\n if (__DEV__) {\n warnStyle(\n `${name}:${typeof value}`,\n `The style property \"${name}\" received a ${typeof value} ` +\n `(${String(value)}); Fig style values must be strings, so this ` +\n \"style is ignored.\",\n );\n }\n return;\n }\n\n if (name.startsWith(\"--\") && typeof style.setProperty === \"function\") {\n style.setProperty(name, String(value));\n } else {\n style[name] = value;\n }\n}\n\nfunction clearStyle(style: StyleTarget, name: string): void {\n if (name.startsWith(\"--\") && typeof style.removeProperty === \"function\") {\n style.removeProperty(name);\n } else {\n style[name] = \"\";\n }\n}\n\nfunction warnStyle(key: string, message: string): void {\n if (warnedStyles.has(key)) return;\n warnedStyles.add(key);\n console.error(message);\n}\n","import type { Props } from \"@bgub/fig\";\nimport { updateBind } from \"./bind.ts\";\nimport { eventDescriptorsFromProps } from \"./event-descriptor.ts\";\nimport { updateEvents } from \"./events.ts\";\nimport {\n type HostUpdateOptions,\n hydratedFormAttributeName,\n isFormProp,\n updateFormControl,\n updateParentSelect,\n updateSelect,\n} from \"./form-controls.ts\";\nimport {\n extraHydratedStyleNames,\n hydratedStyleNames,\n updateStyle,\n} from \"./styles.ts\";\nimport { elementName, isEmptyPropValue, isHtmlElement } from \"./tree.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\n\nconst xlinkNamespace = \"http://www.w3.org/1999/xlink\";\n\nexport function updateElement(\n element: Element,\n previousProps: Props,\n nextProps: Props,\n options: HostUpdateOptions = {},\n): void {\n if (\"mix\" in previousProps || \"mix\" in nextProps) {\n updateEvents(element, eventDescriptorsFromProps(nextProps));\n }\n\n const type = elementName(element);\n const html = isHtmlElement(element);\n const names = Object.keys(previousProps);\n\n for (const name in nextProps) {\n if (Object.hasOwn(nextProps, name) && !Object.hasOwn(previousProps, name)) {\n names.push(name);\n }\n }\n\n for (const name of names) {\n const previous = previousProps[name];\n const next = nextProps[name];\n\n if (name === \"mix\") continue;\n\n if (name === \"bind\") {\n if (previous !== next) updateBind(element, next);\n continue;\n }\n\n if (name === \"unsafeHTML\") {\n if (options.hydrating === true) unsafeHTMLValue(next);\n else if (previous !== next) setUnsafeHTML(element, next);\n continue;\n }\n\n if (reserved(name)) {\n if (__DEV__ && event(name)) {\n warnDroppedProp(name, eventPropWarning(name, type, nextProps));\n }\n continue;\n }\n\n if (isFormProp(name)) {\n if (\n __DEV__ &&\n (name === \"checked\" || name === \"defaultChecked\") &&\n next !== undefined &&\n typeof next !== \"boolean\" &&\n next !== null\n ) {\n warnDroppedProp(\n `${name}:${typeof next}`,\n // The value is useful in a development diagnostic; intentional JS\n // coercion also handles symbols and custom toString implementations.\n // oxlint-disable-next-line typescript/no-base-to-string\n `The \"${name}\" prop received a ${typeof next} (${String(next)}); ` +\n \"Fig treats only `true` as checked, so this renders unchecked.\",\n );\n }\n updateFormControl(element, type, name, next, nextProps, options);\n continue;\n }\n\n if (previous === next) continue;\n if (name === \"style\") updateStyle(element, previous, next);\n else setAttribute(element, hostAttributeName(name, html), next);\n }\n\n updateSelect(element, type, nextProps, options);\n // Only option updates (value/text) can change which option a parent\n // select's stored value matches; skip the ancestor walk for everything\n // else.\n if (type === \"option\" || type === \"optgroup\") updateParentSelect(element);\n}\n\n// Dev-only, deduped by key: silently dropping a prop the author clearly\n// intended (onClick, checked={1}) is the worst failure mode —\n// nothing renders wrong, the behavior just never happens.\nconst warnedDroppedProps = new Set<string>();\n\nfunction warnDroppedProp(key: string, message: string): void {\n if (warnedDroppedProps.has(key)) return;\n warnedDroppedProps.add(key);\n console.error(message);\n}\n\nfunction eventPropWarning(name: string, type: string, props: Props): string {\n // A trailing \"Capture\" is React's capture-phase suffix, except when it is\n // part of the event name itself (onGotPointerCapture/onLostPointerCapture\n // are bubble-phase props for gotpointercapture/lostpointercapture) or is\n // the entire name (an \"onCapture\" prop would leave an empty event name).\n const capture =\n name.endsWith(\"Capture\") &&\n name.length > \"onCapture\".length &&\n name !== \"onGotPointerCapture\" &&\n name !== \"onLostPointerCapture\";\n const rawName = name.slice(2, capture ? -\"Capture\".length : undefined);\n const options = capture ? \", { capture: true }\" : \"\";\n const suggest = (eventName: string) =>\n `Fig has no \"${name}\" event props; use ` +\n `mix={on(\"${eventName}\", handler${options})} instead.`;\n\n if (rawName === \"DoubleClick\") return suggest(\"dblclick\");\n if (rawName === \"Change\" && reactChangeUsesInputEvent(type, props)) {\n return (\n suggest(\"input\") +\n ` (React's onChange on text-editing controls fires per change like the` +\n ` native \"input\" event; on(\"change\") fires only on commit.)`\n );\n }\n return suggest(rawName.toLowerCase());\n}\n\n// React backs onChange on text-editing controls with the native \"input\"\n// event; only checkbox/radio/file inputs (and selects) match the native\n// \"change\" timing, so everything else steers to on(\"input\").\nfunction reactChangeUsesInputEvent(type: string, props: Props): boolean {\n if (type === \"textarea\") return true;\n if (type !== \"input\") return false;\n const inputType = typeof props.type === \"string\" ? props.type : \"text\";\n return (\n inputType !== \"checkbox\" && inputType !== \"radio\" && inputType !== \"file\"\n );\n}\n\nexport function hydrateElement(element: Element, nextProps: Props): void {\n // Snapshot before the update applies: updateElement writes the client\n // style prop into the same declaration and runs the bind callback (which\n // may set attributes), so a post-update enumeration could not tell\n // server-set names from client-set ones.\n const serverStyles = __DEV__ ? hydratedStyleNames(element) : [];\n const serverAttributes = __DEV__ ? attributeNames(element) : [];\n\n updateElement(element, {}, nextProps, { hydrating: true });\n\n if (__DEV__ && nextProps.suppressHydrationWarning !== true) {\n warnExtraHydratedAttributes(\n element,\n nextProps,\n serverStyles,\n serverAttributes,\n );\n }\n}\n\n// Server-only attributes and styles are preserved (extensions and internal\n// markers make removal unsafe), so surface the divergence from a pure client\n// render as a dev warning instead.\nfunction warnExtraHydratedAttributes(\n element: Element,\n nextProps: Props,\n serverStyles: readonly string[],\n serverAttributes: readonly string[],\n): void {\n if (serverAttributes.length === 0 && serverStyles.length === 0) return;\n\n const expectedAttributes = new Set<string>();\n const type = elementName(element);\n const html = isHtmlElement(element);\n\n for (const name of Object.keys(nextProps)) {\n if (name === \"bind\" || reserved(name)) {\n continue;\n }\n\n const attribute = hydratedAttributeName(type, name, html);\n if (attribute !== null) expectedAttributes.add(attribute);\n }\n\n const extra: string[] = [];\n for (const name of serverAttributes) {\n const attribute = hostAttributeName(name, html);\n if (attribute.startsWith(\"data-fig-\")) continue;\n if (!expectedAttributes.has(attribute)) extra.push(name);\n }\n\n extra.push(...extraHydratedStyleNames(serverStyles, nextProps.style));\n\n if (extra.length === 0) return;\n\n console.error(\n `Hydration preserved extra server attributes or styles on <${type}>: ` +\n `${extra.sort().join(\", \")}. They were preserved, so this element now ` +\n \"differs from a pure client render.\",\n );\n}\n\nfunction hydratedAttributeName(\n type: string,\n name: string,\n html: boolean,\n): string | null {\n const formName = hydratedFormAttributeName(type, name);\n return formName === undefined ? hostAttributeName(name, html) : formName;\n}\n\nfunction attributeNames(element: Element): string[] {\n const attributes = element.attributes as\n | (NamedNodeMap & Iterable<Attr>)\n | Record<string, unknown>\n | undefined;\n\n if (attributes === undefined) return [];\n\n if (\n \"length\" in attributes &&\n typeof attributes.length === \"number\" &&\n \"item\" in attributes &&\n typeof attributes.item === \"function\"\n ) {\n const names: string[] = [];\n for (let index = 0; index < attributes.length; index += 1) {\n const attribute = attributes.item(index);\n if (attribute !== null) names.push(attribute.name);\n }\n return names;\n }\n\n if (Symbol.iterator in attributes) {\n return Array.from(\n attributes as Iterable<Attr>,\n (attribute) => attribute.name,\n );\n }\n\n return Object.keys(attributes);\n}\n\nfunction setUnsafeHTML(element: Element, value: unknown): void {\n const html = unsafeHTMLValue(value);\n if (!(\"innerHTML\" in element)) return;\n\n (element as Element & { innerHTML: string }).innerHTML = html ?? \"\";\n}\n\nfunction unsafeHTMLValue(value: unknown): string | null {\n if (isEmptyPropValue(value)) return null;\n if (typeof value === \"string\") return value;\n throw new Error(\"The unsafeHTML prop must be a string.\");\n}\n\nfunction hostAttributeName(name: string, html: boolean): string {\n return html ? name.toLowerCase() : name;\n}\n\nfunction setAttribute(\n element: Element,\n attribute: string,\n value: unknown,\n): void {\n if (isEmptyPropValue(value)) {\n removeAttribute(element, attribute);\n return;\n }\n\n if (attribute === \"xlink:href\") {\n element.setAttributeNS(xlinkNamespace, attribute, String(value));\n return;\n }\n\n element.setAttribute(attribute, String(value));\n}\n\nfunction removeAttribute(element: Element, attribute: string): void {\n if (attribute === \"xlink:href\") {\n element.removeAttributeNS(xlinkNamespace, \"href\");\n return;\n }\n\n element.removeAttribute(attribute);\n}\n\nfunction reserved(name: string): boolean {\n return (\n name === \"children\" ||\n name === \"key\" ||\n name === \"mix\" ||\n name === \"suppressHydrationWarning\" ||\n name === \"unsafeHTML\" ||\n event(name)\n );\n}\n\nfunction event(name: string): boolean {\n return /^on[A-Z]/.test(name);\n}\n","import type { Props } from \"@bgub/fig\";\nimport type { AssetResourceOwner } from \"@bgub/fig-reconciler\";\nimport { updateElement } from \"./props.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\n\nexport class MetadataClaims {\n readonly kind = \"metadata\" as const;\n private readonly byOwner = new Map<AssetResourceOwner, Props>();\n private rendered: Props | null = null;\n private winner: AssetResourceOwner;\n\n constructor(\n readonly element: Element,\n private readonly resourceKind: \"title\" | \"meta\",\n owner: AssetResourceOwner,\n props: Props,\n ) {\n this.winner = owner;\n this.byOwner.set(owner, props);\n this.applyWinner();\n }\n\n acquire(owner: AssetResourceOwner, props: Props): void {\n const isNewOwner = !this.byOwner.has(owner);\n this.byOwner.set(owner, props);\n if (isNewOwner) this.winner = owner;\n if (this.winner === owner) this.applyWinner();\n }\n\n update(owner: AssetResourceOwner, props: Props): void {\n if (!this.byOwner.has(owner)) {\n throw new Error(\"Expected a live metadata claim.\");\n }\n this.byOwner.set(owner, props);\n if (this.winner === owner) this.applyWinner();\n }\n\n release(owner: AssetResourceOwner): \"empty\" | \"retained\" {\n if (!this.byOwner.delete(owner)) {\n if (__DEV__) throw new Error(\"Expected a live metadata claim.\");\n return \"retained\";\n }\n if (this.byOwner.size === 0) return \"empty\";\n if (this.winner !== owner) return \"retained\";\n\n let winner: AssetResourceOwner | null = null;\n for (const candidate of this.byOwner.keys()) winner = candidate;\n if (winner === null) throw new Error(\"Expected a live metadata claim.\");\n this.winner = winner;\n this.applyWinner();\n return \"retained\";\n }\n\n private applyWinner(): void {\n const props = this.byOwner.get(this.winner);\n if (props === undefined) throw new Error(\"Expected a live metadata claim.\");\n\n updateElement(this.element, this.rendered ?? {}, props);\n if (this.resourceKind === \"title\") {\n this.element.textContent = metadataTextValue(props.children);\n }\n this.rendered = props;\n }\n}\n\nfunction metadataTextValue(value: unknown): string {\n if (value === null || value === undefined || typeof value === \"boolean\") {\n return \"\";\n }\n if (typeof value === \"string\" || typeof value === \"number\") {\n return String(value);\n }\n if (Array.isArray(value)) return value.map(metadataTextValue).join(\"\");\n return \"\";\n}\n","import {\n type FigAssetResource,\n type FigAssetResourceList,\n type Props,\n} from \"@bgub/fig\";\nimport {\n assetResourceFromHostAttributes,\n assetResourceFromHostProps,\n assetResourceHostAttributes,\n assetResourceKey,\n isFigAssetResource,\n} from \"@bgub/fig/internal\";\nimport type { AssetResourceOwner } from \"@bgub/fig-reconciler\";\nimport { attachSubtree, detachSubtree } from \"./attachment.ts\";\nimport { MetadataClaims } from \"./metadata-claims.ts\";\nimport { updateElement } from \"./props.ts\";\nimport { elementName, isElementNode } from \"./tree.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\n\ninterface PersistentResourceEntry {\n count: number;\n element: Element;\n kind: \"persistent\";\n ready: Promise<void> | null;\n}\n\ntype MetadataResource = Extract<FigAssetResource, { kind: \"title\" | \"meta\" }>;\n\ntype DocumentResourceEntry = PersistentResourceEntry | MetadataClaims;\n\ninterface DocumentResourceMeta {\n key: string;\n kind: FigAssetResource[\"kind\"];\n}\n\ninterface DocumentResources {\n readonly entries: Map<string, DocumentResourceEntry>;\n readonly head: Element;\n}\n\nconst registries = new WeakMap<Element, DocumentResources>();\nconst resourceMeta = new WeakMap<Element, DocumentResourceMeta>();\n\nexport function commitAssetResources(\n previous: FigAssetResourceList | null,\n next: FigAssetResourceList | null,\n owner: AssetResourceOwner,\n): void {\n const registry = currentDocumentResources();\n if (registry === null) return;\n\n const previousByKey = canonicalResources(previous);\n const nextByKey = canonicalResources(next);\n\n for (const [key] of previousByKey) {\n if (!nextByKey.has(key)) releaseDeclaredResource(registry, key, owner);\n }\n\n for (const [key, resource] of nextByKey) {\n if (!previousByKey.has(key)) {\n acquireDeclaredResource(registry, resource, owner);\n } else if (resource.kind === \"title\" || resource.kind === \"meta\") {\n updateDeclaredMetadata(registry, key, resource, owner);\n }\n }\n}\n\n// Render-phase construction only. Acquisition waits for commit because a\n// render can be discarded. Persistent assets reserve a zero-count entry to\n// dedupe sibling work; metadata stays detached so it cannot mutate a winner.\nexport function adoptDocumentResource(\n type: string,\n props: Props,\n): Element | null {\n const registry = currentDocumentResources();\n const resource = assetResourceFromHostProps(type, props);\n if (registry === null || resource === null) return null;\n\n const key = assetResourceKey(resource);\n if (isMetadataResource(resource)) {\n const element = document.createElement(type);\n resourceMeta.set(element, { key, kind: resource.kind });\n return element;\n }\n\n const entry = registry.entries.get(key);\n if (entry?.kind === \"metadata\") {\n throw new Error(\"Expected a persistent resource entry.\");\n }\n const element =\n entry?.element ??\n findDocumentResource(registry, key) ??\n document.createElement(type);\n\n if (entry === undefined) {\n registry.entries.set(key, {\n count: 0,\n element,\n kind: \"persistent\",\n ready: null,\n });\n resourceMeta.set(element, { key, kind: resource.kind });\n }\n return element;\n}\n\nexport function acquireDocumentResource(\n element: Element,\n props: Props,\n owner: AssetResourceOwner,\n): Element {\n const registry = currentDocumentResources();\n if (registry === null) return element;\n\n const hostResource = assetResourceFromHostProps(elementName(element), props);\n if (hostResource !== null && isMetadataResource(hostResource)) {\n return acquireMetadataClaim(registry, hostResource, props, owner, element);\n }\n\n return acquirePersistentResource(registry, element);\n}\n\nfunction acquirePersistentResource(\n registry: DocumentResources,\n element: Element,\n): Element {\n // Deletions commit before placements, so a sibling's release in the same\n // commit may have dropped the element from the registry; re-derive its\n // identity from its attributes and revive it.\n let meta = resourceMeta.get(element);\n if (meta === undefined) {\n const resource = resourceFromElement(element);\n if (resource === null) return element;\n meta = { key: assetResourceKey(resource), kind: resource.kind };\n resourceMeta.set(element, meta);\n }\n\n const entry = registry.entries.get(meta.key);\n if (entry?.kind === \"metadata\") {\n throw new Error(\"Expected a persistent resource entry.\");\n }\n\n // A payload insertion may have claimed the key while this render was\n // suspended. Its live element is authoritative.\n if (entry !== undefined && entry.element !== element) {\n entry.count += 1;\n return attachDocumentResource(registry, entry.element);\n }\n\n if (entry === undefined) {\n registry.entries.set(meta.key, {\n count: 1,\n element,\n kind: \"persistent\",\n ready: null,\n });\n } else {\n entry.count += 1;\n }\n return attachDocumentResource(registry, element);\n}\n\nexport function releaseDocumentResource(\n element: Element,\n owner: AssetResourceOwner,\n): void {\n const registry = currentDocumentResources();\n const meta = resourceMeta.get(element);\n if (registry === null || meta === undefined) return;\n\n const entry = registry.entries.get(meta.key);\n\n if (entry?.kind === \"metadata\") {\n releaseMetadataClaim(registry, meta.key, entry, owner);\n return;\n }\n if (meta.kind === \"title\" || meta.kind === \"meta\") {\n resourceMeta.delete(element);\n removeReleasedResource(element);\n return;\n }\n\n releasePersistentResource(registry, element);\n}\n\nfunction releasePersistentResource(\n registry: DocumentResources,\n element: Element,\n): void {\n const meta = resourceMeta.get(element);\n if (meta === undefined) return;\n const entry = registry.entries.get(meta.key);\n\n // An element displaced by a rekey collision is untracked. Forget it unless\n // another key still references it; persistent browser effects stay live.\n if (entry === undefined || entry.element !== element) {\n if (registryReferencesElement(registry, element)) return;\n resourceMeta.delete(element);\n return;\n }\n\n if (entry.kind !== \"persistent\") {\n throw new Error(\"Expected a persistent resource entry.\");\n }\n if (entry.count > 0) entry.count -= 1;\n}\n\nexport function updateHoistedResource(\n element: Element,\n previousProps: Props,\n nextProps: Props,\n owner: AssetResourceOwner,\n): Element {\n const type = elementName(element);\n const resource = assetResourceFromHostProps(type, nextProps);\n const meta = resourceMeta.get(element);\n\n // Hoisted placement is static fiber state. Never let props that stop\n // classifying mutate either a shared delivery asset or a metadata claim.\n if (resource === null) {\n if (__DEV__) {\n const previous = assetResourceFromHostProps(type, previousProps);\n const identity =\n meta?.key ?? (previous === null ? null : assetResourceKey(previous));\n const label = identity === null ? \"\" : ` (asset \"${identity}\")`;\n throw new Error(\n `A hoisted <${type}>${label} cannot update into an ordinary in-tree element. Keep its asset classification stable or replace it with a different Fig element key.`,\n );\n }\n return element;\n }\n\n const key = assetResourceKey(resource);\n const registry = currentDocumentResources();\n if (registry === null) {\n updateElement(element, previousProps, nextProps);\n return element;\n }\n\n const entry = meta === undefined ? undefined : registry.entries.get(meta.key);\n if (entry?.kind === \"metadata\") {\n if (!isMetadataResource(resource) || key === meta?.key) {\n entry.update(\n owner,\n isMetadataResource(resource)\n ? metadataClaimProps(resource, nextProps)\n : nextProps,\n );\n return entry.element;\n }\n\n releaseDocumentResource(element, owner);\n const candidate = document.createElement(type);\n updateElement(candidate, {}, nextProps);\n if (resource.kind === \"title\") candidate.textContent = resource.value;\n resourceMeta.set(candidate, {\n key: assetResourceKey(resource),\n kind: resource.kind,\n });\n return acquireMetadataClaim(\n registry,\n resource,\n nextProps,\n owner,\n candidate,\n );\n }\n\n if (meta === undefined || key === meta.key) {\n updateElement(element, previousProps, nextProps);\n return element;\n }\n\n releaseDocumentResource(element, owner);\n\n const nextEntry = registry.entries.get(key);\n const claimed =\n nextEntry?.kind === \"persistent\" && nextEntry.count > 0\n ? nextEntry.element\n : undefined;\n const next = adoptDocumentResource(type, nextProps) ?? element;\n if (next === element) {\n updateElement(element, previousProps, nextProps);\n return element;\n }\n\n // A shared committed element is key-authoritative; only style a fresh or\n // otherwise unclaimed element.\n if (claimed !== next) updateElement(next, {}, nextProps);\n return acquireDocumentResource(next, nextProps, owner);\n}\n\n/**\n * Inserts render-discovered asset resources into the document head. Returns a\n * promise that settles when every newly discovered critical stylesheet loads\n * or errors; hints, scripts, fonts, and non-blocking styles never gate reveal.\n */\nexport function insertAssetResources(\n resources: readonly FigAssetResource[],\n): Promise<void> {\n const registry = currentDocumentResources();\n if (registry === null) return Promise.resolve();\n\n const gates: Promise<void>[] = [];\n for (const resource of resources) {\n if (!isFigAssetResource(resource)) continue;\n if (resource.kind === \"title\" || resource.kind === \"meta\") continue;\n\n const asset = asInsertableResource(resource);\n const key = assetResourceKey(asset);\n // A registry entry only counts as present while its element is attached:\n // a discarded render can leave a detached zero-count element built from\n // host props that need not match this descriptor (media, explicit-key\n // href), so a stale entry is discarded and replaced by a fresh element\n // created from the descriptor below.\n const tracked = registry.entries.get(key)?.element;\n const existing =\n (tracked?.parentNode === registry.head ? tracked : null) ??\n findDocumentResource(registry, key);\n\n if (existing !== null) {\n // Already present (SSR, a host-rendered element, or a prior call):\n // adopt it into the registry for O(1) future lookups. If it is still\n // loading, dependents join that pending gate. In dev, Vite may insert\n // a CSS link first; claim that still-loading element too so route\n // reveal waits for the stylesheet instead of committing a blank\n // payload slot.\n let entry = registry.entries.get(key);\n if (entry?.kind === \"metadata\") {\n throw new Error(\"Expected a persistent resource entry.\");\n }\n if (entry?.element !== existing) {\n entry = {\n count: 1,\n element: existing,\n kind: \"persistent\",\n ready: null,\n };\n registry.entries.set(key, entry);\n resourceMeta.set(existing, { key, kind: asset.kind });\n }\n const gate = gateExistingStylesheet(registry, asset, key, entry);\n if (gate !== null) gates.push(gate);\n continue;\n }\n\n const element = createDeliveryResourceElement(asset);\n const entry: PersistentResourceEntry = {\n count: 1,\n element,\n kind: \"persistent\",\n ready: null,\n };\n entry.ready = isCriticalStylesheet(asset)\n ? whenResourceSettled(element).then(() => {\n if (registry.entries.get(key) === entry) entry.ready = null;\n })\n : null;\n registry.entries.set(key, entry);\n resourceMeta.set(element, { key, kind: asset.kind });\n insertDocumentResource(registry, element);\n if (entry.ready !== null) gates.push(entry.ready);\n }\n\n return gates.length === 0\n ? Promise.resolve()\n : Promise.all(gates).then(() => undefined);\n}\n\nfunction currentDocumentResources(): DocumentResources | null {\n if (typeof document === \"undefined\" || document.head == null) return null;\n\n let registry = registries.get(document.head);\n if (registry === undefined) {\n registry = { entries: new Map(), head: document.head };\n registries.set(document.head, registry);\n }\n return registry;\n}\n\nfunction canonicalResources(\n resources: FigAssetResourceList | null,\n): Map<string, FigAssetResource> {\n const result = new Map<string, FigAssetResource>();\n if (resources === null) return result;\n\n const list = Array.isArray(resources) ? resources : [resources];\n for (const value of list) {\n if (!isFigAssetResource(value)) continue;\n const resource = asInsertableResource(value);\n const key = assetResourceKey(resource);\n if (!result.has(key) || isMetadataResource(resource)) {\n result.set(key, resource);\n }\n }\n return result;\n}\n\nfunction acquireDeclaredResource(\n registry: DocumentResources,\n resource: FigAssetResource,\n owner: AssetResourceOwner,\n): void {\n if (isMetadataResource(resource)) {\n acquireMetadataClaim(\n registry,\n resource,\n metadataResourceProps(resource),\n owner,\n );\n return;\n }\n\n const key = assetResourceKey(resource);\n const entry = registry.entries.get(key);\n if (entry?.kind === \"metadata\") {\n throw new Error(\"Expected a persistent resource entry.\");\n }\n const tracked = entry?.element;\n const element =\n tracked ??\n findDocumentResource(registry, key) ??\n createDeliveryResourceElement(resource);\n\n if (tracked === undefined) {\n registry.entries.set(key, {\n count: 0,\n element,\n kind: \"persistent\",\n ready: null,\n });\n resourceMeta.set(element, { key, kind: resource.kind });\n }\n\n acquirePersistentResource(registry, element);\n}\n\nfunction updateDeclaredMetadata(\n registry: DocumentResources,\n key: string,\n resource: MetadataResource,\n owner: AssetResourceOwner,\n): void {\n const entry = registry.entries.get(key);\n if (entry === undefined) {\n acquireDeclaredResource(registry, resource, owner);\n return;\n }\n if (entry.kind !== \"metadata\") {\n throw new Error(\"Expected a metadata resource entry.\");\n }\n entry.update(owner, metadataResourceProps(resource));\n}\n\nfunction releaseDeclaredResource(\n registry: DocumentResources,\n key: string,\n owner: AssetResourceOwner,\n): void {\n const entry = registry.entries.get(key);\n if (entry === undefined) return;\n if (entry.kind === \"metadata\") {\n releaseMetadataClaim(registry, key, entry, owner);\n } else {\n releasePersistentResource(registry, entry.element);\n }\n}\n\nfunction acquireMetadataClaim(\n registry: DocumentResources,\n resource: MetadataResource,\n props: Props,\n owner: AssetResourceOwner,\n candidate?: Element,\n): Element {\n const key = assetResourceKey(resource);\n const claimProps = metadataClaimProps(resource, props);\n let entry = registry.entries.get(key);\n\n if (entry?.kind === \"persistent\") {\n throw new Error(\"Expected a metadata resource entry.\");\n }\n\n if (entry === undefined) {\n const element =\n findDocumentResource(registry, key) ??\n candidate ??\n document.createElement(resource.kind);\n entry = new MetadataClaims(element, resource.kind, owner, claimProps);\n registry.entries.set(key, entry);\n resourceMeta.set(element, { key, kind: resource.kind });\n } else {\n entry.acquire(owner, claimProps);\n }\n\n return attachDocumentResource(registry, entry.element);\n}\n\nfunction releaseMetadataClaim(\n registry: DocumentResources,\n key: string,\n entry: MetadataClaims,\n owner: AssetResourceOwner,\n): void {\n if (entry.release(owner) === \"retained\") return;\n registry.entries.delete(key);\n resourceMeta.delete(entry.element);\n removeReleasedResource(entry.element);\n}\n\nfunction metadataResourceProps(resource: MetadataResource): Props {\n if (resource.kind === \"title\") return { children: resource.value };\n\n return {\n charset: resource.charset,\n content: resource.content,\n \"data-fig-resource-key\": resource.key,\n \"http-equiv\": resource[\"http-equiv\"],\n name: resource.name,\n property: resource.property,\n };\n}\n\nfunction metadataClaimProps(resource: MetadataResource, props: Props): Props {\n // The resource parser has already read promise-valued title children. Store\n // that resolved value so applying a claim cannot overwrite it with empty\n // text by inspecting the original thenable again during commit.\n return resource.kind === \"title\"\n ? { ...props, children: resource.value }\n : props;\n}\n\nfunction isMetadataResource(\n resource: FigAssetResource,\n): resource is MetadataResource {\n return resource.kind === \"title\" || resource.kind === \"meta\";\n}\n\nfunction attachDocumentResource(\n registry: DocumentResources,\n element: Element,\n): Element {\n if (element.parentNode !== registry.head) {\n insertDocumentResource(registry, element);\n }\n attachSubtree(element);\n return element;\n}\n\n// Stylesheets are grouped by precedence. Bucket order is set by first\n// discovery; later members join before the next bucket.\nfunction insertDocumentResource(\n registry: DocumentResources,\n element: Element,\n): void {\n const precedence = stylesheetPrecedence(element);\n if (precedence === null) {\n registry.head.appendChild(element);\n return;\n }\n\n let foundBucket = false;\n for (\n let child = registry.head.firstChild;\n child !== null;\n child = child.nextSibling\n ) {\n const current = isElementNode(child) ? stylesheetPrecedence(child) : null;\n if (current !== null) {\n if (current === precedence) foundBucket = true;\n else if (foundBucket) {\n registry.head.insertBefore(element, child);\n return;\n }\n }\n }\n registry.head.appendChild(element);\n}\n\nfunction findDocumentResource(\n registry: DocumentResources,\n key: string,\n): Element | null {\n for (\n let child = registry.head.firstChild;\n child !== null;\n child = child.nextSibling\n ) {\n if (isElementNode(child)) {\n const resource = resourceFromElement(child);\n if (resource !== null && assetResourceKey(resource) === key) return child;\n }\n }\n return null;\n}\n\nfunction registryReferencesElement(\n registry: DocumentResources,\n element: Element,\n): boolean {\n for (const entry of registry.entries.values()) {\n if (entry.element === element) return true;\n }\n return false;\n}\n\nfunction gateExistingStylesheet(\n registry: DocumentResources,\n resource: FigAssetResource,\n key: string,\n entry: PersistentResourceEntry,\n): Promise<void> | null {\n if (!isCriticalStylesheet(resource)) return null;\n if (entry.ready !== null) return entry.ready;\n if (!isPendingStylesheetElement(entry.element)) return null;\n\n const gate = whenResourceSettled(entry.element).then(() => {\n if (registry.entries.get(key) === entry) entry.ready = null;\n });\n entry.ready = gate;\n return gate;\n}\n\nfunction resourceFromElement(element: Element): FigAssetResource | null {\n return assetResourceFromHostAttributes(elementName(element), (name) =>\n element.getAttribute(name),\n );\n}\n\nfunction removeReleasedResource(element: Element): void {\n detachSubtree(element);\n element.parentNode?.removeChild(element);\n}\n\nfunction stylesheetPrecedence(element: Element): string | null {\n if (elementName(element) !== \"link\") return null;\n const resource = resourceFromElement(element);\n return resource?.kind === \"stylesheet\" ? (resource.precedence ?? \"\") : null;\n}\n\n// A font is delivered as <link rel=\"preload\" as=\"font\">, which parses back\n// to a preload resource. Normalize it to that shape so its key and DOM\n// round-trip match and it dedupes against SSR/host-rendered font preloads\n// (otherwise the font:<href> lookup key never matches the preload:font:<href>\n// a head <link> parses to, and a duplicate is appended).\nfunction asInsertableResource(resource: FigAssetResource): FigAssetResource {\n if (resource.kind !== \"font\") return resource;\n return {\n as: \"font\",\n crossorigin: resource.crossorigin ?? \"anonymous\",\n fetchpriority: resource.fetchpriority,\n href: resource.href,\n key: resource.key,\n kind: \"preload\",\n type: resource.type,\n };\n}\n\nfunction isCriticalStylesheet(resource: FigAssetResource): boolean {\n if (resource.kind !== \"stylesheet\" || resource.blocking === \"none\") {\n return false;\n }\n if (resource.media === undefined || resource.media === \"\") return true;\n return typeof matchMedia !== \"function\" || matchMedia(resource.media).matches;\n}\n\nfunction isPendingStylesheetElement(element: Element): boolean {\n return (\n elementName(element) === \"link\" &&\n element.getAttribute(\"rel\") === \"stylesheet\" &&\n \"sheet\" in element &&\n (element as { sheet: StyleSheet | null }).sheet === null\n );\n}\n\nfunction whenResourceSettled(element: Element): Promise<void> {\n return new Promise<void>((resolve) => {\n const settle = () => {\n element.removeEventListener(\"load\", settle);\n element.removeEventListener(\"error\", settle);\n resolve();\n };\n // Resolve on error too: a failed stylesheet must not block reveal forever.\n element.addEventListener(\"load\", settle);\n element.addEventListener(\"error\", settle);\n });\n}\n\nfunction createDeliveryResourceElement(resource: FigAssetResource): Element {\n const element = document.createElement(\n resource.kind === \"script\" ? \"script\" : \"link\",\n );\n for (const [name, value] of assetResourceHostAttributes(resource)) {\n element.setAttribute(name, value === true ? \"\" : value);\n }\n return element;\n}\n","import {\n SUSPENSE_CLIENT_MARKER,\n SUSPENSE_COMPLETED_MARKER,\n SUSPENSE_END_MARKER,\n SUSPENSE_PENDING_PREFIX,\n} from \"@bgub/fig/internal\";\nimport type {\n DehydratedSuspenseBoundary,\n DehydratedSuspenseError,\n} from \"@bgub/fig-reconciler\";\n\n// Parsing of the server's Suspense streaming markers (see\n// @bgub/fig/internal suspense-protocol) into dehydrated boundaries, plus the\n// DOM-range helpers that consume them.\n\ntype TextLike = Text | Comment;\n\ninterface SuspenseMarker {\n id: string | null;\n status: DehydratedSuspenseBoundary<Element, TextLike>[\"status\"];\n}\n\nexport function suspenseBoundaryFor(\n node: Element | TextLike,\n): DehydratedSuspenseBoundary<Element, TextLike> | null {\n if (!isComment(node)) return null;\n\n const marker = suspenseMarker(node);\n return marker === null ? null : suspenseBoundary(node, marker);\n}\n\nfunction suspenseBoundary(\n start: TextLike,\n initialMarker: SuspenseMarker,\n): DehydratedSuspenseBoundary<Element, TextLike> | null {\n const end = suspenseBoundaryEnd(start);\n if (end === null) return null;\n return {\n end,\n forceClientRender: false,\n id: initialMarker.id,\n start,\n get error() {\n return suspenseBoundaryError(start);\n },\n get status() {\n return suspenseMarker(start)?.status ?? initialMarker.status;\n },\n };\n}\n\nfunction suspenseMarker(node: unknown): SuspenseMarker | null {\n if (!isComment(node)) return null;\n\n if (node.data === SUSPENSE_COMPLETED_MARKER) {\n return { id: null, status: \"completed\" };\n }\n\n if (node.data === SUSPENSE_CLIENT_MARKER) {\n return { id: null, status: \"client-rendered\" };\n }\n\n const pending = node.data.startsWith(SUSPENSE_PENDING_PREFIX)\n ? node.data.slice(SUSPENSE_PENDING_PREFIX.length)\n : null;\n if (pending !== null && pending !== \"\") {\n return { id: pending, status: \"pending\" };\n }\n return null;\n}\n\nfunction suspenseBoundaryEnd(start: TextLike): TextLike | null {\n let depth = 0;\n\n for (\n let node: Node | null = start.nextSibling;\n node !== null;\n node = node.nextSibling\n ) {\n if (!isComment(node)) continue;\n\n if (suspenseMarker(node) !== null) {\n depth += 1;\n continue;\n }\n\n if (node.data !== SUSPENSE_END_MARKER) continue;\n if (depth === 0) return node;\n depth -= 1;\n }\n\n return null;\n}\n\nfunction suspenseBoundaryError(\n start: TextLike,\n): DehydratedSuspenseError | null {\n const placeholder = start.nextSibling;\n if (!hasDataset(placeholder)) return null;\n\n return {\n digest: placeholder.dataset.dgst,\n message: placeholder.dataset.msg,\n };\n}\n\n// Event-target boundary discovery walks outward from the target instead of\n// searching the tree: at each ancestor level, scanning the preceding siblings\n// right-to-left, an end marker closes over a boundary that sits entirely\n// before the target, so a start marker reached at depth zero is unmatched and\n// its range encloses the target. Passing a returned start marker back in\n// resumes the search at the next enclosing boundary (needed when a marker has\n// no live fiber because it is nested inside an outer dehydrated boundary).\nexport function enclosingSuspenseBoundaryStart(\n target: unknown,\n): TextLike | null {\n if (!isNode(target)) return null;\n\n for (let node: Node | null = target; node !== null; node = node.parentNode) {\n let depth = 0;\n\n for (\n let sibling = node.previousSibling;\n sibling !== null;\n sibling = sibling.previousSibling\n ) {\n if (!isComment(sibling)) continue;\n\n if (sibling.data === SUSPENSE_END_MARKER) {\n depth += 1;\n continue;\n }\n\n if (suspenseMarker(sibling) === null) continue;\n if (depth === 0) return sibling;\n depth -= 1;\n }\n }\n\n return null;\n}\n\nexport function isWithinSuspenseBoundary(\n target: unknown,\n boundary: DehydratedSuspenseBoundary<Element, TextLike>,\n): boolean {\n if (!isNode(target)) return false;\n\n const startParent = boundary.start.parentNode;\n const endParent = boundary.end.parentNode;\n if (startParent === null && endParent === null) return false;\n\n for (let node: Node | null = target; node !== null; node = node.parentNode) {\n if (node === boundary.start || node === boundary.end) return false;\n\n if (startParent !== null && node.parentNode === startParent) {\n return isSiblingAfterStartBeforeEnd(node, boundary.start, boundary.end);\n }\n if (\n endParent !== null &&\n endParent !== startParent &&\n node.parentNode === endParent\n ) {\n return isSiblingBeforeEnd(node, boundary.end);\n }\n }\n\n return false;\n}\n\nfunction isSiblingAfterStartBeforeEnd(\n node: Node,\n start: Node,\n end: Node,\n): boolean {\n for (\n let sibling: Node | null = node;\n sibling !== null;\n sibling = sibling.previousSibling\n ) {\n if (sibling === start) return true;\n if (sibling === end) return false;\n }\n\n return false;\n}\n\nfunction isSiblingBeforeEnd(node: Node, end: Node): boolean {\n for (\n let sibling: Node | null = node;\n sibling !== null;\n sibling = sibling.nextSibling\n ) {\n if (sibling === end) return true;\n }\n\n return false;\n}\n\nexport function removeSuspenseBoundaryRange(\n boundary: DehydratedSuspenseBoundary<Element, TextLike>,\n): void {\n for (let node: Node | null = boundary.start; node !== null;) {\n const next: Node | null = node.nextSibling;\n removeNode(node);\n if (node === boundary.end) return;\n node = next;\n }\n}\n\nexport function removeNode(node: Node): void {\n node.parentNode?.removeChild(node);\n}\n\nfunction isComment(node: unknown): node is Comment {\n return (\n typeof node === \"object\" &&\n node !== null &&\n \"data\" in node &&\n \"nodeType\" in node &&\n node.nodeType === 8\n );\n}\n\nfunction hasDataset(\n node: unknown,\n): node is Element & { dataset: DOMStringMap } {\n return typeof node === \"object\" && node !== null && \"dataset\" in node;\n}\n\nfunction isNode(value: unknown): value is Node {\n return typeof value === \"object\" && value !== null && \"parentNode\" in value;\n}\n","import type { Props } from \"@bgub/fig\";\nimport {\n ACTIVITY_TEMPLATE_ATTRIBUTE,\n HYDRATION_SKIP_ATTRIBUTE,\n TEXT_SEPARATOR_DATA,\n validateInstanceNesting,\n validateTextNesting,\n} from \"@bgub/fig/internal\";\nimport {\n createRenderer,\n type FigRenderer,\n type HostConfig,\n} from \"@bgub/fig-reconciler\";\nimport {\n acquireDocumentResource,\n adoptDocumentResource,\n commitAssetResources,\n releaseDocumentResource,\n updateHoistedResource,\n} from \"./asset-resources.ts\";\nimport { attachSubtree, detachSubtree } from \"./attachment.ts\";\nimport { resumeBind, suspendBind } from \"./bind.ts\";\nimport {\n type Container,\n disableRootHydration,\n registerPortalContainer,\n removePortalContainer,\n replayQueuedEvents,\n setEventBatching,\n} from \"./events.ts\";\nimport {\n shouldRestoreControlledFormState,\n updateParentSelect,\n} from \"./form-controls.ts\";\nimport { hydrateElement, updateElement } from \"./props.ts\";\nimport { configureDomRefreshScheduler } from \"./refresh-internal.ts\";\nimport {\n enclosingSuspenseBoundaryStart,\n isWithinSuspenseBoundary,\n removeNode,\n removeSuspenseBoundaryRange,\n suspenseBoundaryFor,\n} from \"./suspense-markers.ts\";\nimport {\n elementName,\n htmlNamespace,\n isElementNode,\n isEmptyPropValue,\n mathNamespace,\n svgNamespace,\n} from \"./tree.ts\";\n\ntype TextLike = Text | Comment;\ntype HydrationNode = Element | TextLike | DocumentType;\ntype RetriableSuspenseMarker = TextLike & { __figRetry?: () => void };\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\n\nfunction isDocumentContainer(container: Container): container is Document {\n return container.nodeType === 9;\n}\n\nconst hostConfig: HostConfig<Container, Element, TextLike> = {\n createInstance: createDomElement,\n createTextInstance: (text) => document.createTextNode(text),\n // The dev gates below run at call time (never at module scope, which\n // would throw on import wherever bundler defines don't apply). They must\n // stay in block form — `if (dev) { validate() }` — not early-return form:\n // esbuild only eliminates the constant branch (and with it the dom-nesting\n // module import) at parse time, before symbol retention is decided; code\n // after an `if (prod) return` keeps the import referenced and ships the\n // whole module in production bundles.\n validateInstanceNesting: (type, _props, ancestors) => {\n if (__DEV__) {\n validateInstanceNesting(type, ancestors);\n }\n },\n validateTextNesting: (text, ancestors) => {\n if (__DEV__) {\n validateTextNesting(text, ancestors);\n }\n },\n containerType: (container) =>\n isElementNode(container) ? elementName(container) : null,\n appendInitialChild: (parent, child) => {\n parent.appendChild(child);\n // Render-phase assembly: the select is not live yet, so applying its\n // default to options that assemble after it is always safe. Only\n // option-bearing children can change a selection.\n if (isElementNode(child) && optionLike(child)) {\n updateParentSelect(child, true);\n }\n },\n finalizeInitialInstance: (instance, props) =>\n updateElement(instance, {}, props, { initial: true }),\n setTextContent: (instance, text) => {\n if (instance.textContent !== text) instance.textContent = text;\n },\n getFirstHydratableChild: hydratableFirstChild,\n getNextHydratableSibling: (node) =>\n nextHydratableNode(node.nextSibling as HydrationNode | null),\n canHydrateInstance: isHydratableElement,\n canHydrateTextInstance: (node, text, suppressHydrationWarning) =>\n isHydratableText(node) &&\n (suppressHydrationWarning === true || node.nodeValue === text),\n // Password managers and other browser extensions can append their own roots\n // before hydration. Html, head, and body are document singletons, so retain\n // an unmatched tail instead of clearing the document and its stylesheets.\n canRetainHydrationTail: (instance) => {\n const name = elementName(instance);\n return name === \"html\" || name === \"head\" || name === \"body\";\n },\n // Hoisted asset resources never appear at their fiber's server position\n // (the server registers them and emits nothing inline): hydration must not\n // match them against the DOM cursor, and commit acquires/releases them in\n // the head registry instead of inserting/removing at the fiber position.\n resolveHoistedInstance: (type, props, parent) => {\n if (namespaceFor(type, parent) !== htmlNamespace) return null;\n return adoptDocumentResource(type, props);\n },\n commitHoistedInstance: acquireDocumentResource,\n commitAssetResources,\n removeHoistedInstance: releaseDocumentResource,\n updateHoistedInstance: updateHoistedResource,\n shouldCommitUpdate: (type, _previousProps, nextProps) =>\n shouldRestoreControlledFormState(type, nextProps),\n clearContainer: (container) => {\n let child = container.firstChild as HydrationNode | null;\n\n while (child !== null) {\n const next = child.nextSibling as HydrationNode | null;\n if (child.nodeType !== 10) {\n detachSubtree(child);\n container.removeChild(child);\n }\n child = next;\n }\n\n // A cleared container (hydration-mismatch recovery) detaches every\n // queued replayable event's target; drain them.\n queueMicrotask(replayQueuedEvents);\n },\n insertBefore: (parent, child, before) => {\n parent.insertBefore(child, before);\n // Live insertion: re-assert a controlled select's value, but never\n // re-apply an uncontrolled default — the user owns the live selection\n // (defaults are mount-time only, matching React).\n if (isElementNode(child) && optionLike(child)) updateParentSelect(child);\n attachSubtree(child);\n },\n removeChild: (parent, child) => {\n detachSubtree(child);\n parent.removeChild(child);\n },\n commitTextUpdate: (text, value) => {\n if (text.nodeValue !== value) text.nodeValue = value;\n },\n commitUpdate: updateElement,\n commitHydratedInstance: hydrateElement,\n getActivityBoundary: activityBoundary,\n getFirstActivityHydratable: (boundary) =>\n nextHydratableNode(\n (activityTemplateContent(boundary).firstChild ??\n null) as HydrationNode | null,\n ),\n commitHydratedActivityBoundary: (boundary) => {\n const parent = boundary.parentNode;\n if (parent === null) return;\n\n const content = activityTemplateContent(boundary);\n while (content.firstChild !== null) {\n parent.insertBefore(content.firstChild, boundary);\n }\n parent.removeChild(boundary);\n },\n hideInstance: (instance) => {\n suspendBind(instance);\n (instance as HTMLElement).style.setProperty(\"display\", \"none\", \"important\");\n },\n unhideInstance: (instance, props) => {\n const display = props.style?.display;\n (instance as HTMLElement).style.setProperty(\n \"display\",\n typeof display === \"string\" ? display : \"\",\n );\n resumeBind(instance);\n },\n hideTextInstance: (text) => {\n text.nodeValue = \"\";\n },\n unhideTextInstance: (text, value) => {\n if (text.nodeValue !== value) text.nodeValue = value;\n },\n getSuspenseBoundary: suspenseBoundaryFor,\n getEnclosingSuspenseBoundaryStart: enclosingSuspenseBoundaryStart,\n isTargetWithinSuspenseBoundary: isWithinSuspenseBoundary,\n shouldRecoverSuspenseMismatchAtRoot: (container, boundary) =>\n isDocumentContainer(container) &&\n isWithinSuspenseBoundary(container.documentElement, boundary),\n registerSuspenseBoundaryRetry: (boundary, retry) => {\n (boundary.start as RetriableSuspenseMarker).__figRetry = retry;\n },\n commitHydratedSuspenseBoundary: (boundary) => {\n if (boundary.status === \"completed\" && !boundary.forceClientRender) {\n removeNode(boundary.start);\n removeNode(boundary.end);\n } else {\n removeSuspenseBoundaryRange(boundary);\n }\n\n queueMicrotask(replayQueuedEvents);\n },\n removeDehydratedSuspenseBoundary: (boundary) => {\n // The replay pass drops queued events whose targets left the tree with\n // the boundary.\n removeSuspenseBoundaryRange(boundary);\n queueMicrotask(replayQueuedEvents);\n },\n completeRootHydration: (container) => {\n disableRootHydration(container);\n // Non-discrete early events blocked on the pre-commit shell have no\n // boundary hook to re-drain them; root completion is their backstop.\n queueMicrotask(replayQueuedEvents);\n },\n preparePortalContainer: registerPortalContainer,\n removePortalContainer,\n};\n\nexport const domRenderer: FigRenderer<Container, Element> =\n createRenderer(hostConfig);\nsetEventBatching(domRenderer.batchedUpdates);\nconfigureDomRefreshScheduler(domRenderer.scheduleRefresh);\n\n// Real templates hold children in a content fragment; test doubles hold\n// them directly.\nfunction activityTemplateContent(boundary: Element): ParentNode {\n return \"content\" in boundary ? (boundary.content as ParentNode) : boundary;\n}\n\nfunction activityBoundary(node: Element | TextLike): Element | null {\n return isElementNode(node) &&\n elementName(node) === \"template\" &&\n node.getAttribute(ACTIVITY_TEMPLATE_ATTRIBUTE) !== null\n ? node\n : null;\n}\n\nfunction isHydratableElement(\n node: Element | TextLike,\n type: string,\n props: Props,\n): boolean {\n if (!isElementNode(node) || !(\"setAttribute\" in node)) return false;\n if (elementName(node) !== type.toLowerCase()) return false;\n return hasMatchingUnsafeHTML(node, props);\n}\n\nfunction createDomElement(\n type: string,\n _props: Props,\n parent: Container | Element,\n): Element {\n const namespace = namespaceFor(type, parent);\n return namespace === htmlNamespace\n ? document.createElement(type)\n : document.createElementNS(namespace, type);\n}\n\nfunction namespaceFor(type: string, parent: Container | Element): string {\n const normalizedType = type.toLowerCase();\n if (normalizedType === \"svg\") return svgNamespace;\n if (normalizedType === \"math\") return mathNamespace;\n\n return \"namespaceURI\" in parent && elementName(parent) !== \"foreignobject\"\n ? (parent.namespaceURI ?? htmlNamespace)\n : htmlNamespace;\n}\n\nfunction hydratableFirstChild(\n parent: Container | Element,\n props?: Props,\n): Element | TextLike | null {\n if (props !== undefined && unsafeHTMLValue(props) !== null) return null;\n\n if (\n elementName(parent) === \"textarea\" &&\n props !== undefined &&\n hasManagedTextareaContent(props)\n ) {\n return null;\n }\n\n return nextHydratableNode(parent.firstChild as HydrationNode | null);\n}\n\n// The server writes a text-separator comment (TEXT_SEPARATOR_DATA, the\n// shared protocol constant) between adjacent text nodes that come from\n// different fibers. The hydration cursor steps over separators when\n// advancing; only comments with exactly this data are skipped, so the\n// fig:suspense marker comments are never affected.\n// A DocumentType is document metadata rather than content represented by a\n// fiber, so full-document hydration advances through it to the existing html\n// element. This also matters when a root Suspense marker precedes the doctype.\n// Server-owned elements carrying the shared skip marker likewise have no\n// in-tree hydration fiber; the DOM renderer need not know why each exists.\nfunction nextHydratableNode(\n node: HydrationNode | null,\n): Element | TextLike | null {\n let current = node;\n while (\n current !== null &&\n (isTextSeparator(current) ||\n current.nodeType === 10 ||\n isServerOwnedNode(current))\n ) {\n current = current.nextSibling as HydrationNode | null;\n }\n return current as Element | TextLike | null;\n}\n\nfunction isServerOwnedNode(node: HydrationNode): boolean {\n return (\n isElementNode(node) && node.getAttribute(HYDRATION_SKIP_ATTRIBUTE) !== null\n );\n}\n\nfunction isTextSeparator(node: HydrationNode): boolean {\n return node.nodeType === 8 && node.nodeValue === TEXT_SEPARATOR_DATA;\n}\n\nfunction hasManagedTextareaContent(props: Props): boolean {\n return props.value !== undefined || props.defaultValue !== undefined;\n}\n\nfunction unsafeHTMLValue(props: Props): unknown {\n return isEmptyPropValue(props.unsafeHTML) ? null : props.unsafeHTML;\n}\n\nfunction hasMatchingUnsafeHTML(element: Element, props: Props): boolean {\n const expected = unsafeHTMLValue(props);\n if (expected === null) return true;\n return typeof expected !== \"string\" || \"innerHTML\" in element;\n}\n\nfunction isHydratableText(node: Element | TextLike): boolean {\n return node.nodeType === 3;\n}\n\nfunction optionLike(element: Element): boolean {\n const name = elementName(element);\n return name === \"option\" || name === \"optgroup\";\n}\n"],"mappings":"ovBAIA,SAAgB,GACd,EACA,EACM,CACN,GAAI,CAAC,EAAc,CAAI,EAAG,OAK1B,IAAM,EAAsB,CAAC,EAC7B,GAAsB,EAAM,CAAQ,EACpC,IAAK,IAAM,KAAW,EACpB,EAAQ,CAAO,CAEnB,CAEA,SAAS,GAAsB,EAAe,EAA2B,CACvE,EAAS,KAAK,CAAI,EAElB,IAAK,IAAI,EAAQ,EAAK,WAAY,IAAU,KAAM,EAAQ,EAAM,YAC1D,EAAc,CAAK,GAAG,GAAsB,EAAO,CAAQ,CAEnE,CAEA,SAAgB,EAAc,EAAgC,CAC5D,OACE,OAAO,GAAS,YAChB,GACA,aAAc,GACd,EAAK,WAAa,CAEtB,CAEA,SAAgB,EAAY,EAAuB,CAGjD,OAFK,EAAc,CAAI,EAEhB,cAAe,GAAQ,OAAO,EAAK,WAAc,SACpD,EAAK,UAAU,YAAY,EAC3B,YAAa,GAAQ,OAAO,EAAK,SAAY,SAC3C,EAAK,QAAQ,YAAY,EACzB,GAN2B,EAOnC,CAEA,SAAgB,GAAc,EAA2B,CACvD,OACE,EAAQ,eAAiB,MAAQ,EAAQ,eAAA,8BAE7C,CAOA,SAAgB,EAAS,EAAwB,CAC/C,OAAO,OAAO,GAAS,UAAY,GAAiB,eAAgB,EAChE,EAAK,WACL,IACN,CAKA,SAAgB,EAAiB,EAAyB,CACxD,OAAO,GAAU,MAA+B,IAAU,EAC5D,CClDA,MAAM,EAAY,IAAI,QAIhB,EAAwB,IAAI,QAElC,SAAgB,GACd,GAAG,EACM,CACT,IAAM,EAAY,EAAM,OACrB,GAA0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vD,OACE,EAAc,CAAI,GAAK,EAAK,aAAa,CAAwB,IAAM,IAE3E,CAEA,SAAS,GAAgB,EAA8B,CACrD,OAAO,EAAK,WAAa,GAAK,EAAK,YAAc,CACnD,CAEA,SAAS,GAA0B,EAAuB,CACxD,OAAO,EAAM,QAAU,IAAA,IAAa,EAAM,eAAiB,IAAA,EAC7D,CAEA,SAAS,GAAgB,EAAuB,CAC9C,OAAO,EAAiB,EAAM,UAAU,EAAI,KAAO,EAAM,UAC3D,CAEA,SAAS,GAAsB,EAAkB,EAAuB,CACtE,IAAM,EAAW,GAAgB,CAAK,EAEtC,OADI,IAAa,MACV,OAAO,GAAa,UAAY,cAAe,CACxD,CAEA,SAAS,GAAiB,EAAmC,CAC3D,OAAO,EAAK,WAAa,CAC3B,CAEA,SAAS,GAAW,EAA2B,CAC7C,IAAM,EAAO,EAAY,CAAO,EAChC,OAAO,IAAS,UAAY,IAAS,UACvC"}
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./renderer-C0R0O1QP.js";import{VIEW_TRANSITION_PENDING_PROPERTY as t,VIEW_TRANSITION_TIMEOUT_MS as n}from"@bgub/fig/internal";import{createViewTransitionCommitCoordinator as r}from"@bgub/fig-reconciler/view-transitions";const i=new WeakMap;function a(e,t,n){let r={name:t};return i.set(r,{owner:e.ownerDocument,snapshots:n}),r}function o(e){let t=i.get(e);if(t===void 0)throw Error(`The view-transition surface was not created by Fig DOM. Read pseudo elements from a surface passed to <ViewTransition onTransition>.`);let n=c(e.name),r=e=>s(t.owner.documentElement,`::view-transition-${e}(${n})`);return{group:r(`group`),imagePair:r(`image-pair`),new:t.snapshots.new?r(`new`):null,old:t.snapshots.old?r(`old`):null}}function s(e,t){return{selector:t,animate(n,r){let i=typeof r==`number`?{duration:r,pseudoElement:t}:{...r,pseudoElement:t};return e.animate(n,i)},getAnimations(){return e.getAnimations({subtree:!0}).filter(n=>{let r=n.effect;return r!==null&&`target`in r&&r.target===e&&`pseudoElement`in r&&r.pseudoElement===t})},getComputedStyle(){return e.ownerDocument.defaultView?.getComputedStyle(e,t)??getComputedStyle(e,t)}}}function c(e){return globalThis.CSS?.escape?.(e)??e}function l(e,t,n,r,i,a){let o=b(e),s=o.startViewTransition?.bind(o);if(s===void 0)return!1;let c=!1,l=!1,_=!1,v=null,y=null,x=h(i),S=h(a),C=()=>{v?.(),x(!1),S()},w=()=>{n();try{let e=()=>{c=!0,y=r(),y.cancelRootSnapshot&&(v=u(o))},n=s(t.length===0?e:{types:[...t],update:e});n!==void 0&&(f(o,n),d(o,n,()=>y));let i=g(n);i===void 0?C():(n?.ready===void 0?m(i,()=>x(!1)):n.ready.then(()=>x(!0),()=>x(!1)),m(i,()=>{v?.(),S()}))}catch(e){if(!c){if(l){c=!0;try{r()}finally{C()}}else _=!0,C();return}if(C(),!l)throw e;setTimeout(()=>{throw e})}};return p(o,w)?(l=!0,`deferred`):(w(),_?!1:c?`committed`:`deferred`)}function u(e){let t=e.documentElement,n=t.style,r=n.viewTransitionName??``;return n.viewTransitionName=`none`,()=>{n.viewTransitionName=r,t.getAttribute(`style`)===``&&t.removeAttribute(`style`)}}function d(e,t,n){let r=[],i=()=>{for(let e of r)try{e.cancel()}catch{}r.length=0},a=()=>{let t=n();if(t===null||t.canceledNames.length===0&&!t.cancelRootSnapshot)return;let i=e.documentElement;if(typeof i.animate!=`function`)return;let a=e=>{typeof e?.cancel==`function`&&r.push(e)},o=e=>{a(i.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(${e})`}))};try{for(let e of t.canceledNames)o(c(e));t.cancelRootSnapshot&&(o(`root`),a(i.animate({height:[0,0],width:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})))}catch{}},o=t.ready??t.finished;o===void 0?a():o.then(a,()=>void 0),m(g(t),i)}function f(e,n){e[t]=n,m(g(n),()=>{e[t]===n&&(e[t]=null)})}function p(e,r){let i=e[t];if(i==null)return!1;let a=g(i);if(a===void 0)return!1;let o=!0;function s(){o&&(o=!1,clearTimeout(c),e[t]===i&&(e[t]=null),r())}let c=setTimeout(s,n);return m(a,s),!0}function m(e,t){e===void 0?t():e.then(t,t)}function h(e){let t=!1;return(...n)=>{t||(t=!0,e(...n))}}function g(e){return e?.finished??e?.ready}function _(e){if(typeof e.getBoundingClientRect!=`function`)return null;let t=e.getBoundingClientRect(),n=e.ownerDocument?.defaultView??null,r=n===null||t.bottom>=0&&t.right>=0&&t.top<=n.innerHeight&&t.left<=n.innerWidth,i=!1;try{i=n?.getComputedStyle(e).position===`absolute`}catch{}return{absolutelyPositioned:i,height:t.height,inViewport:r,width:t.width,x:t.left,y:t.top}}function v(e,t,n){let r=e.style;r.viewTransitionName=c(t),n!==null&&(r.viewTransitionClass=n)}function y(e,t){let n=e.style,r=t.style,i=r?.viewTransitionName??r?.[`view-transition-name`],a=r?.viewTransitionClass??r?.[`view-transition-class`];n.viewTransitionName=x(i),n.viewTransitionClass=x(a)}function b(e){return e.ownerDocument??document}function x(e){return typeof e==`string`||typeof e==`number`?String(e).trim():``}const S=r({commit:l,apply:v,restore:y,measure:_,createSurface:a,suspend(e,t){return p(b(e),t)}});function C(){e.installCommitCoordinator(S)}export{C as enableViewTransitions,o as getViewTransitionPseudoElements};
2
+ //# sourceMappingURL=view-transitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-transitions.js","names":[],"sources":["../src/view-transition-pseudos.ts","../src/view-transition.ts","../src/view-transitions.ts"],"sourcesContent":["import type { ViewTransitionSurface } from \"@bgub/fig\";\nimport type { ViewTransitionSurfaceSnapshots } from \"@bgub/fig-reconciler/view-transitions\";\n\nexport interface ViewTransitionPseudoElement {\n readonly selector: string;\n animate(\n keyframes: Keyframe[] | PropertyIndexedKeyframes | null,\n options?: number | KeyframeAnimationOptions,\n ): Animation;\n getAnimations(): Animation[];\n getComputedStyle(): CSSStyleDeclaration;\n}\n\nexport interface ViewTransitionPseudoElements {\n readonly group: ViewTransitionPseudoElement;\n readonly imagePair: ViewTransitionPseudoElement;\n readonly new: ViewTransitionPseudoElement | null;\n readonly old: ViewTransitionPseudoElement | null;\n}\n\nconst domSurfaces = new WeakMap<\n ViewTransitionSurface,\n { owner: Document; snapshots: ViewTransitionSurfaceSnapshots }\n>();\n\nexport function createDOMViewTransitionSurface(\n element: Element,\n name: string,\n snapshots: ViewTransitionSurfaceSnapshots,\n): ViewTransitionSurface {\n const surface: ViewTransitionSurface = { name };\n domSurfaces.set(surface, { owner: element.ownerDocument, snapshots });\n return surface;\n}\n\nexport function getViewTransitionPseudoElements(\n surface: ViewTransitionSurface,\n): ViewTransitionPseudoElements {\n const resolved = domSurfaces.get(surface);\n if (resolved === undefined) {\n throw new Error(\n \"The view-transition surface was not created by Fig DOM. Read pseudo \" +\n \"elements from a surface passed to <ViewTransition onTransition>.\",\n );\n }\n\n const name = escapeViewTransitionName(surface.name);\n const pseudo = (kind: string): ViewTransitionPseudoElement =>\n createPseudoElement(\n resolved.owner.documentElement,\n `::view-transition-${kind}(${name})`,\n );\n return {\n group: pseudo(\"group\"),\n imagePair: pseudo(\"image-pair\"),\n new: resolved.snapshots.new ? pseudo(\"new\") : null,\n old: resolved.snapshots.old ? pseudo(\"old\") : null,\n };\n}\n\nfunction createPseudoElement(\n element: HTMLElement,\n selector: string,\n): ViewTransitionPseudoElement {\n return {\n selector,\n animate(keyframes, options): Animation {\n const resolvedOptions: KeyframeAnimationOptions =\n typeof options === \"number\"\n ? { duration: options, pseudoElement: selector }\n : { ...options, pseudoElement: selector };\n return element.animate(keyframes, resolvedOptions);\n },\n getAnimations(): Animation[] {\n return element.getAnimations({ subtree: true }).filter((animation) => {\n const effect = animation.effect;\n return (\n effect !== null &&\n \"target\" in effect &&\n effect.target === element &&\n \"pseudoElement\" in effect &&\n effect.pseudoElement === selector\n );\n });\n },\n getComputedStyle(): CSSStyleDeclaration {\n return (\n element.ownerDocument.defaultView?.getComputedStyle(\n element,\n selector,\n ) ?? getComputedStyle(element, selector)\n );\n },\n };\n}\n\nexport function escapeViewTransitionName(name: string): string {\n return globalThis.CSS?.escape?.(name) ?? name;\n}\n","import type { Props } from \"@bgub/fig\";\nimport {\n VIEW_TRANSITION_PENDING_PROPERTY,\n VIEW_TRANSITION_TIMEOUT_MS,\n} from \"@bgub/fig/internal\";\nimport type {\n ViewTransitionCommitResult,\n ViewTransitionHostConfig,\n ViewTransitionMutationResult,\n ViewTransitionSurfaceMeasurement,\n} from \"@bgub/fig-reconciler/view-transitions\";\nimport type { Container } from \"./events.ts\";\nimport {\n createDOMViewTransitionSurface,\n escapeViewTransitionName,\n} from \"./view-transition-pseudos.ts\";\n\ninterface RunningViewTransition {\n finished?: Promise<unknown>;\n ready?: Promise<unknown>;\n}\n\ninterface CancellableAnimation {\n cancel(): void;\n}\n\ntype ViewTransitionDocument = Document & {\n [VIEW_TRANSITION_PENDING_PROPERTY]?: RunningViewTransition | null;\n};\n\nfunction commitViewTransition(\n container: Container,\n types: readonly string[],\n prepareSnapshot: () => void,\n mutate: () => ViewTransitionMutationResult,\n onReady: (active: boolean) => void,\n onFinished: () => void,\n): ViewTransitionCommitResult {\n const owner = ownerDocument(container);\n const start = owner.startViewTransition?.bind(owner);\n if (start === undefined) return false;\n\n let didMutate = false;\n let chained = false;\n let failedBeforeMutate = false;\n let restoreRootName: (() => void) | null = null;\n let mutationResult: ViewTransitionMutationResult | null = null;\n const notifyReady = once(onReady);\n const notifyFinished = once(onFinished);\n const finishUnanimated = (): void => {\n restoreRootName?.();\n notifyReady(false);\n notifyFinished();\n };\n\n const run = (): void => {\n prepareSnapshot();\n try {\n const update = () => {\n didMutate = true;\n mutationResult = mutate();\n // Before the new capture: when measurement shows every change is\n // contained in a named boundary, drop the root's own snapshot so the\n // page-wide overlay does not swallow pointer events for the\n // animation's duration.\n if (mutationResult.cancelRootSnapshot) {\n restoreRootName = cancelRootViewTransitionName(owner);\n }\n };\n const transition = start(\n types.length === 0 ? update : { types: [...types], update },\n );\n if (transition !== undefined) {\n registerPendingTransition(owner, transition);\n hideCanceledSnapshots(owner, transition, () => mutationResult);\n }\n // Root-name restore waits for the transition to fully settle: putting\n // `view-transition-name: root` back on the live <html> while the\n // transition still runs can re-associate the live root with its\n // (force-hidden) captured group, which paints the page blank for the\n // rest of the animation.\n const settleAfterTransition = transitionSettled(transition);\n if (settleAfterTransition === undefined) {\n finishUnanimated();\n } else {\n if (transition?.ready === undefined) {\n onSettled(settleAfterTransition, () => notifyReady(false));\n } else {\n transition.ready.then(\n () => notifyReady(true),\n () => notifyReady(false),\n );\n }\n const finish = (): void => {\n restoreRootName?.();\n notifyFinished();\n };\n onSettled(settleAfterTransition, finish);\n }\n } catch (error) {\n if (!didMutate) {\n // A chained run has no caller to report a fallback to and the\n // reconciler stays frozen until mutate runs: commit unanimated.\n // A synchronous run reports `false` so the caller falls back.\n if (chained) {\n didMutate = true;\n try {\n mutate();\n } finally {\n finishUnanimated();\n }\n } else {\n failedBeforeMutate = true;\n finishUnanimated();\n }\n return;\n }\n finishUnanimated();\n if (!chained) throw error;\n // Chained commit errors were already routed by the reconciler's\n // deferred-commit handling; a residual throw here is a transition\n // failure that must not vanish into the pending promise.\n setTimeout(() => {\n throw error;\n });\n }\n };\n\n // Serialize per document: starting a transition while one is running makes\n // the browser abruptly skip the running animation, and the skipped\n // transition's restore could race this one's old-state capture. The\n // reconciler normally parks eligible commits upstream (render-during-wait\n // via the adapter's suspend hook), so for fig-dom this chain is a fallback\n // for renderers that wire commit without suspend — chaining freezes the root\n // until the previous animation settles or times out; parking keeps\n // rendering live.\n if (waitForActiveViewTransition(owner, run)) {\n chained = true;\n return \"deferred\";\n }\n\n run();\n if (failedBeforeMutate) return false;\n return didMutate ? \"committed\" : \"deferred\";\n}\n\n// Remove the root element from the new capture, remembering how to restore\n// the author's inline style afterwards.\nfunction cancelRootViewTransitionName(\n owner: ViewTransitionDocument,\n): () => void {\n const element = owner.documentElement;\n const style = element.style;\n const previous = style.viewTransitionName ?? \"\";\n style.viewTransitionName = \"none\";\n\n return () => {\n style.viewTransitionName = previous;\n if (element.getAttribute(\"style\") === \"\") element.removeAttribute(\"style\");\n };\n}\n\n// Old snapshots were captured before the update callback ran and cannot be\n// un-captured; once the pseudo tree exists (ready), hide the groups of\n// measurement-canceled boundaries — and the root group plus the\n// ::view-transition overlay when the whole-page snapshot was dropped — with\n// filling zero-duration animations so untouched regions stay interactive\n// while the remaining groups animate. Mirrors React's\n// cancelViewTransitionName / cancelRootViewTransitionName.\nfunction hideCanceledSnapshots(\n owner: ViewTransitionDocument,\n transition: RunningViewTransition,\n getResult: () => ViewTransitionMutationResult | null,\n): void {\n // The filled zero-duration animations outlive their pseudo tree: without\n // an explicit cancel once the transition settles they would apply to the\n // next transition's pseudo tree and hide its groups.\n const hideAnimations: CancellableAnimation[] = [];\n const cancelHideAnimations = (): void => {\n for (const animation of hideAnimations) {\n try {\n animation.cancel();\n } catch {\n // Cancelling a finished pseudo animation is best-effort.\n }\n }\n hideAnimations.length = 0;\n };\n\n const hide = (): void => {\n const result = getResult();\n if (result === null) return;\n if (result.canceledNames.length === 0 && !result.cancelRootSnapshot) {\n return;\n }\n\n const element = owner.documentElement;\n if (typeof element.animate !== \"function\") return;\n\n const track = (animation: unknown): void => {\n if (\n typeof (animation as CancellableAnimation | null)?.cancel === \"function\"\n ) {\n hideAnimations.push(animation as CancellableAnimation);\n }\n };\n\n const hideGroup = (name: string): void => {\n track(\n element.animate(\n { opacity: [0, 0], pointerEvents: [\"none\", \"none\"] },\n {\n duration: 0,\n fill: \"forwards\",\n pseudoElement: `::view-transition-group(${name})`,\n },\n ),\n );\n };\n\n try {\n for (const name of result.canceledNames) {\n hideGroup(escapeViewTransitionName(name));\n }\n if (result.cancelRootSnapshot) {\n hideGroup(\"root\");\n track(\n element.animate(\n { height: [0, 0], width: [0, 0] },\n {\n duration: 0,\n fill: \"forwards\",\n pseudoElement: \"::view-transition\",\n },\n ),\n );\n }\n } catch {\n // Pseudo-element animation is best-effort: without it the canceled\n // snapshots fall back to the browser's default cross-fade.\n }\n };\n\n const ready = transition.ready ?? transition.finished;\n if (ready === undefined) hide();\n else ready.then(hide, () => undefined);\n\n const settled = transitionSettled(transition);\n onSettled(settled, cancelHideAnimations);\n}\n\nfunction registerPendingTransition(\n owner: ViewTransitionDocument,\n transition: RunningViewTransition,\n): void {\n owner[VIEW_TRANSITION_PENDING_PROPERTY] = transition;\n const release = (): void => {\n if (owner[VIEW_TRANSITION_PENDING_PROPERTY] === transition) {\n owner[VIEW_TRANSITION_PENDING_PROPERTY] = null;\n }\n };\n onSettled(transitionSettled(transition), release);\n}\n\n// React caps suspended commits at 60 seconds. Besides preventing a broken or\n// infinite animation from parking work forever, releasing the document mutex\n// lets the resumed commit start a new transition, which ends the stale one.\nfunction waitForActiveViewTransition(\n owner: ViewTransitionDocument,\n onFinished: () => void,\n): boolean {\n const pending = owner[VIEW_TRANSITION_PENDING_PROPERTY];\n if (pending == null) return false;\n const settled = transitionSettled(pending);\n if (settled === undefined) return false;\n\n let waiting = true;\n function finish(): void {\n if (!waiting) return;\n waiting = false;\n clearTimeout(timeout);\n if (owner[VIEW_TRANSITION_PENDING_PROPERTY] === pending) {\n owner[VIEW_TRANSITION_PENDING_PROPERTY] = null;\n }\n onFinished();\n }\n\n const timeout = setTimeout(finish, VIEW_TRANSITION_TIMEOUT_MS);\n onSettled(settled, finish);\n return true;\n}\n\nfunction onSettled(\n promise: Promise<unknown> | undefined,\n callback: () => void,\n): void {\n if (promise === undefined) callback();\n else promise.then(callback, callback);\n}\n\nfunction once<Args extends unknown[]>(\n callback: (...args: Args) => void,\n): (...args: Args) => void {\n let called = false;\n return (...args) => {\n if (called) return;\n called = true;\n callback(...args);\n };\n}\n\nfunction transitionSettled(\n transition: RunningViewTransition | undefined,\n): Promise<unknown> | undefined {\n return transition?.finished ?? transition?.ready;\n}\n\nfunction measureViewTransitionSurface(\n element: Element,\n): ViewTransitionSurfaceMeasurement | null {\n if (typeof element.getBoundingClientRect !== \"function\") return null;\n\n const rect = element.getBoundingClientRect();\n const view = element.ownerDocument?.defaultView ?? null;\n const inViewport =\n view === null\n ? true\n : rect.bottom >= 0 &&\n rect.right >= 0 &&\n rect.top <= view.innerHeight &&\n rect.left <= view.innerWidth;\n let absolutelyPositioned = false;\n try {\n absolutelyPositioned =\n view?.getComputedStyle(element).position === \"absolute\";\n } catch {\n // Detached elements or minimal test environments: assume static\n // positioning, the conservative choice (resizes keep the root snapshot).\n }\n\n return {\n absolutelyPositioned,\n height: rect.height,\n inViewport,\n width: rect.width,\n x: rect.left,\n y: rect.top,\n };\n}\n\nfunction applyViewTransitionName(\n element: Element,\n name: string,\n className: string | null,\n): void {\n const style = (element as HTMLElement).style;\n\n style.viewTransitionName = escapeViewTransitionName(name);\n if (className !== null) style.viewTransitionClass = className;\n}\n\nfunction restoreViewTransitionName(element: Element, props: Props): void {\n const style = (element as HTMLElement).style;\n const styleProp = props.style;\n const name =\n styleProp?.viewTransitionName ?? styleProp?.[\"view-transition-name\"];\n const className =\n styleProp?.viewTransitionClass ?? styleProp?.[\"view-transition-class\"];\n\n style.viewTransitionName = styleValue(name);\n style.viewTransitionClass = styleValue(className);\n}\n\nfunction ownerDocument(container: Container): ViewTransitionDocument {\n return (container.ownerDocument ?? document) as ViewTransitionDocument;\n}\n\nfunction styleValue(value: unknown): string {\n if (typeof value === \"string\" || typeof value === \"number\") {\n return String(value).trim();\n }\n\n return \"\";\n}\n\nexport const viewTransitionHostConfig: ViewTransitionHostConfig<\n Container,\n Element\n> = {\n commit: commitViewTransition,\n apply: applyViewTransitionName,\n restore: restoreViewTransitionName,\n measure: measureViewTransitionSurface,\n createSurface: createDOMViewTransitionSurface,\n // Park eligible commits behind the shared per-document mutex while\n // rendering continues, then re-schedule once the transition settles.\n suspend(container, onFinished) {\n return waitForActiveViewTransition(ownerDocument(container), onFinished);\n },\n};\n","import { createViewTransitionCommitCoordinator } from \"@bgub/fig-reconciler/view-transitions\";\nimport { domRenderer } from \"./renderer.ts\";\nimport { viewTransitionHostConfig } from \"./view-transition.ts\";\n\nexport {\n getViewTransitionPseudoElements,\n type ViewTransitionPseudoElement,\n type ViewTransitionPseudoElements,\n} from \"./view-transition-pseudos.ts\";\n\nconst coordinator = createViewTransitionCommitCoordinator(\n viewTransitionHostConfig,\n);\n\nexport function enableViewTransitions(): void {\n domRenderer.installCommitCoordinator(coordinator);\n}\n"],"mappings":"+OAoBA,MAAM,EAAc,IAAI,QAKxB,SAAgB,EACd,EACA,EACA,EACuB,CACvB,IAAM,EAAiC,CAAE,MAAK,EAE9C,OADA,EAAY,IAAI,EAAS,CAAE,MAAO,EAAQ,cAAe,WAAU,CAAC,EAC7D,CACT,CAEA,SAAgB,EACd,EAC8B,CAC9B,IAAM,EAAW,EAAY,IAAI,CAAO,EACxC,GAAI,IAAa,IAAA,GACf,MAAU,MACR,sIAEF,EAGF,IAAM,EAAO,EAAyB,EAAQ,IAAI,EAC5C,EAAU,GACd,EACE,EAAS,MAAM,gBACf,qBAAqB,EAAK,GAAG,EAAK,EACpC,EACF,MAAO,CACL,MAAO,EAAO,OAAO,EACrB,UAAW,EAAO,YAAY,EAC9B,IAAK,EAAS,UAAU,IAAM,EAAO,KAAK,EAAI,KAC9C,IAAK,EAAS,UAAU,IAAM,EAAO,KAAK,EAAI,IAChD,CACF,CAEA,SAAS,EACP,EACA,EAC6B,CAC7B,MAAO,CACL,WACA,QAAQ,EAAW,EAAoB,CACrC,IAAM,EACJ,OAAO,GAAY,SACf,CAAE,SAAU,EAAS,cAAe,CAAS,EAC7C,CAAE,GAAG,EAAS,cAAe,CAAS,EAC5C,OAAO,EAAQ,QAAQ,EAAW,CAAe,CACnD,EACA,eAA6B,CAC3B,OAAO,EAAQ,cAAc,CAAE,QAAS,EAAK,CAAC,CAAC,CAAC,OAAQ,GAAc,CACpE,IAAM,EAAS,EAAU,OACzB,OACE,IAAW,MACX,WAAY,GACZ,EAAO,SAAW,GAClB,kBAAmB,GACnB,EAAO,gBAAkB,CAE7B,CAAC,CACH,EACA,kBAAwC,C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,CAAC,CAAC,WAAa,UACjD,MAAQ,CAGR,CAEA,MAAO,CACL,uBACA,OAAQ,EAAK,OACb,aACA,MAAO,EAAK,MACZ,EAAG,EAAK,KACR,EAAG,EAAK,GACV,CACF,CAEA,SAAS,EACP,EACA,EACA,EACM,CACN,IAAM,EAAS,EAAwB,MAEvC,EAAM,mBAAqB,EAAyB,CAAI,EACpD,IAAc,OAAM,EAAM,oBAAsB,EACtD,CAEA,SAAS,EAA0B,EAAkB,EAAoB,CACvE,IAAM,EAAS,EAAwB,MACjC,EAAY,EAAM,MAClB,EACJ,GAAW,oBAAsB,IAAY,wBACzC,EACJ,GAAW,qBAAuB,IAAY,yBAEhD,EAAM,mBAAqB,EAAW,CAAI,EAC1C,EAAM,oBAAsB,EAAW,CAAS,CAClD,CAEA,SAAS,EAAc,EAA8C,CACnE,OAAQ,EAAU,eAAiB,QACrC,CAEA,SAAS,EAAW,EAAwB,CAK1C,OAJI,OAAO,GAAU,UAAY,OAAO,GAAU,SACzC,OAAO,CAAK,CAAC,CAAC,KAAK,EAGrB,EACT,CCrXA,MAAM,EAAc,EAClB,CD0XA,OAAQ,EACR,MAAO,EACP,QAAS,EACT,QAAS,EACT,cAAe,EAGf,QAAQ,EAAW,EAAY,CAC7B,OAAO,EAA4B,EAAc,CAAS,EAAG,CAAU,CACzE,CCnYA,CACF,EAEA,SAAgB,GAA8B,CAC5C,EAAY,yBAAyB,CAAW,CAClD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgub/fig-dom",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.3",
4
4
  "description": "Fig DOM renderer",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/bgub/fig",
@@ -8,31 +8,37 @@
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",
11
+ "fig-development": "./dist-development/index.js",
11
12
  "import": "./dist/index.js",
12
13
  "default": "./dist/index.js"
13
14
  },
14
15
  "./view-transitions": {
15
16
  "types": "./dist/view-transitions.d.ts",
17
+ "fig-development": "./dist-development/view-transitions.js",
16
18
  "import": "./dist/view-transitions.js",
17
19
  "default": "./dist/view-transitions.js"
18
20
  },
19
21
  "./refresh": {
20
22
  "types": "./dist/refresh.d.ts",
23
+ "fig-development": "./dist-development/refresh.js",
21
24
  "import": "./dist/refresh.js",
22
25
  "default": "./dist/refresh.js"
23
26
  },
24
27
  "./test-utils": {
25
28
  "types": "./dist/act.d.ts",
29
+ "fig-development": "./dist-development/act.js",
26
30
  "import": "./dist/act.js",
27
31
  "default": "./dist/act.js"
28
32
  },
29
33
  "./jsx-runtime": {
30
34
  "types": "./dist/jsx-runtime.d.ts",
35
+ "fig-development": "./dist-development/jsx-runtime.js",
31
36
  "import": "./dist/jsx-runtime.js",
32
37
  "default": "./dist/jsx-runtime.js"
33
38
  },
34
39
  "./jsx-dev-runtime": {
35
40
  "types": "./dist/jsx-runtime.d.ts",
41
+ "fig-development": "./dist-development/jsx-runtime.js",
36
42
  "import": "./dist/jsx-runtime.js",
37
43
  "default": "./dist/jsx-runtime.js"
38
44
  },
@@ -41,6 +47,7 @@
41
47
  "types": "./dist/index.d.ts",
42
48
  "files": [
43
49
  "dist",
50
+ "dist-development",
44
51
  "CHANGELOG.md"
45
52
  ],
46
53
  "author": "Ben Gubler <nebrelbug@gmail.com>",
@@ -56,14 +63,15 @@
56
63
  "publishConfig": {
57
64
  "access": "public"
58
65
  },
66
+ "dependencies": {
67
+ "@bgub/fig-reconciler": "0.1.0-alpha.3"
68
+ },
59
69
  "peerDependencies": {
60
- "@bgub/fig": "0.1.0-alpha.1",
61
- "@bgub/fig-reconciler": "0.1.0-alpha.1"
70
+ "@bgub/fig": "0.1.0-alpha.3"
62
71
  },
63
72
  "devDependencies": {
64
- "@bgub/fig": "0.1.0-alpha.1",
65
- "@bgub/fig-reconciler": "0.1.0-alpha.1",
66
- "@bgub/fig-server": "0.1.0-alpha.1"
73
+ "@bgub/fig": "0.1.0-alpha.3",
74
+ "@bgub/fig-server": "0.1.0-alpha.3"
67
75
  },
68
76
  "engines": {
69
77
  "node": "^20.19.0 || >=22.12.0"