token-usage-dashboard 1.0.12 → 1.0.14

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 (126) hide show
  1. package/build/adapter-node.js +11 -0
  2. package/build/client/_app/immutable/chunks/B0VWrXPj.js +1 -0
  3. package/build/client/_app/immutable/chunks/B0VWrXPj.js.br +0 -0
  4. package/build/client/_app/immutable/chunks/B0VWrXPj.js.gz +0 -0
  5. package/build/client/_app/immutable/chunks/BaNbYf_w.js +1 -0
  6. package/build/client/_app/immutable/chunks/BaNbYf_w.js.br +0 -0
  7. package/build/client/_app/immutable/chunks/BaNbYf_w.js.gz +0 -0
  8. package/build/client/_app/immutable/chunks/CbiRHTcG.js +1 -0
  9. package/build/client/_app/immutable/chunks/CbiRHTcG.js.br +0 -0
  10. package/build/client/_app/immutable/chunks/CbiRHTcG.js.gz +0 -0
  11. package/build/client/_app/immutable/chunks/DTingiCe.js +3 -0
  12. package/build/client/_app/immutable/chunks/DTingiCe.js.br +0 -0
  13. package/build/client/_app/immutable/chunks/DTingiCe.js.gz +0 -0
  14. package/build/client/_app/immutable/chunks/ssd4Rw-g.js +3 -0
  15. package/build/client/_app/immutable/chunks/ssd4Rw-g.js.br +0 -0
  16. package/build/client/_app/immutable/chunks/ssd4Rw-g.js.gz +0 -0
  17. package/build/client/_app/immutable/entry/app.CRLWmGVY.js +2 -0
  18. package/build/client/_app/immutable/entry/app.CRLWmGVY.js.br +0 -0
  19. package/build/client/_app/immutable/entry/app.CRLWmGVY.js.gz +0 -0
  20. package/build/client/_app/immutable/entry/payload.DSmR2FwN.js +1 -0
  21. package/build/client/_app/immutable/entry/payload.DSmR2FwN.js.br +0 -0
  22. package/build/client/_app/immutable/entry/payload.DSmR2FwN.js.gz +0 -0
  23. package/build/client/_app/immutable/entry/start.CzGx2BYz.js +2 -0
  24. package/build/client/_app/immutable/entry/start.CzGx2BYz.js.br +0 -0
  25. package/build/client/_app/immutable/entry/start.CzGx2BYz.js.gz +0 -0
  26. package/build/client/_app/immutable/nodes/0.BBGTwdwd.js +1 -0
  27. package/build/client/_app/immutable/nodes/0.BBGTwdwd.js.br +0 -0
  28. package/build/client/_app/immutable/nodes/0.BBGTwdwd.js.gz +0 -0
  29. package/build/client/_app/immutable/nodes/1.Cy2JV0fN.js +1 -0
  30. package/build/client/_app/immutable/nodes/1.Cy2JV0fN.js.br +2 -0
  31. package/build/client/_app/immutable/nodes/1.Cy2JV0fN.js.gz +0 -0
  32. package/build/client/_app/immutable/nodes/2.CRMPKkcX.js +2 -0
  33. package/build/client/_app/immutable/nodes/2.CRMPKkcX.js.br +0 -0
  34. package/build/client/_app/immutable/nodes/2.CRMPKkcX.js.gz +0 -0
  35. package/build/client/_app/version.json +1 -1
  36. package/build/client/_app/version.json.br +0 -0
  37. package/build/client/_app/version.json.gz +0 -0
  38. package/build/handler.js +1 -22
  39. package/build/index.js +1 -145
  40. package/build/server/.vite/manifest.json +271 -0
  41. package/build/server/_app/immutable/assets/_layout.CZ6VMqH1.css +1 -0
  42. package/build/server/_app/immutable/assets/_page.CZocdpCk.css +1 -0
  43. package/build/server/adapter-env.js +2 -0
  44. package/build/server/adapter-index.js +74 -0
  45. package/build/server/adapter-node-env.js +63 -0
  46. package/build/server/adapter-node-handler.js +584 -0
  47. package/build/server/chunks/config.js +10 -0
  48. package/build/server/chunks/functions.js +30 -0
  49. package/build/server/chunks/index-server.js +2 -0
  50. package/build/server/chunks/instance.js +3546 -0
  51. package/build/server/chunks/internal.js +3323 -0
  52. package/build/server/chunks/navigation.js +16 -0
  53. package/build/server/chunks/{chunks/queries.js-BEdRnpMa.js → queries.js} +9 -9
  54. package/build/server/chunks/{chunks/range.js-CiCoLGqh.js → range.js} +3 -2
  55. package/build/server/chunks/{chunks/refresh.js-0W7-GwaH.js → refresh.js} +7 -7
  56. package/build/server/chunks/{chunks/request.js-BF7n7fZo.js → request.js} +5 -5
  57. package/build/server/chunks/server-errors.js +489 -0
  58. package/build/server/chunks/server.js +9 -0
  59. package/build/server/chunks/server2.js +1504 -0
  60. package/build/server/chunks/shared.js +84 -0
  61. package/build/server/chunks/uneval.js +537 -0
  62. package/build/server/entries/endpoints/api/refresh/_server.ts.js +12 -0
  63. package/build/server/entries/endpoints/api/settings/_server.ts.js +15 -0
  64. package/build/server/entries/endpoints/api/usage/_server.ts.js +8 -0
  65. package/build/server/entries/fallbacks/error.svelte.js +47 -0
  66. package/build/server/entries/hooks.server.js +10 -0
  67. package/build/server/{chunks/entries/pages/_layout.svelte.js-C9kkUOBf.js → entries/pages/_layout.svelte.js} +4 -2
  68. package/build/server/entries/pages/_page.server.ts.js +12 -0
  69. package/build/server/{chunks/entries/pages/_page.svelte.js-BqU3UuBL.js → entries/pages/_page.svelte.js} +64 -27
  70. package/build/server/env.js +2 -0
  71. package/build/server/handler.js +2 -0
  72. package/build/server/index.js +67 -0
  73. package/build/server/manifest-full.js +58 -0
  74. package/build/server/manifest.js +58 -0
  75. package/build/server/nodes/0.js +8 -0
  76. package/build/server/nodes/1.js +8 -0
  77. package/build/server/nodes/2.js +10 -0
  78. package/build/server/remote-entry.js +1564 -0
  79. package/build/server/server.js +60 -0
  80. package/package.json +8 -8
  81. package/build/client/_app/immutable/chunks/Dsm7b1TR.js +0 -3
  82. package/build/client/_app/immutable/chunks/Dsm7b1TR.js.br +0 -0
  83. package/build/client/_app/immutable/chunks/Dsm7b1TR.js.gz +0 -0
  84. package/build/client/_app/immutable/chunks/G5wHZJy8.js +0 -2
  85. package/build/client/_app/immutable/chunks/G5wHZJy8.js.br +0 -0
  86. package/build/client/_app/immutable/chunks/G5wHZJy8.js.gz +0 -0
  87. package/build/client/_app/immutable/chunks/xihTtKlq.js +0 -1
  88. package/build/client/_app/immutable/chunks/xihTtKlq.js.br +0 -1
  89. package/build/client/_app/immutable/chunks/xihTtKlq.js.gz +0 -0
  90. package/build/client/_app/immutable/entry/app.CuA0PQ3L.js +0 -2
  91. package/build/client/_app/immutable/entry/app.CuA0PQ3L.js.br +0 -0
  92. package/build/client/_app/immutable/entry/app.CuA0PQ3L.js.gz +0 -0
  93. package/build/client/_app/immutable/entry/start.CV_ip-Hp.js +0 -1
  94. package/build/client/_app/immutable/entry/start.CV_ip-Hp.js.br +0 -1
  95. package/build/client/_app/immutable/entry/start.CV_ip-Hp.js.gz +0 -0
  96. package/build/client/_app/immutable/nodes/0.PGglbI9f.js +0 -1
  97. package/build/client/_app/immutable/nodes/0.PGglbI9f.js.br +0 -0
  98. package/build/client/_app/immutable/nodes/0.PGglbI9f.js.gz +0 -0
  99. package/build/client/_app/immutable/nodes/1.CTCsoy2V.js +0 -1
  100. package/build/client/_app/immutable/nodes/1.CTCsoy2V.js.br +0 -0
  101. package/build/client/_app/immutable/nodes/1.CTCsoy2V.js.gz +0 -0
  102. package/build/client/_app/immutable/nodes/2.DBV8nX84.js +0 -2
  103. package/build/client/_app/immutable/nodes/2.DBV8nX84.js.br +0 -0
  104. package/build/client/_app/immutable/nodes/2.DBV8nX84.js.gz +0 -0
  105. package/build/env.js +0 -70
  106. package/build/server/chunks/chunks/client.js-BQauTa0m.js +0 -28
  107. package/build/server/chunks/chunks/env.js-l0sNRNKZ.js +0 -2
  108. package/build/server/chunks/chunks/exports.js-Bbyr-JtB.js +0 -349
  109. package/build/server/chunks/chunks/internal.js-U26BXAw4.js +0 -1202
  110. package/build/server/chunks/chunks/internal2.js-BlXt2rfE.js +0 -22
  111. package/build/server/chunks/chunks/server.js-UOanU7fq.js +0 -5527
  112. package/build/server/chunks/chunks/shared.js-Dg3Ewm8t.js +0 -255
  113. package/build/server/chunks/chunks/utils.js-DUDFXVFd.js +0 -1049
  114. package/build/server/chunks/entries/endpoints/api/refresh/_server.ts.js-CcG44vTx.js +0 -21
  115. package/build/server/chunks/entries/endpoints/api/settings/_server.ts.js-B0LWCQis.js +0 -24
  116. package/build/server/chunks/entries/endpoints/api/usage/_server.ts.js-CJGTdjik.js +0 -17
  117. package/build/server/chunks/entries/fallbacks/error.svelte.js-BdtN0SJD.js +0 -68
  118. package/build/server/chunks/entries/hooks.server.js-_Fcw_IVA.js +0 -16
  119. package/build/server/chunks/entries/pages/_page.server.ts.js-BBibcAZP.js +0 -17
  120. package/build/server/chunks/handler-D8S2N5vX.js +0 -1475
  121. package/build/server/chunks/index.js-BDweEDAt.js +0 -3972
  122. package/build/server/chunks/manifest.js-CUe1IdHJ.js +0 -63
  123. package/build/server/chunks/nodes/0.js-7EReDAeT.js +0 -9
  124. package/build/server/chunks/nodes/1.js-MVTzwi8l.js +0 -9
  125. package/build/server/chunks/nodes/2.js-C7xGlKUF.js +0 -20
  126. package/build/shims.js +0 -33
