@bquery/bquery 1.9.0 → 1.11.0

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 (216) hide show
  1. package/README.md +221 -40
  2. package/dist/{a11y-_9X-kt-_.js → a11y-DgUQ8-fI.js} +3 -3
  3. package/dist/{a11y-_9X-kt-_.js.map → a11y-DgUQ8-fI.js.map} +1 -1
  4. package/dist/a11y.es.mjs +1 -1
  5. package/dist/{component-L3-JfOFz.js → component-D8ydhe58.js} +20 -19
  6. package/dist/{component-L3-JfOFz.js.map → component-D8ydhe58.js.map} +1 -1
  7. package/dist/component.es.mjs +1 -1
  8. package/dist/concurrency/errors.d.ts +29 -0
  9. package/dist/concurrency/errors.d.ts.map +1 -0
  10. package/dist/concurrency/high-level.d.ts +85 -0
  11. package/dist/concurrency/high-level.d.ts.map +1 -0
  12. package/dist/concurrency/index.d.ts +19 -0
  13. package/dist/concurrency/index.d.ts.map +1 -0
  14. package/dist/concurrency/internal.d.ts +26 -0
  15. package/dist/concurrency/internal.d.ts.map +1 -0
  16. package/dist/concurrency/pipeline.d.ts +30 -0
  17. package/dist/concurrency/pipeline.d.ts.map +1 -0
  18. package/dist/concurrency/pool.d.ts +48 -0
  19. package/dist/concurrency/pool.d.ts.map +1 -0
  20. package/dist/concurrency/reactive.d.ts +107 -0
  21. package/dist/concurrency/reactive.d.ts.map +1 -0
  22. package/dist/concurrency/rpc.d.ts +46 -0
  23. package/dist/concurrency/rpc.d.ts.map +1 -0
  24. package/dist/concurrency/support.d.ts +23 -0
  25. package/dist/concurrency/support.d.ts.map +1 -0
  26. package/dist/concurrency/task.d.ts +31 -0
  27. package/dist/concurrency/task.d.ts.map +1 -0
  28. package/dist/concurrency/types.d.ts +343 -0
  29. package/dist/concurrency/types.d.ts.map +1 -0
  30. package/dist/concurrency-BU1wPEsZ.js +826 -0
  31. package/dist/concurrency-BU1wPEsZ.js.map +1 -0
  32. package/dist/concurrency.es.mjs +29 -0
  33. package/dist/{constraints-D5RHQLmP.js → constraints-Dlbx_m1b.js} +1 -1
  34. package/dist/{constraints-D5RHQLmP.js.map → constraints-Dlbx_m1b.js.map} +1 -1
  35. package/dist/core-CongXJuo.js +87 -0
  36. package/dist/core-CongXJuo.js.map +1 -0
  37. package/dist/{core-EMYSLzaT.js → core-tOP6QOrY.js} +2 -2
  38. package/dist/{core-EMYSLzaT.js.map → core-tOP6QOrY.js.map} +1 -1
  39. package/dist/core.es.mjs +1 -1
  40. package/dist/{custom-directives-Dr4C5lVV.js → custom-directives-5DlKqvd2.js} +1 -1
  41. package/dist/{custom-directives-Dr4C5lVV.js.map → custom-directives-5DlKqvd2.js.map} +1 -1
  42. package/dist/{devtools-BhB2iDPT.js → devtools-QosAqo0T.js} +2 -2
  43. package/dist/{devtools-BhB2iDPT.js.map → devtools-QosAqo0T.js.map} +1 -1
  44. package/dist/devtools.es.mjs +1 -1
  45. package/dist/{dnd-NwZBYh4l.js → dnd-d2OU4len.js} +1 -1
  46. package/dist/{dnd-NwZBYh4l.js.map → dnd-d2OU4len.js.map} +1 -1
  47. package/dist/dnd.es.mjs +1 -1
  48. package/dist/effect-Cc51IH91.js +87 -0
  49. package/dist/effect-Cc51IH91.js.map +1 -0
  50. package/dist/{env-CTdvLaH2.js → env-PvwYHnJq.js} +1 -1
  51. package/dist/{env-CTdvLaH2.js.map → env-PvwYHnJq.js.map} +1 -1
  52. package/dist/{forms-UhAeJEoO.js → forms-BLx4ZzT7.js} +41 -40
  53. package/dist/{forms-UhAeJEoO.js.map → forms-BLx4ZzT7.js.map} +1 -1
  54. package/dist/forms.es.mjs +1 -1
  55. package/dist/full.d.ts +6 -2
  56. package/dist/full.d.ts.map +1 -1
  57. package/dist/full.es.mjs +282 -214
  58. package/dist/full.iife.js +108 -20
  59. package/dist/full.iife.js.map +1 -1
  60. package/dist/full.umd.js +108 -20
  61. package/dist/full.umd.js.map +1 -1
  62. package/dist/{i18n-kuF6Ekj6.js → i18n--p7PM-9r.js} +3 -3
  63. package/dist/{i18n-kuF6Ekj6.js.map → i18n--p7PM-9r.js.map} +1 -1
  64. package/dist/i18n.es.mjs +1 -1
  65. package/dist/index.d.ts +2 -0
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.es.mjs +320 -252
  68. package/dist/match-CrZRVC4z.js +174 -0
  69. package/dist/match-CrZRVC4z.js.map +1 -0
  70. package/dist/media/observers.d.ts.map +1 -1
  71. package/dist/{media-D4zLj9t-.js → media-gjbWNq50.js} +3 -3
  72. package/dist/{media-D4zLj9t-.js.map → media-gjbWNq50.js.map} +1 -1
  73. package/dist/media.es.mjs +1 -1
  74. package/dist/{motion-BJsAuULb.js → motion-BBMso9Ir.js} +1 -1
  75. package/dist/{motion-BJsAuULb.js.map → motion-BBMso9Ir.js.map} +1 -1
  76. package/dist/motion.es.mjs +1 -1
  77. package/dist/{mount-B-JvH6Y0.js → mount-0A9qtcRJ.js} +11 -10
  78. package/dist/{mount-B-JvH6Y0.js.map → mount-0A9qtcRJ.js.map} +1 -1
  79. package/dist/{platform-Dw2gE3zI.js → platform-BPHIXbw8.js} +17 -16
  80. package/dist/{platform-Dw2gE3zI.js.map → platform-BPHIXbw8.js.map} +1 -1
  81. package/dist/platform.es.mjs +1 -1
  82. package/dist/{plugin-C2WuC8SF.js → plugin-SZEirbwq.js} +2 -2
  83. package/dist/{plugin-C2WuC8SF.js.map → plugin-SZEirbwq.js.map} +1 -1
  84. package/dist/plugin.es.mjs +1 -1
  85. package/dist/reactive/watch.d.ts.map +1 -1
  86. package/dist/reactive/websocket.d.ts +6 -3
  87. package/dist/reactive/websocket.d.ts.map +1 -1
  88. package/dist/{reactive-BjpLkclt.js → reactive-BAd2hfl8.js} +436 -449
  89. package/dist/reactive-BAd2hfl8.js.map +1 -0
  90. package/dist/reactive.es.mjs +42 -40
  91. package/dist/readonly-C0ZwS1Tf.js +35 -0
  92. package/dist/readonly-C0ZwS1Tf.js.map +1 -0
  93. package/dist/{registry-B08iilIh.js → registry-jpUQHf4E.js} +1 -1
  94. package/dist/{registry-B08iilIh.js.map → registry-jpUQHf4E.js.map} +1 -1
  95. package/dist/router-C4weu0QL.js +333 -0
  96. package/dist/router-C4weu0QL.js.map +1 -0
  97. package/dist/router.es.mjs +1 -1
  98. package/dist/{sanitize-B1V4JswB.js → sanitize-DOMkRO9G.js} +12 -7
  99. package/dist/{sanitize-B1V4JswB.js.map → sanitize-DOMkRO9G.js.map} +1 -1
  100. package/dist/security.es.mjs +1 -1
  101. package/dist/server/create-server.d.ts +25 -0
  102. package/dist/server/create-server.d.ts.map +1 -0
  103. package/dist/server/index.d.ts +11 -0
  104. package/dist/server/index.d.ts.map +1 -0
  105. package/dist/server/types.d.ts +396 -0
  106. package/dist/server/types.d.ts.map +1 -0
  107. package/dist/server-QdyKtCS1.js +349 -0
  108. package/dist/server-QdyKtCS1.js.map +1 -0
  109. package/dist/server.es.mjs +6 -0
  110. package/dist/ssr/adapters.d.ts +74 -0
  111. package/dist/ssr/adapters.d.ts.map +1 -0
  112. package/dist/ssr/async.d.ts +40 -0
  113. package/dist/ssr/async.d.ts.map +1 -0
  114. package/dist/ssr/config.d.ts +60 -0
  115. package/dist/ssr/config.d.ts.map +1 -0
  116. package/dist/ssr/context.d.ts +73 -0
  117. package/dist/ssr/context.d.ts.map +1 -0
  118. package/dist/ssr/defer-brand.d.ts +5 -0
  119. package/dist/ssr/defer-brand.d.ts.map +1 -0
  120. package/dist/ssr/escape.d.ts +17 -0
  121. package/dist/ssr/escape.d.ts.map +1 -0
  122. package/dist/ssr/expression.d.ts +44 -0
  123. package/dist/ssr/expression.d.ts.map +1 -0
  124. package/dist/ssr/hash.d.ts +39 -0
  125. package/dist/ssr/hash.d.ts.map +1 -0
  126. package/dist/ssr/head.d.ts +102 -0
  127. package/dist/ssr/head.d.ts.map +1 -0
  128. package/dist/ssr/html-parser.d.ts +58 -0
  129. package/dist/ssr/html-parser.d.ts.map +1 -0
  130. package/dist/ssr/index.d.ts +49 -43
  131. package/dist/ssr/index.d.ts.map +1 -1
  132. package/dist/ssr/mismatch.d.ts +60 -0
  133. package/dist/ssr/mismatch.d.ts.map +1 -0
  134. package/dist/ssr/render-async.d.ts +84 -0
  135. package/dist/ssr/render-async.d.ts.map +1 -0
  136. package/dist/ssr/render.d.ts.map +1 -1
  137. package/dist/ssr/renderer.d.ts +25 -0
  138. package/dist/ssr/renderer.d.ts.map +1 -0
  139. package/dist/ssr/resumability.d.ts +65 -0
  140. package/dist/ssr/resumability.d.ts.map +1 -0
  141. package/dist/ssr/router-bridge.d.ts +101 -0
  142. package/dist/ssr/router-bridge.d.ts.map +1 -0
  143. package/dist/ssr/runtime.d.ts +63 -0
  144. package/dist/ssr/runtime.d.ts.map +1 -0
  145. package/dist/ssr/serialize.d.ts.map +1 -1
  146. package/dist/ssr/store-snapshot.d.ts +87 -0
  147. package/dist/ssr/store-snapshot.d.ts.map +1 -0
  148. package/dist/ssr/strategies.d.ts +43 -0
  149. package/dist/ssr/strategies.d.ts.map +1 -0
  150. package/dist/ssr/suspense.d.ts +47 -0
  151. package/dist/ssr/suspense.d.ts.map +1 -0
  152. package/dist/ssr/types.d.ts +17 -0
  153. package/dist/ssr/types.d.ts.map +1 -1
  154. package/dist/ssr-Bt6BQA3J.js +2127 -0
  155. package/dist/ssr-Bt6BQA3J.js.map +1 -0
  156. package/dist/ssr.es.mjs +42 -7
  157. package/dist/{store-CY6sjTW3.js → store-DnXuu6Li.js} +6 -6
  158. package/dist/{store-CY6sjTW3.js.map → store-DnXuu6Li.js.map} +1 -1
  159. package/dist/store.es.mjs +2 -2
  160. package/dist/storybook.es.mjs +1 -1
  161. package/dist/{testing-UjAtu9aQ.js → testing-CeMUwrRD.js} +7 -7
  162. package/dist/{testing-UjAtu9aQ.js.map → testing-CeMUwrRD.js.map} +1 -1
  163. package/dist/testing.es.mjs +1 -1
  164. package/dist/{untrack-D0fnO5k2.js → untrack-bjWDNdyE.js} +11 -10
  165. package/dist/{untrack-D0fnO5k2.js.map → untrack-bjWDNdyE.js.map} +1 -1
  166. package/dist/view.es.mjs +12 -11
  167. package/package.json +24 -15
  168. package/src/concurrency/errors.ts +57 -0
  169. package/src/concurrency/high-level.ts +387 -0
  170. package/src/concurrency/index.ts +63 -0
  171. package/src/concurrency/internal.ts +100 -0
  172. package/src/concurrency/pipeline.ts +133 -0
  173. package/src/concurrency/pool.ts +450 -0
  174. package/src/concurrency/reactive.ts +339 -0
  175. package/src/concurrency/rpc.ts +380 -0
  176. package/src/concurrency/support.ts +44 -0
  177. package/src/concurrency/task.ts +318 -0
  178. package/src/concurrency/types.ts +431 -0
  179. package/src/full.ts +164 -0
  180. package/src/index.ts +6 -0
  181. package/src/media/observers.ts +5 -8
  182. package/src/reactive/watch.ts +10 -9
  183. package/src/reactive/websocket.ts +31 -8
  184. package/src/server/create-server.ts +754 -0
  185. package/src/server/index.ts +33 -0
  186. package/src/server/types.ts +490 -0
  187. package/src/ssr/adapters.ts +330 -0
  188. package/src/ssr/async.ts +125 -0
  189. package/src/ssr/config.ts +86 -0
  190. package/src/ssr/context.ts +245 -0
  191. package/src/ssr/defer-brand.ts +3 -0
  192. package/src/ssr/escape.ts +25 -0
  193. package/src/ssr/expression.ts +669 -0
  194. package/src/ssr/hash.ts +71 -0
  195. package/src/ssr/head.ts +240 -0
  196. package/src/ssr/html-parser.ts +387 -0
  197. package/src/ssr/index.ts +136 -43
  198. package/src/ssr/mismatch.ts +110 -0
  199. package/src/ssr/render-async.ts +286 -0
  200. package/src/ssr/render.ts +130 -59
  201. package/src/ssr/renderer.ts +453 -0
  202. package/src/ssr/resumability.ts +142 -0
  203. package/src/ssr/router-bridge.ts +177 -0
  204. package/src/ssr/runtime.ts +131 -0
  205. package/src/ssr/serialize.ts +1 -27
  206. package/src/ssr/store-snapshot.ts +209 -0
  207. package/src/ssr/strategies.ts +245 -0
  208. package/src/ssr/suspense.ts +504 -0
  209. package/src/ssr/types.ts +18 -0
  210. package/dist/core-DdtZHzsS.js +0 -168
  211. package/dist/core-DdtZHzsS.js.map +0 -1
  212. package/dist/reactive-BjpLkclt.js.map +0 -1
  213. package/dist/router-BieVwgci.js +0 -492
  214. package/dist/router-BieVwgci.js.map +0 -1
  215. package/dist/ssr-CrGSJySz.js +0 -248
  216. package/dist/ssr-CrGSJySz.js.map +0 -1
