@raphy-js/dom 0.0.0-stage → 1.0.0-dev.88

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.
Files changed (175) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +187 -2
  3. package/dist/DOMBlueprintMaterializer-C-icNhvm.cjs +1 -0
  4. package/dist/DOMBlueprintMaterializer-CxzM_TX5.js +201 -0
  5. package/dist/FullDOMOperations-BOlf0_0L.js +2781 -0
  6. package/dist/FullDOMOperations-Dschwj33.cjs +1 -0
  7. package/dist/api/renderer.d.ts +12 -0
  8. package/dist/applicationIdentity-CHbuUlsE.cjs +1 -0
  9. package/dist/applicationIdentity-DjVgpsQq.js +11 -0
  10. package/dist/bind-BEmkQdaL.cjs +1 -0
  11. package/dist/bind-OakIMWpC.js +52 -0
  12. package/dist/binding/DOMValueWriter.d.ts +59 -0
  13. package/dist/binding/materializeComponentProps.d.ts +38 -0
  14. package/dist/binding/mountDOMBinding.d.ts +9 -0
  15. package/dist/binding/mountDOMProps.d.ts +22 -0
  16. package/dist/capture.cjs +1 -0
  17. package/dist/capture.d.ts +7 -0
  18. package/dist/capture.js +166 -0
  19. package/dist/channels-Bs8GHVWn.cjs +1 -0
  20. package/dist/channels-DqAQt-NH.js +33 -0
  21. package/dist/compact/hydration.cjs +1 -0
  22. package/dist/compact/hydration.d.ts +9 -0
  23. package/dist/compact/hydration.js +12 -0
  24. package/dist/compact/index.d.ts +19 -0
  25. package/dist/compact/targetRuntime.d.ts +1 -0
  26. package/dist/compact.cjs +1 -0
  27. package/dist/compact.js +34 -0
  28. package/dist/contracts/freezeGeneratedContract.d.ts +5 -0
  29. package/dist/contracts/manifest.json +25 -0
  30. package/dist/contracts/node.cjs +1 -0
  31. package/dist/contracts/node.contract.json +36889 -0
  32. package/dist/contracts/node.d.ts +6 -0
  33. package/dist/contracts/node.js +19 -0
  34. package/dist/contracts/stylesheet.cjs +1 -0
  35. package/dist/contracts/stylesheet.contract.json +11887 -0
  36. package/dist/contracts/stylesheet.d.ts +6 -0
  37. package/dist/contracts/stylesheet.js +22 -0
  38. package/dist/createDOMDataEventInput-B82pnIav.cjs +1 -0
  39. package/dist/createDOMDataEventInput-BDX50jhu.js +3010 -0
  40. package/dist/createDOMNodeRuntime-BHcsbeO1.cjs +1 -0
  41. package/dist/createDOMNodeRuntime-DIKOUQP7.js +3006 -0
  42. package/dist/createHydrationRenderer-C7srF-66.js +289 -0
  43. package/dist/createHydrationRenderer-DKybWTj4.cjs +1 -0
  44. package/dist/elementRef-D8Ir8tXA.cjs +1 -0
  45. package/dist/elementRef-YPBBElV9.js +32 -0
  46. package/dist/event/DOMEventHub.d.ts +303 -0
  47. package/dist/freezeGeneratedContract-0EZt85o4.js +10 -0
  48. package/dist/freezeGeneratedContract-g_Op1hGY.cjs +1 -0
  49. package/dist/hydration/HydrationEvents.d.ts +20 -0
  50. package/dist/hydration/HydrationSession.d.ts +107 -0
  51. package/dist/hydration/HydrationStream.d.ts +30 -0
  52. package/dist/hydration/activateHydration.d.ts +2 -0
  53. package/dist/hydration/createHydrationRenderer.d.ts +25 -0
  54. package/dist/hydration/index.d.ts +8 -0
  55. package/dist/hydration.cjs +1 -0
  56. package/dist/hydration.js +12 -0
  57. package/dist/index.cjs +1 -0
  58. package/dist/index.d.ts +22 -0
  59. package/dist/index.js +24 -0
  60. package/dist/interaction/clipboard.d.ts +2 -0
  61. package/dist/interaction/contextAction.d.ts +3 -0
  62. package/dist/interaction/contracts/node.cjs +1 -0
  63. package/dist/interaction/contracts/node.d.ts +15 -0
  64. package/dist/interaction/contracts/node.js +60 -0
  65. package/dist/interaction/dragDrop.d.ts +13 -0
  66. package/dist/interaction/focus.d.ts +4 -0
  67. package/dist/interaction/geometry.d.ts +39 -0
  68. package/dist/interaction/hover.d.ts +4 -0
  69. package/dist/interaction/index.d.ts +2 -0
  70. package/dist/interaction/interaction.d.ts +4 -0
  71. package/dist/interaction/internal/DOMInputModality.d.ts +20 -0
  72. package/dist/interaction/internal/DOMInteraction.types.d.ts +29 -0
  73. package/dist/interaction/internal/applicationIdentity.d.ts +3 -0
  74. package/dist/interaction/internal/dragDataTransfer.d.ts +4 -0
  75. package/dist/interaction/internal/solvePosition.d.ts +5 -0
  76. package/dist/interaction/keyboard.d.ts +3 -0
  77. package/dist/interaction/move.d.ts +3 -0
  78. package/dist/interaction/nativeDragDrop.d.ts +18 -0
  79. package/dist/interaction/outside.d.ts +3 -0
  80. package/dist/interaction/press.d.ts +3 -0
  81. package/dist/interaction/profile.cjs +1 -0
  82. package/dist/interaction/profile.d.ts +2 -0
  83. package/dist/interaction/profile.js +48 -0
  84. package/dist/interaction/rovingFocus.d.ts +4 -0
  85. package/dist/interaction/runtime.d.ts +7 -0
  86. package/dist/interaction/textEditing.d.ts +4 -0
  87. package/dist/interaction.cjs +1 -0
  88. package/dist/interaction.js +1603 -0
  89. package/dist/internal/dev.d.ts +20 -0
  90. package/dist/motion/channels.d.ts +5 -0
  91. package/dist/motion/index.d.ts +8 -0
  92. package/dist/motion-scroll/index.d.ts +19 -0
  93. package/dist/motion-scroll.cjs +1 -0
  94. package/dist/motion-scroll.js +169 -0
  95. package/dist/motion.cjs +1 -0
  96. package/dist/motion.js +187 -0
  97. package/dist/operations.cjs +1 -0
  98. package/dist/operations.d.ts +3 -0
  99. package/dist/operations.js +10 -0
  100. package/dist/profile/DOMProfile.d.ts +4 -0
  101. package/dist/profile/index.d.ts +1 -0
  102. package/dist/profile.cjs +1 -0
  103. package/dist/profile.js +23 -0
  104. package/dist/renderer/DOMEffectScope.d.ts +13 -0
  105. package/dist/renderer/DOMPresentation.d.ts +8 -0
  106. package/dist/renderer/DOMRenderer.d.ts +35 -0
  107. package/dist/renderer/DOMRenderer.types.d.ts +12 -0
  108. package/dist/renderer/DOMRendererExtension.types.d.ts +33 -0
  109. package/dist/renderer/DOMRuntimeProfile.d.ts +15 -0
  110. package/dist/renderer/DOMTargetRuntime.d.ts +1 -0
  111. package/dist/renderer/createDOMTargetRuntime.d.ts +3 -0
  112. package/dist/renderer/installAuxiliaryViews.d.ts +8 -0
  113. package/dist/renderer/installDOMRendererExtensions.d.ts +10 -0
  114. package/dist/renderer/resolveDOMMountTarget.d.ts +7 -0
  115. package/dist/renderer-4Wbid5nE.js +30 -0
  116. package/dist/renderer-DHK3lLG-.cjs +1 -0
  117. package/dist/resolveDOMMountTarget-C75JWc5x.cjs +1 -0
  118. package/dist/resolveDOMMountTarget-D944H05N.js +19 -0
  119. package/dist/runtime.cjs +1 -0
  120. package/dist/runtime.d.ts +21 -0
  121. package/dist/runtime.js +25 -0
  122. package/dist/serialization.cjs +1 -0
  123. package/dist/serialization.d.ts +4 -0
  124. package/dist/serialization.js +118 -0
  125. package/dist/stylesheet/DOMStyleManager.d.ts +95 -0
  126. package/dist/stylesheet/DOMStyleReferenceName.d.ts +2 -0
  127. package/dist/stylesheet/DOMStylesheetRuntime.d.ts +25 -0
  128. package/dist/stylesheet/acquireInstanceStylesheets.d.ts +4 -0
  129. package/dist/stylesheet/scopeDOMSelector.d.ts +2 -0
  130. package/dist/stylesheet/serializeDOMStyleValue.d.ts +3 -0
  131. package/dist/targetRuntime-C67QmOgE.cjs +1 -0
  132. package/dist/targetRuntime-C_OdmS5w.js +5 -0
  133. package/dist/template/AdvancedDOMMaterializer.d.ts +14 -0
  134. package/dist/template/AsyncDOMMaterializer.d.ts +4 -0
  135. package/dist/template/BoundaryDOMMaterializer.d.ts +10 -0
  136. package/dist/template/DOMHostPlan.d.ts +4 -0
  137. package/dist/template/DOMNode.types.d.ts +192 -0
  138. package/dist/template/DOMNodeRuntime.d.ts +1 -0
  139. package/dist/template/binding/DOMBinding.types.d.ts +44 -0
  140. package/dist/template/binding/bind.d.ts +16 -0
  141. package/dist/template/blueprint/DOMBlueprintAddressing.d.ts +23 -0
  142. package/dist/template/blueprint/DOMBlueprintMaterializer.d.ts +3 -0
  143. package/dist/template/blueprint/DOMBlueprintMaterializer.types.d.ts +15 -0
  144. package/dist/template/blueprint/DOMHostBlueprint.d.ts +102 -0
  145. package/dist/template/blueprint/DOMHostBlueprintCache.d.ts +86 -0
  146. package/dist/template/blueprint/createDOMDataEventInput.d.ts +5 -0
  147. package/dist/template/blueprint/mountDOMHostBlueprint.d.ts +45 -0
  148. package/dist/template/createDOMNodeRuntime.d.ts +3 -0
  149. package/dist/template/each/mountEach.d.ts +5 -0
  150. package/dist/template/each/mountPureEach.d.ts +22 -0
  151. package/dist/template/error/DOMInvocation.d.ts +58 -0
  152. package/dist/template/error/DOMOperationError.d.ts +25 -0
  153. package/dist/template/html/DOMRawHtmlNode.types.d.ts +21 -0
  154. package/dist/template/html/rawHtml.d.ts +5 -0
  155. package/dist/template/keep-alive/DOMKeepAliveNode.types.d.ts +10 -0
  156. package/dist/template/keep-alive/keepAlive.d.ts +4 -0
  157. package/dist/template/mount/DOMMountTransaction.d.ts +63 -0
  158. package/dist/template/mountNode.d.ts +173 -0
  159. package/dist/template/normalizeChildren.d.ts +5 -0
  160. package/dist/template/operations/DOMOperations.d.ts +56 -0
  161. package/dist/template/operations/FullDOMOperations.d.ts +6 -0
  162. package/dist/template/page/DOMHead.d.ts +7 -0
  163. package/dist/template/page/PageNodePlan.d.ts +31 -0
  164. package/dist/template/ref/DOMElementRef.types.d.ts +7 -0
  165. package/dist/template/ref/componentRefGuard.d.ts +6 -0
  166. package/dist/template/ref/elementRef.d.ts +9 -0
  167. package/dist/template/structural/range/DOMRange.d.ts +145 -0
  168. package/dist/template/teleport/DOMTeleportNode.types.d.ts +8 -0
  169. package/dist/template/teleport/teleport.d.ts +4 -0
  170. package/dist/template/transition/DOMTransitionCoordinator.d.ts +32 -0
  171. package/dist/template/transition/DOMTransitionNode.types.d.ts +30 -0
  172. package/dist/template/transition/transition.d.ts +4 -0
  173. package/dist/template/value/DOMValueDescriptor.types.d.ts +34 -0
  174. package/dist/template/value/valueDescriptors.d.ts +13 -0
  175. package/package.json +157 -4