@@ -0,0 +1,1504 @@
1
+ import { t as uneval } from "./uneval.js";
2
+ //#region node_modules/svelte/src/constants.js
3
+ var UNINITIALIZED = Symbol("uninitialized");
4
+ //#endregion
5
+ //#region node_modules/svelte/src/escaping.js
6
+ var ATTR_REGEX = /[&"<]/g;
7
+ var CONTENT_REGEX = /[&<]/g;
8
+ /**
9
+ * @template V
10
+ * @param {V} value
11
+ * @param {boolean} [is_attr]
12
+ */
13
+ function escape_html(value, is_attr) {
14
+ const str = String(value ?? "");
15
+ const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
16
+ pattern.lastIndex = 0;
17
+ let escaped = "";
18
+ let last = 0;
19
+ while (pattern.test(str)) {
20
+ const i = pattern.lastIndex - 1;
21
+ const ch = str[i];
22
+ escaped += str.substring(last, i) + (ch === "&" ? "&amp;" : ch === "\"" ? "&quot;" : "&lt;");
23
+ last = i + 1;
24
+ }
25
+ return escaped + str.substring(last);
26
+ }
27
+ //#endregion
28
+ //#region node_modules/clsx/dist/clsx.mjs
29
+ function r(e) {
30
+ var t, f, n = "";
31
+ if ("string" == typeof e || "number" == typeof e) n += e;
32
+ else if ("object" == typeof e) if (Array.isArray(e)) {
33
+ var o = e.length;
34
+ for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
35
+ } else for (f in e) e[f] && (n && (n += " "), n += f);
36
+ return n;
37
+ }
38
+ function clsx$1() {
39
+ for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
40
+ return n;
41
+ }
42
+ //#endregion
43
+ //#region node_modules/svelte/src/internal/shared/utils.js
44
+ var is_array = Array.isArray;
45
+ Array.prototype.indexOf;
46
+ Array.prototype.includes;
47
+ Array.from;
48
+ Array.prototype;
49
+ var has_own_property = Object.prototype.hasOwnProperty;
50
+ var noop = () => {};
51
+ /** @param {Function} fn */
52
+ function run(fn) {
53
+ return fn();
54
+ }
55
+ /**
56
+ * TODO replace with Promise.withResolvers once supported widely enough
57
+ * @template [T=void]
58
+ */
59
+ function deferred() {
60
+ /** @type {(value: T) => void} */
61
+ var resolve;
62
+ /** @type {(reason: any) => void} */
63
+ var reject;
64
+ return {
65
+ promise: new Promise((res, rej) => {
66
+ resolve = res;
67
+ reject = rej;
68
+ }),
69
+ resolve,
70
+ reject
71
+ };
72
+ }
73
+ //#endregion
74
+ //#region node_modules/svelte/src/internal/shared/attributes.js
75
+ /**
76
+ * `<div translate={false}>` should be rendered as `<div translate="no">` and _not_
77
+ * `<div translate="false">`, which is equivalent to `<div translate="yes">`. There
78
+ * may be other odd cases that need to be added to this list in future
79
+ * @type {Record<string, Map<any, string>>}
80
+ */
81
+ var replacements = { translate: /* @__PURE__ */ new Map([[true, "yes"], [false, "no"]]) };
82
+ /**
83
+ * @template V
84
+ * @param {string} name
85
+ * @param {V} value
86
+ * @param {boolean} [is_boolean]
87
+ * @returns {string}
88
+ */
89
+ function attr(name, value, is_boolean = false) {
90
+ if (name === "hidden" && value !== "until-found") is_boolean = true;
91
+ if (value == null || is_boolean && !value && value !== "") return "";
92
+ const normalized = has_own_property.call(replacements, name) && replacements[name].get(value) || value;
93
+ return ` ${name}${is_boolean ? `=""` : `="${escape_html(normalized, true)}"`}`;
94
+ }
95
+ /**
96
+ * Small wrapper around clsx to preserve Svelte's (weird) handling of falsy values.
97
+ * TODO Svelte 6 revisit this, and likely turn all falsy values into the empty string (what clsx also does)
98
+ * @param {any} value
99
+ */
100
+ function clsx(value) {
101
+ if (typeof value === "object") return clsx$1(value);
102
+ else return value ?? "";
103
+ }
104
+ var whitespace = [..." \n\r\f\xA0\v"];
105
+ /**
106
+ * @param {any} value
107
+ * @param {string | null} [hash]
108
+ * @param {Record<string, boolean>} [directives]
109
+ * @returns {string | null}
110
+ */
111
+ function to_class(value, hash, directives) {
112
+ var classname = value == null ? "" : "" + value;
113
+ if (hash) classname = classname ? classname + " " + hash : hash;
114
+ if (directives) {
115
+ for (var key of Object.keys(directives)) if (directives[key]) classname = classname ? classname + " " + key : key;
116
+ else if (classname.length) {
117
+ var len = key.length;
118
+ var a = 0;
119
+ while ((a = classname.indexOf(key, a)) >= 0) {
120
+ var b = a + len;
121
+ if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1);
122
+ else a = b;
123
+ }
124
+ }
125
+ }
126
+ return classname === "" ? null : classname;
127
+ }
128
+ /**
129
+ *
130
+ * @param {Record<string,any>} styles
131
+ * @param {boolean} important
132
+ */
133
+ function append_styles(styles, important = false) {
134
+ var separator = important ? " !important;" : ";";
135
+ var css = "";
136
+ for (var key of Object.keys(styles)) {
137
+ var value = styles[key];
138
+ if (value != null && value !== "") css += " " + key + ": " + value + separator;
139
+ }
140
+ return css;
141
+ }
142
+ /**
143
+ * @param {string} name
144
+ * @returns {string}
145
+ */
146
+ function to_css_name(name) {
147
+ if (name[0] !== "-" || name[1] !== "-") return name.toLowerCase();
148
+ return name;
149
+ }
150
+ /**
151
+ * @param {any} value
152
+ * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [styles]
153
+ * @returns {string | null}
154
+ */
155
+ function to_style(value, styles) {
156
+ if (styles) {
157
+ var new_style = "";
158
+ /** @type {Record<string,any> | undefined} */
159
+ var normal_styles;
160
+ /** @type {Record<string,any> | undefined} */
161
+ var important_styles;
162
+ if (Array.isArray(styles)) {
163
+ normal_styles = styles[0];
164
+ important_styles = styles[1];
165
+ } else normal_styles = styles;
166
+ if (value) {
167
+ value = String(value).replaceAll(/\/\*.*?\*\//g, "").trim();
168
+ /** @type {boolean | '"' | "'"} */
169
+ var in_str = false;
170
+ var in_apo = 0;
171
+ var in_comment = false;
172
+ var reserved_names = [];
173
+ if (normal_styles) reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
174
+ if (important_styles) reserved_names.push(...Object.keys(important_styles).map(to_css_name));
175
+ var start_index = 0;
176
+ var name_index = -1;
177
+ const len = value.length;
178
+ for (var i = 0; i < len; i++) {
179
+ var c = value[i];
180
+ if (in_comment) {
181
+ if (c === "/" && value[i - 1] === "*") in_comment = false;
182
+ } else if (in_str) {
183
+ if (in_str === c) in_str = false;
184
+ } else if (c === "/" && value[i + 1] === "*") in_comment = true;
185
+ else if (c === "\"" || c === "'") in_str = c;
186
+ else if (c === "(") in_apo++;
187
+ else if (c === ")") in_apo--;
188
+ if (!in_comment && in_str === false && in_apo === 0) {
189
+ if (c === ":" && name_index === -1) name_index = i;
190
+ else if (c === ";" || i === len - 1) {
191
+ if (name_index !== -1) {
192
+ var name = to_css_name(value.substring(start_index, name_index).trim());
193
+ if (!reserved_names.includes(name)) {
194
+ if (c !== ";") i++;
195
+ var property = value.substring(start_index, i).trim();
196
+ new_style += " " + property + ";";
197
+ }
198
+ }
199
+ start_index = i + 1;
200
+ name_index = -1;
201
+ }
202
+ }
203
+ }
204
+ }
205
+ if (normal_styles) new_style += append_styles(normal_styles);
206
+ if (important_styles) new_style += append_styles(important_styles, true);
207
+ new_style = new_style.trim();
208
+ return new_style === "" ? null : new_style;
209
+ }
210
+ return value == null ? null : String(value);
211
+ }
212
+ //#endregion
213
+ //#region node_modules/svelte/src/internal/client/constants.js
214
+ var CLEAN = 1024;
215
+ var DIRTY = 2048;
216
+ var MAYBE_DIRTY = 4096;
217
+ /** allow users to ignore aborted signal errors if `reason.name === 'StaleReactionError` */
218
+ var STALE_REACTION = new class StaleReactionError extends Error {
219
+ name = "StaleReactionError";
220
+ message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
221
+ }();
222
+ globalThis.document?.contentType;
223
+ //#endregion
224
+ //#region node_modules/svelte/src/internal/shared/errors.js
225
+ /**
226
+ * `%name%(...)` can only be used during component initialisation
227
+ * @param {string} name
228
+ * @returns {never}
229
+ */
230
+ function lifecycle_outside_component(name) {
231
+ throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
232
+ }
233
+ //#endregion
234
+ //#region node_modules/svelte/src/internal/flags/index.js
235
+ /** True if experimental.async=true */
236
+ var async_mode_flag = false;
237
+ //#endregion
238
+ //#region node_modules/svelte/src/internal/shared/context.js
239
+ /**
240
+ * @typedef {{ p: Context | null, c: Map<unknown, unknown> | null }} Context
241
+ */
242
+ /**
243
+ * @param {Context} context
244
+ * @returns {Map<unknown, unknown> | null}
245
+ */
246
+ function get_parent_context(context) {
247
+ let parent = context.p;
248
+ while (parent !== null && parent.c === null) parent = parent.p;
249
+ return parent?.c ?? null;
250
+ }
251
+ /**
252
+ * @param {Context | null} context
253
+ * @param {string} name
254
+ * @returns {Map<unknown, unknown>}
255
+ */
256
+ function get_or_init_context_map(context, name) {
257
+ if (context === null) lifecycle_outside_component(name);
258
+ return context.c ??= new Map(get_parent_context(context) || void 0);
259
+ }
260
+ ~(DIRTY | MAYBE_DIRTY | CLEAN);
261
+ //#endregion
262
+ //#region node_modules/svelte/src/internal/server/hydration.js
263
+ var BLOCK_OPEN = `<!--[-->`;
264
+ var BLOCK_CLOSE = `<!--]-->`;
265
+ var EMPTY_COMMENT = `<!---->`;
266
+ //#endregion
267
+ //#region node_modules/svelte/src/utils.js
268
+ var VOID_ELEMENT_NAMES = [
269
+ "area",
270
+ "base",
271
+ "br",
272
+ "col",
273
+ "command",
274
+ "embed",
275
+ "hr",
276
+ "img",
277
+ "input",
278
+ "keygen",
279
+ "link",
280
+ "meta",
281
+ "param",
282
+ "source",
283
+ "track",
284
+ "wbr"
285
+ ];
286
+ /**
287
+ * Returns `true` if `name` is of a void element
288
+ * @param {string} name
289
+ */
290
+ function is_void(name) {
291
+ return VOID_ELEMENT_NAMES.includes(name) || name.toLowerCase() === "!doctype";
292
+ }
293
+ /**
294
+ * Attributes that are boolean, i.e. they are present or not present.
295
+ */
296
+ var DOM_BOOLEAN_ATTRIBUTES = [
297
+ "allowfullscreen",
298
+ "async",
299
+ "autofocus",
300
+ "autoplay",
301
+ "checked",
302
+ "controls",
303
+ "default",
304
+ "disabled",
305
+ "formnovalidate",
306
+ "indeterminate",
307
+ "inert",
308
+ "ismap",
309
+ "loop",
310
+ "multiple",
311
+ "muted",
312
+ "nomodule",
313
+ "novalidate",
314
+ "open",
315
+ "playsinline",
316
+ "readonly",
317
+ "required",
318
+ "reversed",
319
+ "seamless",
320
+ "selected",
321
+ "webkitdirectory",
322
+ "defer",
323
+ "disablepictureinpicture",
324
+ "disableremoteplayback"
325
+ ];
326
+ /**
327
+ * Returns `true` if `name` is a boolean attribute
328
+ * @param {string} name
329
+ */
330
+ function is_boolean_attribute(name) {
331
+ return DOM_BOOLEAN_ATTRIBUTES.includes(name);
332
+ }
333
+ [...DOM_BOOLEAN_ATTRIBUTES];
334
+ /** List of elements that require raw contents and should not have SSR comments put in them */
335
+ var RAW_TEXT_ELEMENTS = [
336
+ "textarea",
337
+ "script",
338
+ "style",
339
+ "title"
340
+ ];
341
+ /** @param {string} name */
342
+ function is_raw_text_element(name) {
343
+ return RAW_TEXT_ELEMENTS.includes(name);
344
+ }
345
+ var REGEX_VALID_TAG_NAME = /^[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9.\-_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]*)?$/u;
346
+ //#endregion
347
+ //#region node_modules/svelte/src/internal/server/errors.js
348
+ /**
349
+ * The node API `AsyncLocalStorage` is not available, but is required to use async server rendering.
350
+ * @returns {never}
351
+ */
352
+ function async_local_storage_unavailable() {
353
+ const error = /* @__PURE__ */ new Error(`async_local_storage_unavailable\nThe node API \`AsyncLocalStorage\` is not available, but is required to use async server rendering.\nhttps://svelte.dev/e/async_local_storage_unavailable`);
354
+ error.name = "Svelte error";
355
+ throw error;
356
+ }
357
+ /**
358
+ * Encountered asynchronous work while rendering synchronously.
359
+ * @returns {never}
360
+ */
361
+ function await_invalid() {
362
+ const error = /* @__PURE__ */ new Error(`await_invalid\nEncountered asynchronous work while rendering synchronously.\nhttps://svelte.dev/e/await_invalid`);
363
+ error.name = "Svelte error";
364
+ throw error;
365
+ }
366
+ /**
367
+ * `<svelte:element this="%tag%">` is not a valid element name — the element will not be rendered
368
+ * @param {string} tag
369
+ * @returns {never}
370
+ */
371
+ function dynamic_element_invalid_tag(tag) {
372
+ const error = /* @__PURE__ */ new Error(`dynamic_element_invalid_tag\n\`<svelte:element this="${tag}">\` is not a valid element name — the element will not be rendered\nhttps://svelte.dev/e/dynamic_element_invalid_tag`);
373
+ error.name = "Svelte error";
374
+ throw error;
375
+ }
376
+ /**
377
+ * The `html` property of server render results has been deprecated. Use `body` instead.
378
+ * @returns {never}
379
+ */
380
+ function html_deprecated() {
381
+ const error = /* @__PURE__ */ new Error(`html_deprecated\nThe \`html\` property of server render results has been deprecated. Use \`body\` instead.\nhttps://svelte.dev/e/html_deprecated`);
382
+ error.name = "Svelte error";
383
+ throw error;
384
+ }
385
+ /**
386
+ * `csp.nonce` was set while `csp.hash` was `true`. These options cannot be used simultaneously.
387
+ * @returns {never}
388
+ */
389
+ function invalid_csp() {
390
+ const error = /* @__PURE__ */ new Error(`invalid_csp\n\`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously.\nhttps://svelte.dev/e/invalid_csp`);
391
+ error.name = "Svelte error";
392
+ throw error;
393
+ }
394
+ /**
395
+ * The `idPrefix` option cannot include `--`.
396
+ * @returns {never}
397
+ */
398
+ function invalid_id_prefix() {
399
+ const error = /* @__PURE__ */ new Error(`invalid_id_prefix\nThe \`idPrefix\` option cannot include \`--\`.\nhttps://svelte.dev/e/invalid_id_prefix`);
400
+ error.name = "Svelte error";
401
+ throw error;
402
+ }
403
+ /**
404
+ * Could not resolve `render` context.
405
+ * @returns {never}
406
+ */
407
+ function server_context_required() {
408
+ const error = /* @__PURE__ */ new Error(`server_context_required\nCould not resolve \`render\` context.\nhttps://svelte.dev/e/server_context_required`);
409
+ error.name = "Svelte error";
410
+ throw error;
411
+ }
412
+ //#endregion
413
+ //#region node_modules/svelte/src/internal/server/context.js
414
+ /** @import { SSRContext } from '#server' */
415
+ /** @type {SSRContext | null} */
416
+ var ssr_context = null;
417
+ /** @param {SSRContext | null} v */
418
+ function set_ssr_context(v) {
419
+ ssr_context = v;
420
+ }
421
+ /**
422
+ * @template T
423
+ * @param {any} key
424
+ * @returns {T}
425
+ */
426
+ function getContext(key) {
427
+ return get_or_init_context_map(ssr_context, "getContext").get(key);
428
+ }
429
+ /**
430
+ * @param {Function} [fn]
431
+ */
432
+ function push(fn) {
433
+ ssr_context = {
434
+ p: ssr_context,
435
+ c: null,
436
+ r: null,
437
+ i: false
438
+ };
439
+ }
440
+ function pop() {
441
+ ssr_context = ssr_context.p;
442
+ }
443
+ /**
444
+ * A `hydratable` value with key `%key%` was created, but at least part of it was not used during the render.
445
+ *
446
+ * The `hydratable` was initialized in:
447
+ * %stack%
448
+ * @param {string} key
449
+ * @param {string} stack
450
+ */
451
+ function unresolved_hydratable(key, stack) {
452
+ console.warn(`https://svelte.dev/e/unresolved_hydratable`);
453
+ }
454
+ //#endregion
455
+ //#region node_modules/svelte/src/internal/server/render-context.js
456
+ /** @import { AsyncLocalStorage } from 'node:async_hooks' */
457
+ /** @import { RenderContext } from '#server' */
458
+ /** @type {Promise<void> | null} */
459
+ var current_render = null;
460
+ /** @type {RenderContext | null} */
461
+ var context = null;
462
+ /** @returns {RenderContext} */
463
+ function get_render_context() {
464
+ const store = context ?? als?.getStore();
465
+ if (!store) server_context_required();
466
+ return store;
467
+ }
468
+ /**
469
+ * @template T
470
+ * @param {() => Promise<T>} fn
471
+ * @returns {Promise<T>}
472
+ */
473
+ async function with_render_context(fn) {
474
+ context = { hydratable: {
475
+ lookup: /* @__PURE__ */ new Map(),
476
+ comparisons: [],
477
+ unresolved_promises: /* @__PURE__ */ new Map()
478
+ } };
479
+ if (in_webcontainer()) {
480
+ const { promise, resolve } = deferred();
481
+ const previous_render = current_render;
482
+ current_render = promise;
483
+ await previous_render;
484
+ return fn().finally(resolve);
485
+ }
486
+ try {
487
+ if (als === null) async_local_storage_unavailable();
488
+ return als.run(context, fn);
489
+ } finally {
490
+ context = null;
491
+ }
492
+ }
493
+ /** @type {AsyncLocalStorage<RenderContext | null> | null} */
494
+ var als = null;
495
+ /** @type {Promise<void> | null} */
496
+ var als_import = null;
497
+ /**
498
+ *
499
+ * @returns {Promise<void>}
500
+ */
501
+ function init_render_context() {
502
+ als_import ??= import("node:async_hooks").then((hooks) => {
503
+ als = new hooks.AsyncLocalStorage();
504
+ }).then(noop, noop);
505
+ return als_import;
506
+ }
507
+ function in_webcontainer() {
508
+ return !!globalThis.process?.versions?.webcontainer;
509
+ }
510
+ //#endregion
511
+ //#region node_modules/svelte/src/internal/server/crypto.js
512
+ var text_encoder;
513
+ var crypto;
514
+ /** @param {string} module_name */
515
+ var obfuscated_import = (module_name) => import(
516
+ /* @vite-ignore */
517
+ module_name
518
+ );
519
+ /** @param {string} data */
520
+ async function sha256(data) {
521
+ text_encoder ??= new TextEncoder();
522
+ crypto ??= globalThis.crypto?.subtle?.digest ? globalThis.crypto : (await obfuscated_import("node:crypto")).webcrypto;
523
+ return base64_encode(await crypto.subtle.digest("SHA-256", text_encoder.encode(data)));
524
+ }
525
+ /**
526
+ * @param {Uint8Array} bytes
527
+ * @returns {string}
528
+ */
529
+ function base64_encode(bytes) {
530
+ if (globalThis.Buffer) return globalThis.Buffer.from(bytes).toString("base64");
531
+ let binary = "";
532
+ for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
533
+ return btoa(binary);
534
+ }
535
+ //#endregion
536
+ //#region node_modules/svelte/src/internal/server/renderer.js
537
+ /** @import { Component } from 'svelte' */
538
+ /** @import { HydratableContext, SSRContext } from './types.js' */
539
+ /** @import { Csp, RenderOutput, SyncRenderOutput, Sha256Source } from '../../server/public.js' */
540
+ /** @import { MaybePromise } from '#shared' */
541
+ /** @typedef {'head' | 'body'} RendererType */
542
+ /** @typedef {{ [key in RendererType]: string }} AccumulatedContent */
543
+ /**
544
+ * @typedef {string | Renderer} RendererItem
545
+ */
546
+ var RenderResult = class {
547
+ /** @type {() => AccumulatedContent} */
548
+ #render;
549
+ /** @type {() => Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>} */
550
+ #render_async;
551
+ /** @type {AccumulatedContent | undefined} */
552
+ #sync;
553
+ /** @type {{ script: '' }} */
554
+ #hashes = { script: "" };
555
+ /** @type {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }> | undefined} */
556
+ #promise;
557
+ /**
558
+ * @param {() => AccumulatedContent} render
559
+ * @param {() => Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>} render_async
560
+ */
561
+ constructor(render, render_async) {
562
+ this.#render = render;
563
+ this.#render_async = render_async;
564
+ }
565
+ #get() {
566
+ return this.#sync ??= this.#render();
567
+ }
568
+ get html() {
569
+ return this.#get().body;
570
+ }
571
+ get head() {
572
+ return this.#get().head;
573
+ }
574
+ get body() {
575
+ return this.#get().body;
576
+ }
577
+ get hashes() {
578
+ return this.#hashes;
579
+ }
580
+ /**
581
+ * This is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
582
+ *
583
+ * @template TResult1
584
+ * @template [TResult2=never]
585
+ * @param {(value: SyncRenderOutput) => TResult1} onfulfilled
586
+ * @param {(reason: unknown) => TResult2} onrejected
587
+ */
588
+ then(onfulfilled, onrejected) {
589
+ if (!async_mode_flag) {
590
+ const result = this.#get();
591
+ const user_result = onfulfilled({
592
+ head: result.head,
593
+ body: result.body,
594
+ html: result.body,
595
+ hashes: { script: [] }
596
+ });
597
+ return Promise.resolve(user_result);
598
+ }
599
+ this.#promise ??= this.#render_async().then((result) => {
600
+ Object.defineProperty(result, "html", { get: () => {
601
+ html_deprecated();
602
+ } });
603
+ return result;
604
+ });
605
+ return this.#promise.then((result) => onfulfilled(result), onrejected);
606
+ }
607
+ };
608
+ /**
609
+ * Renderers are basically a tree of `string | Renderer`s, where each `Renderer` in the tree represents
610
+ * work that may or may not have completed. A renderer can be {@link collect}ed to aggregate the
611
+ * content from itself and all of its children, but this will throw if any of the children are
612
+ * performing asynchronous work. To asynchronously collect a renderer, just `await` it.
613
+ *
614
+ * The `string` values within a renderer are always associated with the {@link type} of that renderer. To switch types,
615
+ * call {@link child} with a different `type` argument.
616
+ */
617
+ var Renderer = class Renderer {
618
+ /**
619
+ * The contents of the renderer.
620
+ * @type {RendererItem[]}
621
+ */
622
+ #out = [];
623
+ /**
624
+ * Any `onDestroy` callbacks registered during execution of this renderer.
625
+ * @type {(() => void)[] | undefined}
626
+ */
627
+ #on_destroy = void 0;
628
+ /**
629
+ * Whether this renderer is a component body.
630
+ * @type {boolean}
631
+ */
632
+ #is_component_body = false;
633
+ /**
634
+ * If set, this renderer is an error boundary. When async collection
635
+ * of the children fails, the failed snippet is rendered instead.
636
+ * @type {{
637
+ * failed: (renderer: Renderer, error: unknown, reset: () => void) => void;
638
+ * transformError: (error: unknown) => unknown;
639
+ * context: SSRContext | null;
640
+ * } | null}
641
+ */
642
+ #boundary = null;
643
+ /**
644
+ * The type of string content that this renderer is accumulating.
645
+ * @type {RendererType}
646
+ */
647
+ type;
648
+ /** @type {Renderer | undefined} */
649
+ #parent;
650
+ /**
651
+ * Asynchronous work associated with this renderer
652
+ * @type {Promise<void> | undefined}
653
+ */
654
+ promise = void 0;
655
+ /**
656
+ * State which is associated with the content tree as a whole.
657
+ * It will be re-exposed, uncopied, on all children.
658
+ * @type {SSRState}
659
+ * @readonly
660
+ */
661
+ global;
662
+ /**
663
+ * State that is local to the branch it is declared in.
664
+ * It will be shallow-copied to all children.
665
+ *
666
+ * @type {{ select_value: any, multiple: boolean }}
667
+ */
668
+ local;
669
+ /**
670
+ * @param {SSRState} global
671
+ * @param {Renderer | undefined} [parent]
672
+ */
673
+ constructor(global, parent) {
674
+ this.#parent = parent;
675
+ this.global = global;
676
+ this.local = parent ? { ...parent.local } : {
677
+ select_value: void 0,
678
+ multiple: false
679
+ };
680
+ this.type = parent ? parent.type : "body";
681
+ }
682
+ /**
683
+ * @param {(renderer: Renderer) => void} fn
684
+ */
685
+ head(fn) {
686
+ const head = new Renderer(this.global, this);
687
+ head.type = "head";
688
+ this.#out.push(head);
689
+ head.child(fn);
690
+ }
691
+ /**
692
+ * @param {Array<Promise<void>>} blockers
693
+ * @param {(renderer: Renderer) => void} fn
694
+ */
695
+ async_block(blockers, fn) {
696
+ this.#out.push(BLOCK_OPEN);
697
+ this.async(blockers, fn);
698
+ this.#out.push(BLOCK_CLOSE);
699
+ }
700
+ /**
701
+ * @param {Array<Promise<void>>} blockers
702
+ * @param {(renderer: Renderer) => void} fn
703
+ */
704
+ async(blockers, fn) {
705
+ let callback = fn;
706
+ if (blockers.length > 0) {
707
+ const context = ssr_context;
708
+ callback = (renderer) => {
709
+ return Promise.all(blockers).then(() => {
710
+ const previous_context = ssr_context;
711
+ try {
712
+ set_ssr_context(context);
713
+ return fn(renderer);
714
+ } finally {
715
+ set_ssr_context(previous_context);
716
+ }
717
+ });
718
+ };
719
+ }
720
+ this.child(callback);
721
+ }
722
+ /**
723
+ * @param {Array<() => void>} thunks
724
+ */
725
+ run(thunks) {
726
+ const context = ssr_context;
727
+ let promise = Promise.resolve(thunks[0]());
728
+ const promises = [promise];
729
+ if (context !== null && thunks.length > 1) context.i = true;
730
+ for (const fn of thunks.slice(1)) {
731
+ promise = promise.then(() => {
732
+ const previous_context = ssr_context;
733
+ set_ssr_context(context);
734
+ try {
735
+ return fn();
736
+ } finally {
737
+ set_ssr_context(previous_context);
738
+ }
739
+ });
740
+ promises.push(promise);
741
+ }
742
+ promise.catch(noop);
743
+ this.promise = this.global.track(promise);
744
+ return promises;
745
+ }
746
+ /**
747
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
748
+ */
749
+ child_block(fn) {
750
+ this.#out.push(BLOCK_OPEN);
751
+ this.child(fn);
752
+ this.#out.push(BLOCK_CLOSE);
753
+ }
754
+ /**
755
+ * Create a child renderer. The child renderer inherits the state from the parent,
756
+ * but has its own content.
757
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
758
+ */
759
+ child(fn) {
760
+ const child = new Renderer(this.global, this);
761
+ this.#out.push(child);
762
+ const parent = ssr_context;
763
+ set_ssr_context({
764
+ ...ssr_context,
765
+ p: parent,
766
+ c: null,
767
+ r: child,
768
+ i: ssr_context?.i ?? false
769
+ });
770
+ const result = fn(child);
771
+ set_ssr_context(parent);
772
+ if (result instanceof Promise) {
773
+ result.catch(noop);
774
+ result.finally(() => set_ssr_context(null)).catch(noop);
775
+ if (child.global.mode === "sync") await_invalid();
776
+ child.promise = child.global.track(result);
777
+ }
778
+ return child;
779
+ }
780
+ /**
781
+ * Render children inside an error boundary. If the children throw and the API-level
782
+ * `transformError` transform handles the error (doesn't re-throw), the `failed` snippet is
783
+ * rendered instead. Otherwise the error propagates.
784
+ *
785
+ * @param {{ failed?: (renderer: Renderer, error: unknown, reset: () => void) => void }} props
786
+ * @param {(renderer: Renderer) => MaybePromise<void>} children_fn
787
+ */
788
+ boundary(props, children_fn) {
789
+ const child = new Renderer(this.global, this);
790
+ this.#out.push(child);
791
+ const parent_context = ssr_context;
792
+ if (props.failed) child.#boundary = {
793
+ failed: props.failed,
794
+ transformError: this.global.transformError,
795
+ context: parent_context
796
+ };
797
+ set_ssr_context({
798
+ ...ssr_context,
799
+ p: parent_context,
800
+ c: null,
801
+ r: child,
802
+ i: ssr_context?.i ?? false
803
+ });
804
+ try {
805
+ const result = children_fn(child);
806
+ set_ssr_context(parent_context);
807
+ if (result instanceof Promise) {
808
+ if (child.global.mode === "sync") await_invalid();
809
+ result.catch(noop);
810
+ child.promise = child.global.track(result);
811
+ }
812
+ } catch (error) {
813
+ set_ssr_context(parent_context);
814
+ const failed_snippet = props.failed;
815
+ if (!failed_snippet) throw error;
816
+ const result = this.global.transformError(error);
817
+ child.#out.length = 0;
818
+ child.#boundary = null;
819
+ if (result instanceof Promise) {
820
+ if (this.global.mode === "sync") await_invalid();
821
+ child.promise = child.global.track(
822
+ /** @type {Promise<unknown>} */
823
+ result.then((transformed) => {
824
+ set_ssr_context(parent_context);
825
+ child.#out.push(Renderer.#serialize_failed_boundary(transformed));
826
+ failed_snippet(child, transformed, noop);
827
+ child.#out.push(BLOCK_CLOSE);
828
+ })
829
+ );
830
+ child.promise.catch(noop);
831
+ } else {
832
+ child.#out.push(Renderer.#serialize_failed_boundary(result));
833
+ failed_snippet(child, result, noop);
834
+ child.#out.push(BLOCK_CLOSE);
835
+ }
836
+ }
837
+ }
838
+ /**
839
+ * Create a component renderer. The component renderer inherits the state from the parent,
840
+ * but has its own content. It is treated as an ordering boundary for ondestroy callbacks.
841
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
842
+ * @param {Function} [component_fn]
843
+ * @returns {void}
844
+ */
845
+ component(fn, component_fn) {
846
+ push(component_fn);
847
+ this.child((renderer) => {
848
+ renderer.#is_component_body = true;
849
+ return fn(renderer);
850
+ });
851
+ pop();
852
+ }
853
+ /**
854
+ * @param {Record<string, any>} attrs
855
+ * @param {(renderer: Renderer) => void} fn
856
+ * @param {string | undefined} [css_hash]
857
+ * @param {Record<string, boolean> | undefined} [classes]
858
+ * @param {Record<string, string> | undefined} [styles]
859
+ * @param {number | undefined} [flags]
860
+ * @param {boolean | undefined} [is_rich]
861
+ * @returns {void}
862
+ */
863
+ select(attrs, fn, css_hash, classes, styles, flags, is_rich) {
864
+ const { value, defaultValue, ...select_attrs } = attrs;
865
+ if (select_attrs.multiple === "") select_attrs.multiple = true;
866
+ this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags)}>`);
867
+ this.child((renderer) => {
868
+ renderer.local.select_value = value === void 0 ? defaultValue : value;
869
+ renderer.local.multiple = !!select_attrs.multiple;
870
+ fn(renderer);
871
+ });
872
+ this.push(`${is_rich ? "<!>" : ""}</select>`);
873
+ }
874
+ /**
875
+ * @param {Record<string, any>} attrs
876
+ * @param {string | number | boolean | ((renderer: Renderer) => void)} body
877
+ * @param {string | undefined} [css_hash]
878
+ * @param {Record<string, boolean> | undefined} [classes]
879
+ * @param {Record<string, string> | undefined} [styles]
880
+ * @param {number | undefined} [flags]
881
+ * @param {boolean | undefined} [is_rich]
882
+ */
883
+ option(attrs, body, css_hash, classes, styles, flags, is_rich) {
884
+ this.#out.push(`<option${attributes(attrs, css_hash, classes, styles, flags)}`);
885
+ /**
886
+ * @param {Renderer} renderer
887
+ * @param {any} value
888
+ * @param {{ head?: string, body: any }} content
889
+ */
890
+ const close = (renderer, value, { head, body }) => {
891
+ if (has_own_property.call(attrs, "value")) value = attrs.value;
892
+ var select_value = this.local.select_value;
893
+ if (this.local.multiple && is_array(select_value) ? select_value.includes(value) : value === select_value) renderer.#out.push(" selected=\"\"");
894
+ renderer.#out.push(`>${body}${is_rich ? "<!>" : ""}</option>`);
895
+ if (head) renderer.head((child) => child.push(head));
896
+ };
897
+ if (typeof body === "function") this.child((renderer) => {
898
+ const r = new Renderer(this.global, this);
899
+ body(r);
900
+ if (this.global.mode === "async") return r.#collect_content_async().then((content) => {
901
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
902
+ });
903
+ else {
904
+ const content = r.#collect_content();
905
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
906
+ }
907
+ });
908
+ else close(this, body, { body: escape_html(body) });
909
+ }
910
+ /**
911
+ * @param {(renderer: Renderer) => void} fn
912
+ */
913
+ title(fn) {
914
+ const path = this.get_path();
915
+ /** @param {string} head */
916
+ const close = (head) => {
917
+ this.global.set_title(head, path);
918
+ };
919
+ this.child((renderer) => {
920
+ const r = new Renderer(renderer.global, renderer);
921
+ fn(r);
922
+ if (renderer.global.mode === "async") return r.#collect_content_async().then((content) => {
923
+ close(content.head);
924
+ });
925
+ else {
926
+ const content = r.#collect_content();
927
+ close(content.head);
928
+ }
929
+ });
930
+ }
931
+ /**
932
+ * @param {string | (() => Promise<string>)} content
933
+ */
934
+ push(content) {
935
+ if (typeof content === "function") this.child(async (renderer) => renderer.push(await content()));
936
+ else this.#out.push(content);
937
+ }
938
+ /**
939
+ * @param {() => void} fn
940
+ */
941
+ on_destroy(fn) {
942
+ (this.#on_destroy ??= []).push(fn);
943
+ }
944
+ /**
945
+ * @returns {number[]}
946
+ */
947
+ get_path() {
948
+ return this.#parent ? [...this.#parent.get_path(), this.#parent.#out.indexOf(this)] : [];
949
+ }
950
+ /**
951
+ * @deprecated this is needed for legacy component bindings
952
+ */
953
+ copy() {
954
+ const copy = new Renderer(this.global, this.#parent);
955
+ copy.type = this.type;
956
+ copy.#out = this.#out.map((item) => item instanceof Renderer ? item.copy() : item);
957
+ copy.promise = this.promise;
958
+ return copy;
959
+ }
960
+ /**
961
+ * @param {Renderer} other
962
+ * @deprecated this is needed for legacy component bindings
963
+ */
964
+ subsume(other) {
965
+ if (this.global.mode !== other.global.mode) throw new Error("invariant: A renderer cannot switch modes. If you're seeing this, there's a compiler bug. File an issue!");
966
+ this.local = other.local;
967
+ this.#out = other.#out.map((item, i) => {
968
+ const current = this.#out[i];
969
+ if (current instanceof Renderer && item instanceof Renderer) {
970
+ current.subsume(item);
971
+ return current;
972
+ }
973
+ return item;
974
+ });
975
+ this.promise = other.promise;
976
+ this.type = other.type;
977
+ }
978
+ get length() {
979
+ return this.#out.length;
980
+ }
981
+ /**
982
+ * Creates the hydration comment that marks the start of a failed boundary.
983
+ * The error is JSON-serialized and embedded inside an HTML comment for the client
984
+ * to parse during hydration. The JSON is escaped to prevent `-->` or `<!--` sequences
985
+ * from breaking out of the comment (XSS). Uses unicode escapes which `JSON.parse()`
986
+ * handles transparently.
987
+ * @param {unknown} error
988
+ * @returns {string}
989
+ */
990
+ static #serialize_failed_boundary(error) {
991
+ return `<!--[?${JSON.stringify(error).replace(/>/g, "\\u003e").replace(/</g, "\\u003c")}-->`;
992
+ }
993
+ /**
994
+ * Only available on the server and when compiling with the `server` option.
995
+ * Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app.
996
+ * @template {Record<string, any>} Props
997
+ * @param {Component<Props>} component
998
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} [options]
999
+ * @returns {RenderOutput}
1000
+ */
1001
+ static render(component, options = {}) {
1002
+ return new RenderResult(() => Renderer.#render(component, options), () => init_render_context().then(() => with_render_context(() => Renderer.#render_async(component, options))));
1003
+ }
1004
+ /**
1005
+ * Collect all of the `onDestroy` callbacks registered during rendering. In an async context, this is only safe to call
1006
+ * after awaiting `collect_async`.
1007
+ *
1008
+ * Child renderers are "porous" and don't affect execution order, but component body renderers
1009
+ * create ordering boundaries. Within a renderer, callbacks run in order until hitting a component boundary.
1010
+ * @returns {Iterable<() => void>}
1011
+ */
1012
+ *#collect_on_destroy() {
1013
+ for (const component of this.#traverse_components()) yield* component.#collect_ondestroy();
1014
+ }
1015
+ /**
1016
+ * Performs a depth-first search of renderers, yielding the deepest components first, then additional components as we backtrack up the tree.
1017
+ * @returns {Iterable<Renderer>}
1018
+ */
1019
+ *#traverse_components() {
1020
+ for (const child of this.#out) if (typeof child !== "string") yield* child.#traverse_components();
1021
+ if (this.#is_component_body) yield this;
1022
+ }
1023
+ /**
1024
+ * @returns {Iterable<() => void>}
1025
+ */
1026
+ *#collect_ondestroy() {
1027
+ if (this.#on_destroy) for (const fn of this.#on_destroy) yield fn;
1028
+ for (const child of this.#out) if (child instanceof Renderer && !child.#is_component_body) yield* child.#collect_ondestroy();
1029
+ }
1030
+ /**
1031
+ * Runs every `onDestroy` callback in this renderer tree. On a failed render,
1032
+ * cleanup errors are suppressed so they do not mask the render error.
1033
+ * @param {boolean} suppress_errors
1034
+ */
1035
+ #run_on_destroy(suppress_errors) {
1036
+ let first_error;
1037
+ let has_error = false;
1038
+ for (const cleanup of this.#collect_on_destroy()) try {
1039
+ cleanup();
1040
+ } catch (error) {
1041
+ if (!suppress_errors && !has_error) {
1042
+ first_error = error;
1043
+ has_error = true;
1044
+ }
1045
+ }
1046
+ if (has_error) throw first_error;
1047
+ }
1048
+ /**
1049
+ * @param {'sync' | 'async'} mode
1050
+ * @param {{ idPrefix?: string; csp?: Csp; transformError?: (error: unknown) => unknown }} options
1051
+ * @returns {Renderer}
1052
+ */
1053
+ static #create(mode, options) {
1054
+ if (options.idPrefix?.includes("--")) invalid_id_prefix();
1055
+ return new Renderer(new SSRState(mode, options.idPrefix ? options.idPrefix + "-" : "", options.csp, options.transformError));
1056
+ }
1057
+ /**
1058
+ * Render a component. Throws if any of the children are performing asynchronous work.
1059
+ *
1060
+ * @template {Record<string, any>} Props
1061
+ * @param {Component<Props>} component
1062
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string }} options
1063
+ * @returns {AccumulatedContent}
1064
+ */
1065
+ static #render(component, options) {
1066
+ var previous_context = ssr_context;
1067
+ const renderer = Renderer.#create("sync", options);
1068
+ /** @type {AccumulatedContent | undefined} */
1069
+ let result;
1070
+ let render_error;
1071
+ let failed = false;
1072
+ try {
1073
+ try {
1074
+ Renderer.#open_render(renderer, component, options);
1075
+ result = Renderer.#close_render(renderer.#collect_content(), renderer);
1076
+ } catch (error) {
1077
+ render_error = error;
1078
+ failed = true;
1079
+ }
1080
+ renderer.#run_on_destroy(failed);
1081
+ if (failed) throw render_error;
1082
+ return result;
1083
+ } finally {
1084
+ renderer.global.abort();
1085
+ set_ssr_context(previous_context);
1086
+ }
1087
+ }
1088
+ /**
1089
+ * Render a component.
1090
+ *
1091
+ * @template {Record<string, any>} Props
1092
+ * @param {Component<Props>} component
1093
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
1094
+ * @returns {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>}
1095
+ */
1096
+ static async #render_async(component, options) {
1097
+ const previous_context = ssr_context;
1098
+ const renderer = Renderer.#create("async", options);
1099
+ /** @type {(AccumulatedContent & { hashes: { script: Sha256Source[] } }) | undefined} */
1100
+ let result;
1101
+ let render_error;
1102
+ let failed = false;
1103
+ try {
1104
+ try {
1105
+ Renderer.#open_render(renderer, component, options);
1106
+ const content = await renderer.#collect_content_async();
1107
+ const hydratables = await renderer.#collect_hydratables();
1108
+ if (hydratables !== null) content.head = hydratables + content.head;
1109
+ result = Renderer.#close_render(content, renderer);
1110
+ } catch (error) {
1111
+ render_error = error;
1112
+ failed = true;
1113
+ renderer.global.abort();
1114
+ await renderer.global.settle();
1115
+ }
1116
+ renderer.#run_on_destroy(failed);
1117
+ if (failed) throw render_error;
1118
+ return result;
1119
+ } finally {
1120
+ set_ssr_context(previous_context);
1121
+ renderer.global.abort();
1122
+ }
1123
+ }
1124
+ /**
1125
+ * Collect all of the code from the `out` array and return it as a string, or a promise resolving to a string.
1126
+ * @param {AccumulatedContent} content
1127
+ * @returns {AccumulatedContent}
1128
+ */
1129
+ #collect_content(content = {
1130
+ head: "",
1131
+ body: ""
1132
+ }) {
1133
+ for (const item of this.#out) if (typeof item === "string") content[this.type] += item;
1134
+ else if (item instanceof Renderer) item.#collect_content(content);
1135
+ return content;
1136
+ }
1137
+ /**
1138
+ * Collect all of the code from the `out` array and return it as a string.
1139
+ * @param {AccumulatedContent} content
1140
+ * @returns {Promise<AccumulatedContent>}
1141
+ */
1142
+ async #collect_content_async(content = {
1143
+ head: "",
1144
+ body: ""
1145
+ }) {
1146
+ await this.promise;
1147
+ for (const item of this.#out) if (typeof item === "string") content[this.type] += item;
1148
+ else if (item instanceof Renderer) {
1149
+ if (item.#boundary) {
1150
+ /** @type {AccumulatedContent} */
1151
+ const boundary_content = {
1152
+ head: "",
1153
+ body: ""
1154
+ };
1155
+ try {
1156
+ await item.#collect_content_async(boundary_content);
1157
+ content.head += boundary_content.head;
1158
+ content.body += boundary_content.body;
1159
+ } catch (error) {
1160
+ const { context, failed, transformError } = item.#boundary;
1161
+ set_ssr_context(context);
1162
+ let promise = transformError(error);
1163
+ set_ssr_context(null);
1164
+ let transformed = await promise;
1165
+ set_ssr_context(context);
1166
+ const failed_renderer = new Renderer(item.global, item);
1167
+ failed_renderer.type = item.type;
1168
+ failed_renderer.#out.push(Renderer.#serialize_failed_boundary(transformed));
1169
+ failed(failed_renderer, transformed, noop);
1170
+ failed_renderer.#out.push(BLOCK_CLOSE);
1171
+ await failed_renderer.#collect_content_async(content);
1172
+ }
1173
+ } else await item.#collect_content_async(content);
1174
+ }
1175
+ return content;
1176
+ }
1177
+ async #collect_hydratables() {
1178
+ const ctx = get_render_context().hydratable;
1179
+ for (const [_, key] of ctx.unresolved_promises) unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? "<missing stack trace>");
1180
+ for (const comparison of ctx.comparisons) await comparison;
1181
+ return await this.#hydratable_block(ctx);
1182
+ }
1183
+ /**
1184
+ * @template {Record<string, any>} Props
1185
+ * @param {Renderer} renderer
1186
+ * @param {import('svelte').Component<Props>} component
1187
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp; transformError?: (error: unknown) => unknown }} options
1188
+ * @returns {void}
1189
+ */
1190
+ static #open_render(renderer, component, options) {
1191
+ var previous_context = ssr_context;
1192
+ try {
1193
+ set_ssr_context({
1194
+ p: null,
1195
+ c: options.context ?? null,
1196
+ r: renderer,
1197
+ i: false
1198
+ });
1199
+ renderer.push(BLOCK_OPEN);
1200
+ component(renderer, options.props ?? {});
1201
+ renderer.push(BLOCK_CLOSE);
1202
+ } finally {
1203
+ set_ssr_context(previous_context);
1204
+ }
1205
+ }
1206
+ /**
1207
+ * @param {AccumulatedContent} content
1208
+ * @param {Renderer} renderer
1209
+ * @returns {AccumulatedContent & { hashes: { script: Sha256Source[] } }}
1210
+ */
1211
+ static #close_render(content, renderer) {
1212
+ let head = content.head + renderer.global.get_title();
1213
+ let body = content.body;
1214
+ for (const { hash, code } of renderer.global.css) head += `<style id="${hash}">${code}</style>`;
1215
+ return {
1216
+ head,
1217
+ body,
1218
+ hashes: { script: renderer.global.csp.script_hashes }
1219
+ };
1220
+ }
1221
+ /**
1222
+ * @param {HydratableContext} ctx
1223
+ */
1224
+ async #hydratable_block(ctx) {
1225
+ if (ctx.lookup.size === 0) return null;
1226
+ let entries = [];
1227
+ let has_promises = false;
1228
+ for (const [k, v] of ctx.lookup) {
1229
+ if (v.promises) {
1230
+ has_promises = true;
1231
+ for (const p of v.promises) await p;
1232
+ }
1233
+ entries.push(`[${uneval(k)},${v.serialized}]`);
1234
+ }
1235
+ let prelude = `const h = (window.__svelte ??= {}).h ??= new Map();`;
1236
+ if (has_promises) prelude = `const r = (v) => Promise.resolve(v);
1237
+ ${prelude}`;
1238
+ const body = `
1239
+ {
1240
+ ${prelude}
1241
+
1242
+ for (const [k, v] of [
1243
+ ${entries.join(",\n ")}
1244
+ ]) {
1245
+ h.set(k, v);
1246
+ }
1247
+ }
1248
+ `;
1249
+ let csp_attr = "";
1250
+ if (this.global.csp.nonce) csp_attr = ` nonce="${this.global.csp.nonce}"`;
1251
+ else if (this.global.csp.hash) {
1252
+ const hash = await sha256(body);
1253
+ this.global.csp.script_hashes.push(`sha256-${hash}`);
1254
+ }
1255
+ return `\n\t\t<script${csp_attr}>${body}<\/script>`;
1256
+ }
1257
+ };
1258
+ var SSRState = class {
1259
+ /** @readonly @type {Csp & { script_hashes: Sha256Source[] }} */
1260
+ csp;
1261
+ /** @readonly @type {'sync' | 'async'} */
1262
+ mode;
1263
+ /** @readonly @type {() => string} */
1264
+ uid;
1265
+ /** @readonly @type {Set<{ hash: string; code: string }>} */
1266
+ css = /* @__PURE__ */ new Set();
1267
+ /** @type {Set<Promise<unknown>>} */
1268
+ #pending = /* @__PURE__ */ new Set();
1269
+ /** @type {AbortController | null} */
1270
+ #controller = null;
1271
+ #aborted = false;
1272
+ /**
1273
+ * `transformError` passed to `render`. Called when an error boundary catches an error.
1274
+ * Throws by default if unset in `render`.
1275
+ * @type {(error: unknown) => unknown}
1276
+ */
1277
+ transformError;
1278
+ /** @type {{ path: number[], value: string }} */
1279
+ #title = {
1280
+ path: [],
1281
+ value: ""
1282
+ };
1283
+ /**
1284
+ * @param {'sync' | 'async'} mode
1285
+ * @param {string} id_prefix
1286
+ * @param {Csp} csp
1287
+ * @param {((error: unknown) => unknown) | undefined} [transformError]
1288
+ */
1289
+ constructor(mode, id_prefix = "", csp = { hash: false }, transformError) {
1290
+ this.mode = mode;
1291
+ this.csp = {
1292
+ ...csp,
1293
+ script_hashes: []
1294
+ };
1295
+ this.transformError = transformError ?? ((error) => {
1296
+ throw error;
1297
+ });
1298
+ let uid = 1;
1299
+ this.uid = () => `${id_prefix}s${uid++}`;
1300
+ }
1301
+ /**
1302
+ * @template T
1303
+ * @param {Promise<T>} promise
1304
+ * @returns {Promise<T>}
1305
+ */
1306
+ track(promise) {
1307
+ this.#pending.add(promise);
1308
+ promise.then(() => this.#pending.delete(promise), () => this.#pending.delete(promise));
1309
+ return promise;
1310
+ }
1311
+ async settle() {
1312
+ while (this.#pending.size > 0) await Promise.allSettled([...this.#pending]);
1313
+ }
1314
+ abort() {
1315
+ if (this.#aborted) return;
1316
+ this.#aborted = true;
1317
+ this.#controller?.abort(STALE_REACTION);
1318
+ }
1319
+ get_abort_signal() {
1320
+ const controller = this.#controller ??= new AbortController();
1321
+ if (this.#aborted) controller.abort(STALE_REACTION);
1322
+ return controller.signal;
1323
+ }
1324
+ get_title() {
1325
+ return this.#title.value;
1326
+ }
1327
+ /**
1328
+ * Performs a depth-first (lexicographic) comparison using the path. Rejects sets
1329
+ * from earlier than or equal to the current value.
1330
+ * @param {string} value
1331
+ * @param {number[]} path
1332
+ */
1333
+ set_title(value, path) {
1334
+ const current = this.#title.path;
1335
+ let i = 0;
1336
+ let l = Math.min(path.length, current.length);
1337
+ while (i < l && path[i] === current[i]) i += 1;
1338
+ if (path[i] === void 0) return;
1339
+ if (current[i] === void 0 || path[i] > current[i]) {
1340
+ this.#title.path = path;
1341
+ this.#title.value = value;
1342
+ }
1343
+ }
1344
+ };
1345
+ //#endregion
1346
+ //#region node_modules/svelte/src/internal/server/index.js
1347
+ var INVALID_ATTR_NAME_CHAR_REGEX = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
1348
+ /**
1349
+ * @param {Renderer} renderer
1350
+ * @param {string} tag
1351
+ * @param {() => void} attributes_fn
1352
+ * @param {() => void} children_fn
1353
+ * @returns {void}
1354
+ */
1355
+ function element(renderer, tag, attributes_fn = noop, children_fn = noop) {
1356
+ renderer.push("<!---->");
1357
+ if (tag) {
1358
+ if (!REGEX_VALID_TAG_NAME.test(tag)) dynamic_element_invalid_tag(tag);
1359
+ renderer.push(`<${tag}`);
1360
+ attributes_fn();
1361
+ renderer.push(`>`);
1362
+ if (!is_void(tag)) {
1363
+ children_fn();
1364
+ if (!is_raw_text_element(tag)) renderer.push(EMPTY_COMMENT);
1365
+ renderer.push(`</${tag}>`);
1366
+ }
1367
+ }
1368
+ renderer.push("<!---->");
1369
+ }
1370
+ /**
1371
+ * Only available on the server and when compiling with the `server` option.
1372
+ * Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app.
1373
+ * @template {Record<string, any>} Props
1374
+ * @param {Component<Props> | ComponentType<SvelteComponent<Props>>} component
1375
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp; transformError?: (error: unknown) => unknown }} [options]
1376
+ * @returns {RenderOutput}
1377
+ */
1378
+ function render(component, options = {}) {
1379
+ if (options.csp?.hash && options.csp.nonce) invalid_csp();
1380
+ return Renderer.render(component, options);
1381
+ }
1382
+ /**
1383
+ * @param {string} hash
1384
+ * @param {Renderer} renderer
1385
+ * @param {(renderer: Renderer) => Promise<void> | void} fn
1386
+ * @returns {void}
1387
+ */
1388
+ function head(hash, renderer, fn) {
1389
+ renderer.head((renderer) => {
1390
+ renderer.push(`<!--${hash}-->`);
1391
+ renderer.child(fn);
1392
+ renderer.push(EMPTY_COMMENT);
1393
+ });
1394
+ }
1395
+ /**
1396
+ * @param {Record<string, unknown>} attrs
1397
+ * @param {string} [css_hash]
1398
+ * @param {Record<string, boolean>} [classes]
1399
+ * @param {Record<string, string>} [styles]
1400
+ * @param {number} [flags]
1401
+ * @returns {string}
1402
+ */
1403
+ function attributes(attrs, css_hash, classes, styles, flags = 0) {
1404
+ if (styles) attrs.style = to_style(attrs.style, styles);
1405
+ if (attrs.class) attrs.class = clsx(attrs.class);
1406
+ if (css_hash || classes) attrs.class = to_class(attrs.class, css_hash, classes);
1407
+ let attr_str = "";
1408
+ let name;
1409
+ const is_html = (flags & 1) === 0;
1410
+ const lowercase = (flags & 2) === 0;
1411
+ const is_input = (flags & 4) !== 0;
1412
+ const names = Object.keys(attrs);
1413
+ outer: for (let i = 0; i < names.length; i++) {
1414
+ name = names[i];
1415
+ if (typeof attrs[name] === "function") continue;
1416
+ if (name[0] === "$" && name[1] === "$") continue;
1417
+ if (name === "" || INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
1418
+ var value = attrs[name];
1419
+ var lower = name.toLowerCase();
1420
+ if (lowercase) name = lower;
1421
+ if (lower.length > 2 && lower.startsWith("on")) continue;
1422
+ if (is_input) {
1423
+ if (name === "defaultvalue" || name === "defaultchecked") {
1424
+ name = name === "defaultvalue" ? "value" : "checked";
1425
+ if (name in attrs) continue;
1426
+ for (let j = 0; j < names.length; j++) if (names[j].toLowerCase() === name) continue outer;
1427
+ }
1428
+ }
1429
+ attr_str += attr(name, value, is_html && is_boolean_attribute(name));
1430
+ }
1431
+ return attr_str;
1432
+ }
1433
+ /**
1434
+ * @param {unknown} value
1435
+ * @returns {string}
1436
+ */
1437
+ function stringify(value) {
1438
+ return typeof value === "string" ? value : value == null ? "" : value + "";
1439
+ }
1440
+ /**
1441
+ * @param {any} value
1442
+ * @param {string | undefined} [hash]
1443
+ * @param {Record<string, boolean>} [directives]
1444
+ */
1445
+ function attr_class(value, hash, directives) {
1446
+ var result = to_class(value, hash, directives);
1447
+ return result ? ` class="${escape_html(result, true)}"` : "";
1448
+ }
1449
+ /**
1450
+ * @param {any} value
1451
+ * @param {Record<string,any>|[Record<string,any>,Record<string,any>]} [directives]
1452
+ */
1453
+ function attr_style(value, directives) {
1454
+ var result = to_style(value, directives);
1455
+ return result ? ` style="${escape_html(result, true)}"` : "";
1456
+ }
1457
+ /**
1458
+ * Legacy mode: If the prop has a fallback and is bound in the
1459
+ * parent component, propagate the fallback value upwards.
1460
+ * @param {Record<string, unknown>} props_parent
1461
+ * @param {Record<string, unknown>} props_now
1462
+ */
1463
+ function bind_props(props_parent, props_now) {
1464
+ for (const key of Object.keys(props_now)) {
1465
+ const initial_value = props_parent[key];
1466
+ const value = props_now[key];
1467
+ if (initial_value === void 0 && value !== void 0 && Object.getOwnPropertyDescriptor(props_parent, key)?.set) props_parent[key] = value;
1468
+ }
1469
+ }
1470
+ /** @param {any} array_like_or_iterator */
1471
+ function ensure_array_like(array_like_or_iterator) {
1472
+ if (array_like_or_iterator) return array_like_or_iterator.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
1473
+ return [];
1474
+ }
1475
+ /**
1476
+ * @template V
1477
+ * @param {() => V} get_value
1478
+ */
1479
+ function once(get_value) {
1480
+ let value = UNINITIALIZED;
1481
+ return () => {
1482
+ if (value === UNINITIALIZED) value = get_value();
1483
+ return value;
1484
+ };
1485
+ }
1486
+ /**
1487
+ * @template T
1488
+ * @param {()=>T} fn
1489
+ * @returns {(new_value?: T) => (T | void)}
1490
+ */
1491
+ function derived(fn) {
1492
+ const get_value = ssr_context === null ? fn : once(fn);
1493
+ /** @type {T | undefined} */
1494
+ let updated_value;
1495
+ return function(new_value) {
1496
+ if (arguments.length === 0) return updated_value ?? get_value();
1497
+ updated_value = new_value;
1498
+ return updated_value;
1499
+ };
1500
+ }
1501
+ //#endregion
1502
+ export { element as a, render as c, attr as d, run as f, derived as i, stringify as l, attr_style as n, ensure_array_like as o, escape_html as p, bind_props as r, head as s, attr_class as t, getContext as u };
1503
+
1504
+ //# sourceMappingURL=server2.js.map