@@ -0,0 +1,2127 @@
1
+ import { _ as Ke, g as Xe, h as et, m as xe, p as tt, s as rt, v as nt } from "./sanitize-DOMkRO9G.js";
2
+ import { i as g } from "./object-BCk-1c8T.js";
3
+ import { c as U, l as D } from "./reactive-BAd2hfl8.js";
4
+ import { t as it } from "./env-PvwYHnJq.js";
5
+ import { n as ot, o as st } from "./match-CrZRVC4z.js";
6
+ import { i as _e, n as Z } from "./registry-jpUQHf4E.js";
7
+ import { n as at } from "./mount-0A9qtcRJ.js";
8
+ var ct = (e, t, r = {}) => {
9
+ const { hydrate: n = !0, ...i } = r;
10
+ if (!n) throw new Error("bQuery ssr: hydrateMount() requires { hydrate: true } when options are provided.");
11
+ return at(e, t, i);
12
+ }, _ = {
13
+ backend: "auto",
14
+ documentImpl: null
15
+ }, nn = (e) => {
16
+ e.backend !== void 0 && (_.backend = e.backend), e.documentImpl !== void 0 && (_.documentImpl = e.documentImpl);
17
+ }, on = () => ({
18
+ backend: _.backend,
19
+ documentImpl: _.documentImpl
20
+ }), ut = () => _.backend === "pure" ? "pure" : _.backend === "dom" || _.documentImpl || typeof globalThis.DOMParser == "function" ? "dom" : "pure", lt = () => _.documentImpl ? _.documentImpl.DOMParser : typeof globalThis.DOMParser == "function" ? globalThis.DOMParser : null, de = (e) => {
21
+ let t = 5381;
22
+ for (let r = 0; r < e.length; r++) t = (t << 5) + t + e.charCodeAt(r) | 0;
23
+ return (t >>> 0).toString(36);
24
+ }, pe = "data-bq-h", ft = (e, t, r) => {
25
+ const n = [];
26
+ for (const i of e)
27
+ i !== "data-bq-h" && (i.startsWith(`${r}-`) || i.startsWith(":")) && n.push(`${i}=${t[i] ?? ""}`);
28
+ return n.join("|");
29
+ }, Ne = (e, t) => {
30
+ const r = [];
31
+ for (const n of Array.from(e.attributes))
32
+ n.name !== "data-bq-h" && (n.name.startsWith(`${t}-`) || n.name.startsWith(":")) && r.push(`${n.name}=${n.value}`);
33
+ return r.join("|");
34
+ }, dt = (e) => D(e) || U(e) ? e.value : e, pt = [
35
+ "===",
36
+ "!==",
37
+ "==",
38
+ "!=",
39
+ "<=",
40
+ ">=",
41
+ "&&",
42
+ "||",
43
+ "??",
44
+ "?."
45
+ ], ht = "+-*/%<>!?:,.()[]", Le = (e) => e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "_" || e === "$", vt = (e) => Le(e) || e >= "0" && e <= "9", re = (e) => e >= "0" && e <= "9", mt = (e) => {
46
+ const t = [], r = e.length;
47
+ let n = 0;
48
+ for (; n < r; ) {
49
+ const i = e[n];
50
+ if (i === " " || i === " " || i === `
51
+ ` || i === "\r") {
52
+ n++;
53
+ continue;
54
+ }
55
+ if (i === '"' || i === "'") {
56
+ const s = i, a = n;
57
+ n++;
58
+ let u = "";
59
+ for (; n < r && e[n] !== s; ) {
60
+ if (e[n] === "\\" && n + 1 < r) {
61
+ const c = e[n + 1];
62
+ c === "n" ? u += `
63
+ ` : c === "t" ? u += " " : c === "r" ? u += "\r" : c === "\\" ? u += "\\" : c === s ? u += s : u += c, n += 2;
64
+ continue;
65
+ }
66
+ u += e[n], n++;
67
+ }
68
+ if (n >= r) throw new Error("Unterminated string literal in SSR expression");
69
+ n++, t.push({
70
+ kind: "string",
71
+ value: u,
72
+ start: a
73
+ });
74
+ continue;
75
+ }
76
+ if (re(i) || i === "." && n + 1 < r && re(e[n + 1])) {
77
+ const s = n;
78
+ for (; n < r && (re(e[n]) || e[n] === "."); ) n++;
79
+ t.push({
80
+ kind: "number",
81
+ value: e.slice(s, n),
82
+ start: s
83
+ });
84
+ continue;
85
+ }
86
+ if (Le(i)) {
87
+ const s = n;
88
+ for (; n < r && vt(e[n]); ) n++;
89
+ t.push({
90
+ kind: "ident",
91
+ value: e.slice(s, n),
92
+ start: s
93
+ });
94
+ continue;
95
+ }
96
+ let o = !1;
97
+ for (const s of pt) if (e.startsWith(s, n)) {
98
+ t.push({
99
+ kind: "punct",
100
+ value: s,
101
+ start: n
102
+ }), n += s.length, o = !0;
103
+ break;
104
+ }
105
+ if (!o) {
106
+ if (ht.includes(i)) {
107
+ t.push({
108
+ kind: "punct",
109
+ value: i,
110
+ start: n
111
+ }), n++;
112
+ continue;
113
+ }
114
+ throw new Error(`Unexpected character "${i}" in SSR expression`);
115
+ }
116
+ }
117
+ return t.push({
118
+ kind: "eof",
119
+ value: "",
120
+ start: r
121
+ }), t;
122
+ }, $ = (e) => e.tokens[e.pos], C = (e) => e.tokens[e.pos++], S = (e, t) => {
123
+ const r = $(e);
124
+ if (r.kind !== "punct" || r.value !== t) throw new Error(`Expected "${t}" in SSR expression, got "${r.value}"`);
125
+ e.pos++;
126
+ }, Y = (e, t) => {
127
+ const r = $(e);
128
+ return r.kind === "punct" && r.value === t ? (e.pos++, !0) : !1;
129
+ }, V = (e, t, r) => {
130
+ S(e, t);
131
+ const n = [t];
132
+ for (; n.length > 0; ) {
133
+ const i = C(e);
134
+ if (!i || i.kind === "eof") throw new Error(`Unterminated "${t}${r}" group in SSR expression`);
135
+ if (i.kind === "punct") {
136
+ if (i.value === "(" || i.value === "[") {
137
+ n.push(i.value);
138
+ continue;
139
+ }
140
+ if (i.value === ")" || i.value === "]") {
141
+ const o = n[n.length - 1], s = o === "(" ? ")" : "]";
142
+ if (i.value !== s) throw new Error(`Mismatched "${o}${s}" group in SSR expression`);
143
+ n.pop();
144
+ }
145
+ }
146
+ }
147
+ }, he = (e) => {
148
+ const t = $(e);
149
+ if (t.kind === "punct" && t.value === "[") {
150
+ V(e, "[", "]");
151
+ return;
152
+ }
153
+ if (t.kind === "punct" && t.value === "(") {
154
+ V(e, "(", ")");
155
+ return;
156
+ }
157
+ if (t.kind === "ident") {
158
+ e.pos++;
159
+ return;
160
+ }
161
+ throw new Error("Invalid optional chain in SSR expression");
162
+ }, yt = (e) => {
163
+ for (; ; ) {
164
+ const t = $(e);
165
+ if (t.kind !== "punct") break;
166
+ if (t.value === ".") {
167
+ if (e.pos++, C(e).kind !== "ident") throw new Error('Expected identifier after "."');
168
+ continue;
169
+ }
170
+ if (t.value === "[") {
171
+ V(e, "[", "]");
172
+ continue;
173
+ }
174
+ if (t.value === "(") {
175
+ V(e, "(", ")");
176
+ continue;
177
+ }
178
+ if (t.value === "?.") {
179
+ e.pos++, he(e);
180
+ continue;
181
+ }
182
+ break;
183
+ }
184
+ }, gt = (e) => {
185
+ const t = C(e);
186
+ if (!t || t.kind === "eof") throw new Error("Unexpected end of SSR expression");
187
+ if (!(t.kind === "number" || t.kind === "string" || t.kind === "ident")) {
188
+ if (t.kind === "punct" && t.value === "(") {
189
+ R(e, 0), S(e, ")");
190
+ return;
191
+ }
192
+ throw new Error(`Unexpected token "${t.value}" in SSR expression`);
193
+ }
194
+ }, bt = (e) => {
195
+ if (S(e, "("), !Y(e, ")")) {
196
+ for (; ; )
197
+ if (R(e, 0), !Y(e, ",")) {
198
+ S(e, ")");
199
+ break;
200
+ }
201
+ }
202
+ }, wt = (e) => {
203
+ for (gt(e); ; ) {
204
+ const t = $(e);
205
+ if (t.kind !== "punct") break;
206
+ if (t.value === ".") {
207
+ if (e.pos++, C(e).kind !== "ident") throw new Error('Expected identifier after "."');
208
+ continue;
209
+ }
210
+ if (t.value === "?.") {
211
+ e.pos++, he(e);
212
+ continue;
213
+ }
214
+ if (t.value === "[") {
215
+ e.pos++, R(e, 0), S(e, "]");
216
+ continue;
217
+ }
218
+ if (t.value === "(") {
219
+ bt(e);
220
+ continue;
221
+ }
222
+ break;
223
+ }
224
+ }, ne = (e) => {
225
+ const t = $(e);
226
+ if (t.kind === "punct" && (t.value === "!" || t.value === "-" || t.value === "+")) {
227
+ e.pos++, ne(e);
228
+ return;
229
+ }
230
+ if (t.kind === "ident" && t.value === "typeof") {
231
+ e.pos++, ne(e);
232
+ return;
233
+ }
234
+ wt(e);
235
+ }, R = (e, t = 0) => {
236
+ for (ne(e); ; ) {
237
+ const r = $(e);
238
+ if (r.kind !== "punct") break;
239
+ if (r.value === "?" && t <= 0) {
240
+ e.pos++, R(e, 0), S(e, ":"), R(e, 0);
241
+ continue;
242
+ }
243
+ const n = Ce[r.value];
244
+ if (n === void 0 || n < t) break;
245
+ e.pos++, R(e, n + 1);
246
+ }
247
+ }, St = (e, t) => {
248
+ if (t === "true") return !0;
249
+ if (t === "false") return !1;
250
+ if (t === "null") return null;
251
+ if (t !== "undefined" && !g(t))
252
+ return dt(e.context[t]);
253
+ }, W = (e, t) => {
254
+ if (e != null && !(typeof t == "string" && g(t)))
255
+ return e[t];
256
+ }, Ce = {
257
+ "||": 1,
258
+ "??": 1,
259
+ "&&": 2,
260
+ "==": 3,
261
+ "!=": 3,
262
+ "===": 3,
263
+ "!==": 3,
264
+ "<": 4,
265
+ "<=": 4,
266
+ ">": 4,
267
+ ">=": 4,
268
+ "+": 5,
269
+ "-": 5,
270
+ "*": 6,
271
+ "/": 6,
272
+ "%": 6
273
+ }, A = (e, t = 0) => {
274
+ let r = I(e);
275
+ for (; ; ) {
276
+ const n = $(e);
277
+ if (n.kind !== "punct") break;
278
+ if (n.value === "?" && t <= 0) {
279
+ if (e.pos++, r) {
280
+ const s = A(e, 0);
281
+ S(e, ":"), R(e, 0), r = s;
282
+ } else
283
+ R(e, 0), S(e, ":"), r = A(e, 0);
284
+ continue;
285
+ }
286
+ const i = Ce[n.value];
287
+ if (i === void 0 || i < t) break;
288
+ if (e.pos++, n.value === "&&") {
289
+ r ? r = A(e, i + 1) : R(e, i + 1);
290
+ continue;
291
+ }
292
+ if (n.value === "||") {
293
+ r ? R(e, i + 1) : r = A(e, i + 1);
294
+ continue;
295
+ }
296
+ if (n.value === "??") {
297
+ r != null ? R(e, i + 1) : r = A(e, i + 1);
298
+ continue;
299
+ }
300
+ const o = A(e, i + 1);
301
+ r = Et(n.value, r, o);
302
+ }
303
+ return r;
304
+ }, Et = (e, t, r) => {
305
+ switch (e) {
306
+ case "||":
307
+ return t || r;
308
+ case "&&":
309
+ return t && r;
310
+ case "??":
311
+ return t ?? r;
312
+ case "==":
313
+ return t == r;
314
+ case "!=":
315
+ return t != r;
316
+ case "===":
317
+ return t === r;
318
+ case "!==":
319
+ return t !== r;
320
+ case "<":
321
+ return t < r;
322
+ case "<=":
323
+ return t <= r;
324
+ case ">":
325
+ return t > r;
326
+ case ">=":
327
+ return t >= r;
328
+ case "+":
329
+ return typeof t == "string" || typeof r == "string" ? String(t ?? "") + String(r ?? "") : t + r;
330
+ case "-":
331
+ return t - r;
332
+ case "*":
333
+ return t * r;
334
+ case "/":
335
+ return t / r;
336
+ case "%":
337
+ return t % r;
338
+ default:
339
+ throw new Error(`Unsupported binary operator "${e}"`);
340
+ }
341
+ }, I = (e) => {
342
+ const t = $(e);
343
+ if (t.kind === "punct") {
344
+ if (t.value === "!")
345
+ return e.pos++, !I(e);
346
+ if (t.value === "-")
347
+ return e.pos++, -I(e);
348
+ if (t.value === "+")
349
+ return e.pos++, +I(e);
350
+ }
351
+ return t.kind === "ident" && t.value === "typeof" ? (e.pos++, typeof I(e)) : $t(e);
352
+ }, $t = (e) => {
353
+ let t = kt(e), r;
354
+ for (; ; ) {
355
+ const n = $(e);
356
+ if (n.kind !== "punct") break;
357
+ if (n.value === ".") {
358
+ e.pos++;
359
+ const i = C(e);
360
+ if (i.kind !== "ident") throw new Error('Expected identifier after "."');
361
+ r = t, t = W(t, i.value);
362
+ continue;
363
+ }
364
+ if (n.value === "?.") {
365
+ if (e.pos++, t == null) {
366
+ he(e), yt(e), t = void 0, r = void 0;
367
+ continue;
368
+ }
369
+ const i = $(e);
370
+ if (i.kind === "punct" && i.value === "[") {
371
+ e.pos++;
372
+ const o = t, s = A(e, 0);
373
+ S(e, "]"), r = o, t = W(t, s);
374
+ } else if (i.kind === "punct" && i.value === "(")
375
+ t = we(e, t, r), r = void 0;
376
+ else if (i.kind === "ident")
377
+ e.pos++, r = t, t = W(t, i.value);
378
+ else throw new Error("Invalid optional chain in SSR expression");
379
+ continue;
380
+ }
381
+ if (n.value === "[") {
382
+ e.pos++;
383
+ const i = t, o = A(e, 0);
384
+ S(e, "]"), r = i, t = W(t, o);
385
+ continue;
386
+ }
387
+ if (n.value === "(") {
388
+ t = we(e, t, r), r = void 0;
389
+ continue;
390
+ }
391
+ break;
392
+ }
393
+ return t;
394
+ }, we = (e, t, r) => {
395
+ S(e, "(");
396
+ const n = [];
397
+ if (!Y(e, ")")) {
398
+ for (; ; )
399
+ if (n.push(A(e, 0)), !Y(e, ",")) {
400
+ S(e, ")");
401
+ break;
402
+ }
403
+ }
404
+ if (typeof t == "function")
405
+ return t.apply(r, n);
406
+ }, kt = (e) => {
407
+ const t = C(e);
408
+ if (t.kind === "number") return Number(t.value);
409
+ if (t.kind === "string") return t.value;
410
+ if (t.kind === "ident") return St(e, t.value);
411
+ if (t.kind === "punct" && t.value === "(") {
412
+ const r = A(e, 0);
413
+ return S(e, ")"), r;
414
+ }
415
+ throw new Error(`Unexpected token "${t.value}" in SSR expression`);
416
+ }, x = (e, t) => {
417
+ const r = e.trim();
418
+ if (r !== "")
419
+ try {
420
+ const n = {
421
+ tokens: mt(r),
422
+ pos: 0,
423
+ context: t
424
+ }, i = A(n, 0);
425
+ return $(n).kind !== "eof" ? void 0 : i;
426
+ } catch {
427
+ return;
428
+ }
429
+ }, At = /* @__PURE__ */ new Set([
430
+ "area",
431
+ "base",
432
+ "br",
433
+ "col",
434
+ "embed",
435
+ "hr",
436
+ "img",
437
+ "input",
438
+ "link",
439
+ "meta",
440
+ "param",
441
+ "source",
442
+ "track",
443
+ "wbr"
444
+ ]), Rt = /* @__PURE__ */ new Set([
445
+ "script",
446
+ "style",
447
+ "textarea",
448
+ "title"
449
+ ]), Tt = {
450
+ amp: "&",
451
+ lt: "<",
452
+ gt: ">",
453
+ quot: '"',
454
+ apos: "'",
455
+ nbsp: " "
456
+ }, ie = (e) => e.indexOf("&") === -1 ? e : e.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (t, r) => {
457
+ if (r[0] === "#") {
458
+ const n = r[1] === "x" || r[1] === "X", i = parseInt(r.slice(n ? 2 : 1), n ? 16 : 10);
459
+ if (Number.isFinite(i)) try {
460
+ return String.fromCodePoint(i);
461
+ } catch {
462
+ return t;
463
+ }
464
+ return t;
465
+ }
466
+ return Tt[r.toLowerCase()] ?? t;
467
+ }), q = (e) => e === " " || e === " " || e === `
468
+ ` || e === "\r" || e === "\f", z = (e) => {
469
+ for (; e.pos < e.src.length && q(e.src[e.pos]); ) e.pos++;
470
+ }, Ot = (e, t) => {
471
+ const r = e.pos, n = e.src.indexOf(t, r);
472
+ return n === -1 ? (e.pos = e.src.length, e.src.slice(r)) : (e.pos = n, e.src.slice(r, n));
473
+ }, Se = (e) => {
474
+ const t = e.pos;
475
+ for (; e.pos < e.src.length; ) {
476
+ const r = e.src[e.pos];
477
+ if (q(r) || r === ">" || r === "/") break;
478
+ e.pos++;
479
+ }
480
+ return e.src.slice(t, e.pos).toLowerCase();
481
+ }, xt = (e) => {
482
+ const t = e.pos;
483
+ for (; e.pos < e.src.length; ) {
484
+ const r = e.src[e.pos];
485
+ if (q(r) || r === "=" || r === ">" || r === "/") break;
486
+ e.pos++;
487
+ }
488
+ return e.src.slice(t, e.pos);
489
+ }, _t = (e) => {
490
+ const t = e.src[e.pos];
491
+ if (t === '"' || t === "'") {
492
+ const n = t;
493
+ e.pos++;
494
+ const i = e.pos;
495
+ for (; e.pos < e.src.length && e.src[e.pos] !== n; ) e.pos++;
496
+ const o = e.src.slice(i, e.pos);
497
+ return e.pos < e.src.length && e.pos++, ie(o);
498
+ }
499
+ const r = e.pos;
500
+ for (; e.pos < e.src.length; ) {
501
+ const n = e.src[e.pos];
502
+ if (q(n) || n === ">" || n === "/" && e.src[e.pos + 1] === ">") break;
503
+ e.pos++;
504
+ }
505
+ return ie(e.src.slice(r, e.pos));
506
+ }, Nt = (e) => {
507
+ const t = /* @__PURE__ */ Object.create(null), r = [];
508
+ let n = !1;
509
+ for (; e.pos < e.src.length; ) {
510
+ z(e);
511
+ const i = e.src[e.pos];
512
+ if (i === ">") {
513
+ e.pos++;
514
+ break;
515
+ }
516
+ if (i === "/") {
517
+ if (e.pos++, z(e), e.src[e.pos] === ">") {
518
+ n = !0, e.pos++;
519
+ break;
520
+ }
521
+ continue;
522
+ }
523
+ if (e.pos >= e.src.length) break;
524
+ const o = xt(e);
525
+ if (!o) {
526
+ for (; e.pos < e.src.length; ) {
527
+ const u = e.src[e.pos];
528
+ if (q(u) || u === ">" || u === "/") break;
529
+ e.pos++;
530
+ }
531
+ continue;
532
+ }
533
+ const s = o.toLowerCase();
534
+ z(e);
535
+ let a = "";
536
+ e.src[e.pos] === "=" && (e.pos++, z(e), a = _t(e)), s in t || r.push(s), t[s] = a;
537
+ }
538
+ return {
539
+ attributes: t,
540
+ order: r,
541
+ selfClose: n
542
+ };
543
+ }, K = (e) => {
544
+ const t = {
545
+ src: e,
546
+ pos: 0
547
+ }, r = {
548
+ type: "fragment",
549
+ children: []
550
+ }, n = [r], i = () => n[n.length - 1];
551
+ for (; t.pos < t.src.length; ) {
552
+ if (t.src[t.pos] === "<") {
553
+ if (t.src.startsWith("<!--", t.pos)) {
554
+ t.pos += 4;
555
+ const s = t.src.indexOf("-->", t.pos), a = s === -1 ? t.src.slice(t.pos) : t.src.slice(t.pos, s);
556
+ t.pos = s === -1 ? t.src.length : s + 3, i().children.push({
557
+ type: "comment",
558
+ value: a
559
+ });
560
+ continue;
561
+ }
562
+ if (t.src.startsWith("<!", t.pos) || t.src.startsWith("<?", t.pos)) {
563
+ const s = t.src.indexOf(">", t.pos);
564
+ t.pos = s === -1 ? t.src.length : s + 1;
565
+ continue;
566
+ }
567
+ if (t.src[t.pos + 1] === "/") {
568
+ t.pos += 2;
569
+ const s = Se(t), a = t.src.indexOf(">", t.pos);
570
+ t.pos = a === -1 ? t.src.length : a + 1;
571
+ for (let u = n.length - 1; u > 0; u--) {
572
+ const c = n[u];
573
+ if (c.type === "element" && c.tag === s) {
574
+ n.length = u;
575
+ break;
576
+ }
577
+ }
578
+ continue;
579
+ }
580
+ if (t.pos + 1 < t.src.length && /[a-zA-Z]/.test(t.src[t.pos + 1])) {
581
+ t.pos++;
582
+ const s = Se(t), { attributes: a, order: u, selfClose: c } = Nt(t), l = At.has(s), p = {
583
+ type: "element",
584
+ tag: s,
585
+ attributes: a,
586
+ attributeOrder: u,
587
+ children: [],
588
+ void: l,
589
+ raw: Rt.has(s)
590
+ };
591
+ if (i().children.push(p), l || c) continue;
592
+ if (p.raw) {
593
+ const d = `</${s}`, h = t.pos, f = t.src.toLowerCase().indexOf(d, h), v = f === -1 ? t.src.slice(h) : t.src.slice(h, f);
594
+ if (v && p.children.push({
595
+ type: "text",
596
+ value: v
597
+ }), f === -1) t.pos = t.src.length;
598
+ else {
599
+ t.pos = f;
600
+ const m = t.src.indexOf(">", t.pos);
601
+ t.pos = m === -1 ? t.src.length : m + 1;
602
+ }
603
+ continue;
604
+ }
605
+ n.push(p);
606
+ continue;
607
+ }
608
+ i().children.push({
609
+ type: "text",
610
+ value: "<"
611
+ }), t.pos++;
612
+ continue;
613
+ }
614
+ const o = Ot(t, "<");
615
+ o && i().children.push({
616
+ type: "text",
617
+ value: ie(o)
618
+ });
619
+ }
620
+ return r;
621
+ }, Lt = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), Ct = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"), H = (e) => {
622
+ if (e.type === "text") return Lt(e.value);
623
+ if (e.type === "comment") return `<!--${e.value}-->`;
624
+ if (e.type === "fragment") {
625
+ let i = "";
626
+ for (const o of e.children) i += H(o);
627
+ return i;
628
+ }
629
+ const t = e;
630
+ let r = "";
631
+ for (const i of t.attributeOrder) {
632
+ const o = t.attributes[i];
633
+ r += ` ${i}="${Ct(o)}"`;
634
+ }
635
+ if (t.void) return `<${t.tag}${r}>`;
636
+ let n = "";
637
+ if (t.raw)
638
+ for (const i of t.children) i.type === "text" && (n += i.value);
639
+ else for (const i of t.children) n += H(i);
640
+ return `<${t.tag}${r}>${n}</${t.tag}>`;
641
+ }, oe = (e) => e.type === "element" ? {
642
+ type: "element",
643
+ tag: e.tag,
644
+ attributes: { ...e.attributes },
645
+ attributeOrder: [...e.attributeOrder],
646
+ children: e.children.map(oe),
647
+ void: e.void,
648
+ raw: e.raw
649
+ } : e.type === "fragment" ? {
650
+ type: "fragment",
651
+ children: e.children.map(oe)
652
+ } : e.type === "text" ? {
653
+ type: "text",
654
+ value: e.value
655
+ } : {
656
+ type: "comment",
657
+ value: e.value
658
+ }, It = (e) => {
659
+ const t = e.toLowerCase();
660
+ return t === "href" || t === "src" || t === "xlink:href" || t === "formaction" || t === "action" || t === "poster" || t === "background" || t === "cite" || t === "data";
661
+ }, Ut = (e) => e.trim().replace(/[\u0000-\u001F\u007F]+/g, "").replace(/[\u200B-\u200D\uFEFF\u2028\u2029]+/g, "").replace(/\\u[\da-fA-F]{4}/g, "").replace(/\s+/g, "").toLowerCase(), Ie = (e) => {
662
+ const t = Ut(e);
663
+ return xe.some((r) => t.startsWith(r));
664
+ }, Dt = /^[a-zA-Z][a-zA-Z0-9+.-]*:/, Ht = /\s+/, Pt = (e) => {
665
+ const t = e.toLowerCase();
666
+ for (const r of tt) if (t.startsWith(r)) return !1;
667
+ return t.startsWith("data-") || t.startsWith("aria-") ? !0 : Xe.has(t);
668
+ }, qt = (e) => !nt.has(e.toLowerCase().trim()), jt = (e) => {
669
+ try {
670
+ const t = e.trim();
671
+ if (t.startsWith("//")) return !0;
672
+ const r = t.toLowerCase();
673
+ return !r.startsWith("http://") && !r.startsWith("https://") ? !!Dt.test(t) : typeof window > "u" || !window.location ? !0 : new URL(t, window.location.href).origin !== window.location.origin;
674
+ } catch {
675
+ return !0;
676
+ }
677
+ }, F = (e, t) => {
678
+ if (!t) return;
679
+ const r = e.attributes.class, n = r ? `${r} ${t}` : t;
680
+ "class" in e.attributes || e.attributeOrder.push("class"), e.attributes.class = n;
681
+ }, Ee = (e, t) => {
682
+ let r = e.attributes.style ?? "";
683
+ for (const [n, i] of Object.entries(t)) {
684
+ if (i == null || i === !1) continue;
685
+ const o = n.replace(/([A-Z])/g, "-$1").toLowerCase();
686
+ r && !r.endsWith(";") && (r += "; "), r += `${o}: ${String(i)};`;
687
+ }
688
+ "style" in e.attributes || e.attributeOrder.push("style"), e.attributes.style = r;
689
+ }, k = (e, t) => {
690
+ if (t in e.attributes) {
691
+ delete e.attributes[t];
692
+ const r = e.attributeOrder.indexOf(t);
693
+ r !== -1 && e.attributeOrder.splice(r, 1);
694
+ }
695
+ }, B = (e, t, r) => {
696
+ t in e.attributes || e.attributeOrder.push(t), e.attributes[t] = r;
697
+ }, Mt = (e, t) => ft(e.attributeOrder, e.attributes, t), Wt = (e) => {
698
+ const t = e.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);
699
+ return t ? {
700
+ itemName: t[1],
701
+ indexName: t[2] || void 0,
702
+ listExpr: t[3].trim()
703
+ } : null;
704
+ }, se = (e, t) => {
705
+ if (e.type !== "element") {
706
+ if (e.type === "fragment") for (const r of e.children) se(r, t);
707
+ return;
708
+ }
709
+ for (const r of [...e.attributeOrder]) (r.startsWith(`${t}-`) || r.startsWith(":")) && k(e, r);
710
+ for (const r of e.children) se(r, t);
711
+ }, zt = (e, t) => {
712
+ e.children = [{
713
+ type: "text",
714
+ value: t
715
+ }];
716
+ }, Ft = (e, t) => {
717
+ e.children = K(t).children;
718
+ }, Ue = (e) => {
719
+ const t = (r) => {
720
+ if (r.type === "fragment")
721
+ return r.children = r.children.flatMap((n) => {
722
+ const i = t(n);
723
+ return i ? [i] : [];
724
+ }), r;
725
+ if (r.type !== "element") return r;
726
+ if (et.has(r.tag) || !Ke.has(r.tag)) return null;
727
+ for (const n of [...r.attributeOrder]) {
728
+ const i = r.attributes[n], o = n.toLowerCase();
729
+ if (!Pt(o)) {
730
+ k(r, n);
731
+ continue;
732
+ }
733
+ if ((o === "id" || o === "name") && !qt(i)) {
734
+ k(r, n);
735
+ continue;
736
+ }
737
+ if ((o === "href" || o === "src") && Ie(i)) {
738
+ k(r, n);
739
+ continue;
740
+ }
741
+ }
742
+ if (r.tag === "a") {
743
+ const n = r.attributes.href, i = r.attributes.target?.toLowerCase() === "_blank", o = n ? jt(n) : !1;
744
+ if (i || o) {
745
+ const s = new Set((r.attributes.rel ?? "").trim().split(Ht).filter(Boolean));
746
+ s.add("noopener"), s.add("noreferrer"), B(r, "rel", Array.from(s).join(" "));
747
+ }
748
+ }
749
+ return r.children = r.children.flatMap((n) => {
750
+ const i = t(n);
751
+ return i ? [i] : [];
752
+ }), r;
753
+ };
754
+ return H(t(K(e)) ?? {
755
+ type: "fragment",
756
+ children: []
757
+ });
758
+ }, De = (e, t, r) => {
759
+ const n = [];
760
+ for (const i of e.children) {
761
+ if (i.type !== "element") {
762
+ n.push(i);
763
+ continue;
764
+ }
765
+ const o = He(i, t, r);
766
+ if (o !== null)
767
+ if (Array.isArray(o)) for (const s of o) n.push(s);
768
+ else n.push(o);
769
+ }
770
+ e.children = n;
771
+ }, He = (e, t, r) => {
772
+ const { prefix: n } = r, i = e.attributes[`${n}-for`];
773
+ if (i !== void 0) {
774
+ const d = Wt(i);
775
+ if (d || k(e, `${n}-for`), d) {
776
+ const h = x(d.listExpr, t);
777
+ if (!Array.isArray(h)) return null;
778
+ const f = [];
779
+ for (let v = 0; v < h.length; v++) {
780
+ const m = oe(e);
781
+ k(m, `${n}-for`), k(m, `${n}-key`), k(m, ":key");
782
+ const E = {
783
+ ...t,
784
+ [d.itemName]: h[v]
785
+ };
786
+ d.indexName && (E[d.indexName] = v);
787
+ const y = He(m, E, r);
788
+ y !== null && (Array.isArray(y) ? f.push(...y) : f.push(y));
789
+ }
790
+ return f;
791
+ }
792
+ }
793
+ const o = r.annotateHydration ? Mt(e, n) : "", s = e.attributes[`${n}-if`];
794
+ if (s !== void 0 && !x(s, t))
795
+ return null;
796
+ const a = e.attributes[`${n}-show`];
797
+ a !== void 0 && (x(a, t) || Ee(e, { display: "none" }));
798
+ const u = e.attributes[`${n}-text`];
799
+ if (u !== void 0) {
800
+ const d = x(u, t);
801
+ zt(e, String(d ?? ""));
802
+ }
803
+ const c = e.attributes[`${n}-html`];
804
+ if (c !== void 0) {
805
+ const d = x(c, t);
806
+ Ft(e, Ue(String(d ?? "")));
807
+ }
808
+ const l = e.attributes[`${n}-class`];
809
+ if (l !== void 0) {
810
+ const d = l.trim();
811
+ if (d.startsWith("{")) {
812
+ const h = d.slice(1, -1).split(",");
813
+ for (const f of h) {
814
+ const v = f.indexOf(":");
815
+ if (v < 0) continue;
816
+ const m = f.slice(0, v).trim().replace(/^['"]|['"]$/g, "");
817
+ x(f.slice(v + 1), t) && F(e, m);
818
+ }
819
+ } else {
820
+ const h = x(l, t);
821
+ if (typeof h == "string") for (const f of h.split(/\s+/).filter(Boolean)) F(e, f);
822
+ else if (Array.isArray(h))
823
+ for (const f of h) typeof f == "string" && f && F(e, f);
824
+ else if (h && typeof h == "object")
825
+ for (const [f, v] of Object.entries(h)) v && F(e, f);
826
+ }
827
+ }
828
+ const p = e.attributes[`${n}-style`];
829
+ if (p !== void 0) {
830
+ const d = x(p, t);
831
+ d && typeof d == "object" && Ee(e, d);
832
+ }
833
+ for (const d of [...e.attributeOrder]) {
834
+ if (!d.startsWith(`${n}-bind:`)) continue;
835
+ const h = d.slice(`${n}-bind:`.length), f = x(e.attributes[d], t);
836
+ f === !1 || f == null ? k(e, h) : f === !0 ? B(e, h, "") : B(e, h, String(f));
837
+ }
838
+ for (const d of [...e.attributeOrder]) {
839
+ const h = d.toLowerCase();
840
+ if (h.startsWith("on")) {
841
+ k(e, d);
842
+ continue;
843
+ }
844
+ It(h) && Ie(e.attributes[d] ?? "") && k(e, d);
845
+ }
846
+ return e.tag === "script" ? null : (De(e, t, r), o && B(e, pe, de(o)), e);
847
+ }, Bt = (e, t, r = {}) => {
848
+ const n = {
849
+ prefix: r.prefix ?? "bq",
850
+ stripDirectives: r.stripDirectives ?? !1,
851
+ annotateHydration: r.annotateHydration ?? !1
852
+ }, i = K(e);
853
+ return De(i, t, n), n.stripDirectives && se(i, n.prefix), H(i);
854
+ }, L = (e) => e.replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\//g, "\\u002f").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"), P = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), Q = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ve = (e) => {
855
+ const t = {};
856
+ for (const [r, n] of Object.entries(e))
857
+ g(r) || (t[r] = n);
858
+ return t;
859
+ }, ae = (e = {}) => {
860
+ const { scriptId: t = "__BQUERY_STORE_STATE__", globalKey: r = "__BQUERY_INITIAL_STATE__", storeIds: n, serialize: i = JSON.stringify } = e;
861
+ if (g(r)) throw new Error(`serializeStoreState: invalid globalKey "${r}" - prototype-pollution keys are not allowed.`);
862
+ if (g(t)) throw new Error(`serializeStoreState: invalid scriptId "${t}" - prototype-pollution keys are not allowed.`);
863
+ const o = n ?? _e(), s = /* @__PURE__ */ Object.create(null);
864
+ for (const l of o) {
865
+ if (g(l)) continue;
866
+ const p = Z(l);
867
+ p && (s[l] = ve(p.$state));
868
+ }
869
+ const a = i(s);
870
+ if (typeof a != "string") throw new Error("serializeStoreState: custom serialize function must return a string.");
871
+ if (i !== JSON.stringify) {
872
+ let l;
873
+ try {
874
+ l = JSON.parse(a);
875
+ } catch {
876
+ throw new Error("serializeStoreState: custom serialize function returned invalid JSON.");
877
+ }
878
+ if (!Q(l)) throw new Error("serializeStoreState: custom serialize function must return a JSON object string.");
879
+ }
880
+ const u = L(a), c = L(JSON.stringify(r));
881
+ return {
882
+ stateJson: a,
883
+ scriptTag: `<script id="${P(t)}">window[${c}]=${u}<\/script>`
884
+ };
885
+ }, sn = (e = "__BQUERY_INITIAL_STATE__", t = "__BQUERY_STORE_STATE__") => {
886
+ if (g(e)) throw new Error(`deserializeStoreState: invalid globalKey "${e}" - prototype-pollution keys are not allowed.`);
887
+ if (g(t)) throw new Error(`deserializeStoreState: invalid scriptId "${t}" - prototype-pollution keys are not allowed.`);
888
+ if (typeof window > "u") return {};
889
+ const r = window[e];
890
+ if (!r) return {};
891
+ try {
892
+ delete window[e];
893
+ } catch {
894
+ window[e] = void 0;
895
+ }
896
+ if (typeof document < "u" && typeof document.getElementById == "function") {
897
+ const i = document.getElementById(t);
898
+ i && i.remove();
899
+ }
900
+ if (!Q(r)) return {};
901
+ for (const i of Object.values(r)) if (!Q(i)) return {};
902
+ const n = /* @__PURE__ */ Object.create(null);
903
+ for (const [i, o] of Object.entries(r))
904
+ g(i) || !Q(o) || (n[i] = ve(o));
905
+ return n;
906
+ }, Qt = (e, t) => {
907
+ const r = Z(e);
908
+ r && typeof r.$patch == "function" && r.$patch(ve(t));
909
+ }, an = (e) => {
910
+ for (const [t, r] of Object.entries(e)) Qt(t, r);
911
+ }, Jt = /* @__PURE__ */ new Set([
912
+ "area",
913
+ "base",
914
+ "br",
915
+ "col",
916
+ "embed",
917
+ "hr",
918
+ "img",
919
+ "input",
920
+ "link",
921
+ "meta",
922
+ "param",
923
+ "source",
924
+ "track",
925
+ "wbr"
926
+ ]), Yt = 3, Vt = 1, Pe = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), Gt = (e) => Pe(e).replace(/"/g, "&quot;"), Zt = (e) => {
927
+ const t = e.toLowerCase();
928
+ return t === "href" || t === "src" || t === "xlink:href" || t === "formaction" || t === "action" || t === "poster" || t === "background" || t === "cite" || t === "data";
929
+ }, Kt = (e) => e.trim().replace(/[\u0000-\u001F\u007F]+/g, "").replace(/[\u200B-\u200D\uFEFF\u2028\u2029]+/g, "").replace(/\\u[\da-fA-F]{4}/g, "").replace(/\s+/g, "").toLowerCase(), Xt = (e) => {
930
+ const t = Kt(e);
931
+ return xe.some((r) => t.startsWith(r));
932
+ }, qe = (e) => {
933
+ if (e.nodeType === Yt) return Pe(e.textContent ?? "");
934
+ if (e.nodeType !== Vt) return "";
935
+ const t = e, r = t.tagName.toLowerCase();
936
+ if (r === "script") return "";
937
+ let n = "";
938
+ for (const o of t.attributes) {
939
+ const s = o.name.toLowerCase();
940
+ s.startsWith("on") || Zt(s) && Xt(o.value) || (n += ` ${o.name}="${Gt(o.value)}"`);
941
+ }
942
+ if (Jt.has(r)) return `<${r}${n}>`;
943
+ let i = "";
944
+ for (const o of t.childNodes) i += qe(o);
945
+ return `<${r}${n}>${i}</${r}>`;
946
+ }, $e = (e) => D(e) || U(e) ? e.value : e, O = (e, t) => {
947
+ const r = e.trim();
948
+ if (r.startsWith("!")) return !O(r.slice(1).trim(), t);
949
+ if (r.startsWith("'") && r.endsWith("'") || r.startsWith('"') && r.endsWith('"')) return r.slice(1, -1);
950
+ if (/^-?\d+(\.\d+)?$/.test(r)) return Number(r);
951
+ if (r === "true") return !0;
952
+ if (r === "false") return !1;
953
+ if (r === "null") return null;
954
+ if (r !== "undefined") {
955
+ if (/^[\w$]+(?:\.[\w$]+)*$/.test(r)) {
956
+ const n = r.split(".");
957
+ let i = t;
958
+ for (const o of n) {
959
+ if (i == null) return;
960
+ i === t ? i = $e(i[o]) : i = i[o];
961
+ }
962
+ return i;
963
+ }
964
+ try {
965
+ const n = Object.keys(t), i = n.map((o) => $e(t[o]));
966
+ return new Function(...n, `return (${r});`)(...i);
967
+ } catch {
968
+ return;
969
+ }
970
+ }
971
+ }, er = (e) => {
972
+ const t = e.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);
973
+ return t ? {
974
+ itemName: t[1],
975
+ indexName: t[2] || void 0,
976
+ listExpr: t[3].trim()
977
+ } : null;
978
+ }, ce = (e, t, r, n = !1) => {
979
+ const i = e.getAttribute(`${r}-for`), o = i !== null ? er(i) : null;
980
+ i !== null && !o && e.removeAttribute(`${r}-for`);
981
+ const s = n ? Ne(e, r) : "";
982
+ if (i !== null && o) {
983
+ const f = O(o.listExpr, t);
984
+ if (e.parentNode) {
985
+ const v = e.parentNode;
986
+ if (!Array.isArray(f))
987
+ return v.removeChild(e), !0;
988
+ for (let m = 0; m < f.length; m++) {
989
+ const E = f[m], y = e.cloneNode(!0);
990
+ y.removeAttribute(`${r}-for`), y.removeAttribute(":key"), y.removeAttribute(`${r}-key`);
991
+ const w = {
992
+ ...t,
993
+ [o.itemName]: E
994
+ };
995
+ o.indexName && (w[o.indexName] = m), ce(y, w, r, n) && (me(y, w, r, n), v.insertBefore(y, e));
996
+ }
997
+ return v.removeChild(e), !0;
998
+ }
999
+ }
1000
+ const a = e.getAttribute(`${r}-if`);
1001
+ if (a !== null && !O(a, t))
1002
+ return !1;
1003
+ const u = e.getAttribute(`${r}-show`);
1004
+ if (u !== null && !O(u, t)) {
1005
+ const f = e;
1006
+ f.style ? f.style.display = "none" : e.setAttribute("style", "display: none;");
1007
+ }
1008
+ const c = e.getAttribute(`${r}-text`);
1009
+ if (c !== null) {
1010
+ const f = O(c, t);
1011
+ e.textContent = String(f ?? "");
1012
+ }
1013
+ const l = e.getAttribute(`${r}-html`);
1014
+ if (l !== null) {
1015
+ const f = O(l, t);
1016
+ e.innerHTML = Ue(String(f ?? ""));
1017
+ }
1018
+ const p = e.getAttribute(`${r}-class`);
1019
+ if (p !== null) {
1020
+ const f = p.trim();
1021
+ if (f.startsWith("{")) {
1022
+ const v = f.slice(1, -1).trim().split(",");
1023
+ for (const m of v) {
1024
+ const E = m.indexOf(":");
1025
+ if (E > -1) {
1026
+ const y = m.slice(0, E).trim().replace(/^['"]|['"]$/g, "");
1027
+ O(m.slice(E + 1).trim(), t) && e.classList.add(y);
1028
+ }
1029
+ }
1030
+ } else {
1031
+ const v = O(p, t);
1032
+ typeof v == "string" ? v.split(/\s+/).filter(Boolean).forEach((m) => e.classList.add(m)) : Array.isArray(v) && v.filter(Boolean).forEach((m) => e.classList.add(m));
1033
+ }
1034
+ }
1035
+ const d = e.getAttribute(`${r}-style`);
1036
+ if (d !== null) {
1037
+ const f = O(d, t);
1038
+ if (f && typeof f == "object") {
1039
+ const v = e;
1040
+ for (const [m, E] of Object.entries(f)) {
1041
+ const y = m.replace(/([A-Z])/g, "-$1").toLowerCase();
1042
+ v.style.setProperty(y, String(E));
1043
+ }
1044
+ }
1045
+ }
1046
+ const h = Array.from(e.attributes);
1047
+ for (const f of h) if (f.name.startsWith(`${r}-bind:`)) {
1048
+ const v = f.name.slice(`${r}-bind:`.length), m = O(f.value, t);
1049
+ m === !1 || m === null || m === void 0 ? e.removeAttribute(v) : m === !0 ? e.setAttribute(v, "") : e.setAttribute(v, String(m));
1050
+ }
1051
+ return s && e.setAttribute(pe, de(s)), !0;
1052
+ }, me = (e, t, r, n = !1) => {
1053
+ const i = Array.from(e.children);
1054
+ for (const o of i) {
1055
+ let s = !1;
1056
+ if (o.hasAttribute(`${r}-for`)) {
1057
+ const a = ce(o, t, r, n);
1058
+ if (s = !0, !a) {
1059
+ o.remove();
1060
+ continue;
1061
+ }
1062
+ if (o.parentNode !== e) continue;
1063
+ }
1064
+ if (!s && !ce(o, t, r, n)) {
1065
+ o.remove();
1066
+ continue;
1067
+ }
1068
+ me(o, t, r, n);
1069
+ }
1070
+ }, je = (e, t) => {
1071
+ const r = Array.from(e.attributes);
1072
+ for (const n of r) (n.name.startsWith(`${t}-`) || n.name.startsWith(":") || n.name === ":key") && e.removeAttribute(n.name);
1073
+ for (const n of Array.from(e.children)) je(n, t);
1074
+ }, ye = (e, t, r = {}) => {
1075
+ const { prefix: n = "bq", stripDirectives: i = !1, includeStoreState: o = !1, annotateHydration: s = !1 } = r;
1076
+ if (!e || typeof e != "string") throw new Error("bQuery SSR: template must be a non-empty string.");
1077
+ const a = e.trim();
1078
+ if (ut() === "pure") {
1079
+ const h = Bt(a, t, {
1080
+ prefix: n,
1081
+ stripDirectives: i,
1082
+ annotateHydration: s
1083
+ });
1084
+ let f;
1085
+ return o && (f = ae({ storeIds: Array.isArray(o) ? o : void 0 }).stateJson), {
1086
+ html: h,
1087
+ storeState: f
1088
+ };
1089
+ }
1090
+ const u = lt();
1091
+ if (!u) throw new Error("bQuery SSR: DOMParser is not available in this environment. Provide a DOMParser-compatible implementation before calling renderToString().");
1092
+ const c = new u().parseFromString(a, "text/html"), l = c.body || c.documentElement;
1093
+ if (!l) throw new Error("bQuery SSR: Failed to parse template.");
1094
+ if (me(l, t, n, s), i) for (const h of Array.from(l.children)) je(h, n);
1095
+ let p = "";
1096
+ for (const h of l.childNodes) p += qe(h);
1097
+ let d;
1098
+ return o && (d = ae({ storeIds: Array.isArray(o) ? o : void 0 }).stateJson), {
1099
+ html: p,
1100
+ storeState: d
1101
+ };
1102
+ }, Me = () => typeof globalThis < "u" ? globalThis : {}, ge = () => {
1103
+ const e = Me();
1104
+ if (typeof e.Bun?.version == "string") return "bun";
1105
+ if (typeof e.Deno?.version?.deno == "string") return "deno";
1106
+ const t = e.navigator;
1107
+ return typeof t?.userAgent == "string" && t.userAgent.toLowerCase().includes("cloudflare-workers") ? "workerd" : typeof e.process?.versions?.node == "string" ? "node" : typeof e.window < "u" && typeof e.document < "u" ? "browser" : "unknown";
1108
+ }, cn = () => {
1109
+ const e = ge();
1110
+ return e === "bun" || e === "deno" || e === "node" || e === "workerd";
1111
+ }, un = () => ge() === "browser", ln = () => {
1112
+ const e = Me(), t = e.crypto;
1113
+ return {
1114
+ fetchApi: typeof e.Request == "function" && typeof e.Response == "function" && typeof e.fetch == "function",
1115
+ webStreams: typeof e.ReadableStream == "function",
1116
+ textEncoder: typeof e.TextEncoder == "function",
1117
+ subtleCrypto: typeof t?.subtle == "object" && t?.subtle !== null,
1118
+ randomUuid: typeof t?.randomUUID == "function",
1119
+ domParser: typeof e.DOMParser == "function"
1120
+ };
1121
+ }, j = /* @__PURE__ */ Symbol.for("bquery.ssr.defer"), fn = (e) => (Object.defineProperty(e, j, {
1122
+ value: !0,
1123
+ enumerable: !1,
1124
+ configurable: !0
1125
+ }), e), dn = (e, t) => {
1126
+ const r = e instanceof Promise ? e : Promise.resolve(e);
1127
+ return {
1128
+ [j]: !0,
1129
+ promise: r,
1130
+ fallback: t
1131
+ };
1132
+ }, tr = (e) => typeof e == "object" && e !== null && e[j] === !0, rr = async (e, t) => {
1133
+ const r = /* @__PURE__ */ Object.create(null), n = Object.entries(e);
1134
+ await Promise.all(n.map(async ([i, o]) => {
1135
+ if (!g(i)) {
1136
+ if (D(o) || U(o)) {
1137
+ r[i] = o;
1138
+ return;
1139
+ }
1140
+ if (tr(o)) {
1141
+ try {
1142
+ r[i] = await o.promise;
1143
+ } catch (s) {
1144
+ t.reportError(s), r[i] = o.fallback;
1145
+ }
1146
+ return;
1147
+ }
1148
+ if (o && typeof o.then == "function") {
1149
+ try {
1150
+ r[i] = await o;
1151
+ } catch (s) {
1152
+ t.reportError(s), r[i] = void 0;
1153
+ }
1154
+ return;
1155
+ }
1156
+ if (typeof o == "function" && o[j]) {
1157
+ try {
1158
+ r[i] = await Promise.resolve(o(t));
1159
+ } catch (s) {
1160
+ t.reportError(s), r[i] = void 0;
1161
+ }
1162
+ return;
1163
+ }
1164
+ r[i] = o;
1165
+ }
1166
+ }));
1167
+ for (const [i, o] of Object.entries(e)) !g(i) && !Object.prototype.hasOwnProperty.call(r, i) && (D(o) || U(o)) && (r[i] = o);
1168
+ return r;
1169
+ }, b = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), nr = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), ir = (e) => e.replace(/<\/(script)/gi, "<\\/$1").replace(/<!--/g, "<\\!--").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"), or = () => {
1170
+ const e = {
1171
+ title: null,
1172
+ titleTemplate: null,
1173
+ meta: [],
1174
+ link: [],
1175
+ script: []
1176
+ };
1177
+ return {
1178
+ add: (i) => {
1179
+ typeof i.title == "string" && (e.title = i.title), typeof i.titleTemplate == "string" && (e.titleTemplate = i.titleTemplate), Array.isArray(i.meta) && e.meta.push(...i.meta), Array.isArray(i.link) && e.link.push(...i.link), Array.isArray(i.script) && e.script.push(...i.script);
1180
+ },
1181
+ state: () => ({
1182
+ ...e,
1183
+ meta: [...e.meta],
1184
+ link: [...e.link],
1185
+ script: [...e.script]
1186
+ }),
1187
+ render: (i = {}) => {
1188
+ let o = "";
1189
+ if (e.title !== null) {
1190
+ const s = e.titleTemplate ? e.titleTemplate.replace(/%s/g, e.title) : e.title;
1191
+ o += `<title>${nr(s)}</title>`;
1192
+ }
1193
+ for (const s of e.meta) {
1194
+ let a = "";
1195
+ for (const [u, c] of Object.entries(s))
1196
+ c != null && (g(u) || (a += ` ${u === "httpEquiv" ? "http-equiv" : u}="${b(String(c))}"`));
1197
+ o += `<meta${a}>`;
1198
+ }
1199
+ for (const s of e.link) {
1200
+ let a = ` rel="${b(s.rel)}" href="${b(s.href)}"`;
1201
+ s.as && (a += ` as="${b(s.as)}"`), s.type && (a += ` type="${b(s.type)}"`), s.crossorigin && (a += ` crossorigin="${b(s.crossorigin)}"`), s.media && (a += ` media="${b(s.media)}"`), s.integrity && (a += ` integrity="${b(s.integrity)}"`), (s.nonce ?? i.nonce) && (a += ` nonce="${b(s.nonce ?? i.nonce)}"`), o += `<link${a}>`;
1202
+ }
1203
+ for (const s of e.script) {
1204
+ let a = "";
1205
+ s.src && (a += ` src="${b(s.src)}"`), s.type ? a += ` type="${b(s.type)}"` : s.module && (a += ' type="module"'), s.defer && (a += " defer"), s.async && (a += " async"), s.crossorigin && (a += ` crossorigin="${b(s.crossorigin)}"`), s.integrity && (a += ` integrity="${b(s.integrity)}"`);
1206
+ const u = s.nonce ?? i.nonce;
1207
+ u && (a += ` nonce="${b(u)}"`), o += `<script${a}>${s.body ? ir(s.body) : ""}<\/script>`;
1208
+ }
1209
+ return o;
1210
+ },
1211
+ reset: () => {
1212
+ e.title = null, e.titleTemplate = null, e.meta = [], e.link = [], e.script = [];
1213
+ }
1214
+ };
1215
+ }, sr = () => {
1216
+ const e = [];
1217
+ return {
1218
+ preload(t, r = {}) {
1219
+ e.push({
1220
+ href: t,
1221
+ rel: "preload",
1222
+ ...r
1223
+ });
1224
+ },
1225
+ module(t, r = {}) {
1226
+ e.push({
1227
+ href: t,
1228
+ rel: "modulepreload",
1229
+ ...r
1230
+ });
1231
+ },
1232
+ style(t, r = {}) {
1233
+ e.push({
1234
+ href: t,
1235
+ rel: "stylesheet",
1236
+ ...r
1237
+ });
1238
+ },
1239
+ list: () => [...e],
1240
+ render(t = {}) {
1241
+ let r = "";
1242
+ for (const n of e) {
1243
+ let i = ` rel="${b(n.rel)}" href="${b(n.href)}"`;
1244
+ n.as && (i += ` as="${b(n.as)}"`), n.type && (i += ` type="${b(n.type)}"`), n.crossorigin && (i += ` crossorigin="${b(n.crossorigin)}"`), n.integrity && (i += ` integrity="${b(n.integrity)}"`), t.nonce && (i += ` nonce="${b(t.nonce)}"`), r += `<link${i}>`;
1245
+ }
1246
+ return r;
1247
+ },
1248
+ reset() {
1249
+ e.length = 0;
1250
+ }
1251
+ };
1252
+ }, ar = (e) => {
1253
+ const t = /* @__PURE__ */ Object.create(null);
1254
+ if (!e) return t;
1255
+ for (const r of e.split(/;\s*/)) {
1256
+ const n = r.indexOf("=");
1257
+ if (n === -1) continue;
1258
+ const i = r.slice(0, n).trim(), o = r.slice(n + 1).trim();
1259
+ if (!(!i || g(i)))
1260
+ try {
1261
+ t[i] = decodeURIComponent(o);
1262
+ } catch {
1263
+ t[i] = o;
1264
+ }
1265
+ }
1266
+ return t;
1267
+ }, cr = (e) => {
1268
+ if (!e) return "en";
1269
+ const t = e.split(",").map((r) => {
1270
+ const [n, ...i] = r.trim().split(";"), o = i.find((a) => a.trim().startsWith("q=")), s = o ? Number.parseFloat(o.split("=")[1]) : 1;
1271
+ return {
1272
+ tag: n.trim(),
1273
+ q: Number.isFinite(s) ? s : 0
1274
+ };
1275
+ }).filter((r) => r.tag);
1276
+ return t.length ? (t.sort((r, n) => n.q - r.q), t[0].tag) : "en";
1277
+ }, ur = () => {
1278
+ try {
1279
+ return rt();
1280
+ } catch {
1281
+ return "";
1282
+ }
1283
+ }, We = () => {
1284
+ const e = /* @__PURE__ */ new Map(), t = {
1285
+ append(r, n) {
1286
+ const i = String(r).toLowerCase(), o = e.get(i);
1287
+ o ? o.push(String(n)) : e.set(i, [String(n)]);
1288
+ },
1289
+ delete(r) {
1290
+ e.delete(String(r).toLowerCase());
1291
+ },
1292
+ get(r) {
1293
+ const n = e.get(String(r).toLowerCase());
1294
+ return n ? n.join(", ") : null;
1295
+ },
1296
+ has(r) {
1297
+ return e.has(String(r).toLowerCase());
1298
+ },
1299
+ set(r, n) {
1300
+ e.set(String(r).toLowerCase(), [String(n)]);
1301
+ },
1302
+ forEach(r, n) {
1303
+ for (const [i, o] of e) r.call(n, o.join(", "), i, t);
1304
+ },
1305
+ *entries() {
1306
+ for (const [r, n] of e) yield [r, n.join(", ")];
1307
+ },
1308
+ [Symbol.iterator]() {
1309
+ return t.entries();
1310
+ }
1311
+ };
1312
+ return t;
1313
+ }, ke = () => ({
1314
+ aborted: !1,
1315
+ onabort: null,
1316
+ reason: void 0,
1317
+ addEventListener() {
1318
+ },
1319
+ removeEventListener() {
1320
+ },
1321
+ dispatchEvent() {
1322
+ return !1;
1323
+ },
1324
+ throwIfAborted() {
1325
+ }
1326
+ }), lr = (e) => typeof e == "object" && e !== null && typeof e.get == "function", fr = (e) => typeof e == "object" && e !== null && typeof e.aborted == "boolean", Ae = () => typeof Headers == "function" ? new Headers() : We(), X = (e = {}) => {
1327
+ const t = e.url instanceof URL ? e.url.toString() : typeof e.url == "string" ? new URL(e.url, "http://localhost/").toString() : "http://localhost/", r = e.request ?? (typeof Request == "function" ? new Request(t) : {
1328
+ url: t,
1329
+ headers: We(),
1330
+ signal: ke()
1331
+ }), n = e.url ?? r.url, i = n instanceof URL ? n : new URL(String(n), "http://localhost/"), o = lr(r.headers) ? r.headers : Ae();
1332
+ return {
1333
+ request: r,
1334
+ url: i,
1335
+ headers: o,
1336
+ cookies: ar(o.get("cookie") ?? ""),
1337
+ userAgent: e.userAgent ?? o.get("user-agent") ?? "",
1338
+ locale: e.locale ?? cr(o.get("accept-language")),
1339
+ signal: e.signal ?? (fr(r.signal) ? r.signal : ke()),
1340
+ nonce: e.nonce ?? ur(),
1341
+ mode: e.mode ?? "string",
1342
+ head: or(),
1343
+ assets: sr(),
1344
+ status: 200,
1345
+ responseHeaders: Ae(),
1346
+ reportError(s) {
1347
+ e.onError?.(s);
1348
+ }
1349
+ };
1350
+ }, dr = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), pr = (e) => e === " " || e === `
1351
+ ` || e === " " || e === "\r" || e === "\f", hr = (e, t) => {
1352
+ if (e.slice(0, 7).toLowerCase() !== "<script") return e;
1353
+ const r = e[7];
1354
+ return r !== ">" && !pr(r) ? e : `<script nonce="${dr(t)}"${e.slice(7)}`;
1355
+ }, vr = (e, t) => {
1356
+ if (!t) return e;
1357
+ const r = e.toLowerCase().indexOf("</head>");
1358
+ return r === -1 ? e : e.slice(0, r) + t + e.slice(r);
1359
+ }, mr = (e, t) => {
1360
+ if (!t) return e;
1361
+ const r = e.toLowerCase().lastIndexOf("</body>");
1362
+ return r === -1 ? e : e.slice(0, r) + t + e.slice(r);
1363
+ }, ze = async (e, t, r = {}) => {
1364
+ const n = r.context ?? X({ mode: "string" });
1365
+ if (n.signal.aborted) throw new DOMException("SSR render aborted", "AbortError");
1366
+ const i = await rr(t, n);
1367
+ if (n.signal.aborted) throw new DOMException("SSR render aborted", "AbortError");
1368
+ let { html: o, storeState: s } = ye(e, i, {
1369
+ prefix: r.prefix,
1370
+ stripDirectives: r.stripDirectives,
1371
+ includeStoreState: !1,
1372
+ annotateHydration: r.annotateHydration
1373
+ });
1374
+ const a = n.head.render({ nonce: n.nonce }), u = n.assets.render({ nonce: n.nonce });
1375
+ let c = "";
1376
+ if (r.includeStoreState) {
1377
+ const l = ae({
1378
+ storeIds: Array.isArray(r.includeStoreState) ? r.includeStoreState : void 0,
1379
+ scriptId: r.storeScriptId,
1380
+ globalKey: r.storeGlobalKey
1381
+ });
1382
+ s = l.stateJson, c = l.scriptTag, n.nonce && (c = hr(c, n.nonce));
1383
+ }
1384
+ return r.injectHead !== !1 && (o = vr(o, a + u), o = mr(o, c)), {
1385
+ html: o,
1386
+ storeState: s,
1387
+ context: n,
1388
+ headHtml: a,
1389
+ assetsHtml: u,
1390
+ storeScriptTag: c
1391
+ };
1392
+ }, Fe = () => {
1393
+ if (typeof TextEncoder > "u") throw new Error("bQuery SSR: TextEncoder is not available in this runtime.");
1394
+ return new TextEncoder();
1395
+ }, pn = (e, t, r = {}) => {
1396
+ if (typeof ReadableStream > "u") throw new Error("bQuery SSR: ReadableStream is not available in this runtime.");
1397
+ const n = Fe(), i = r.context ?? X({
1398
+ ...r,
1399
+ mode: "stream"
1400
+ }), o = {
1401
+ ...r,
1402
+ context: i
1403
+ };
1404
+ return new ReadableStream({ async start(s) {
1405
+ const a = () => {
1406
+ try {
1407
+ s.error(new DOMException("SSR stream aborted", "AbortError"));
1408
+ } catch {
1409
+ }
1410
+ };
1411
+ if (i.signal.aborted) {
1412
+ a();
1413
+ return;
1414
+ }
1415
+ i.signal.addEventListener("abort", a, { once: !0 });
1416
+ try {
1417
+ const u = await ze(e, t, o);
1418
+ s.enqueue(n.encode(u.html)), s.close();
1419
+ } catch (u) {
1420
+ i.signal.removeEventListener("abort", a);
1421
+ try {
1422
+ s.error(u);
1423
+ } catch {
1424
+ }
1425
+ } finally {
1426
+ i.signal.removeEventListener("abort", a);
1427
+ }
1428
+ } });
1429
+ }, yr = async (e) => {
1430
+ const t = globalThis.crypto?.subtle;
1431
+ if (!t) return null;
1432
+ try {
1433
+ const r = await t.digest("SHA-1", Fe().encode(e)), n = new Uint8Array(r);
1434
+ let i = "";
1435
+ for (const o of n) i += o.toString(16).padStart(2, "0");
1436
+ return `W/"${i.slice(0, 27)}"`;
1437
+ } catch {
1438
+ return null;
1439
+ }
1440
+ }, hn = async (e, t, r = {}) => {
1441
+ const n = r.context ?? X({
1442
+ ...r,
1443
+ mode: "string"
1444
+ }), i = await ze(e, t, {
1445
+ ...r,
1446
+ context: n
1447
+ }), o = r.status ?? n.status ?? 200, s = new Headers(r.headers);
1448
+ for (const [a, u] of n.responseHeaders) s.append(a, u);
1449
+ if (s.has("content-type") || s.set("content-type", r.contentType ?? "text/html; charset=utf-8"), r.cacheControl && s.set("cache-control", r.cacheControl), r.etag) {
1450
+ const a = await yr(i.html);
1451
+ if (a) {
1452
+ s.set("etag", a);
1453
+ const u = n.headers.get("if-none-match");
1454
+ if (u && u === a) return new Response(null, {
1455
+ status: 304,
1456
+ headers: s
1457
+ });
1458
+ }
1459
+ }
1460
+ return new Response(i.html, {
1461
+ status: o,
1462
+ headers: s
1463
+ });
1464
+ }, be = (e) => {
1465
+ if (typeof e != "string") return e;
1466
+ if (typeof document > "u") return null;
1467
+ try {
1468
+ return document.querySelector(e);
1469
+ } catch {
1470
+ return null;
1471
+ }
1472
+ }, M = (e, t, r) => {
1473
+ const n = be(e);
1474
+ return n ? ct(n, t, r) : null;
1475
+ }, T = () => {
1476
+ }, gr = (e) => {
1477
+ if (typeof window > "u")
1478
+ return e(), T;
1479
+ const t = window.requestIdleCallback;
1480
+ if (typeof t == "function") {
1481
+ const n = t(e);
1482
+ return () => {
1483
+ const i = window.cancelIdleCallback;
1484
+ typeof i == "function" && i(n);
1485
+ };
1486
+ }
1487
+ const r = setTimeout(e, 1);
1488
+ return () => clearTimeout(r);
1489
+ }, ee = (e) => {
1490
+ let t = !1, r = T, n = T;
1491
+ const i = new Promise((a, u) => {
1492
+ r = a, n = u;
1493
+ });
1494
+ let o = T;
1495
+ return {
1496
+ handle: {
1497
+ ready: i,
1498
+ cancel() {
1499
+ t || (t = !0, o(), r(null));
1500
+ }
1501
+ },
1502
+ arm: (a) => {
1503
+ o = e(() => {
1504
+ if (!t)
1505
+ try {
1506
+ const u = a();
1507
+ r(u);
1508
+ } catch (u) {
1509
+ n(u);
1510
+ }
1511
+ });
1512
+ }
1513
+ };
1514
+ }, vn = (e, t, r = {}) => {
1515
+ const { rootMargin: n, threshold: i, ...o } = r, { handle: s, arm: a } = ee((u) => {
1516
+ const c = be(e);
1517
+ if (!c || typeof IntersectionObserver > "u")
1518
+ return u(), T;
1519
+ const l = new IntersectionObserver((p) => {
1520
+ for (const d of p) if (d.isIntersecting) {
1521
+ l.disconnect(), u();
1522
+ return;
1523
+ }
1524
+ }, {
1525
+ rootMargin: n ?? "0px",
1526
+ threshold: i ?? 0
1527
+ });
1528
+ return l.observe(c), () => l.disconnect();
1529
+ });
1530
+ return a(() => M(e, t, o)), s;
1531
+ }, mn = (e, t, r = {}) => {
1532
+ const { handle: n, arm: i } = ee((o) => gr(o));
1533
+ return i(() => M(e, t, r)), n;
1534
+ }, yn = (e, t, r = {}) => {
1535
+ const n = r.events ?? [
1536
+ "pointerdown",
1537
+ "click",
1538
+ "keydown",
1539
+ "touchstart",
1540
+ "focusin"
1541
+ ], { events: i, ...o } = r, { handle: s, arm: a } = ee((u) => {
1542
+ const c = be(e);
1543
+ if (!c)
1544
+ return u(), T;
1545
+ const l = () => {
1546
+ p(), u();
1547
+ }, p = () => {
1548
+ for (const d of n) c.removeEventListener(d, l, !0);
1549
+ };
1550
+ for (const d of n) c.addEventListener(d, l, {
1551
+ once: !0,
1552
+ capture: !0
1553
+ });
1554
+ return p;
1555
+ });
1556
+ return a(() => M(e, t, o)), s;
1557
+ }, gn = (e, t, r, n = {}) => {
1558
+ const { handle: i, arm: o } = ee((s) => {
1559
+ if (typeof window > "u" || typeof window.matchMedia != "function")
1560
+ return s(), T;
1561
+ const a = window.matchMedia(r);
1562
+ if (a.matches)
1563
+ return s(), T;
1564
+ let u = T;
1565
+ const c = (p) => {
1566
+ p.matches && (u(), s());
1567
+ };
1568
+ if (typeof a.addEventListener == "function")
1569
+ return a.addEventListener("change", c), u = () => a.removeEventListener("change", c), u;
1570
+ const l = a;
1571
+ return typeof l.addListener == "function" && typeof l.removeListener == "function" ? (l.addListener(c), u = () => l.removeListener(c), u) : (s(), T);
1572
+ });
1573
+ return o(() => M(e, t, n)), i;
1574
+ }, bn = (e, t, r = {}) => M(e, t, r), wn = (e, t = {}) => {
1575
+ const r = t.prefix ?? "bq", n = t.warn ?? it(), i = t.onMismatch, o = [];
1576
+ if (!e || typeof e.querySelectorAll != "function") return o;
1577
+ const s = [];
1578
+ typeof e.getAttribute == "function" && e.getAttribute("data-bq-h") !== null && s.push(e);
1579
+ for (const a of Array.from(e.querySelectorAll(`[${pe}]`))) s.push(a);
1580
+ for (const a of s) {
1581
+ const u = a.getAttribute("data-bq-h") ?? "", c = Ne(a, r), l = de(c);
1582
+ if (l !== u) {
1583
+ const p = {
1584
+ element: a,
1585
+ expected: u,
1586
+ actual: l,
1587
+ signature: c
1588
+ };
1589
+ o.push(p), i?.(p), n && console.warn(`[bQuery SSR] Hydration mismatch on <${a.tagName.toLowerCase()}>: server="${u}" client="${l}" signature="${c}".`, a);
1590
+ }
1591
+ }
1592
+ return o;
1593
+ }, br = (e) => typeof e == "object" && e !== null && e[j] === !0, wr = (e) => D(e) || U(e), Sr = /^[A-Za-z][\w-]*$/, Er = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)+$/, Re = (e, t) => typeof e != "string" || !Sr.test(e) ? t : e, $r = (e, t) => typeof e != "string" || !Er.test(e) ? t : e, kr = (e) => {
1594
+ const t = e.replace(/-s$/, "-r");
1595
+ return t === e && e.endsWith("-r") ? `${e}-template` : t === e ? `${e}-r` : t;
1596
+ }, Ar = (e, t) => {
1597
+ const r = {}, n = [];
1598
+ let i = 0;
1599
+ for (const [o, s] of Object.entries(e)) {
1600
+ if (wr(s)) {
1601
+ r[o] = s;
1602
+ continue;
1603
+ }
1604
+ if (br(s)) {
1605
+ const a = `${t}-${i++}`;
1606
+ n.push({
1607
+ id: a,
1608
+ key: o,
1609
+ promise: s.promise
1610
+ }), r[o] = s.fallback;
1611
+ continue;
1612
+ }
1613
+ if (s && typeof s.then == "function") {
1614
+ const a = `${t}-${i++}`;
1615
+ n.push({
1616
+ id: a,
1617
+ key: o,
1618
+ promise: s
1619
+ }), r[o] = void 0;
1620
+ continue;
1621
+ }
1622
+ r[o] = s;
1623
+ }
1624
+ return {
1625
+ syncContext: r,
1626
+ slots: n
1627
+ };
1628
+ }, ue = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), J = (e) => ue(e).replace(/"/g, "&quot;"), Rr = (e) => e.replace(/<\/(script)/gi, "<\\/$1").replace(/<!--/g, "<\\!--").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"), Tr = Rr('(()=>{var c=document.currentScript;if(!c)return;var slotId=c.getAttribute("data-bq-slot");var templateId=c.getAttribute("data-bq-template");if(!slotId||!templateId)return;var s=document.getElementById(slotId);var t=document.getElementById(templateId);if(!s||!t)return;var f=t.content?t.content.cloneNode(true):t;while(s.firstChild)s.removeChild(s.firstChild);s.appendChild(f);t.parentNode&&t.parentNode.removeChild(t);s.parentNode&&s.replaceWith(...s.childNodes);})();'), Or = (e, t, r) => `<script${r ? ` nonce="${J(r)}"` : ""} data-bq-slot="${J(e)}" data-bq-template="${J(t)}">${Tr}<\/script>`, xr = (e, t, r, n, i, o) => {
1629
+ const s = t[`__suspense_${n}`];
1630
+ return typeof s == "string" ? ye(s, {
1631
+ ...r,
1632
+ [n]: i
1633
+ }, {
1634
+ prefix: o.prefix,
1635
+ stripDirectives: o.stripDirectives,
1636
+ annotateHydration: o.annotateHydration
1637
+ }).html : i == null ? "" : ue(typeof i == "string" ? i : String(i));
1638
+ }, _r = (e, t) => {
1639
+ if (!(t in e.attributes)) return;
1640
+ delete e.attributes[t];
1641
+ const r = e.attributeOrder.indexOf(t);
1642
+ r !== -1 && e.attributeOrder.splice(r, 1);
1643
+ }, Te = (e, t, r = []) => ({
1644
+ type: "element",
1645
+ tag: e,
1646
+ attributes: { id: t },
1647
+ attributeOrder: ["id"],
1648
+ children: r,
1649
+ void: !1,
1650
+ raw: !1
1651
+ }), Be = (e, t) => {
1652
+ for (const r of e)
1653
+ r.type === "element" && (t(r), Be(r.children, t));
1654
+ }, Qe = (e, t) => {
1655
+ for (const r of e) {
1656
+ if (r.type !== "element") continue;
1657
+ if (r.tag === t) return r;
1658
+ const n = Qe(r.children, t);
1659
+ if (n) return n;
1660
+ }
1661
+ return null;
1662
+ }, Nr = (e, t, r, n) => {
1663
+ const i = $r(n.slotTag, "bq-slot"), o = K(e), s = new Map(r.map((c) => [c.key, c])), a = /* @__PURE__ */ new Set();
1664
+ Be(o.children, (c) => {
1665
+ const l = c.attributes["data-bq-defer"];
1666
+ if (!l) return;
1667
+ _r(c, "data-bq-defer");
1668
+ const p = s.get(l);
1669
+ if (!p || a.has(p.id)) return;
1670
+ const d = c.children;
1671
+ c.children = [Te(i, p.id, d)], a.add(p.id);
1672
+ });
1673
+ const u = Qe(o.children, "body")?.children ?? o.children;
1674
+ for (const c of r)
1675
+ a.has(c.id) || u.push(Te(i, c.id));
1676
+ return H(o);
1677
+ }, Lr = (e) => e !== void 0 && /\s/.test(e), Cr = (e) => e === void 0 || e === "=" || e === ">" || e === "/" || /\s/.test(e), Ir = (e) => {
1678
+ let t = "", r = 0, n = !1, i = "", o = !1, s = !1, a = !0;
1679
+ const u = "bq-defer";
1680
+ for (; r < e.length; ) {
1681
+ const c = e[r];
1682
+ if (!n) {
1683
+ c === "<" && (n = !0, o = !1, s = !1, a = !0), t += c, r++;
1684
+ continue;
1685
+ }
1686
+ if (i) {
1687
+ t += c, c === i && (i = ""), r++;
1688
+ continue;
1689
+ }
1690
+ if (c === '"' || c === "'") {
1691
+ i = c, t += c, r++;
1692
+ continue;
1693
+ }
1694
+ if (c === ">") {
1695
+ n = !1, t += c, r++;
1696
+ continue;
1697
+ }
1698
+ if (!o) {
1699
+ if (t += c, r++, !s) {
1700
+ if (/\s/.test(c)) continue;
1701
+ s = !0, (c === "/" || c === "!" || c === "?") && (a = !1);
1702
+ continue;
1703
+ }
1704
+ a && /\s/.test(c) && (o = !0);
1705
+ continue;
1706
+ }
1707
+ if (a && e.startsWith(u, r) && Lr(e[r - 1]) && Cr(e[r + 8])) {
1708
+ t += "data-bq-defer", r += 8;
1709
+ continue;
1710
+ }
1711
+ t += c, r++;
1712
+ }
1713
+ return t;
1714
+ }, Ur = () => {
1715
+ if (typeof TextEncoder > "u") throw new Error("bQuery SSR: TextEncoder is not available in this runtime.");
1716
+ return new TextEncoder();
1717
+ }, Sn = (e, t, r = {}) => {
1718
+ if (typeof ReadableStream > "u") throw new Error("bQuery SSR: ReadableStream is not available in this runtime.");
1719
+ const n = Ur(), i = r.context ?? X({
1720
+ ...r,
1721
+ mode: "stream"
1722
+ }), o = Re(r.slotIdPrefix ?? "bq-s", "bq-s"), s = Re(kr(o), "bq-r");
1723
+ return new ReadableStream({ async start(a) {
1724
+ const u = () => {
1725
+ try {
1726
+ a.error(new DOMException("SSR stream aborted", "AbortError"));
1727
+ } catch {
1728
+ }
1729
+ };
1730
+ if (i.signal.aborted) {
1731
+ u();
1732
+ return;
1733
+ }
1734
+ i.signal.addEventListener("abort", u, { once: !0 });
1735
+ try {
1736
+ const { syncContext: c, slots: l } = Ar(t, o), p = ye(Ir(e), c, {
1737
+ prefix: r.prefix,
1738
+ stripDirectives: r.stripDirectives,
1739
+ annotateHydration: r.annotateHydration
1740
+ }).html, d = Nr(p, c, l, r);
1741
+ a.enqueue(n.encode(d));
1742
+ const h = [], f = [];
1743
+ let v = l.length;
1744
+ const m = (y) => {
1745
+ const w = f.shift();
1746
+ if (w) {
1747
+ w(y);
1748
+ return;
1749
+ }
1750
+ h.push(y);
1751
+ };
1752
+ for (const [y, w] of l.entries()) w.promise.then((N) => ({
1753
+ index: y,
1754
+ slot: w,
1755
+ ok: !0,
1756
+ value: N
1757
+ }), (N) => ({
1758
+ index: y,
1759
+ slot: w,
1760
+ ok: !1,
1761
+ error: N
1762
+ })).then(m);
1763
+ const E = async () => {
1764
+ const y = h.shift();
1765
+ return y || new Promise((w) => {
1766
+ f.push(w);
1767
+ });
1768
+ };
1769
+ for (; v > 0; ) {
1770
+ if (i.signal.aborted) return;
1771
+ const y = await E();
1772
+ v--;
1773
+ const { slot: w } = y, N = `${s}-${w.id.split("-").pop()}`;
1774
+ let te;
1775
+ y.ok ? te = xr(e, t, c, w.key, y.value, r) : (i.reportError(y.error), te = "");
1776
+ const Ge = `<template id="${J(N)}">${te}</template>`, Ze = Or(w.id, N, i.nonce);
1777
+ a.enqueue(n.encode(Ge + Ze));
1778
+ }
1779
+ a.close();
1780
+ } catch (c) {
1781
+ try {
1782
+ a.error(c);
1783
+ } catch {
1784
+ }
1785
+ } finally {
1786
+ i.signal.removeEventListener("abort", u);
1787
+ }
1788
+ } });
1789
+ }, Dr = (e) => {
1790
+ if (!e || !e.meta) return;
1791
+ const t = e.meta.loader;
1792
+ return typeof t == "function" ? t : void 0;
1793
+ }, Hr = (e) => {
1794
+ const t = typeof e.url == "string" ? new URL(e.url, "http://localhost/") : e.url, r = e.base ?? "";
1795
+ let n = t.pathname;
1796
+ r && (n === r ? n = "/" : n.startsWith(`${r}/`) && (n = n.slice(r.length) || "/"));
1797
+ const i = ot(n, e.routes), o = {
1798
+ path: n,
1799
+ params: i?.params ?? {},
1800
+ query: st(t.search),
1801
+ matched: i?.matched ?? null,
1802
+ hash: t.hash.replace(/^#/, "")
1803
+ }, s = i !== null, a = i?.matched ?? null, u = !!a && "redirectTo" in a && typeof a.redirectTo == "string";
1804
+ return {
1805
+ route: o,
1806
+ matched: s,
1807
+ isRedirect: u,
1808
+ redirectTo: u ? a.redirectTo : void 0
1809
+ };
1810
+ }, Pr = async (e, t) => {
1811
+ const r = Dr(e.matched);
1812
+ if (r)
1813
+ try {
1814
+ return await r({
1815
+ route: e,
1816
+ ctx: t
1817
+ });
1818
+ } catch (n) {
1819
+ t.reportError(n);
1820
+ return;
1821
+ }
1822
+ }, En = async (e) => {
1823
+ const t = Hr({
1824
+ url: e.url,
1825
+ routes: e.routes,
1826
+ base: e.base
1827
+ }), r = t.matched ? await Pr(t.route, e.ctx) : void 0;
1828
+ return {
1829
+ route: t.route,
1830
+ matched: t.matched,
1831
+ isRedirect: t.isRedirect,
1832
+ redirectTo: t.redirectTo,
1833
+ data: r,
1834
+ bindings: {
1835
+ route: t.route,
1836
+ params: t.route.params,
1837
+ query: t.route.query,
1838
+ data: r
1839
+ }
1840
+ };
1841
+ }, le = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Je = (e) => {
1842
+ const t = {};
1843
+ for (const [r, n] of Object.entries(e))
1844
+ g(r) || (t[r] = n);
1845
+ return t;
1846
+ }, $n = (e) => {
1847
+ const { version: t, storeIds: r, scriptId: n = "__BQUERY_STORE_SNAPSHOT__", globalKey: i = "__BQUERY_STORE_SNAPSHOT__", nonce: o } = e;
1848
+ if (typeof t != "string" || t.length === 0) throw new Error("serializeStoreSnapshot: `version` is required and must be a non-empty string.");
1849
+ if (g(n) || g(i)) throw new Error("serializeStoreSnapshot: invalid scriptId/globalKey.");
1850
+ const s = r ?? _e(), a = /* @__PURE__ */ Object.create(null);
1851
+ for (const d of s) {
1852
+ if (g(d)) continue;
1853
+ const h = Z(d);
1854
+ h && (a[d] = Je(h.$state));
1855
+ }
1856
+ const u = {
1857
+ version: t,
1858
+ state: a
1859
+ }, c = JSON.stringify(u), l = L(c), p = L(JSON.stringify(i));
1860
+ return {
1861
+ snapshot: u,
1862
+ json: c,
1863
+ scriptTag: `<script id="${P(n)}"${o ? ` nonce="${P(o)}"` : ""}>window[${p}]=${l}<\/script>`
1864
+ };
1865
+ }, Ye = (e) => {
1866
+ if (!le(e)) return !1;
1867
+ const t = e.version, r = e.state;
1868
+ return typeof t == "string" && le(r);
1869
+ }, kn = (e, t = {}) => {
1870
+ if (!Ye(e))
1871
+ return t.strict && console.warn("[bQuery SSR] hydrateStoreSnapshot: snapshot has invalid shape."), {
1872
+ applied: !1,
1873
+ reason: "invalid-shape",
1874
+ appliedIds: [],
1875
+ unknownIds: []
1876
+ };
1877
+ if (typeof t.expectedVersion == "string" && t.expectedVersion !== e.version)
1878
+ return t.strict && console.warn(`[bQuery SSR] hydrateStoreSnapshot: version mismatch — server="${e.version}" client="${t.expectedVersion}". Skipping.`), {
1879
+ applied: !1,
1880
+ reason: "version-mismatch",
1881
+ appliedIds: [],
1882
+ unknownIds: []
1883
+ };
1884
+ const r = [], n = [];
1885
+ for (const [i, o] of Object.entries(e.state)) {
1886
+ if (g(i) || !le(o)) continue;
1887
+ const s = Z(i);
1888
+ if (!s || typeof s.$patch != "function") {
1889
+ n.push(i), t.strict && console.warn(`[bQuery SSR] hydrateStoreSnapshot: store "${i}" is not registered; skipping.`);
1890
+ continue;
1891
+ }
1892
+ s.$patch(Je(o)), r.push(i);
1893
+ }
1894
+ return {
1895
+ applied: r.length > 0,
1896
+ appliedIds: r,
1897
+ unknownIds: n
1898
+ };
1899
+ }, An = (e = "__BQUERY_STORE_SNAPSHOT__", t = "__BQUERY_STORE_SNAPSHOT__") => {
1900
+ if (g(e) || g(t) || typeof window > "u") return null;
1901
+ const r = window[e];
1902
+ try {
1903
+ delete window[e];
1904
+ } catch {
1905
+ window[e] = void 0;
1906
+ }
1907
+ if (typeof document < "u" && typeof document.getElementById == "function") {
1908
+ const n = document.getElementById(t);
1909
+ n && n.remove();
1910
+ }
1911
+ return Ye(r) ? r : null;
1912
+ }, Ve = (e) => {
1913
+ const t = /* @__PURE__ */ Object.create(null);
1914
+ for (const [r, n] of Object.entries(e))
1915
+ g(r) || (t[r] = n);
1916
+ return t;
1917
+ }, Rn = (e = {}) => {
1918
+ const t = /* @__PURE__ */ Object.create(null);
1919
+ if (e.initial)
1920
+ for (const [r, n] of Object.entries(e.initial)) g(r) || (t[r] = n);
1921
+ return {
1922
+ set(r, n) {
1923
+ g(r) || (t[r] = n);
1924
+ },
1925
+ get(r) {
1926
+ return t[r];
1927
+ },
1928
+ entries() {
1929
+ return Ve(t);
1930
+ },
1931
+ render(r = {}) {
1932
+ const n = r.scriptId ?? "__BQUERY_RESUME__", i = r.globalKey ?? "__BQUERY_RESUME__";
1933
+ if (g(n) || g(i)) return "";
1934
+ const o = L(JSON.stringify(t)), s = L(JSON.stringify(i));
1935
+ return `<script id="${P(n)}"${r.nonce ? ` nonce="${P(r.nonce)}"` : ""}>window[${s}]=${o}<\/script>`;
1936
+ }
1937
+ };
1938
+ }, Tn = (e = "__BQUERY_RESUME__", t = "__BQUERY_RESUME__") => {
1939
+ const r = {
1940
+ get: () => {
1941
+ },
1942
+ hasSnapshot: !1,
1943
+ entries: () => ({})
1944
+ };
1945
+ if (g(e) || g(t) || typeof window > "u") return r;
1946
+ const n = window[e];
1947
+ try {
1948
+ delete window[e];
1949
+ } catch {
1950
+ window[e] = void 0;
1951
+ }
1952
+ if (typeof document < "u" && typeof document.getElementById == "function") {
1953
+ const o = document.getElementById(t);
1954
+ o && o.remove();
1955
+ }
1956
+ if (!n || typeof n != "object") return r;
1957
+ const i = n;
1958
+ return {
1959
+ hasSnapshot: !0,
1960
+ get(o) {
1961
+ if (!g(o))
1962
+ return i[o];
1963
+ },
1964
+ entries() {
1965
+ return Ve(i);
1966
+ }
1967
+ };
1968
+ }, qr = (e) => e, jr = (e) => async (t) => Promise.resolve(e(t)), Mr = (e) => async (t) => Promise.resolve(e(t)), Wr = (e) => e !== "GET" && e !== "HEAD", fe = class extends Error {
1969
+ constructor(e) {
1970
+ super(e), this.name = "NodeRequestLimitError";
1971
+ }
1972
+ }, G = (e, t) => {
1973
+ const r = e[t];
1974
+ return Array.isArray(r) ? r[0] : r;
1975
+ }, zr = (e) => {
1976
+ const t = G(e.headers, "content-length");
1977
+ if (!t) return null;
1978
+ const r = Number.parseInt(t, 10);
1979
+ return Number.isSafeInteger(r) && r >= 0 ? r : null;
1980
+ }, Fr = (e, t) => new Promise((r, n) => {
1981
+ const i = [];
1982
+ let o = 0, s = !1;
1983
+ const a = (c) => {
1984
+ s || (s = !0, i.length = 0, o = 0, e.destroy?.(c instanceof Error ? c : void 0), n(c));
1985
+ }, u = zr(e);
1986
+ if (t !== void 0 && u !== null && u > t) {
1987
+ a(new fe(`Request body exceeds ${t} bytes.`));
1988
+ return;
1989
+ }
1990
+ e.on("data", (c) => {
1991
+ if (s) return;
1992
+ const l = typeof c == "string" ? new TextEncoder().encode(c) : c;
1993
+ if (o += l.byteLength, t !== void 0 && o > t) {
1994
+ a(new fe(`Request body exceeds ${t} bytes.`));
1995
+ return;
1996
+ }
1997
+ i.push(l);
1998
+ }), e.on("end", () => {
1999
+ if (s) return;
2000
+ s = !0;
2001
+ const c = new ArrayBuffer(o), l = new Uint8Array(c);
2002
+ let p = 0;
2003
+ for (const d of i)
2004
+ l.set(d, p), p += d.byteLength;
2005
+ r(c);
2006
+ }), e.on("error", a);
2007
+ }), Br = (e, t) => {
2008
+ const r = `${t}://localhost`, n = G(e.headers, "host") || "localhost";
2009
+ try {
2010
+ return new URL(e.url ?? "/", `${t}://${n}`);
2011
+ } catch {
2012
+ try {
2013
+ return new URL(e.url ?? "/", r);
2014
+ } catch {
2015
+ return new URL("/", r);
2016
+ }
2017
+ }
2018
+ }, Qr = async (e, t = {}) => {
2019
+ const r = typeof G(e.headers, "x-forwarded-proto") == "string" ? G(e.headers, "x-forwarded-proto").split(",")[0].trim().toLowerCase() : "", n = Br(e, r === "http" || r === "https" ? r : "http"), i = new Headers();
2020
+ for (const [a, u] of Object.entries(e.headers))
2021
+ if (u !== void 0)
2022
+ if (Array.isArray(u)) for (const c of u) i.append(a, c);
2023
+ else i.append(a, u);
2024
+ const o = (e.method ?? "GET").toUpperCase(), s = {
2025
+ method: o,
2026
+ headers: i
2027
+ };
2028
+ return Wr(o) && (s.body = await Fr(e, t.maxBodyBytes)), new Request(n.toString(), s);
2029
+ }, Jr = (e) => {
2030
+ const t = e.getSetCookie?.();
2031
+ if (Array.isArray(t) && t.length > 0) return t;
2032
+ const r = e.get("set-cookie");
2033
+ return r ? [r] : [];
2034
+ }, Yr = (e) => new Promise((t, r) => {
2035
+ const n = typeof e.once == "function" ? e.once.bind(e) : void 0, i = typeof e.on == "function" ? e.on.bind(e) : void 0, o = n ?? i;
2036
+ if (!o) {
2037
+ t();
2038
+ return;
2039
+ }
2040
+ o("drain", () => t()), o("error", (s) => {
2041
+ r(s instanceof Error ? s : /* @__PURE__ */ new Error("Node response stream errored while draining."));
2042
+ });
2043
+ }), Oe = async (e, t) => {
2044
+ t.statusCode = e.status;
2045
+ const r = Jr(e.headers);
2046
+ if (r.length > 0 && t.setHeader("set-cookie", r.length === 1 ? r[0] : r), e.headers.forEach((i, o) => {
2047
+ o.toLowerCase() !== "set-cookie" && t.setHeader(o, i);
2048
+ }), !e.body) {
2049
+ t.end();
2050
+ return;
2051
+ }
2052
+ const n = e.body.getReader();
2053
+ for (; ; ) {
2054
+ const { value: i, done: o } = await n.read();
2055
+ if (o) break;
2056
+ i && !t.write(i) && await Yr(t);
2057
+ }
2058
+ t.end();
2059
+ }, Vr = (e, t = {}) => async (r, n) => {
2060
+ let i;
2061
+ try {
2062
+ i = await Qr(r, t);
2063
+ } catch (o) {
2064
+ if (o instanceof fe) {
2065
+ await Oe(new Response(o.message, { status: 413 }), n);
2066
+ return;
2067
+ }
2068
+ throw o;
2069
+ }
2070
+ await Oe(await Promise.resolve(e(i)), n);
2071
+ }, On = (e) => {
2072
+ switch (ge()) {
2073
+ case "node":
2074
+ return Vr(e);
2075
+ case "bun":
2076
+ return jr(e);
2077
+ case "deno":
2078
+ return Mr(e);
2079
+ default:
2080
+ return qr(e);
2081
+ }
2082
+ };
2083
+ export {
2084
+ ln as A,
2085
+ on as B,
2086
+ ze as C,
2087
+ dn as D,
2088
+ or as E,
2089
+ Qt as F,
2090
+ an as I,
2091
+ ae as L,
2092
+ cn as M,
2093
+ ye as N,
2094
+ fn as O,
2095
+ sn as P,
2096
+ pe as R,
2097
+ pn as S,
2098
+ sr as T,
2099
+ ct as V,
2100
+ mn as _,
2101
+ qr as a,
2102
+ vn as b,
2103
+ kn as c,
2104
+ En as d,
2105
+ Hr as f,
2106
+ bn as g,
2107
+ wn as h,
2108
+ On as i,
2109
+ un as j,
2110
+ ge as k,
2111
+ An as l,
2112
+ Sn as m,
2113
+ Mr as n,
2114
+ Rn as o,
2115
+ Pr as p,
2116
+ Vr as r,
2117
+ Tn as s,
2118
+ jr as t,
2119
+ $n as u,
2120
+ yn as v,
2121
+ X as w,
2122
+ hn as x,
2123
+ gn as y,
2124
+ nn as z
2125
+ };
2126
+
2127
+ //# sourceMappingURL=ssr-Bt6BQA3J.js.map