@@ -0,0 +1,3006 @@
1
+ import { a as U, E as ke, x as Re, m as yt, o as De, q as C, B as q, C as Z, n as mt, G as P, g as O, h as x, J, N as tt, u as Ee, I as A, T as rt, K as W, F as vt, M as F, L as N, Q as wt, U as ot, S as gt, V as ze, W as bt, X as _t, Y as St, t as Ot, i as Ve, p as Mt, l as kt, b as Rt } from "./createDOMDataEventInput-BDX50jhu.js";
2
+ import { serializeStyleValue as ve } from "./serialization.js";
3
+ import { isNodeDynamicValue as L, BranchBlock as ee, getComponentSlotStyleScope as Le, waitForOwnedPromise as He, createStylesheet as nt, createTargetRuntime as Dt, createNodeRuntime as Et, isTargetRef as We, getComponentModelListenerMetadata as At } from "@raphy-js/core";
4
+ import { i as se, b as Tt } from "./bind-OakIMWpC.js";
5
+ import { PRESENTATION_CAPABILITY as Nt } from "@raphy-js/core/presentation";
6
+ import { AUXILIARY_VIEW_CAPABILITY as Ct } from "@raphy-js/core/views";
7
+ import { i as Ue } from "./elementRef-YPBBElV9.js";
8
+ function we(t, e) {
9
+ return `--r-${Fe(t)}-${e.map(Fe).join("-")}`;
10
+ }
11
+ function Fe(t) {
12
+ const e = [...t].map((r) => /^[a-z0-9-]$/i.test(r) ? r : `_u${r.codePointAt(0).toString(16)}_`).join("");
13
+ return `${e.length}_${e}`;
14
+ }
15
+ let Ye = 0;
16
+ class Pt {
17
+ get applicationId() {
18
+ return this._context.applicationId;
19
+ }
20
+ // Identity известна до materialization всех owned узлов, включая поздние definitions.
21
+ applicationScopeId;
22
+ _hasApplicationLayer;
23
+ // Immutable application bridge and DOM delivery configuration.
24
+ _applicationMarker;
25
+ _compiled = /* @__PURE__ */ new WeakMap();
26
+ _context;
27
+ _definitions = [];
28
+ _definitionSet = /* @__PURE__ */ new Set();
29
+ _markerLeases = /* @__PURE__ */ new Map();
30
+ _nonce;
31
+ _providerBindings;
32
+ _providerStops = [];
33
+ _roots = /* @__PURE__ */ new Map();
34
+ _scopedProviders = /* @__PURE__ */ new Map();
35
+ _scopedProviderStates = /* @__PURE__ */ new Set();
36
+ _scopedProviderCounter = 0;
37
+ // Guards exactly-once cleanup after renderer rollback or disposal.
38
+ _disposed = !1;
39
+ /** Creates the primary style root and starts one application-owned provider projection. */
40
+ constructor(e, r) {
41
+ this._context = e, this._nonce = r.styleNonce, this._applicationMarker = r.applicationMarker ?? It(e.applicationId), this.applicationScopeId = this._applicationMarker, this._hasApplicationLayer = e.stylesheets?.some(
42
+ (o) => o.metadata.applicationScoped === !0
43
+ ) ?? !1, this._providerBindings = this._readProviderBindings();
44
+ try {
45
+ this._ensureRoot(
46
+ Ke(r.target),
47
+ this._providerBindings
48
+ ), this.retainBoundary(r.target), this.acquire(e.stylesheets);
49
+ for (const o of this._providerBindings)
50
+ this._providerStops.push(
51
+ e.applicationNode.effect(
52
+ U,
53
+ () => {
54
+ this._updateProviderValue(o);
55
+ },
56
+ { initial: "sync" }
57
+ )
58
+ );
59
+ } catch (o) {
60
+ throw this.dispose(), o;
61
+ }
62
+ }
63
+ /** Captures stylesheet and tree-root state for synchronous mount rollback. */
64
+ checkpoint() {
65
+ return this._assertActive(), {
66
+ definitionCount: this._definitions.length,
67
+ markerLeases: new Map(
68
+ [...this._markerLeases].map(([e, r]) => [
69
+ e,
70
+ new Set(r)
71
+ ])
72
+ ),
73
+ roots: new Set(this._roots.keys())
74
+ };
75
+ }
76
+ /** Materializes new definitions once and installs them in every retained tree root. */
77
+ acquire(e) {
78
+ if (this._assertActive(), e !== void 0)
79
+ for (const r of e) {
80
+ if (this._definitionSet.has(r))
81
+ continue;
82
+ const o = this._materialize(r);
83
+ this._definitionSet.add(r), this._definitions.push(r);
84
+ for (const n of this._roots.values())
85
+ this._installDefinition(n, r, o);
86
+ }
87
+ }
88
+ /** Creates one marker controller for a logical wrapperless style-value scope. */
89
+ createValueBoundary(e, r = !1) {
90
+ return this._assertActive(), new Bt(this, e, r);
91
+ }
92
+ /** Removes every artifact created after a failed synchronous mount checkpoint. */
93
+ rollback(e) {
94
+ if (this._disposed)
95
+ return;
96
+ for (; this._definitions.length > e.definitionCount; ) {
97
+ const o = this._definitions.pop();
98
+ this._definitionSet.delete(o);
99
+ for (const n of this._roots.values())
100
+ n.definitionNodes.get(o)?.remove(), n.definitionNodes.delete(o);
101
+ }
102
+ for (const [o, n] of this._roots)
103
+ if (!e.roots.has(o))
104
+ try {
105
+ this._removeRoot(n);
106
+ } finally {
107
+ this._roots.delete(o);
108
+ }
109
+ const r = /* @__PURE__ */ new Set([
110
+ ...this._markerLeases.keys(),
111
+ ...e.markerLeases.keys()
112
+ ]);
113
+ for (const o of r) {
114
+ const n = e.markerLeases.get(o);
115
+ if (n === void 0 || n.size === 0) {
116
+ this._markerLeases.delete(o), fe(o, this._applicationMarker);
117
+ continue;
118
+ }
119
+ this._markerLeases.set(o, new Set(n)), Je(o, this._applicationMarker);
120
+ }
121
+ }
122
+ /** Retains CSS-variable inheritance and stylesheet delivery for a DOM boundary. */
123
+ retainBoundary(e) {
124
+ this._assertActive(), this._ensureRoot(Ke(e));
125
+ const r = e.nodeType === 11 ? e.host : e;
126
+ let o = this._markerLeases.get(r);
127
+ o === void 0 && (o = /* @__PURE__ */ new Set(), this._markerLeases.set(r, o), Je(r, this._applicationMarker));
128
+ const n = Symbol("DOM style boundary");
129
+ o.add(n);
130
+ let i = !1;
131
+ return () => {
132
+ if (i)
133
+ return;
134
+ i = !0;
135
+ const s = this._markerLeases.get(r);
136
+ s === void 0 || !s.delete(n) || s.size === 0 && (this._markerLeases.delete(r), fe(r, this._applicationMarker));
137
+ };
138
+ }
139
+ /** Reinstalls manager-owned nodes after renderer replacement of a ShadowRoot target. */
140
+ restoreRoot(e) {
141
+ if (e.nodeType !== 11)
142
+ return;
143
+ const r = e, o = this._roots.get(r);
144
+ if (o !== void 0) {
145
+ r.append(o.variablesNode), o.variablesDeclaration = Ge(
146
+ o.variablesNode,
147
+ o.variableValues
148
+ );
149
+ for (const n of this._definitions) {
150
+ const i = o.definitionNodes.get(n);
151
+ i !== void 0 && r.append(i);
152
+ }
153
+ for (const n of this._scopedProviderStates) {
154
+ const i = n.nodes.get(r);
155
+ r.append(i.node), i.declaration = Ge(i.node, i.values);
156
+ }
157
+ }
158
+ }
159
+ /** Stops subscriptions and removes all styles and marker tokens exactly once. */
160
+ dispose() {
161
+ if (this._disposed)
162
+ return;
163
+ this._disposed = !0;
164
+ let e;
165
+ for (const r of this._providerStops.splice(0))
166
+ try {
167
+ r();
168
+ } catch (o) {
169
+ (e ??= []).push(o);
170
+ }
171
+ for (const r of [...this._scopedProviderStates])
172
+ try {
173
+ this._removeScopedProvider(r);
174
+ } catch (o) {
175
+ (e ??= []).push(o);
176
+ }
177
+ for (const r of this._roots.values())
178
+ try {
179
+ this._removeRoot(r);
180
+ } catch (o) {
181
+ (e ??= []).push(o);
182
+ }
183
+ this._roots.clear();
184
+ for (const r of this._markerLeases.keys())
185
+ try {
186
+ fe(r, this._applicationMarker);
187
+ } catch (o) {
188
+ (e ??= []).push(o);
189
+ }
190
+ if (this._markerLeases.clear(), this._definitions.length = 0, this._definitionSet.clear(), e?.length === 1)
191
+ throw e[0];
192
+ if (e !== void 0)
193
+ throw new AggregateError(
194
+ e,
195
+ "[RaphyDOM] Style manager disposal failed."
196
+ );
197
+ }
198
+ /** Rejects calls that would recreate renderer-owned resources after disposal. */
199
+ _assertActive() {
200
+ if (this._disposed)
201
+ throw new Error("[RaphyDOM] Style manager is disposed.");
202
+ }
203
+ /** Creates the application-owned style nodes for one Document or ShadowRoot. */
204
+ _ensureRoot(e, r = this._providerBindings) {
205
+ const o = this._roots.get(e);
206
+ if (o !== void 0)
207
+ return o;
208
+ const n = ue(e, this._nonce);
209
+ n.dataset.rTheme = this._applicationMarker;
210
+ const i = `[data-r-app~="${this._applicationMarker}"]`, s = e.nodeType === 11 ? `:host(${i}),${i}` : i;
211
+ n.textContent = `${s}{}`, pe(e, n);
212
+ const a = /* @__PURE__ */ new Map(), l = ge(n) ?? be(n, s, a), d = {
213
+ clearVariables() {
214
+ a.clear(), n.textContent = `${s}{}`;
215
+ },
216
+ definitionNodes: /* @__PURE__ */ new Map(),
217
+ root: e,
218
+ variableValues: a,
219
+ variablesDeclaration: l,
220
+ variablesNode: n
221
+ };
222
+ this._roots.set(e, d);
223
+ for (const u of this._definitions)
224
+ this._installDefinition(d, u, this._materialize(u));
225
+ for (const u of r)
226
+ this._writeProviderValue(d, u, u.binding.value.peek());
227
+ for (const u of this._scopedProviderStates)
228
+ this._installScopedProvider(d.root, u);
229
+ return d;
230
+ }
231
+ /** Retains one rule/subscription set per distinct provider identity and namespace. */
232
+ _retainScopedProvider(e, r) {
233
+ this._assertActive();
234
+ let o = this._scopedProviders.get(r), n = o?.get(e);
235
+ if (n === void 0) {
236
+ const s = `${this._applicationMarker}-v${(++this._scopedProviderCounter).toString(36)}`;
237
+ n = {
238
+ bindings: Object.freeze(
239
+ r.bindings.map(
240
+ (a) => Object.freeze({
241
+ binding: a,
242
+ name: we(e, a.path)
243
+ })
244
+ )
245
+ ),
246
+ namespace: e,
247
+ nodes: /* @__PURE__ */ new Map(),
248
+ provider: r,
249
+ references: 0,
250
+ stops: [],
251
+ token: s
252
+ }, o ??= /* @__PURE__ */ new Map(), o.set(e, n), this._scopedProviders.set(r, o), this._scopedProviderStates.add(n);
253
+ try {
254
+ for (const a of this._roots.keys())
255
+ this._installScopedProvider(a, n);
256
+ if (r !== this._context.styleEnvironment.providers.get(e))
257
+ for (const a of n.bindings)
258
+ n.stops.push(
259
+ this._context.applicationNode.effect(
260
+ U,
261
+ () => {
262
+ this._updateScopedProviderValue(n, a);
263
+ },
264
+ { initial: "sync" }
265
+ )
266
+ );
267
+ } catch (a) {
268
+ throw this._removeScopedProvider(n), a;
269
+ }
270
+ }
271
+ n.references += 1;
272
+ let i = !1;
273
+ return Object.freeze({
274
+ provider: r,
275
+ release: () => {
276
+ i || (i = !0, n.references -= 1, n.references === 0 && this._removeScopedProvider(n));
277
+ },
278
+ token: n.token
279
+ });
280
+ }
281
+ /** Physical portals also project root providers onto their own logical roots. */
282
+ _resolveScopedProviders(e, r) {
283
+ this._assertActive();
284
+ const o = [], n = this._context.styleEnvironment;
285
+ for (const i of n.providers.keys())
286
+ e.getProviderSource(i) === n.rootScope.getProviderSource(i) ? r && o.push([i, n.providers.get(i)]) : o.push([i, e.getProvider(i)]);
287
+ return o;
288
+ }
289
+ /** Installs one provider rule into one retained Document or ShadowRoot. */
290
+ _installScopedProvider(e, r) {
291
+ const o = ue(e, this._nonce);
292
+ o.dataset.rStyleValuesRule = r.token;
293
+ const n = `[data-r-style-values~="${r.token}"]`;
294
+ o.textContent = `${n}{}`, pe(e, o);
295
+ const i = /* @__PURE__ */ new Map(), s = ge(o) ?? be(o, n, i);
296
+ r.nodes.set(e, { declaration: s, node: o, values: i });
297
+ for (const a of r.bindings)
298
+ this._writeScopedProviderValue(
299
+ r.nodes.get(e),
300
+ a,
301
+ a.binding.value.peek()
302
+ );
303
+ }
304
+ /** Projects one scoped binding into all roots retaining its provider. */
305
+ _updateScopedProviderValue(e, r) {
306
+ const o = r.binding.value.get();
307
+ for (const n of e.nodes.values())
308
+ this._writeScopedProviderValue(n, r, o);
309
+ }
310
+ _writeScopedProviderValue(e, r, o) {
311
+ const n = ve(
312
+ Object.freeze({
313
+ kind: r.binding.kind,
314
+ value: o
315
+ })
316
+ );
317
+ e.values.get(r.name) !== n && (e.values.set(r.name, n), e.declaration.setProperty(r.name, n));
318
+ }
319
+ /** Releases subscriptions, rules and cache identity for one unused provider. */
320
+ _removeScopedProvider(e) {
321
+ let r;
322
+ for (const n of e.stops.splice(0).reverse())
323
+ try {
324
+ n();
325
+ } catch (i) {
326
+ (r ??= []).push(i);
327
+ }
328
+ for (const n of e.nodes.values()) {
329
+ try {
330
+ n.node.remove();
331
+ } catch (i) {
332
+ (r ??= []).push(i);
333
+ }
334
+ n.values.clear();
335
+ }
336
+ e.nodes.clear(), this._scopedProviderStates.delete(e);
337
+ const o = this._scopedProviders.get(e.provider);
338
+ if (o?.delete(e.namespace), o?.size === 0 && this._scopedProviders.delete(e.provider), r?.length === 1)
339
+ throw r[0];
340
+ if (r !== void 0)
341
+ throw new AggregateError(
342
+ r,
343
+ "[RaphyDOM] Scoped style provider cleanup failed."
344
+ );
345
+ }
346
+ /** Appends one compiled definition to one retained tree root. */
347
+ _installDefinition(e, r, o) {
348
+ const n = ue(e.root, this._nonce);
349
+ if (n.dataset.rStyle = r.metadata.id, n.dataset.rStyleApp = this._applicationMarker, !this._hasApplicationLayer || r.metadata.global === !0)
350
+ n.textContent = o;
351
+ else {
352
+ const i = `${this._applicationMarker}-components`, s = `${this._applicationMarker}-application`, a = r.metadata.applicationScoped === !0 ? s : i;
353
+ n.textContent = `@layer ${i},${s};@layer ${a}{${o}}`;
354
+ }
355
+ pe(e.root, n), e.definitionNodes.set(r, n);
356
+ }
357
+ /** Compiles a definition once through the renderer-declared Core runtime. */
358
+ _materialize(e) {
359
+ const r = this._compiled.get(e);
360
+ if (r !== void 0)
361
+ return r;
362
+ const o = this._context.targetRuntime.stylesheet;
363
+ if (o === void 0)
364
+ throw new Error(
365
+ "[RaphyDOM] Renderer does not provide a stylesheet runtime."
366
+ );
367
+ if (e.metadata.applicationScoped === !0 && (!this._hasApplicationLayer || e.metadata.scopeId === void 0))
368
+ throw new Error(
369
+ "[RaphyDOM] Application-scoped stylesheets must declare scopeId and be installed before root setup."
370
+ );
371
+ const i = o.run(e.factory, {
372
+ applicationScope: this.applicationScopeId,
373
+ definition: e,
374
+ styleEnvironment: this._context.styleEnvironment
375
+ });
376
+ if (typeof i != "string")
377
+ throw new TypeError(
378
+ "[RaphyDOM] DOM stylesheet adapter must materialize a CSS string."
379
+ );
380
+ return this._compiled.set(e, i), i;
381
+ }
382
+ /** Creates the immutable DOM projection for every Core style binding. */
383
+ _readProviderBindings() {
384
+ const e = [], r = /* @__PURE__ */ new Set();
385
+ for (const [o, n] of this._context.styleEnvironment.providers)
386
+ for (const i of n.bindings) {
387
+ const s = we(o, i.path);
388
+ if (r.has(s))
389
+ throw new Error(
390
+ `[RaphyDOM] Style value name "${s}" is registered more than once.`
391
+ );
392
+ r.add(s), e.push(Object.freeze({ binding: i, name: s, namespace: o, provider: n }));
393
+ }
394
+ return Object.freeze(e);
395
+ }
396
+ /** Projects one changed semantic value into every retained DOM root. */
397
+ _updateProviderValue(e) {
398
+ const r = e.binding.value.get();
399
+ for (const n of this._roots.values())
400
+ this._writeProviderValue(n, e, r);
401
+ const o = this._scopedProviders.get(e.provider)?.get(e.namespace);
402
+ if (o !== void 0)
403
+ for (const n of o.nodes.values())
404
+ this._writeScopedProviderValue(n, e, r);
405
+ }
406
+ /** Writes one application-scoped CSS custom property when its value changed. */
407
+ _writeProviderValue(e, r, o) {
408
+ const n = Object.freeze({
409
+ kind: r.binding.kind,
410
+ value: o
411
+ }), i = ve(n);
412
+ e.variableValues.get(r.name) !== i && (e.variableValues.set(r.name, i), e.variablesDeclaration.setProperty(r.name, i));
413
+ }
414
+ /** Removes every style node owned by this manager from one root. */
415
+ _removeRoot(e) {
416
+ let r;
417
+ try {
418
+ e.clearVariables();
419
+ } catch (o) {
420
+ (r ??= []).push(o);
421
+ }
422
+ try {
423
+ e.variablesNode.remove();
424
+ } catch (o) {
425
+ (r ??= []).push(o);
426
+ }
427
+ for (const o of e.definitionNodes.values())
428
+ try {
429
+ o.remove();
430
+ } catch (n) {
431
+ (r ??= []).push(n);
432
+ }
433
+ e.definitionNodes.clear();
434
+ for (const o of this._scopedProviderStates) {
435
+ const n = o.nodes.get(e.root);
436
+ try {
437
+ n.node.remove();
438
+ } catch (i) {
439
+ (r ??= []).push(i);
440
+ }
441
+ n.values.clear(), o.nodes.delete(e.root);
442
+ }
443
+ if (r?.length === 1)
444
+ throw r[0];
445
+ if (r !== void 0)
446
+ throw new AggregateError(r, "[RaphyDOM] Style root cleanup failed.");
447
+ }
448
+ }
449
+ class Bt {
450
+ _elements = /* @__PURE__ */ new Set();
451
+ _manager;
452
+ _scope;
453
+ _includeApplicationProviders;
454
+ _leases = /* @__PURE__ */ new Map();
455
+ _disposed = !1;
456
+ constructor(e, r, o) {
457
+ this._manager = e, this._scope = r, this._includeApplicationProviders = o;
458
+ }
459
+ /** Validates and stages every provider before publishing new marker tokens. */
460
+ refresh() {
461
+ if (this._disposed)
462
+ throw new Error("[RaphyDOM] Style-value boundary is disposed.");
463
+ const e = /* @__PURE__ */ new Map(), r = [];
464
+ try {
465
+ for (const [i, s] of this._manager._resolveScopedProviders(
466
+ this._scope,
467
+ this._includeApplicationProviders
468
+ )) {
469
+ const a = this._leases.get(i);
470
+ if (a?.provider === s) {
471
+ e.set(i, a);
472
+ continue;
473
+ }
474
+ const c = this._manager._retainScopedProvider(i, s);
475
+ r.push(c), e.set(i, c);
476
+ }
477
+ } catch (i) {
478
+ for (const s of r.reverse())
479
+ s.release();
480
+ throw i;
481
+ }
482
+ const o = [...this._leases.values()].map(
483
+ (i) => i.token
484
+ ), n = [...e.values()].map((i) => i.token);
485
+ for (const i of this._elements)
486
+ te(i, o, n);
487
+ for (const [i, s] of this._leases)
488
+ e.get(i) !== s && s.release();
489
+ this._leases.clear();
490
+ for (const [i, s] of e)
491
+ this._leases.set(i, s);
492
+ }
493
+ /** Marks one first materialized element of a logical root branch. */
494
+ attach(e) {
495
+ this._disposed || this._elements.has(e) || (this._elements.add(e), te(
496
+ e,
497
+ [],
498
+ [...this._leases.values()].map((r) => r.token)
499
+ ));
500
+ }
501
+ /** Forgets a replaced raw-HTML root without touching markers owned by others. */
502
+ detach(e) {
503
+ this._elements.delete(e) && te(
504
+ e,
505
+ [...this._leases.values()].map((r) => r.token),
506
+ []
507
+ );
508
+ }
509
+ /** Releases markers and provider rules after physical DOM range removal. */
510
+ dispose() {
511
+ if (this._disposed)
512
+ return;
513
+ this._disposed = !0;
514
+ const e = [...this._leases.values()].map((r) => r.token);
515
+ for (const r of this._elements)
516
+ te(r, e, []);
517
+ this._elements.clear();
518
+ for (const r of [...this._leases.values()].reverse())
519
+ r.release();
520
+ this._leases.clear();
521
+ }
522
+ }
523
+ function ge(t) {
524
+ const e = t.sheet?.cssRules[0];
525
+ return typeof e?.style?.setProperty == "function" ? e.style : void 0;
526
+ }
527
+ function Ge(t, e) {
528
+ const r = ge(t);
529
+ if (r !== void 0) {
530
+ for (const [n, i] of e)
531
+ r.setProperty(n, i);
532
+ return r;
533
+ }
534
+ const o = t.textContent.slice(0, t.textContent.indexOf("{"));
535
+ return be(t, o, e);
536
+ }
537
+ function be(t, e, r) {
538
+ return Object.freeze({
539
+ setProperty() {
540
+ const o = [...r].map(([n, i]) => `${n}:${i};`).join("");
541
+ t.textContent = `${e}{${o}}`;
542
+ }
543
+ });
544
+ }
545
+ function Ke(t) {
546
+ if (t.nodeType === 11)
547
+ return t;
548
+ const e = t.getRootNode();
549
+ return e.nodeType === 11 ? e : t.ownerDocument;
550
+ }
551
+ function ue(t, e) {
552
+ const o = (t.nodeType === 9 ? t : t.ownerDocument).createElement("style");
553
+ return e !== void 0 && (o.nonce = e), o;
554
+ }
555
+ function pe(t, e) {
556
+ if (t.nodeType === 11) {
557
+ t.append(e);
558
+ return;
559
+ }
560
+ const r = t;
561
+ (r.head ?? r.documentElement).append(e);
562
+ }
563
+ function It(t) {
564
+ let e = 2166136261;
565
+ for (let r = 0; r < t.length; r++)
566
+ e ^= t.charCodeAt(r), e = Math.imul(e, 16777619);
567
+ return Ye += 1, `r${(e >>> 0).toString(36)}-${Ye.toString(36)}`;
568
+ }
569
+ function Je(t, e) {
570
+ const r = it(t);
571
+ r.add(e), t.setAttribute("data-r-app", [...r].join(" "));
572
+ }
573
+ function fe(t, e) {
574
+ const r = it(t);
575
+ r.delete(e), r.size === 0 ? t.removeAttribute("data-r-app") : t.setAttribute("data-r-app", [...r].join(" "));
576
+ }
577
+ function it(t) {
578
+ return new Set(
579
+ (t.getAttribute("data-r-app") ?? "").split(/\s+/u).filter(Boolean)
580
+ );
581
+ }
582
+ function te(t, e, r) {
583
+ const o = new Set(
584
+ (t.getAttribute("data-r-style-values") ?? "").split(/\s+/u).filter(Boolean)
585
+ );
586
+ for (const n of e)
587
+ o.delete(n);
588
+ for (const n of r)
589
+ o.add(n);
590
+ o.size === 0 ? t.removeAttribute("data-r-style-values") : t.setAttribute("data-r-style-values", [...o].join(" "));
591
+ }
592
+ const Xe = Object.prototype.hasOwnProperty;
593
+ function $t(t, e, r, o, n, i, s) {
594
+ if (e === ke)
595
+ return;
596
+ if (L(e)) {
597
+ Lt(t, e, r, o, n, i, s);
598
+ return;
599
+ }
600
+ let a;
601
+ for (const c in e) {
602
+ if (!Xe.call(e, c))
603
+ continue;
604
+ const l = e[c];
605
+ if ((c === "data-r-scope" || c === "data-r-slotted") && st(c), c === "ref")
606
+ throw new TypeError("[RaphyDOM] Element ref cannot be dynamic.");
607
+ typeof l == "object" && l !== null && se(l) && (a ??= [], a.push(c));
608
+ }
609
+ a !== void 0 && Ut(t, e);
610
+ for (const c in e) {
611
+ if (!Xe.call(e, c))
612
+ continue;
613
+ const l = e[c];
614
+ let d = null, u = l;
615
+ if (typeof l == "object" && l !== null) {
616
+ if (a !== void 0 && se(l))
617
+ continue;
618
+ if (Re(l) && (d = l, u = l.kind === "listener" ? l.handler : l.value), L(u)) {
619
+ c === "class" && d === null ? zt(t, u, o, i, s) : Vt(
620
+ t,
621
+ c,
622
+ u,
623
+ d,
624
+ r,
625
+ o,
626
+ n,
627
+ i,
628
+ s
629
+ );
630
+ continue;
631
+ }
632
+ }
633
+ yt(
634
+ t,
635
+ c,
636
+ u,
637
+ r,
638
+ n,
639
+ i,
640
+ s,
641
+ d
642
+ ) || De(
643
+ t,
644
+ c,
645
+ r,
646
+ n,
647
+ i,
648
+ s,
649
+ d
650
+ ).write(u);
651
+ }
652
+ return a;
653
+ }
654
+ function jt(t, e, r, o, n, i, s, a, c) {
655
+ const l = (d, u) => a(s, d, u);
656
+ for (let d = 0; d < r.length; d++) {
657
+ const u = r[d];
658
+ c(
659
+ t,
660
+ u,
661
+ e[u],
662
+ o,
663
+ n,
664
+ i,
665
+ l
666
+ );
667
+ }
668
+ }
669
+ function zt(t, e, r, o, n) {
670
+ let i = t.hasAttribute("class") ? void 0 : "";
671
+ q(r, () => {
672
+ try {
673
+ const s = mt(e.read());
674
+ if (Object.is(i, s))
675
+ return;
676
+ s.length === 0 ? t.removeAttribute("class") : t.setAttribute("class", s), i = s;
677
+ } catch (s) {
678
+ if (!n(o, s, "element-prop:class"))
679
+ throw s;
680
+ }
681
+ }, Z);
682
+ }
683
+ function Vt(t, e, r, o, n, i, s, a, c) {
684
+ const l = De(
685
+ t,
686
+ e,
687
+ n,
688
+ s,
689
+ a,
690
+ c,
691
+ o
692
+ );
693
+ q(i, () => {
694
+ try {
695
+ l.write(r.read());
696
+ } catch (d) {
697
+ if (!c(a, d, `element-prop:${e}`))
698
+ throw d;
699
+ }
700
+ }, Z);
701
+ }
702
+ function Lt(t, e, r, o, n, i, s) {
703
+ let a;
704
+ const c = (p, h) => {
705
+ const y = Wt(h);
706
+ let v = a?.get(p);
707
+ if (v === void 0)
708
+ v = {
709
+ descriptor: y,
710
+ writer: De(
711
+ t,
712
+ p,
713
+ r,
714
+ n,
715
+ i,
716
+ s,
717
+ h
718
+ )
719
+ }, a ??= /* @__PURE__ */ new Map(), a.set(p, v);
720
+ else if (v.descriptor !== y)
721
+ throw new Error(`[RaphyDOM] DOM descriptor for "${p}" cannot change dynamically.`);
722
+ return v.writer;
723
+ };
724
+ let l = /* @__PURE__ */ new Set();
725
+ const d = () => {
726
+ try {
727
+ const p = Ft(e.read()), h = Object.keys(p), y = new Set(h);
728
+ for (const v of l)
729
+ y.has(v) || c(v, null).clear();
730
+ for (const v of h) {
731
+ const w = p[v];
732
+ if (st(v), v === "ref")
733
+ throw new TypeError("[RaphyDOM] Element ref cannot be dynamic.");
734
+ const _ = Re(w) ? w : null, S = Ht(w);
735
+ if (L(S))
736
+ throw new TypeError("[RaphyDOM] Grouped dynamic props cannot contain nested dynamic() values.");
737
+ if (se(S))
738
+ throw new TypeError("[RaphyDOM] Grouped dynamic props cannot contain bind() values.");
739
+ c(v, _).write(S);
740
+ }
741
+ l = y;
742
+ } catch (p) {
743
+ if (!s(i, p, "element-props-write"))
744
+ throw p;
745
+ }
746
+ }, u = C(t.ownerDocument);
747
+ q(o, u?.initialBinding(r, d) ?? d, Z);
748
+ }
749
+ function st(t) {
750
+ if (t === "data-r-scope" || t === "data-r-slotted")
751
+ throw new TypeError(`[RaphyDOM] Attribute "${t}" is renderer-owned.`);
752
+ }
753
+ function Ht(t) {
754
+ return Re(t) ? t.kind === "listener" ? t.handler : t.value : t;
755
+ }
756
+ function Wt(t) {
757
+ if (t === null)
758
+ return "auto";
759
+ if (t.kind === "property")
760
+ return "property";
761
+ if (t.kind === "attribute")
762
+ return `attribute:${t.namespace ?? ""}:${t.name ?? ""}`;
763
+ const e = t.options;
764
+ return `listener:${e.capture === !0}:${e.once === !0}:${e.passive === !0}:${e.prevent === !0}:${e.self === !0}:${e.stop === !0}`;
765
+ }
766
+ function Ut(t, e) {
767
+ if (t instanceof HTMLInputElement && L(e.type))
768
+ throw new TypeError("[RaphyDOM] Bound input type must be static.");
769
+ if (t instanceof HTMLSelectElement && L(e.multiple))
770
+ throw new TypeError("[RaphyDOM] Bound select multiple property must be static.");
771
+ }
772
+ function Ft(t) {
773
+ if (t == null)
774
+ return ke;
775
+ if (typeof t != "object" || Array.isArray(t))
776
+ throw new TypeError("[RaphyDOM] Grouped dynamic props must return an object, null, or undefined.");
777
+ return t;
778
+ }
779
+ function Qe(t, e) {
780
+ const r = e();
781
+ if (!Array.isArray(r))
782
+ throw new TypeError("[RaphyDOM] Component instance stylesheets must be an array.");
783
+ const o = t.checkpoint();
784
+ try {
785
+ t.acquire(r);
786
+ } catch (n) {
787
+ throw t.rollback(o), n;
788
+ }
789
+ }
790
+ const ie = /* @__PURE__ */ new WeakMap();
791
+ function Gr(t) {
792
+ return (ie.get(t.ownerDocument)?.get(JSON.stringify([
793
+ t.getAttribute("data-r-head"),
794
+ t.getAttribute("data-r-head-key")
795
+ ]))?.length ?? 0) !== 0;
796
+ }
797
+ function Yt(t, e, r) {
798
+ if (!["title", "meta", "link", "base"].includes(r.tag))
799
+ throw new TypeError("[RaphyDOM] Invalid head tag.");
800
+ for (const u of Object.keys(r.props ?? {}))
801
+ if (/^on/i.test(u) || !/^[\w:-]+$/.test(u))
802
+ throw new TypeError("[RaphyDOM] Invalid head attribute.");
803
+ const o = r.key ?? (r.tag === "meta" ? `meta:${r.props?.name ?? r.props?.property ?? r.props?.["http-equiv"]}` : r.tag === "link" ? `link:${r.props?.rel}:${r.props?.href}` : r.tag);
804
+ let n = ie.get(t);
805
+ n === void 0 && (n = /* @__PURE__ */ new Map(), ie.set(t, n));
806
+ const i = JSON.stringify([e, o]);
807
+ let s = n.get(i);
808
+ s === void 0 && (s = [], n.set(i, s));
809
+ const a = s.at(-1)?.element ?? [...t.head.querySelectorAll("[data-r-head-key]")].find(
810
+ (u) => u.getAttribute("data-r-head-key") === o && u.getAttribute("data-r-head") === e
811
+ ), c = a?.localName === r.tag ? a : t.createElement(r.tag);
812
+ a !== void 0 && a !== c ? a.replaceWith(c) : c.parentNode === null && t.head.appendChild(c);
813
+ const l = { entry: r, element: c };
814
+ s.push(l), qe(c, r, e, o);
815
+ let d = !1;
816
+ return () => {
817
+ if (d)
818
+ return;
819
+ d = !0;
820
+ const u = s.indexOf(l), p = u === s.length - 1;
821
+ if (s.splice(u, 1), !p)
822
+ return;
823
+ const h = s.at(-1);
824
+ h === void 0 ? (c.remove(), n.delete(i), n.size === 0 && ie.delete(t)) : (h.element !== c && c.replaceWith(h.element), qe(h.element, h.entry, e, o));
825
+ };
826
+ }
827
+ function qe(t, e, r, o) {
828
+ for (const n of [...t.attributes])
829
+ t.removeAttribute(n.name);
830
+ for (const [n, i] of Object.entries(e.props ?? {}))
831
+ t.setAttribute(n, i);
832
+ t.setAttribute("data-r-head-key", o), t.setAttribute("data-r-head", r), e.tag === "title" && (t.textContent = e.text ?? "");
833
+ }
834
+ class R {
835
+ /**
836
+ * Связывает общую среду с owner, effect scope и transaction одной entry.
837
+ */
838
+ constructor(e, r, o, n) {
839
+ this.env = e, this.effectScope = r, this.ownerNode = o, this.transaction = n;
840
+ }
841
+ }
842
+ const ae = /* @__PURE__ */ new WeakMap(), Gt = Object.freeze({ componentInstances: ae, MountContext: R, captureDOMCleanupError: le, captureDOMError: B, clearDOMBranchForTransaction: ut, materializeElement: Q, materializeHostBlueprint: lt, mountChildren: I, mountKeyedItem: qt, ownDOMOutput: M, registerHydratingEffect: Y, rethrowUnhandledDOMOperationError: k, runMountTransaction: j, runTemplateOperation: $, selectDOMBranch: H });
843
+ function X(t, e, r, o, n, i, s, a, c, l = "html", d = null, u = null, p = [], h = [], y) {
844
+ const v = a.checkpoint();
845
+ try {
846
+ const w = t.view, _ = w === null ? t.definition.template : t.definition.views?.[w];
847
+ if (_ === void 0) {
848
+ const D = t.definition.name ?? t.node.id;
849
+ throw new Error(
850
+ w === null ? `[RaphyDOM] Component "${D}" does not define a template.` : `[RaphyDOM] Component "${D}" does not define view "${w}".`
851
+ );
852
+ }
853
+ c.prepare(t.definition);
854
+ const S = {
855
+ props: t.props,
856
+ slots: t.slots,
857
+ state: t.state
858
+ };
859
+ a.acquire(_.stylesheets);
860
+ const T = _.resolveStylesheets;
861
+ T !== void 0 && Qe(a, () => T(S));
862
+ const f = r.node.run(
863
+ () => _.render(S),
864
+ { styleScopeId: _.styleScopeId }
865
+ ), m = u === null ? t.node : P(u, t.node), g = new R(
866
+ {
867
+ operations: c,
868
+ asyncBoundary: d,
869
+ document: o,
870
+ eventHub: i,
871
+ host: e,
872
+ hostBlueprintCache: n,
873
+ ownerComponent: t,
874
+ namespace: l,
875
+ styleManager: a,
876
+ styleValues: t.styleValues,
877
+ styleValueBoundary: y,
878
+ componentRoot: !0,
879
+ inheritedStyleScopeIds: p,
880
+ slottedStyleScopeIds: h,
881
+ styleScopeId: _.styleScopeId,
882
+ targetRuntime: r
883
+ },
884
+ m,
885
+ t.node,
886
+ s
887
+ );
888
+ T !== void 0 && q(m, () => {
889
+ try {
890
+ Qe(a, () => T(S));
891
+ } catch (D) {
892
+ k(g, D, "stylesheet-resolve");
893
+ }
894
+ }, Z);
895
+ const b = I(f, g, "raphy:component");
896
+ return t.node.disposed || (M(t.node, b, g), s.addComponent(
897
+ t,
898
+ (D) => {
899
+ const E = B(D, g, {
900
+ layer: "core",
901
+ operation: "mount-hook"
902
+ });
903
+ if (!E.handled)
904
+ throw new O(E.report.error);
905
+ return !0;
906
+ }
907
+ )), b;
908
+ } catch (w) {
909
+ throw a.rollback(v), w instanceof x ? w : J(
910
+ t,
911
+ t.node,
912
+ w instanceof O ? w.error : w,
913
+ { layer: "renderer", operation: "template-mount" }
914
+ );
915
+ }
916
+ }
917
+ const K = /* @__PURE__ */ Object.freeze({ componentInstances: ae, MountContext: R, rethrowUnhandledDOMOperationError: k, mountChildren: I, rangeElements: ce, mountComponent: Ae, removeDOMOutputWithOutcome: Ne, registerHydratingEffect: Y, ownDOMOutput: M, runMountTransaction: j, runTemplateOperation: $, captureDOMError: B, scheduleUnhandledAsyncError: V }), re = /* @__PURE__ */ Object.freeze({ MountContext: R, mountChildren: I, runTemplateOperation: $, runMountTransaction: j, rethrowUnhandledDOMOperationError: k, ownDOMOutput: M, rangeElements: ce, clearDOMBranchForTransaction: ut, selectDOMBranch: H, clearDOMBranch: G, commitOrAbsorbTransaction: Te, scheduleUnhandledAsyncError: V, captureDOMError: B, removeDOMOutputWithOutcome: Ne });
918
+ function at(t, e) {
919
+ switch (t.kind) {
920
+ case "hydration-boundary":
921
+ return e.env.operations.boundaries(re, t.kind).mountHydrationBoundary(t, e);
922
+ case "client-only":
923
+ return e.env.operations.boundaries(re, t.kind).mountClientOnly(t, e);
924
+ case "head":
925
+ return ar(t, e);
926
+ case "async-boundary":
927
+ return e.env.operations.asyncBoundary(re)(t, e);
928
+ case "component":
929
+ return Ae(t, e);
930
+ case "contribution":
931
+ return e.env.operations.advanced(K).contribution(t, e);
932
+ case "dynamic-component":
933
+ return Jt(t, e);
934
+ case "each":
935
+ return e.env.operations.mountEach(t, e, Gt);
936
+ case "element":
937
+ return Qt(t, e);
938
+ case "error-boundary":
939
+ return e.env.operations.boundaries(re, t.kind).mountErrorBoundary(t, e);
940
+ case "host-blueprint":
941
+ return xt(t, e);
942
+ case "keep-alive":
943
+ return e.env.operations.advanced(K).keepAlive(t, e);
944
+ case "match":
945
+ return rr(t, e);
946
+ case "slot":
947
+ return or(t, e);
948
+ case "style-value-scope":
949
+ return Xt(t, e);
950
+ case "raw-html":
951
+ return Zt(t, e);
952
+ case "region":
953
+ return e.env.operations.advanced(K).region(t, e);
954
+ case "teleport":
955
+ return e.env.operations.advanced(K).teleport(t, e);
956
+ case "text": {
957
+ const r = C(e.env.document)?.text() ?? e.env.document.createTextNode("");
958
+ return q(
959
+ e.effectScope,
960
+ () => {
961
+ try {
962
+ const o = t.read();
963
+ C(e.env.document)?.checkText(
964
+ r,
965
+ o == null ? "" : String(o)
966
+ );
967
+ const n = o == null ? "" : String(o);
968
+ r.data !== n && (r.data = n);
969
+ } catch (o) {
970
+ k(e, o, "text-write");
971
+ }
972
+ },
973
+ Z
974
+ ), A.single(r);
975
+ }
976
+ case "when":
977
+ return tr(t, e);
978
+ case "transition":
979
+ return e.env.operations.advanced(K).transition(t, e);
980
+ }
981
+ }
982
+ function Ae(t, e) {
983
+ const r = e.env.host.loadAsyncComponent(t.definition);
984
+ return r !== null ? Kt(t, r, e) : _e(t, e).output;
985
+ }
986
+ function _e(t, e) {
987
+ const r = bt(
988
+ t.props,
989
+ t.definition.emits?.names ?? [],
990
+ (a) => e.ownerNode.computed(a)
991
+ ), o = e.env.host.createChildComponent(
992
+ e.env.ownerComponent,
993
+ t.definition,
994
+ r.initial.props,
995
+ {
996
+ listeners: r.initial.listeners,
997
+ identity: C(e.env.document)?.componentIdentity(),
998
+ owner: e.ownerNode,
999
+ slots: t.slots,
1000
+ styleValues: e.env.styleValues,
1001
+ view: t.view
1002
+ }
1003
+ );
1004
+ ae.set(o.node, o), o.node.own(() => ae.delete(o.node)), t.ref !== null && e.transaction.addComponentRef(
1005
+ t.ref,
1006
+ o
1007
+ );
1008
+ for (const a of r.bindings)
1009
+ e.env.host.bindComponentInputs(o, a.source, {
1010
+ replaceListeners: a.replace,
1011
+ replaceProps: a.replace
1012
+ });
1013
+ const n = C(e.env.document);
1014
+ if (n !== void 0 && (o.setupStatus !== "ready" || n.work.hasPending(o.node))) {
1015
+ const a = o.setupStatus !== "ready", c = A.anchored(
1016
+ e.env.document,
1017
+ a ? "raphy:async-component" : "raphy:component"
1018
+ ), l = n.defer(c.first, !a);
1019
+ M(o.node, c, e);
1020
+ const u = (async () => {
1021
+ const p = await o.waitForSetup();
1022
+ if (p.status === "failed")
1023
+ throw p.error;
1024
+ if (await n.work.wait(o.node), o.disposed || c.parentNode === null)
1025
+ return;
1026
+ const h = new F();
1027
+ l.run(() => {
1028
+ const y = X(
1029
+ o,
1030
+ e.env.host,
1031
+ e.env.targetRuntime,
1032
+ e.env.document,
1033
+ e.env.hostBlueprintCache,
1034
+ e.env.eventHub,
1035
+ h,
1036
+ e.env.styleManager,
1037
+ e.env.operations,
1038
+ e.env.namespace,
1039
+ null,
1040
+ e.effectScope,
1041
+ he(e.env),
1042
+ ye(e.env),
1043
+ e.env.styleValueBoundary
1044
+ );
1045
+ c.adopt(y), y.moveBefore(c.parentNode, c.last);
1046
+ }), l.remaining(), l.commit(
1047
+ () => {
1048
+ N(h.commit(e.env.host), (y) => k(
1049
+ e,
1050
+ y,
1051
+ "hydrate-component",
1052
+ !0
1053
+ ));
1054
+ },
1055
+ () => {
1056
+ h.cancelAndTakeCompleted();
1057
+ }
1058
+ ), await l.ready();
1059
+ })();
1060
+ return e.env.host.trackRenderWork(o.node, u), n.track(u), {
1061
+ component: o,
1062
+ output: c
1063
+ };
1064
+ }
1065
+ if (o.setupStatus === "ready") {
1066
+ const a = X(
1067
+ o,
1068
+ e.env.host,
1069
+ e.env.targetRuntime,
1070
+ e.env.document,
1071
+ e.env.hostBlueprintCache,
1072
+ e.env.eventHub,
1073
+ e.transaction,
1074
+ e.env.styleManager,
1075
+ e.env.operations,
1076
+ e.env.namespace,
1077
+ e.env.asyncBoundary,
1078
+ e.effectScope,
1079
+ he(e.env),
1080
+ ye(e.env),
1081
+ e.env.styleValueBoundary
1082
+ );
1083
+ return {
1084
+ component: o,
1085
+ output: a
1086
+ };
1087
+ }
1088
+ const i = A.anchored(
1089
+ e.env.document,
1090
+ "raphy:async-component"
1091
+ );
1092
+ M(o.node, i, e);
1093
+ const s = async () => {
1094
+ const a = await o.waitForSetup();
1095
+ if (a.status === "disposed" || o.disposed)
1096
+ return;
1097
+ if (a.status === "failed") {
1098
+ Ze(o, a.error, e);
1099
+ return;
1100
+ }
1101
+ let c, l;
1102
+ try {
1103
+ l = new F();
1104
+ const d = X(
1105
+ o,
1106
+ e.env.host,
1107
+ e.env.targetRuntime,
1108
+ e.env.document,
1109
+ e.env.hostBlueprintCache,
1110
+ e.env.eventHub,
1111
+ l,
1112
+ e.env.styleManager,
1113
+ e.env.operations,
1114
+ e.env.namespace,
1115
+ e.env.asyncBoundary,
1116
+ e.effectScope,
1117
+ he(e.env),
1118
+ ye(e.env),
1119
+ e.env.styleValueBoundary
1120
+ );
1121
+ if (o.disposed || i.parentNode === null) {
1122
+ d.remove();
1123
+ return;
1124
+ }
1125
+ i.adopt(d), d.moveBefore(i.parentNode, i.last), c = Te(l, e);
1126
+ } catch (d) {
1127
+ const u = l?.open ? l.abortAndTakeCompleted(d) : void 0;
1128
+ if (u !== void 0) {
1129
+ let p;
1130
+ try {
1131
+ N(u, (h) => {
1132
+ const y = B(
1133
+ h,
1134
+ new R(
1135
+ { ...e.env, ownerComponent: o },
1136
+ e.effectScope,
1137
+ o.node,
1138
+ l
1139
+ ),
1140
+ { layer: "core", operation: "component-setup" }
1141
+ );
1142
+ if (!y.handled)
1143
+ throw new O(y.report.error);
1144
+ });
1145
+ } catch (h) {
1146
+ p = h;
1147
+ }
1148
+ try {
1149
+ o.dispose();
1150
+ } catch (h) {
1151
+ const y = p instanceof O ? p.error : p;
1152
+ throw new O(
1153
+ new AggregateError(
1154
+ [y, h],
1155
+ "[RaphyDOM] Async materialization and cleanup failed."
1156
+ )
1157
+ );
1158
+ }
1159
+ throw p;
1160
+ }
1161
+ Ze(o, d, e);
1162
+ return;
1163
+ }
1164
+ c !== void 0 && N(c, (d) => k(
1165
+ e,
1166
+ d,
1167
+ "async-component-resolve",
1168
+ !0
1169
+ ));
1170
+ };
1171
+ if (e.env.asyncBoundary === null) {
1172
+ const a = s();
1173
+ e.env.host.trackRenderWork(o.node, a), a.catch(V);
1174
+ } else
1175
+ e.env.asyncBoundary.register(s);
1176
+ return {
1177
+ component: o,
1178
+ output: i
1179
+ };
1180
+ }
1181
+ function Kt(t, e, r) {
1182
+ const o = A.anchored(
1183
+ r.env.document,
1184
+ "raphy:lazy-component"
1185
+ ), n = C(r.env.document);
1186
+ if (n !== void 0) {
1187
+ const c = n.defer(o.first), l = He(r.ownerNode, e).then((d) => {
1188
+ if (!(r.ownerNode.disposed || o.parentNode === null))
1189
+ return c.run(
1190
+ () => j(r, "hydrate-lazy", (u) => {
1191
+ const p = _e(
1192
+ { ...t, definition: d },
1193
+ new R(
1194
+ r.env,
1195
+ r.effectScope,
1196
+ r.ownerNode,
1197
+ u
1198
+ )
1199
+ ).output;
1200
+ o.adopt(p), p.moveBefore(o.parentNode, o.last);
1201
+ })
1202
+ ), c.remaining(), c.ready();
1203
+ });
1204
+ return r.env.host.trackRenderWork(r.ownerNode, l), n.track(l), M(r.ownerNode, o, r), o;
1205
+ }
1206
+ const i = new ee(
1207
+ r.ownerNode
1208
+ ), s = P(r.effectScope, i.node);
1209
+ M(i.node, o, r);
1210
+ const a = async () => {
1211
+ let c, l;
1212
+ try {
1213
+ const d = await He(i.node, e);
1214
+ if (i.disposed || o.parentNode === null)
1215
+ return;
1216
+ l = new F(), i.node.runtime.untracked(() => {
1217
+ H(
1218
+ i,
1219
+ r,
1220
+ l,
1221
+ "definition-resolve",
1222
+ "resolved",
1223
+ d,
1224
+ (u) => {
1225
+ const p = P(s, u.node), h = _e(
1226
+ {
1227
+ ...t,
1228
+ definition: d
1229
+ },
1230
+ new R(
1231
+ r.env,
1232
+ p,
1233
+ u.node,
1234
+ l
1235
+ )
1236
+ );
1237
+ M(u.node, h.output, r), o.adopt(h.output), h.output.moveBefore(o.parentNode, o.last);
1238
+ }
1239
+ );
1240
+ }), c = Te(l, r);
1241
+ } catch (d) {
1242
+ const u = l?.open ? l.abortAndTakeCompleted(d) : void 0;
1243
+ if (u !== void 0) {
1244
+ N(u, (h) => k(
1245
+ r,
1246
+ h,
1247
+ "definition-resolve",
1248
+ !0
1249
+ ));
1250
+ return;
1251
+ }
1252
+ if (d instanceof x)
1253
+ return;
1254
+ if (d instanceof O)
1255
+ throw d;
1256
+ if (i.disposed)
1257
+ return;
1258
+ const p = B(
1259
+ d,
1260
+ new R(
1261
+ r.env,
1262
+ r.effectScope,
1263
+ i.node,
1264
+ r.transaction
1265
+ ),
1266
+ {
1267
+ layer: "core",
1268
+ operation: "async-component-loader"
1269
+ }
1270
+ );
1271
+ if (!p.handled)
1272
+ throw p.report.error;
1273
+ }
1274
+ c !== void 0 && N(c, (d) => k(
1275
+ r,
1276
+ d,
1277
+ "definition-resolve",
1278
+ !0
1279
+ ));
1280
+ };
1281
+ if (r.env.asyncBoundary !== null)
1282
+ r.env.asyncBoundary.register(a);
1283
+ else {
1284
+ const c = a();
1285
+ r.env.host.trackRenderWork(i.node, c), c.catch(V);
1286
+ }
1287
+ return o;
1288
+ }
1289
+ function Jt(t, e) {
1290
+ const r = A.anchored(
1291
+ e.env.document,
1292
+ "raphy:dynamic-component"
1293
+ ), o = new ee(e.ownerNode), n = P(e.effectScope, o.node);
1294
+ let i = 0, s = null, a;
1295
+ return M(o.node, r, e), Y(
1296
+ r,
1297
+ e,
1298
+ n,
1299
+ () => {
1300
+ try {
1301
+ const c = t.readDefinition(), l = t.key();
1302
+ if (c == null) {
1303
+ s = null, a = void 0, o.node.runtime.untracked(
1304
+ () => G(o, e, "dynamic-component-update")
1305
+ );
1306
+ return;
1307
+ }
1308
+ if (c === s && Object.is(l, a))
1309
+ return;
1310
+ s = c, a = l;
1311
+ const d = ++i;
1312
+ j(
1313
+ e,
1314
+ "dynamic-component-update",
1315
+ (u) => {
1316
+ o.node.runtime.untracked(() => {
1317
+ H(
1318
+ o,
1319
+ e,
1320
+ u,
1321
+ "dynamic-component-update",
1322
+ d,
1323
+ { definition: c, key: l },
1324
+ (p) => {
1325
+ const h = P(n, p.node), y = Ae(
1326
+ {
1327
+ definition: c,
1328
+ kind: "component",
1329
+ props: t.props,
1330
+ ref: t.ref,
1331
+ slots: t.slots,
1332
+ view: null
1333
+ },
1334
+ new R(
1335
+ e.env,
1336
+ h,
1337
+ p.node,
1338
+ u
1339
+ )
1340
+ );
1341
+ M(p.node, y, e), r.adopt(y), y.moveBefore(r.parentNode, r.last);
1342
+ }
1343
+ );
1344
+ });
1345
+ }
1346
+ );
1347
+ } catch (c) {
1348
+ k(
1349
+ e,
1350
+ c,
1351
+ "dynamic-component-update"
1352
+ );
1353
+ }
1354
+ },
1355
+ { initial: "sync" }
1356
+ ), r;
1357
+ }
1358
+ function Ze(t, e, r) {
1359
+ if (e instanceof x) {
1360
+ try {
1361
+ t.dispose();
1362
+ } catch (n) {
1363
+ V(n);
1364
+ }
1365
+ return;
1366
+ }
1367
+ if (e instanceof O) {
1368
+ let n = e.error;
1369
+ try {
1370
+ t.dispose();
1371
+ } catch (i) {
1372
+ n = new AggregateError(
1373
+ [n, i],
1374
+ "[RaphyDOM] Async materialization and cleanup failed."
1375
+ );
1376
+ }
1377
+ V(n);
1378
+ return;
1379
+ }
1380
+ const o = B(
1381
+ e,
1382
+ new R(
1383
+ { ...r.env, ownerComponent: t },
1384
+ r.effectScope,
1385
+ t.node,
1386
+ r.transaction
1387
+ ),
1388
+ {
1389
+ layer: "core",
1390
+ operation: "component-setup"
1391
+ }
1392
+ );
1393
+ t.dispose(), o.handled || V(o.report.error);
1394
+ }
1395
+ function Te(t, e) {
1396
+ if (e.transaction.open) {
1397
+ e.transaction.absorb(t);
1398
+ return;
1399
+ }
1400
+ return t.commit(e.env.host);
1401
+ }
1402
+ function V(t) {
1403
+ if (t instanceof x)
1404
+ return;
1405
+ const e = t instanceof O ? t.error : t;
1406
+ queueMicrotask(() => {
1407
+ throw e;
1408
+ });
1409
+ }
1410
+ function Xt(t, e) {
1411
+ const r = e.env.host.createStyleValueScope(
1412
+ e.env.styleValues,
1413
+ t.overrides
1414
+ ), o = e.env.styleManager.createValueBoundary(r);
1415
+ try {
1416
+ o.refresh(), W(
1417
+ e.effectScope,
1418
+ () => {
1419
+ try {
1420
+ o.refresh();
1421
+ } catch (s) {
1422
+ k(
1423
+ e,
1424
+ s,
1425
+ "style-value-scope-update"
1426
+ );
1427
+ }
1428
+ },
1429
+ { initial: "scheduled" }
1430
+ );
1431
+ const n = $(
1432
+ e.env.targetRuntime,
1433
+ e.env.styleScopeId,
1434
+ t.content
1435
+ ), i = I(
1436
+ n,
1437
+ new R(
1438
+ {
1439
+ ...e.env,
1440
+ styleValueBoundary: o,
1441
+ styleValues: r
1442
+ },
1443
+ e.effectScope,
1444
+ e.ownerNode,
1445
+ e.transaction
1446
+ ),
1447
+ "raphy:style-value-scope"
1448
+ );
1449
+ return i.onRemoved(() => o.dispose()), i;
1450
+ } catch (n) {
1451
+ throw o.dispose(), n;
1452
+ }
1453
+ }
1454
+ function Qt(t, e) {
1455
+ const r = Q(t, e), o = A.single(r), n = e.env.styleValueBoundary;
1456
+ return n !== void 0 && o.onRemoved(() => n.detach(r)), o;
1457
+ }
1458
+ function Q(t, e) {
1459
+ const r = e.env, o = nr(r.namespace, t.tag), n = o === "svg" ? "http://www.w3.org/2000/svg" : o === "mathml" ? "http://www.w3.org/1998/Math/MathML" : "http://www.w3.org/1999/xhtml", i = C(r.document), s = i?.element(t.tag, n);
1460
+ if (i !== void 0 && s === void 0)
1461
+ return i.suspend(() => Q(t, e));
1462
+ const a = s ?? (o === "svg" ? r.document.createElementNS("http://www.w3.org/2000/svg", t.tag) : o === "mathml" ? r.document.createElementNS(
1463
+ "http://www.w3.org/1998/Math/MathML",
1464
+ t.tag
1465
+ ) : r.document.createElement(t.tag));
1466
+ if (r.styleValueBoundary?.attach(a), r.styleManager.applicationScopeId !== void 0 && (s === void 0 && (o !== "html" || !t.tag.includes("-")) ? a.setAttribute("data-r-scope", r.styleManager.applicationScopeId) : z(
1467
+ a,
1468
+ "data-r-scope",
1469
+ r.styleManager.applicationScopeId
1470
+ )), r.styleScopeId !== void 0 && z(a, "data-r-scope", r.styleScopeId), r.componentRoot === !0) {
1471
+ for (const p of r.inheritedStyleScopeIds ?? [])
1472
+ z(a, "data-r-scope", p);
1473
+ for (const p of r.slottedStyleScopeIds ?? [])
1474
+ z(a, "data-r-slotted", p);
1475
+ }
1476
+ const c = t.props, l = $t(
1477
+ a,
1478
+ c,
1479
+ e.ownerNode,
1480
+ e.effectScope,
1481
+ r.eventHub,
1482
+ e,
1483
+ Se
1484
+ );
1485
+ t.ref !== null && e.transaction.addElementRef(t.ref, a, e.ownerNode);
1486
+ const d = t.children, u = d.length;
1487
+ if (u !== 0) {
1488
+ const p = ir(o, t), y = r.componentRoot !== !0 && r.styleValueBoundary === void 0 && p === r.namespace && (r.inheritedStyleScopeIds?.length ?? 0) === 0 && (r.slottedStyleScopeIds?.length ?? 0) === 0 ? e : new R(
1489
+ {
1490
+ ...r,
1491
+ componentRoot: !1,
1492
+ inheritedStyleScopeIds: [],
1493
+ namespace: p,
1494
+ slottedStyleScopeIds: [],
1495
+ styleValueBoundary: void 0
1496
+ },
1497
+ e.effectScope,
1498
+ e.ownerNode,
1499
+ e.transaction
1500
+ );
1501
+ for (let v = 0; v < u; v++) {
1502
+ const w = d[v];
1503
+ typeof w == "string" ? ze(a, rt(r.document, w)) : w.kind === "element" ? ze(a, Q(w, y)) : at(w, y).moveBefore(a, null);
1504
+ }
1505
+ }
1506
+ return l !== void 0 && jt(
1507
+ a,
1508
+ c,
1509
+ l,
1510
+ e.ownerNode,
1511
+ e.effectScope,
1512
+ r.eventHub,
1513
+ e,
1514
+ Se,
1515
+ r.operations.binding()
1516
+ ), C(r.document)?.finishElement(
1517
+ a,
1518
+ t.tag === "textarea" && u === 0
1519
+ ), a;
1520
+ }
1521
+ function ct(t, e) {
1522
+ return typeof t == "string" ? A.single(rt(e.env.document, t)) : at(t, e);
1523
+ }
1524
+ function I(t, e, r) {
1525
+ return dt(Ee(t), e, r);
1526
+ }
1527
+ function qt(t, e) {
1528
+ const r = Ee(t);
1529
+ return r.length === 1 ? ct(r[0], e) : dt(r, e, "raphy:each:item");
1530
+ }
1531
+ function dt(t, e, r) {
1532
+ const o = A.anchored(e.env.document, r), n = o.parentNode;
1533
+ for (const i of t) {
1534
+ if (e.ownerNode.disposed)
1535
+ break;
1536
+ const s = ct(i, e);
1537
+ if (e.ownerNode.disposed)
1538
+ break;
1539
+ s.plainNode() === null && o.adopt(s), s.moveBefore(n, o.last);
1540
+ }
1541
+ return o;
1542
+ }
1543
+ function Zt(t, e) {
1544
+ const r = A.anchored(e.env.document, "raphy:raw-html"), o = C(e.env.document);
1545
+ o?.owns(r.first) && o.skip(r.first);
1546
+ let n = o?.owns(r.first) === !0;
1547
+ const i = /* @__PURE__ */ new Set();
1548
+ return r.onRemoved(() => {
1549
+ for (const s of i)
1550
+ e.env.styleValueBoundary?.detach(s);
1551
+ i.clear();
1552
+ }), W(
1553
+ e.effectScope,
1554
+ () => {
1555
+ try {
1556
+ const s = t.read();
1557
+ if (s != null) {
1558
+ if (t.unsafe && typeof s != "string")
1559
+ throw new TypeError(
1560
+ "[RaphyDOM] unsafeHtml() source must contain a string."
1561
+ );
1562
+ if (!t.unsafe && typeof s != "string" && typeof s != "object")
1563
+ throw new TypeError(
1564
+ "[RaphyDOM] safeHtml() source must contain TrustedHTML or branded-safe text."
1565
+ );
1566
+ }
1567
+ const a = e.env.document.createElement("template");
1568
+ if (a.innerHTML = s == null ? "" : String(s), n) {
1569
+ n = !1;
1570
+ for (const c of ce(r)) {
1571
+ for (const l of [c, ...c.querySelectorAll("*")])
1572
+ z(l, "data-r-scope", e.env.styleManager.applicationScopeId);
1573
+ e.env.styleValueBoundary?.attach(c), i.add(c);
1574
+ }
1575
+ return;
1576
+ }
1577
+ if (e.env.styleManager.applicationScopeId !== void 0)
1578
+ for (const c of a.content.querySelectorAll("*"))
1579
+ z(
1580
+ c,
1581
+ "data-r-scope",
1582
+ e.env.styleManager.applicationScopeId
1583
+ );
1584
+ for (const c of i)
1585
+ e.env.styleValueBoundary?.detach(c);
1586
+ i.clear(), r.clear(), r.parentNode.insertBefore(a.content, r.last);
1587
+ for (const c of ce(r))
1588
+ e.env.styleValueBoundary?.attach(c), i.add(c);
1589
+ } catch (s) {
1590
+ k(
1591
+ e,
1592
+ s,
1593
+ t.unsafe ? "unsafe-html-write" : "safe-html-write"
1594
+ );
1595
+ }
1596
+ },
1597
+ { initial: "sync" }
1598
+ ), r;
1599
+ }
1600
+ function xt(t, e) {
1601
+ const r = lt(t, e), o = A.single(r), n = e.env.styleValueBoundary;
1602
+ return n !== void 0 && o.onRemoved(() => n.detach(r)), o;
1603
+ }
1604
+ const er = /* @__PURE__ */ Object.freeze({ materializeElement: Q, appendStyleScope: z, captureDOMWriteError: Se, rethrowUnhandledDOMOperationError: k });
1605
+ function lt(t, e) {
1606
+ const r = e.env.hostBlueprintCache;
1607
+ if (r === void 0)
1608
+ throw new TypeError("[RaphyDOM] Foreign host-blueprint plan requires the Full target.");
1609
+ return r.materialize(t, e, er);
1610
+ }
1611
+ function Y(t, e, r, o, n) {
1612
+ const i = C(e.env.document);
1613
+ if (i === void 0) {
1614
+ if (n.initial !== "sync") {
1615
+ W(r, o, n);
1616
+ return;
1617
+ }
1618
+ wt(e.transaction, e.ownerNode, o, (d) => W(r, d, n));
1619
+ return;
1620
+ }
1621
+ if (!i.owns(t.first)) {
1622
+ W(r, () => i.suspend(o), n);
1623
+ return;
1624
+ }
1625
+ const s = i.defer(t.first);
1626
+ let a = !0, c, l;
1627
+ i.track(
1628
+ new Promise((d, u) => {
1629
+ c = d, l = u;
1630
+ })
1631
+ ), W(
1632
+ r,
1633
+ () => {
1634
+ if (!a) {
1635
+ o();
1636
+ return;
1637
+ }
1638
+ a = !1;
1639
+ try {
1640
+ s.run(o), s.remaining(), s.ready().then(c, l);
1641
+ } catch (d) {
1642
+ throw l(d), d;
1643
+ }
1644
+ },
1645
+ n
1646
+ );
1647
+ }
1648
+ function tr(t, e) {
1649
+ const r = A.anchored(e.env.document, "raphy:when"), o = new ee(
1650
+ e.ownerNode
1651
+ ), n = P(e.effectScope, o.node);
1652
+ return M(o.node, r, e), Y(
1653
+ r,
1654
+ e,
1655
+ n,
1656
+ () => {
1657
+ try {
1658
+ const i = t.condition(), s = i ? "consequent" : "alternate", a = i ? t.consequent : t.alternate;
1659
+ j(e, "when-update", (c) => {
1660
+ o.node.runtime.untracked(() => {
1661
+ if (a === void 0) {
1662
+ G(o, e, "when-update");
1663
+ return;
1664
+ }
1665
+ H(
1666
+ o,
1667
+ e,
1668
+ c,
1669
+ "when-update",
1670
+ s,
1671
+ i,
1672
+ (l) => {
1673
+ const d = P(n, l.node), u = I(
1674
+ $(
1675
+ e.env.targetRuntime,
1676
+ e.env.styleScopeId,
1677
+ a
1678
+ ),
1679
+ new R(
1680
+ e.env,
1681
+ d,
1682
+ l.node,
1683
+ c
1684
+ ),
1685
+ `raphy:when:${s}`
1686
+ );
1687
+ l.node.disposed || (M(l.node, u, e), r.adopt(u), u.moveBefore(r.parentNode, r.last));
1688
+ }
1689
+ );
1690
+ });
1691
+ });
1692
+ } catch (i) {
1693
+ k(e, i, "when-update");
1694
+ }
1695
+ },
1696
+ { initial: "sync" }
1697
+ ), r;
1698
+ }
1699
+ function rr(t, e) {
1700
+ const r = A.anchored(e.env.document, "raphy:match"), o = new ee(e.ownerNode), n = P(e.effectScope, o.node);
1701
+ return M(o.node, r, e), Y(
1702
+ r,
1703
+ e,
1704
+ n,
1705
+ () => {
1706
+ try {
1707
+ const i = t.read();
1708
+ let s = -1;
1709
+ for (const [c, l] of t.clauses.entries())
1710
+ if (l.kind === "otherwise" || l.predicate(i)) {
1711
+ s = c;
1712
+ break;
1713
+ }
1714
+ if (s === -1) {
1715
+ o.node.runtime.untracked(
1716
+ () => G(o, e, "match-update")
1717
+ );
1718
+ return;
1719
+ }
1720
+ const a = t.clauses[s];
1721
+ j(e, "match-update", (c) => {
1722
+ o.node.runtime.untracked(() => {
1723
+ H(
1724
+ o,
1725
+ e,
1726
+ c,
1727
+ "match-update",
1728
+ s,
1729
+ i,
1730
+ (l) => {
1731
+ const d = P(n, l.node), u = I(
1732
+ $(
1733
+ e.env.targetRuntime,
1734
+ e.env.styleScopeId,
1735
+ () => a.render(() => l.value.get())
1736
+ ),
1737
+ new R(
1738
+ e.env,
1739
+ d,
1740
+ l.node,
1741
+ c
1742
+ ),
1743
+ `raphy:match:${s}`
1744
+ );
1745
+ l.node.disposed || (M(l.node, u, e), r.adopt(u), u.moveBefore(r.parentNode, r.last));
1746
+ }
1747
+ );
1748
+ });
1749
+ });
1750
+ } catch (i) {
1751
+ k(e, i, "match-update");
1752
+ }
1753
+ },
1754
+ { initial: "sync" }
1755
+ ), r;
1756
+ }
1757
+ function k(t, e, r, o = !1) {
1758
+ if (e instanceof x) {
1759
+ if (t.ownerNode.disposed)
1760
+ throw e;
1761
+ return;
1762
+ }
1763
+ if (e instanceof O)
1764
+ throw o ? e : e.error;
1765
+ if (t.ownerNode.disposed) {
1766
+ const i = e instanceof tt ? e.cause : e;
1767
+ if (i instanceof O)
1768
+ throw o ? i : i.error;
1769
+ return;
1770
+ }
1771
+ const n = B(e, t, {
1772
+ layer: "renderer",
1773
+ operation: r,
1774
+ phase: U
1775
+ });
1776
+ if (!n.handled)
1777
+ throw o ? new O(n.report.error) : n.report.error;
1778
+ }
1779
+ function Se(t, e, r) {
1780
+ if (t.env.eventHub._disposed)
1781
+ return !1;
1782
+ const o = B(e, t, {
1783
+ layer: "renderer",
1784
+ operation: r,
1785
+ phase: U
1786
+ });
1787
+ if (!o.handled)
1788
+ throw o.report.error;
1789
+ return !0;
1790
+ }
1791
+ function $(t, e, r) {
1792
+ return e === void 0 ? t.node.run(r) : t.node.run(r, { styleScopeId: e });
1793
+ }
1794
+ function B(t, e, r) {
1795
+ const o = J(
1796
+ e.env.ownerComponent,
1797
+ e.ownerNode,
1798
+ t,
1799
+ r
1800
+ );
1801
+ return e.env.host.captureError(
1802
+ o.component,
1803
+ o.owner,
1804
+ o.cause,
1805
+ o.source
1806
+ );
1807
+ }
1808
+ function j(t, e, r) {
1809
+ if (t.transaction.open) {
1810
+ r(t.transaction);
1811
+ return;
1812
+ }
1813
+ const o = new F();
1814
+ let n;
1815
+ try {
1816
+ r(o);
1817
+ } catch (i) {
1818
+ n = o.abort(i);
1819
+ }
1820
+ if (n !== void 0) {
1821
+ N(n, (i) => k(t, i, e, !0));
1822
+ return;
1823
+ }
1824
+ o.afterHolds(() => {
1825
+ const i = o.commit(t.env.host);
1826
+ i !== void 0 && N(i, (s) => k(t, s, e, !0));
1827
+ });
1828
+ }
1829
+ function M(t, e, r) {
1830
+ const o = r.env.host, n = r.env.ownerComponent;
1831
+ t._ownCompletedCleanup(
1832
+ () => Ne(e, o, n)
1833
+ );
1834
+ }
1835
+ function Ne(t, e, r, o = !1) {
1836
+ try {
1837
+ t.remove(o);
1838
+ } catch (n) {
1839
+ const i = le(n, e, r, {
1840
+ layer: "renderer",
1841
+ operation: "dom-output-dispose"
1842
+ });
1843
+ if (!i.handled)
1844
+ return {
1845
+ error: i.report.error,
1846
+ hasUnrouted: !1,
1847
+ completed: { error: i.report.error }
1848
+ };
1849
+ }
1850
+ }
1851
+ function le(t, e, r, o) {
1852
+ return e.captureError(r, r.node, t, o, {
1853
+ rendererBoundary: !1
1854
+ });
1855
+ }
1856
+ function G(t, e, r) {
1857
+ t._clearWithDisposalFailure((o) => {
1858
+ ot(o, (n) => le(
1859
+ n,
1860
+ e.env.host,
1861
+ e.env.ownerComponent,
1862
+ { layer: "renderer", operation: r, phase: U }
1863
+ ));
1864
+ });
1865
+ }
1866
+ function ut(t, e, r, o) {
1867
+ try {
1868
+ G(t, e, o);
1869
+ } catch (n) {
1870
+ if (!(n instanceof O))
1871
+ throw n;
1872
+ r.deferCompletedFailure(n.error);
1873
+ }
1874
+ }
1875
+ function H(t, e, r, o, n, i, s) {
1876
+ gt(
1877
+ (a) => t._selectWithDisposalFailure(n, i, a, (c) => {
1878
+ try {
1879
+ ot(c, (l) => le(
1880
+ l,
1881
+ e.env.host,
1882
+ e.env.ownerComponent,
1883
+ { layer: "renderer", operation: o, phase: U }
1884
+ ));
1885
+ } catch (l) {
1886
+ if (!(l instanceof O))
1887
+ throw l;
1888
+ r.deferCompletedFailure(l.error);
1889
+ }
1890
+ }),
1891
+ s,
1892
+ (a, c) => B(
1893
+ a,
1894
+ new R(
1895
+ e.env,
1896
+ e.effectScope,
1897
+ c.node,
1898
+ e.transaction
1899
+ ),
1900
+ { layer: "renderer", operation: o }
1901
+ )
1902
+ );
1903
+ }
1904
+ function or(t, e) {
1905
+ const r = A.anchored(e.env.document, "raphy:slot"), o = vt(t.props, (d) => e.ownerNode.computed(d)), n = e.env.host.createSlotBlock(
1906
+ e.env.ownerComponent,
1907
+ e.ownerNode,
1908
+ o.initial
1909
+ ), i = P(e.effectScope, n.node);
1910
+ M(n.node, r, e);
1911
+ for (const d of o.bindings)
1912
+ e.env.host.bindSlotProps(n, d.source, {
1913
+ replace: d.replace
1914
+ });
1915
+ if (t.providerSource !== void 0) {
1916
+ const d = new ee(n.node), u = Symbol("raphy-slot-fallback");
1917
+ return Y(
1918
+ r,
1919
+ e,
1920
+ i,
1921
+ () => {
1922
+ try {
1923
+ const p = t.providerSource(), h = p ?? t.fallback;
1924
+ if (h === void 0) {
1925
+ G(d, e, "slot-update");
1926
+ return;
1927
+ }
1928
+ const y = p ?? u;
1929
+ j(e, "slot-update", (v) => {
1930
+ n.node.runtime.untracked(() => {
1931
+ H(
1932
+ d,
1933
+ e,
1934
+ v,
1935
+ "slot-update",
1936
+ y,
1937
+ h,
1938
+ (w) => {
1939
+ const _ = P(i, w.node), S = p === void 0 ? e.env.styleScopeId : Le(p), T = $(
1940
+ e.env.targetRuntime,
1941
+ S,
1942
+ () => p === void 0 ? t.fallback() : t.scoped ? p(n.props) : p()
1943
+ ), f = I(
1944
+ T,
1945
+ new R(
1946
+ {
1947
+ ...e.env,
1948
+ componentRoot: !0,
1949
+ slottedStyleScopeIds: p === void 0 ? e.env.slottedStyleScopeIds : [
1950
+ ...e.env.slottedStyleScopeIds ?? [],
1951
+ e.env.styleScopeId
1952
+ ].filter(Oe),
1953
+ styleScopeId: S
1954
+ },
1955
+ _,
1956
+ w.node,
1957
+ v
1958
+ ),
1959
+ p === void 0 ? "raphy:slot:fallback" : "raphy:slot:content"
1960
+ );
1961
+ w.node.disposed || (M(w.node, f, e), r.adopt(f), f.moveBefore(r.parentNode, r.last));
1962
+ }
1963
+ );
1964
+ });
1965
+ });
1966
+ } catch (p) {
1967
+ k(
1968
+ e,
1969
+ p,
1970
+ "slot-provider-update"
1971
+ );
1972
+ }
1973
+ },
1974
+ { initial: "sync" }
1975
+ ), r;
1976
+ }
1977
+ if ((t.provider ?? t.fallback) === void 0)
1978
+ return r;
1979
+ const a = t.provider === void 0 ? e.env.styleScopeId : Le(t.provider), c = n.node.runtime.untracked(
1980
+ () => $(e.env.targetRuntime, a, () => t.provider === void 0 ? t.fallback() : t.scoped ? t.provider(n.props) : t.provider())
1981
+ ), l = I(
1982
+ c,
1983
+ new R(
1984
+ {
1985
+ ...e.env,
1986
+ componentRoot: !0,
1987
+ slottedStyleScopeIds: t.provider === void 0 ? e.env.slottedStyleScopeIds : [
1988
+ ...e.env.slottedStyleScopeIds ?? [],
1989
+ e.env.styleScopeId
1990
+ ].filter(Oe),
1991
+ styleScopeId: a
1992
+ },
1993
+ i,
1994
+ n.node,
1995
+ e.transaction
1996
+ ),
1997
+ t.provider === void 0 ? "raphy:slot:fallback" : "raphy:slot:content"
1998
+ );
1999
+ return n.node.disposed || (M(n.node, l, e), r.adopt(l), l.moveBefore(r.parentNode, r.last)), r;
2000
+ }
2001
+ function nr(t, e) {
2002
+ return e === "svg" ? "svg" : e === "math" ? "mathml" : t;
2003
+ }
2004
+ function ir(t, e) {
2005
+ if (t === "svg" && (e.tag === "foreignObject" || e.tag === "desc" || e.tag === "title"))
2006
+ return "html";
2007
+ if (t !== "mathml")
2008
+ return t;
2009
+ if (e.tag === "svg")
2010
+ return "svg";
2011
+ if (e.tag === "mi" || e.tag === "mo" || e.tag === "mn" || e.tag === "ms" || e.tag === "mtext")
2012
+ return "html";
2013
+ if (e.tag === "annotation-xml") {
2014
+ const r = sr(e.props, "encoding");
2015
+ if (typeof r == "string" && (r.toLowerCase() === "text/html" || r.toLowerCase() === "application/xhtml+xml"))
2016
+ return "html";
2017
+ }
2018
+ return "mathml";
2019
+ }
2020
+ function sr(t, e) {
2021
+ if (typeof t != "object" || t === null || "read" in t)
2022
+ return;
2023
+ const r = Reflect.get(t, e);
2024
+ return typeof r == "object" && r !== null && "read" in r ? void 0 : r;
2025
+ }
2026
+ function ce(t) {
2027
+ const e = [];
2028
+ let r = t.first.nextSibling;
2029
+ for (; r !== null && r !== t.last; )
2030
+ r.nodeType === 1 && e.push(r), r = r.nextSibling;
2031
+ return t.first === t.last && t.first.nodeType === 1 && e.push(t.first), e;
2032
+ }
2033
+ function z(t, e, r) {
2034
+ if (r === void 0)
2035
+ return;
2036
+ const o = new Set(
2037
+ (t.getAttribute(e) ?? "").split(/\s+/).filter(Boolean)
2038
+ );
2039
+ o.add(r), t.setAttribute(e, [...o].join(" "));
2040
+ }
2041
+ function he(t) {
2042
+ return [
2043
+ ...t.componentRoot === !0 ? t.inheritedStyleScopeIds ?? [] : [],
2044
+ t.styleScopeId
2045
+ ].filter(Oe);
2046
+ }
2047
+ function ye(t) {
2048
+ return t.componentRoot === !0 ? t.slottedStyleScopeIds ?? [] : [];
2049
+ }
2050
+ function Oe(t) {
2051
+ return t !== void 0;
2052
+ }
2053
+ function ar(t, e) {
2054
+ const r = A.anchored(e.env.document, "raphy:head");
2055
+ for (const o of t.entries)
2056
+ e.ownerNode.own(
2057
+ Yt(
2058
+ e.env.document,
2059
+ e.env.styleManager.applicationId,
2060
+ o
2061
+ )
2062
+ );
2063
+ return r;
2064
+ }
2065
+ const me = /* @__PURE__ */ new WeakMap();
2066
+ function Ce(t) {
2067
+ const e = t.getRootNode();
2068
+ return t.parentElement ?? (e.nodeType === 11 && "host" in e ? e.host : null);
2069
+ }
2070
+ function xe(t, e, r) {
2071
+ return (t.getAttribute(e) ?? "").split(/\s+/u).includes(r);
2072
+ }
2073
+ function cr(t, e) {
2074
+ for (let r = e; r !== null; r = Ce(r))
2075
+ if (r === t)
2076
+ return !0;
2077
+ return !1;
2078
+ }
2079
+ function et(t, e) {
2080
+ for (let r = t; r !== null; r = Ce(r)) {
2081
+ if (r.hasAttribute("hidden") || r.hasAttribute("inert") || r.getAttribute("aria-hidden") === "true" || r.tagName === "DIALOG" && !r.hasAttribute("open"))
2082
+ return !1;
2083
+ const o = e.getComputedStyle(r);
2084
+ if (o.display === "none" || o.visibility === "hidden" || o.visibility === "collapse")
2085
+ return !1;
2086
+ }
2087
+ return !t.matches(':disabled, input[type="hidden"]');
2088
+ }
2089
+ function oe(t) {
2090
+ if (t !== void 0 && !Number.isFinite(t))
2091
+ throw new TypeError("[RaphyDOM] Presentation coordinates must be finite.");
2092
+ }
2093
+ function dr(t) {
2094
+ const e = t.history;
2095
+ if (!("scrollRestoration" in e))
2096
+ return () => {
2097
+ };
2098
+ let r = me.get(t);
2099
+ r === void 0 && (r = { count: 0, previous: e.scrollRestoration }, e.scrollRestoration = "manual", me.set(t, r)), r.count++;
2100
+ let o = !0;
2101
+ return () => {
2102
+ o && (o = !1, r.count--, r.count === 0 && (me.delete(t), e.scrollRestoration === "manual" && (e.scrollRestoration = r.previous)));
2103
+ };
2104
+ }
2105
+ function lr(t, e, r, o) {
2106
+ const n = e.ownerDocument, i = n.defaultView;
2107
+ if (i === null)
2108
+ return Object.freeze({ dispose: () => {
2109
+ } });
2110
+ const s = /* @__PURE__ */ new Set();
2111
+ let a, c = !1;
2112
+ const l = () => {
2113
+ if (c || t.applicationNode.disposed)
2114
+ throw new Error("[RaphyDOM] Application presentation is disposed.");
2115
+ }, d = (f, m = r.boundaries()) => {
2116
+ if (!f.isConnected || f.ownerDocument !== n || !xe(f, "data-r-scope", o))
2117
+ return !1;
2118
+ for (let g = f; g !== null; g = Ce(g)) {
2119
+ if (g.hasAttribute("data-r-app") && !xe(g, "data-r-app", o))
2120
+ return !1;
2121
+ if (m.some((b) => g === b || b.nodeType === 11 && g === b.host))
2122
+ return !0;
2123
+ }
2124
+ return !1;
2125
+ }, u = (f) => {
2126
+ const m = /* @__PURE__ */ new Set(), g = r.boundaries();
2127
+ for (const b of g) {
2128
+ b.nodeType === 1 && b.matches(f) && d(b, g) && m.add(b);
2129
+ for (const D of b.querySelectorAll(f))
2130
+ d(D, g) && m.add(D);
2131
+ }
2132
+ return [...m];
2133
+ }, p = (f) => {
2134
+ const m = t.host.resolveAuxiliaryTarget(f);
2135
+ if (!(m instanceof i.Element) || !d(m))
2136
+ throw new TypeError("[RaphyDOM] Presentation target must be a live element owned by this application.");
2137
+ return m;
2138
+ }, h = (f) => {
2139
+ if (typeof f != "string")
2140
+ throw new TypeError("[RaphyDOM] Presentation anchor must be a string.");
2141
+ let m;
2142
+ try {
2143
+ m = decodeURIComponent(f.startsWith("#") ? f.slice(1) : f);
2144
+ } catch {
2145
+ return;
2146
+ }
2147
+ return m.length === 0 ? void 0 : u("[id]").find((g) => g.id === m);
2148
+ }, y = (f) => {
2149
+ if (f.target !== void 0 && f.anchor !== void 0)
2150
+ throw new TypeError("[RaphyDOM] Presentation target and anchor are mutually exclusive.");
2151
+ return f.target !== void 0 ? p(f.target) : f.anchor !== void 0 ? h(f.anchor) : void 0;
2152
+ }, v = (f) => {
2153
+ l();
2154
+ const m = f === void 0 ? void 0 : p(f);
2155
+ return Object.freeze({ x: m?.scrollLeft ?? i.scrollX, y: m?.scrollTop ?? i.scrollY });
2156
+ }, w = (f) => {
2157
+ l(), oe(f.x), oe(f.y), oe(f.offset?.x), oe(f.offset?.y);
2158
+ const m = f.container === void 0 ? void 0 : p(f.container), g = y(f);
2159
+ if (f.anchor !== void 0 && g === void 0 || g === void 0 && f.x === void 0 && f.y === void 0)
2160
+ return;
2161
+ if (m !== void 0 && g !== void 0 && !cr(m, g))
2162
+ throw new TypeError("[RaphyDOM] Presentation target is outside the requested scroll container.");
2163
+ const b = v(f.container);
2164
+ let D = f.x ?? b.x, E = f.y ?? b.y;
2165
+ if (g !== void 0) {
2166
+ const $e = g.getBoundingClientRect(), je = m?.getBoundingClientRect();
2167
+ D = $e.left + b.x - (je?.left ?? 0) - (m?.clientLeft ?? 0) - (f.offset?.x ?? 0), E = $e.top + b.y - (je?.top ?? 0) - (m?.clientTop ?? 0) - (f.offset?.y ?? 0);
2168
+ }
2169
+ const Ie = f.behavior === "smooth" && i.matchMedia?.("(prefers-reduced-motion: reduce)").matches !== !0 ? "smooth" : "instant";
2170
+ m === void 0 ? i.scrollTo({ left: D, top: E, behavior: Ie }) : m.scrollTo({ left: D, top: E, behavior: Ie });
2171
+ }, _ = (f) => {
2172
+ l();
2173
+ const m = f.target !== void 0 || f.anchor !== void 0, g = e.nodeType === 11 ? e.host : e, b = y(f) ?? (m ? void 0 : [
2174
+ ...u('main, [role="main"]'),
2175
+ ...u("h1"),
2176
+ g
2177
+ ].find((E) => et(E, i)));
2178
+ if (b === void 0 || !et(b, i))
2179
+ return;
2180
+ const D = Reflect.get(b, "focus");
2181
+ if (typeof D == "function") {
2182
+ if (a?.(), !b.hasAttribute("tabindex") && Reflect.get(b, "tabIndex") < 0) {
2183
+ b.setAttribute("tabindex", "-1");
2184
+ const E = () => {
2185
+ b.removeEventListener("blur", E), b.getAttribute("tabindex") === "-1" && b.removeAttribute("tabindex"), a === E && (a = void 0);
2186
+ };
2187
+ a = E, b.addEventListener("blur", E, { once: !0 });
2188
+ }
2189
+ try {
2190
+ Reflect.apply(D, b, [{ preventScroll: f.preventScroll ?? !0 }]);
2191
+ } catch (E) {
2192
+ throw a?.(), E;
2193
+ }
2194
+ }
2195
+ }, S = () => {
2196
+ if (c)
2197
+ return;
2198
+ c = !0, a?.();
2199
+ const f = [];
2200
+ for (const m of [...s])
2201
+ try {
2202
+ m();
2203
+ } catch (g) {
2204
+ f.push(g);
2205
+ }
2206
+ if (f.length > 0)
2207
+ throw new AggregateError(f, "[RaphyDOM] Presentation cleanup failed.");
2208
+ }, T = Object.freeze({
2209
+ readScroll: v,
2210
+ scroll: w,
2211
+ focus: _,
2212
+ manualScrollRestoration() {
2213
+ l();
2214
+ const f = dr(i), m = () => {
2215
+ s.delete(m), f();
2216
+ };
2217
+ return s.add(m), m;
2218
+ }
2219
+ });
2220
+ return t.applicationNode.own(S), t.capabilities.provide(Nt, T), Object.freeze({ dispose: S });
2221
+ }
2222
+ function ur(t, e, r, o, n, i) {
2223
+ const s = /* @__PURE__ */ new Map();
2224
+ t.applicationNode.own(() => {
2225
+ const d = [...s.values()].reverse();
2226
+ s.clear();
2227
+ const u = [];
2228
+ for (const p of d)
2229
+ try {
2230
+ p.dispose();
2231
+ } catch (h) {
2232
+ u.push(h);
2233
+ }
2234
+ if (u.length)
2235
+ throw new AggregateError(u, "[RaphyDOM] Auxiliary shared cleanup failed.");
2236
+ });
2237
+ const a = (d, u) => {
2238
+ const p = n.checkpoint(), h = new F();
2239
+ try {
2240
+ const y = X(d, t.host, t.targetRuntime, e.target.ownerDocument, r, o, h, n, i);
2241
+ y.moveBefore(u, null);
2242
+ const v = h.commit(t.host);
2243
+ return N(v, (w) => {
2244
+ throw w;
2245
+ }), y;
2246
+ } catch (y) {
2247
+ const v = y instanceof tt ? y.cause : y instanceof O ? y.error : y, w = [v];
2248
+ try {
2249
+ n.rollback(p);
2250
+ } catch (_) {
2251
+ w.push(_);
2252
+ }
2253
+ if (h.open)
2254
+ try {
2255
+ N(h.abortAndTakeCompleted(y), (_) => {
2256
+ throw _;
2257
+ });
2258
+ } catch (_) {
2259
+ w.push(_ instanceof O ? _.error : _);
2260
+ }
2261
+ try {
2262
+ d.dispose();
2263
+ } catch (_) {
2264
+ w.push(_);
2265
+ }
2266
+ throw w.length > 1 ? new AggregateError(w, "[RaphyDOM] Auxiliary mount rollback failed.") : v;
2267
+ }
2268
+ }, c = (d, u) => {
2269
+ const p = t.host.resolveAuxiliaryTarget(d, u);
2270
+ if (!(p instanceof e.target.ownerDocument.defaultView.Element) || p.ownerDocument !== e.target.ownerDocument || !p.isConnected)
2271
+ throw new TypeError("[RaphyDOM] Auxiliary placement requires a connected same-document target.");
2272
+ return p;
2273
+ }, l = {
2274
+ shared(d, u) {
2275
+ if (t.applicationNode.disposed)
2276
+ throw new Error("[RaphyDOM] Auxiliary application is disposed.");
2277
+ let p = s.get(d);
2278
+ return p === void 0 && (p = u(), s.set(d, p)), p.value;
2279
+ },
2280
+ create(d, u, p) {
2281
+ const h = t.host.createAuxiliaryComponent(d, u, p);
2282
+ let y, v;
2283
+ const w = () => {
2284
+ const S = v;
2285
+ v = void 0, S?.dispose();
2286
+ };
2287
+ return Object.freeze({
2288
+ get state() {
2289
+ return h.state;
2290
+ },
2291
+ mount(S) {
2292
+ if (h.disposed)
2293
+ throw new Error("[RaphyDOM] Auxiliary view is disposed.");
2294
+ const T = c(S);
2295
+ let f = e.target, m = T;
2296
+ for (; m !== null; ) {
2297
+ let g = !1;
2298
+ if (typeof Reflect.get(m, "showPopover") == "function")
2299
+ try {
2300
+ g = m.matches(":popover-open");
2301
+ } catch {
2302
+ }
2303
+ if (m.tagName === "DIALOG" && m.hasAttribute("open") || g) {
2304
+ f = m;
2305
+ break;
2306
+ }
2307
+ const b = m.getRootNode();
2308
+ m = m.parentElement ?? (b instanceof e.target.ownerDocument.defaultView.ShadowRoot ? b.host : null);
2309
+ }
2310
+ y === void 0 ? y = a(h, f) : y.moveBefore(f, null);
2311
+ },
2312
+ replaceContent(S, T) {
2313
+ if (h.disposed || y === void 0)
2314
+ throw new Error("[RaphyDOM] Auxiliary view must be mounted before content.");
2315
+ const f = c(T, h), m = t.host.createAuxiliaryContent(S);
2316
+ a(m, f);
2317
+ const g = v;
2318
+ v = m, g?.dispose();
2319
+ },
2320
+ clearContent: w,
2321
+ dispose: () => {
2322
+ try {
2323
+ w();
2324
+ } finally {
2325
+ h.dispose();
2326
+ }
2327
+ }
2328
+ });
2329
+ }
2330
+ };
2331
+ t.capabilities.provide(Ct, Object.freeze(l));
2332
+ }
2333
+ function pr(t, e, r) {
2334
+ const o = [], n = /* @__PURE__ */ new Set();
2335
+ try {
2336
+ for (const s of e.extensions ?? []) {
2337
+ const a = hr(s, n), c = new fr(
2338
+ a,
2339
+ e.target.ownerDocument,
2340
+ t.runtime,
2341
+ r
2342
+ );
2343
+ let l;
2344
+ try {
2345
+ const d = s.install(Object.freeze({
2346
+ applicationId: t.applicationId,
2347
+ capabilities: t.capabilities,
2348
+ document: e.target.ownerDocument,
2349
+ events: c.facade,
2350
+ owner: t.applicationNode,
2351
+ root: e.target,
2352
+ runtime: t.runtime,
2353
+ trackRenderWork: t.host.trackRenderWork
2354
+ }));
2355
+ l = yr(a, d);
2356
+ } catch (d) {
2357
+ throw gr(
2358
+ d,
2359
+ () => c.dispose(),
2360
+ `[RaphyDOM] Extension "${a}" installation rollback failed.`
2361
+ );
2362
+ }
2363
+ o.push({
2364
+ id: a,
2365
+ dispose: () => mr(a, l, c.dispose)
2366
+ }), n.add(a);
2367
+ }
2368
+ } catch (s) {
2369
+ throw vr(s, o);
2370
+ }
2371
+ let i = !0;
2372
+ return Object.freeze({
2373
+ dispose() {
2374
+ i && (i = !1, pt(o));
2375
+ }
2376
+ });
2377
+ }
2378
+ class fr {
2379
+ facade;
2380
+ _cleanups = /* @__PURE__ */ new Set();
2381
+ _active = !0;
2382
+ constructor(e, r, o, n) {
2383
+ const i = (s, a, c) => {
2384
+ if (!this._active)
2385
+ throw new Error(`[RaphyDOM] Event scope for extension "${e}" is disposed.`);
2386
+ const l = a.trim();
2387
+ if (l.length === 0)
2388
+ throw new TypeError("[RaphyDOM] Extension event type must not be empty.");
2389
+ let d = !0;
2390
+ const u = o.action(
2391
+ `@raphy-js/dom:extension:${e}:${l}`,
2392
+ (v) => c(v)
2393
+ ), h = s((v) => {
2394
+ d && this._active && !o.disposed && u(v);
2395
+ }), y = () => {
2396
+ d && (d = !1, this._cleanups.delete(y), h());
2397
+ };
2398
+ return this._cleanups.add(y), y;
2399
+ };
2400
+ this.facade = Object.freeze({
2401
+ listen: (s, a, c, l = !1) => (br(s, r), i((d) => (s.addEventListener(a.trim(), d, l), () => s.removeEventListener(a.trim(), d, _r(l))), a, c)),
2402
+ listenBoundaries: (s, a, c = !1) => i(
2403
+ (l) => n.subscribeBoundaries(s, l, c),
2404
+ s,
2405
+ a
2406
+ )
2407
+ });
2408
+ }
2409
+ dispose = () => {
2410
+ this._active && (this._active = !1, wr([...this._cleanups], "[RaphyDOM] Extension event cleanup failed."));
2411
+ };
2412
+ }
2413
+ function hr(t, e) {
2414
+ if (typeof t != "object" || t === null)
2415
+ throw new TypeError("[RaphyDOM] Renderer extension must be an object.");
2416
+ const r = t.id?.trim();
2417
+ if (r === void 0 || r.length === 0 || r !== t.id)
2418
+ throw new TypeError("[RaphyDOM] Renderer extension id must be a non-empty trimmed string.");
2419
+ if (typeof t.install != "function")
2420
+ throw new TypeError(`[RaphyDOM] Renderer extension "${r}" must provide install().`);
2421
+ if (e.has(r))
2422
+ throw new Error(`[RaphyDOM] Renderer extension "${r}" is registered more than once.`);
2423
+ return r;
2424
+ }
2425
+ function yr(t, e) {
2426
+ if (e === void 0)
2427
+ return () => {
2428
+ };
2429
+ if (typeof e == "function")
2430
+ return e;
2431
+ if (typeof e == "object" && e !== null && typeof e.dispose == "function")
2432
+ return e.dispose.bind(e);
2433
+ throw new TypeError(`[RaphyDOM] Extension "${t}" returned an invalid cleanup.`);
2434
+ }
2435
+ function mr(t, e, r) {
2436
+ const o = [];
2437
+ for (const n of [e, r])
2438
+ try {
2439
+ n();
2440
+ } catch (i) {
2441
+ o.push(i);
2442
+ }
2443
+ Pe(o, `[RaphyDOM] Extension "${t}" cleanup failed.`);
2444
+ }
2445
+ function vr(t, e) {
2446
+ try {
2447
+ pt(e);
2448
+ } catch (r) {
2449
+ return new AggregateError(
2450
+ [t, r],
2451
+ "[RaphyDOM] Renderer extension installation and rollback failed."
2452
+ );
2453
+ }
2454
+ return t;
2455
+ }
2456
+ function pt(t) {
2457
+ const e = [];
2458
+ for (let r = t.length - 1; r >= 0; r--)
2459
+ try {
2460
+ t[r].dispose();
2461
+ } catch (o) {
2462
+ e.push(o);
2463
+ }
2464
+ Pe(e, "[RaphyDOM] Renderer extension cleanup failed.");
2465
+ }
2466
+ function wr(t, e) {
2467
+ const r = [];
2468
+ for (let o = t.length - 1; o >= 0; o--)
2469
+ try {
2470
+ t[o]();
2471
+ } catch (n) {
2472
+ r.push(n);
2473
+ }
2474
+ Pe(r, e);
2475
+ }
2476
+ function gr(t, e, r) {
2477
+ try {
2478
+ e();
2479
+ } catch (o) {
2480
+ return new AggregateError([t, o], r);
2481
+ }
2482
+ return t;
2483
+ }
2484
+ function Pe(t, e) {
2485
+ if (t.length === 1)
2486
+ throw t[0];
2487
+ if (t.length > 1)
2488
+ throw new AggregateError(t, e);
2489
+ }
2490
+ function br(t, e) {
2491
+ if (!(t === e || t === e.defaultView) && !(typeof t == "object" && t !== null && Reflect.get(t, "ownerDocument") === e))
2492
+ throw new Error("[RaphyDOM] Renderer extension cannot listen on a foreign document target.");
2493
+ }
2494
+ function _r(t) {
2495
+ return typeof t == "boolean" ? t : t.capture === !0;
2496
+ }
2497
+ class Kr {
2498
+ // Сохраняют application boundary и неизменяемую DOM-конфигурацию renderer.
2499
+ _context;
2500
+ _eventHub;
2501
+ _extensions;
2502
+ _hostBlueprintCache;
2503
+ _options;
2504
+ _styleManager;
2505
+ _presentation;
2506
+ _operations;
2507
+ // Содержит принадлежащий renderer DOM root после mount.
2508
+ _mountedOutput = null;
2509
+ /**
2510
+ * Связывает renderer instance с одним application и одним DOM target.
2511
+ */
2512
+ constructor(e, r, o, n) {
2513
+ this._operations = new _t(o), this._context = e, this._eventHub = new St(r.target, e.runtime), this._options = r, this._styleManager = new Pt(e, r), this._hostBlueprintCache = n?.create(r.target.ownerDocument, this._eventHub, this._styleManager.applicationScopeId);
2514
+ try {
2515
+ this._presentation = lr(e, r.target, this._eventHub, this._styleManager.applicationScopeId), ur(
2516
+ e,
2517
+ r,
2518
+ this._hostBlueprintCache,
2519
+ this._eventHub,
2520
+ this._styleManager,
2521
+ this._operations
2522
+ ), this._extensions = pr(
2523
+ e,
2524
+ r,
2525
+ this._eventHub
2526
+ );
2527
+ } catch (i) {
2528
+ const s = [i];
2529
+ for (const a of [
2530
+ () => this._presentation?.dispose(),
2531
+ () => this._hostBlueprintCache?.dispose(),
2532
+ () => this._styleManager.dispose(),
2533
+ () => this._eventHub.dispose()
2534
+ ])
2535
+ try {
2536
+ a();
2537
+ } catch (c) {
2538
+ s.push(c);
2539
+ }
2540
+ throw s.length === 1 ? i : new AggregateError(
2541
+ s,
2542
+ "[RaphyDOM] Renderer creation rollback failed."
2543
+ );
2544
+ }
2545
+ }
2546
+ /**
2547
+ * Создаёт и устанавливает DOM root после успешного setup root component.
2548
+ */
2549
+ mount(e) {
2550
+ if (this._mountedOutput !== null)
2551
+ throw new Error("[RaphyDOM] Renderer is already mounted.");
2552
+ const r = this._styleManager.checkpoint(), o = new F();
2553
+ let n;
2554
+ try {
2555
+ const i = X(
2556
+ e,
2557
+ this._context.host,
2558
+ this._context.targetRuntime,
2559
+ this._options.target.ownerDocument,
2560
+ this._hostBlueprintCache,
2561
+ this._eventHub,
2562
+ o,
2563
+ this._styleManager,
2564
+ this._operations,
2565
+ Sr(this._options.target)
2566
+ );
2567
+ C(this._options.target.ownerDocument) === void 0 && this._options.target.replaceChildren(), this._styleManager.restoreRoot(this._options.target), i.moveBefore(this._options.target, null), this._mountedOutput = i;
2568
+ const s = C(this._options.target.ownerDocument);
2569
+ if (s !== void 0) {
2570
+ s.commit(
2571
+ () => {
2572
+ N(
2573
+ o.commit(this._context.host),
2574
+ (a) => {
2575
+ throw a;
2576
+ }
2577
+ );
2578
+ },
2579
+ () => {
2580
+ o.cancelAndTakeCompleted();
2581
+ }
2582
+ );
2583
+ return;
2584
+ }
2585
+ n = o.commit(this._context.host);
2586
+ } catch (i) {
2587
+ this._styleManager.rollback(r);
2588
+ const s = o.open ? o.abortAndTakeCompleted(i) : void 0;
2589
+ if (s !== void 0)
2590
+ try {
2591
+ N(s, (d) => {
2592
+ const u = J(
2593
+ e,
2594
+ e.node,
2595
+ d,
2596
+ { layer: "renderer", operation: "application-mount" }
2597
+ ), p = this._context.host.captureError(
2598
+ u.component,
2599
+ u.owner,
2600
+ u.cause,
2601
+ u.source
2602
+ );
2603
+ if (!p.handled)
2604
+ throw p.report.error;
2605
+ });
2606
+ } catch (d) {
2607
+ throw d instanceof O ? d.error : d;
2608
+ }
2609
+ if (i instanceof O)
2610
+ throw i.error;
2611
+ const a = J(e, e.node, i, {
2612
+ layer: "renderer",
2613
+ operation: "application-mount"
2614
+ }), c = this._context.host.captureError(
2615
+ a.component,
2616
+ a.owner,
2617
+ a.cause,
2618
+ a.source
2619
+ );
2620
+ if (!c.handled)
2621
+ throw c.report.error;
2622
+ e.dispose();
2623
+ const l = A.anchored(
2624
+ this._options.target.ownerDocument,
2625
+ "raphy:error"
2626
+ );
2627
+ this._options.target.replaceChildren(), this._styleManager.restoreRoot(this._options.target), l.moveBefore(this._options.target, null), this._mountedOutput = l;
2628
+ }
2629
+ if (n !== void 0)
2630
+ try {
2631
+ N(n, (i) => {
2632
+ const s = J(e, e.node, i, {
2633
+ layer: "renderer",
2634
+ operation: "application-mount"
2635
+ }), a = this._context.host.captureError(
2636
+ s.component,
2637
+ s.owner,
2638
+ s.cause,
2639
+ s.source
2640
+ );
2641
+ if (!a.handled)
2642
+ throw a.report.error;
2643
+ });
2644
+ } catch (i) {
2645
+ throw i instanceof O ? i.error : i;
2646
+ }
2647
+ }
2648
+ /**
2649
+ * Удаляет принадлежащий renderer DOM root, не освобождая application самостоятельно.
2650
+ */
2651
+ dispose() {
2652
+ this._operations.dispose();
2653
+ let e;
2654
+ try {
2655
+ this._presentation?.dispose();
2656
+ } catch (o) {
2657
+ (e ??= []).push(o);
2658
+ }
2659
+ try {
2660
+ this._extensions.dispose();
2661
+ } catch (o) {
2662
+ (e ??= []).push(o);
2663
+ }
2664
+ try {
2665
+ this._eventHub.dispose();
2666
+ } catch (o) {
2667
+ (e ??= []).push(o);
2668
+ }
2669
+ try {
2670
+ this._hostBlueprintCache?.dispose();
2671
+ } catch (o) {
2672
+ (e ??= []).push(o);
2673
+ }
2674
+ const r = this._mountedOutput;
2675
+ this._mountedOutput = null;
2676
+ try {
2677
+ r?.remove(!0);
2678
+ } catch (o) {
2679
+ (e ??= []).push(o);
2680
+ }
2681
+ try {
2682
+ this._styleManager.dispose();
2683
+ } catch (o) {
2684
+ (e ??= []).push(o);
2685
+ }
2686
+ if (e?.length === 1)
2687
+ throw e[0];
2688
+ if (e !== void 0)
2689
+ throw new AggregateError(e, "[RaphyDOM] Renderer disposal failed.");
2690
+ }
2691
+ }
2692
+ function Sr(t) {
2693
+ const e = t.nodeType === 11 ? t.host : t;
2694
+ return e.namespaceURI === "http://www.w3.org/2000/svg" ? "svg" : e.namespaceURI === "http://www.w3.org/1998/Math/MathML" ? "mathml" : "html";
2695
+ }
2696
+ function Be(t, e) {
2697
+ const r = `:where([data-r-scope~=${JSON.stringify(e)}])`;
2698
+ let o = "", n = "";
2699
+ const i = () => {
2700
+ if (n.trim() !== "") {
2701
+ const s = Mr(n);
2702
+ o += `${n.slice(0, s)}${r}${n.slice(s)}`;
2703
+ } else
2704
+ o += n;
2705
+ n = "";
2706
+ };
2707
+ for (let s = 0; s < t.length; ) {
2708
+ const a = t[s];
2709
+ if (a === "\\" || a === '"' || a === "'" || a === "[" || t.startsWith("/*", s)) {
2710
+ const c = de(t, s);
2711
+ n += t.slice(s, c), s = c;
2712
+ } else if (a === "(") {
2713
+ const c = de(t, s), l = /:([\w-]+)$/.exec(n)?.[1]?.toLowerCase(), d = t.slice(s + 1, c - 1);
2714
+ n += `(${l !== void 0 && ["is", "where", "not", "has", "host", "host-context", "slotted"].includes(l) ? Be(d, e) : l === "nth-child" || l === "nth-last-child" ? Or(d, e) : d})`, s = c;
2715
+ } else if (/[\s,>+~]/.test(a) || t.startsWith("||", s)) {
2716
+ i();
2717
+ const c = t.startsWith("||", s) ? 2 : 1;
2718
+ o += t.slice(s, s + c), s += c;
2719
+ } else
2720
+ n += a, s += 1;
2721
+ }
2722
+ return i(), o;
2723
+ }
2724
+ function Or(t, e) {
2725
+ const r = /\s+of\s+/i.exec(t);
2726
+ return r === null ? t : `${t.slice(0, r.index + r[0].length)}${Be(t.slice(r.index + r[0].length), e)}`;
2727
+ }
2728
+ function Mr(t) {
2729
+ for (let e = 0; e < t.length; ) {
2730
+ if (t[e] === ":")
2731
+ return e;
2732
+ const r = t[e];
2733
+ e = r === "\\" || r === '"' || r === "'" || r === "[" || r === "(" || t.startsWith("/*", e) ? de(t, e) : e + 1;
2734
+ }
2735
+ return t.length;
2736
+ }
2737
+ function de(t, e) {
2738
+ const r = t[e];
2739
+ if (r === "\\") {
2740
+ const n = /^\\[\da-f]{1,6}\s?/i.exec(t.slice(e));
2741
+ return Math.min(t.length, e + (n?.[0].length ?? 2));
2742
+ }
2743
+ if (t.startsWith("/*", e)) {
2744
+ const n = t.indexOf("*/", e + 2);
2745
+ if (n < 0)
2746
+ throw new Error("[RaphyDOM] Unterminated selector comment.");
2747
+ return n + 2;
2748
+ }
2749
+ const o = r === "[" ? "]" : r === "(" ? ")" : r;
2750
+ for (let n = e + 1; n < t.length; ) {
2751
+ const i = t[n];
2752
+ if (i === o)
2753
+ return n + 1;
2754
+ i === "\\" || r !== '"' && r !== "'" && (i === '"' || i === "'" || i === "[" || i === "(" || t.startsWith("/*", n)) ? n = de(t, n) : n += 1;
2755
+ }
2756
+ throw new Error("[RaphyDOM] Unterminated selector token.");
2757
+ }
2758
+ const kr = Object.freeze({
2759
+ "(": ")",
2760
+ "[": "]",
2761
+ "{": "}"
2762
+ }), ft = Object.freeze({
2763
+ createSemanticValue(t) {
2764
+ return ve(t);
2765
+ },
2766
+ createAtRule(t, e, r, o) {
2767
+ const n = /^(?:(?:-webkit-)?keyframes|property)$/i.test(t) ? ne(e.join(""), o) : e.join("");
2768
+ return Object.freeze({ kind: "at-rule", name: t, prelude: n, block: r });
2769
+ },
2770
+ createBlock(t, e) {
2771
+ return `${t}${e.join("")}${kr[t]}`;
2772
+ },
2773
+ createDeclaration(t, e, r, o) {
2774
+ const n = ne(e.join(""), o);
2775
+ return `${ne(t, o)}:${n}${r ? "!important" : ""};`;
2776
+ },
2777
+ createFunction(t, e) {
2778
+ return `${t}(${e.join("")})`;
2779
+ },
2780
+ createQualifiedRule(t, e, r) {
2781
+ const o = ne(t.join(""), r, !0);
2782
+ return Object.freeze({ kind: "qualified", selector: o, block: e });
2783
+ },
2784
+ createReference(t, e, r) {
2785
+ return Rr(t, e, r);
2786
+ },
2787
+ createStylesheet(t, e) {
2788
+ const r = e.definition?.metadata.global === !0 ? void 0 : e.applicationScope;
2789
+ return Me(t, r);
2790
+ },
2791
+ createToken(t) {
2792
+ return t;
2793
+ },
2794
+ renderer: "@raphy-js/dom"
2795
+ }), Jr = nt(ft);
2796
+ function Me(t, e, r = !1) {
2797
+ return t.map((o) => {
2798
+ if (typeof o == "string")
2799
+ return o;
2800
+ if (o.kind === "qualified")
2801
+ return `${e === void 0 || r ? o.selector : Be(o.selector, e)}{${Me(o.block, e, r)}}`;
2802
+ const n = `@${o.name}${o.prelude}`;
2803
+ return o.block === null ? `${n};` : `${n}{${Me(o.block, e, r || /^(?:-webkit-)?keyframes$/i.test(o.name))}}`;
2804
+ }).join("");
2805
+ }
2806
+ function ne(t, e, r = !1) {
2807
+ if (e.definition?.metadata.applicationScoped !== !0)
2808
+ return t;
2809
+ const o = e.definition.metadata.scopeId;
2810
+ if (o === void 0 || e.applicationScope === void 0)
2811
+ throw new Error("[RaphyDOM] Application-scoped stylesheet requires a renderer-owned scope identity.");
2812
+ const n = `-${o}`;
2813
+ let i = t.replace(/url\((?:\\.|[^)\\])*\)|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[\w-]+/gi, (s) => !s.startsWith('"') && !s.startsWith("'") && !/^url\(/i.test(s) && s.endsWith(n) ? `${s.slice(0, -n.length)}-${e.applicationScope}` : s);
2814
+ return r && (i = i.replace(/\[data-r-scope~=("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')\]/g, (s, a) => a.slice(1, -1) === o ? `[data-r-scope~=${JSON.stringify(e.applicationScope)}]` : s)), i;
2815
+ }
2816
+ function Rr(t, e, r) {
2817
+ if (r.styleEnvironment.resolve(t, e) === void 0)
2818
+ throw new Error(
2819
+ `[RaphyDOM] Style reference "${t}:${e.join(".")}" is not provided by this application.`
2820
+ );
2821
+ return `var(${we(t, e)})`;
2822
+ }
2823
+ function Xr(t, e = nt(ft)) {
2824
+ return Dt({ node: t, stylesheet: e });
2825
+ }
2826
+ function Dr(t) {
2827
+ return ht(t, !1);
2828
+ }
2829
+ function Er(t) {
2830
+ return ht(t, !0);
2831
+ }
2832
+ function ht(t, e) {
2833
+ return Object.freeze({
2834
+ kind: "raw-html",
2835
+ read: L(t) ? t.read : () => t,
2836
+ unsafe: e
2837
+ });
2838
+ }
2839
+ function Ar(t, e = {}) {
2840
+ if (t.kind !== "dynamic-component")
2841
+ throw new TypeError("[RaphyDOM] keepAlive() requires dynamicComponent().");
2842
+ if (e.max !== void 0 && (!Number.isInteger(e.max) || e.max <= 0))
2843
+ throw new TypeError("[RaphyDOM] keepAlive() max must be a positive integer.");
2844
+ return Object.freeze({ component: t, kind: "keep-alive", max: e.max });
2845
+ }
2846
+ function Tr(t, e) {
2847
+ switch (t) {
2848
+ case "hydration-boundary":
2849
+ return {
2850
+ kind: t,
2851
+ content: e[0],
2852
+ strategy: e[1]
2853
+ };
2854
+ case "client-only":
2855
+ return {
2856
+ kind: t,
2857
+ load: e[0],
2858
+ fallback: e[1]
2859
+ };
2860
+ case "head":
2861
+ return { kind: t, entries: e[0] };
2862
+ }
2863
+ }
2864
+ function Nr(t, e) {
2865
+ if (typeof t != "string" && !Cr(t))
2866
+ throw new TypeError("[RaphyDOM] teleport() target must be a selector, Element or ShadowRoot.");
2867
+ if (typeof t == "string" && t.trim().length === 0)
2868
+ throw new TypeError("[RaphyDOM] teleport() selector must not be empty.");
2869
+ return Object.freeze({ content: e, kind: "teleport", target: t });
2870
+ }
2871
+ function Cr(t) {
2872
+ return typeof t == "object" && t !== null && (Reflect.get(t, "nodeType") === 1 || Reflect.get(t, "nodeType") === 11);
2873
+ }
2874
+ function Pr(t, e = {}) {
2875
+ const r = e.name ?? "raphy";
2876
+ if (typeof r != "string" && typeof r != "function")
2877
+ throw new TypeError("[RaphyDOM] transition() name must be a string or reader.");
2878
+ if (typeof r == "string" && r.trim().length === 0)
2879
+ throw new TypeError("[RaphyDOM] transition() name must not be empty.");
2880
+ const o = e.mode ?? "simultaneous";
2881
+ if (o !== "simultaneous" && o !== "out-in" && o !== "in-out")
2882
+ throw new TypeError(`[RaphyDOM] Unsupported transition mode "${String(o)}".`);
2883
+ return Object.freeze({
2884
+ content: t,
2885
+ kind: "transition",
2886
+ options: Object.freeze({ ...e, mode: o, name: r })
2887
+ });
2888
+ }
2889
+ const Br = Object.prototype.hasOwnProperty, Ir = Object.freeze({
2890
+ // Компактный профиль использует существующий Core replay через createHostNode.
2891
+ // Replay slot 'data-event': descriptor listener() с data рядом с общим handler.
2892
+ createDataEventInput: Ot,
2893
+ createInput: $r,
2894
+ createHostNode: zr,
2895
+ createPrimitive: jr,
2896
+ renderer: "@raphy-js/dom",
2897
+ validateComponentInput: (t) => {
2898
+ if (se(t))
2899
+ throw new TypeError(
2900
+ "[RaphyDOM] bind() can only control a native DOM element."
2901
+ );
2902
+ }
2903
+ });
2904
+ function Qr(t, e) {
2905
+ return Et(Object.freeze({ ...Ir, createHostBlueprint: t, resolveTarget: e }));
2906
+ }
2907
+ function $r(t, e) {
2908
+ switch (t) {
2909
+ case "attribute":
2910
+ return Rt(e[0], e[1]);
2911
+ case "binding":
2912
+ return Tt(e[0], e[1]);
2913
+ case "event":
2914
+ return kt(e[0], e[1]);
2915
+ case "property":
2916
+ return Mt(e[0]);
2917
+ default:
2918
+ throw new Error(`[RaphyDOM] Unsupported node input "${String(t)}".`);
2919
+ }
2920
+ }
2921
+ function jr(t, e) {
2922
+ switch (t) {
2923
+ case "client-only":
2924
+ case "hydration-boundary":
2925
+ case "head":
2926
+ return Tr(t, e);
2927
+ case "keep-alive":
2928
+ return Ar(e[0], e[1]);
2929
+ case "safe-html":
2930
+ return Dr(e[0]);
2931
+ case "teleport":
2932
+ return Nr(e[0], e[1]);
2933
+ case "transition":
2934
+ return Pr(e[0], e[1]);
2935
+ case "unsafe-html":
2936
+ return Er(e[0]);
2937
+ default:
2938
+ throw new Error(
2939
+ `[RaphyDOM] Unsupported node primitive "${String(t)}".`
2940
+ );
2941
+ }
2942
+ }
2943
+ function zr(t, e, r) {
2944
+ let o = ke, n = null;
2945
+ if (e !== null)
2946
+ if (L(e)) {
2947
+ o = e;
2948
+ const s = Reflect.get(e, "ref");
2949
+ if (s != null) {
2950
+ if (!Ue(s) && !We(s))
2951
+ throw new TypeError(
2952
+ "[RaphyDOM] Element ref must be created by elementRef() or targetRef()."
2953
+ );
2954
+ n = s;
2955
+ }
2956
+ } else {
2957
+ const s = { ...e };
2958
+ let a, c = !1, l = !1;
2959
+ for (const d in s) {
2960
+ if (!Br.call(s, d))
2961
+ continue;
2962
+ const u = s[d];
2963
+ if (typeof u == "function" && At(u) !== null)
2964
+ throw new TypeError(
2965
+ "[RaphyDOM] model() can only bind a Raphy component."
2966
+ );
2967
+ d === "ref" ? (a = u, c = !0) : l = !0;
2968
+ }
2969
+ if (a != null) {
2970
+ if (!Ue(a) && !We(a))
2971
+ throw new TypeError(
2972
+ "[RaphyDOM] Element ref must be created by elementRef() or targetRef()."
2973
+ );
2974
+ n = a;
2975
+ }
2976
+ if (l || Object.getOwnPropertySymbols(s).length !== 0) {
2977
+ let d = s;
2978
+ if (c) {
2979
+ const { ref: u, ...p } = s;
2980
+ d = p;
2981
+ }
2982
+ o = Ve ? Object.freeze(d) : d;
2983
+ }
2984
+ }
2985
+ const i = {
2986
+ children: Ee(r),
2987
+ kind: "element",
2988
+ props: o,
2989
+ ref: n,
2990
+ tag: t
2991
+ };
2992
+ return Ve ? Object.freeze(i) : i;
2993
+ }
2994
+ export {
2995
+ ft as D,
2996
+ Jr as a,
2997
+ Pr as b,
2998
+ Kr as c,
2999
+ Xr as d,
3000
+ Qr as e,
3001
+ Ar as k,
3002
+ Gr as o,
3003
+ Dr as s,
3004
+ Nr as t,
3005
+ Er as u
3006
+ };