@sentropic/h2a 0.85.16 → 0.85.18

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 (193) hide show
  1. package/.claude-plugin/plugin.json +29 -0
  2. package/.codex-plugin/plugin.json +35 -0
  3. package/.mcp.json +19 -0
  4. package/README.md +3 -0
  5. package/dist/bin-routing.d.ts +14 -3
  6. package/dist/bin-routing.d.ts.map +1 -1
  7. package/dist/bin-routing.js +31 -6
  8. package/dist/bin-routing.js.map +1 -1
  9. package/dist/bin.js +45 -14
  10. package/dist/bin.js.map +1 -1
  11. package/dist/cli-contract.d.ts.map +1 -1
  12. package/dist/cli-contract.js +41 -1
  13. package/dist/cli-contract.js.map +1 -1
  14. package/dist/cli.d.ts +4 -0
  15. package/dist/cli.d.ts.map +1 -1
  16. package/dist/cli.js +146 -18
  17. package/dist/cli.js.map +1 -1
  18. package/dist/index.d.ts +4 -3
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +3 -2
  21. package/dist/index.js.map +1 -1
  22. package/dist/mcp.d.ts +1 -1
  23. package/dist/mcp.d.ts.map +1 -1
  24. package/dist/mcp.js +1 -0
  25. package/dist/mcp.js.map +1 -1
  26. package/dist/runtime/focus/serve.d.ts +42 -0
  27. package/dist/runtime/focus/serve.d.ts.map +1 -0
  28. package/dist/runtime/focus/serve.js +366 -0
  29. package/dist/runtime/focus/serve.js.map +1 -0
  30. package/dist/runtime/loop/engine/adapters.d.ts +62 -6
  31. package/dist/runtime/loop/engine/adapters.d.ts.map +1 -1
  32. package/dist/runtime/loop/engine/adapters.js +272 -36
  33. package/dist/runtime/loop/engine/adapters.js.map +1 -1
  34. package/dist/runtime/loop/engine/decision.d.ts.map +1 -1
  35. package/dist/runtime/loop/engine/decision.js +20 -2
  36. package/dist/runtime/loop/engine/decision.js.map +1 -1
  37. package/dist/runtime/loop/engine/execute.d.ts +13 -4
  38. package/dist/runtime/loop/engine/execute.d.ts.map +1 -1
  39. package/dist/runtime/loop/engine/execute.js +17 -7
  40. package/dist/runtime/loop/engine/execute.js.map +1 -1
  41. package/dist/runtime/loop/index.d.ts +16 -0
  42. package/dist/runtime/loop/index.d.ts.map +1 -1
  43. package/dist/runtime/loop/index.js +146 -13
  44. package/dist/runtime/loop/index.js.map +1 -1
  45. package/dist/runtime/mcp/agent-launch.d.ts +33 -0
  46. package/dist/runtime/mcp/agent-launch.d.ts.map +1 -0
  47. package/dist/runtime/mcp/agent-launch.js +250 -0
  48. package/dist/runtime/mcp/agent-launch.js.map +1 -0
  49. package/dist/runtime/mcp/handlers.d.ts +8 -0
  50. package/dist/runtime/mcp/handlers.d.ts.map +1 -1
  51. package/dist/runtime/mcp/handlers.js +34 -4
  52. package/dist/runtime/mcp/handlers.js.map +1 -1
  53. package/dist/runtime/mcp/index.d.ts +2 -1
  54. package/dist/runtime/mcp/index.d.ts.map +1 -1
  55. package/dist/runtime/mcp/index.js +2 -1
  56. package/dist/runtime/mcp/index.js.map +1 -1
  57. package/dist/runtime/mcp/server.d.ts +5 -0
  58. package/dist/runtime/mcp/server.d.ts.map +1 -1
  59. package/dist/runtime/mcp/server.js +3 -0
  60. package/dist/runtime/mcp/server.js.map +1 -1
  61. package/dist/runtime/mcp/stdio.d.ts +17 -0
  62. package/dist/runtime/mcp/stdio.d.ts.map +1 -1
  63. package/dist/runtime/mcp/stdio.js +65 -13
  64. package/dist/runtime/mcp/stdio.js.map +1 -1
  65. package/dist/runtime/mcp/tools.d.ts.map +1 -1
  66. package/dist/runtime/mcp/tools.js +96 -5
  67. package/dist/runtime/mcp/tools.js.map +1 -1
  68. package/dist/runtime/path-safety.d.ts +3 -0
  69. package/dist/runtime/path-safety.d.ts.map +1 -0
  70. package/dist/runtime/path-safety.js +12 -0
  71. package/dist/runtime/path-safety.js.map +1 -0
  72. package/dist/runtime/reporting/config.d.ts +21 -0
  73. package/dist/runtime/reporting/config.d.ts.map +1 -0
  74. package/dist/runtime/reporting/config.js +76 -0
  75. package/dist/runtime/reporting/config.js.map +1 -0
  76. package/dist/runtime/reporting/context.d.ts +27 -0
  77. package/dist/runtime/reporting/context.d.ts.map +1 -0
  78. package/dist/runtime/reporting/context.js +265 -0
  79. package/dist/runtime/reporting/context.js.map +1 -0
  80. package/dist/runtime/reporting/index.d.ts +4 -0
  81. package/dist/runtime/reporting/index.d.ts.map +1 -0
  82. package/dist/runtime/reporting/index.js +4 -0
  83. package/dist/runtime/reporting/index.js.map +1 -0
  84. package/dist/runtime/reporting/report-ai.d.ts +49 -0
  85. package/dist/runtime/reporting/report-ai.d.ts.map +1 -0
  86. package/dist/runtime/reporting/report-ai.js +325 -0
  87. package/dist/runtime/reporting/report-ai.js.map +1 -0
  88. package/focus-app/client/_app/immutable/assets/0.BdzHFb9q.css +1 -0
  89. package/focus-app/client/_app/immutable/assets/0.BdzHFb9q.css.br +2 -0
  90. package/focus-app/client/_app/immutable/assets/0.BdzHFb9q.css.gz +0 -0
  91. package/focus-app/client/_app/immutable/assets/2.Ddxq02y4.css +1 -0
  92. package/focus-app/client/_app/immutable/assets/2.Ddxq02y4.css.br +0 -0
  93. package/focus-app/client/_app/immutable/assets/2.Ddxq02y4.css.gz +0 -0
  94. package/focus-app/client/_app/immutable/chunks/Bs3f1UbD.js +2 -0
  95. package/focus-app/client/_app/immutable/chunks/Bs3f1UbD.js.br +0 -0
  96. package/focus-app/client/_app/immutable/chunks/Bs3f1UbD.js.gz +0 -0
  97. package/focus-app/client/_app/immutable/chunks/Bv8OL8ib.js +1 -0
  98. package/focus-app/client/_app/immutable/chunks/Bv8OL8ib.js.br +0 -0
  99. package/focus-app/client/_app/immutable/chunks/Bv8OL8ib.js.gz +0 -0
  100. package/focus-app/client/_app/immutable/chunks/CVq_IFFr.js +2 -0
  101. package/focus-app/client/_app/immutable/chunks/CVq_IFFr.js.br +0 -0
  102. package/focus-app/client/_app/immutable/chunks/CVq_IFFr.js.gz +0 -0
  103. package/focus-app/client/_app/immutable/chunks/Cj6wo28J.js +1 -0
  104. package/focus-app/client/_app/immutable/chunks/Cj6wo28J.js.br +0 -0
  105. package/focus-app/client/_app/immutable/chunks/Cj6wo28J.js.gz +0 -0
  106. package/focus-app/client/_app/immutable/chunks/DEmooz0s.js +1 -0
  107. package/focus-app/client/_app/immutable/chunks/DEmooz0s.js.br +0 -0
  108. package/focus-app/client/_app/immutable/chunks/DEmooz0s.js.gz +0 -0
  109. package/focus-app/client/_app/immutable/chunks/DQIRXgdC.js +2 -0
  110. package/focus-app/client/_app/immutable/chunks/DQIRXgdC.js.br +0 -0
  111. package/focus-app/client/_app/immutable/chunks/DQIRXgdC.js.gz +0 -0
  112. package/focus-app/client/_app/immutable/chunks/ZxFklh9T.js +1 -0
  113. package/focus-app/client/_app/immutable/chunks/ZxFklh9T.js.br +0 -0
  114. package/focus-app/client/_app/immutable/chunks/ZxFklh9T.js.gz +0 -0
  115. package/focus-app/client/_app/immutable/chunks/_wRuVGPs.js +1 -0
  116. package/focus-app/client/_app/immutable/chunks/_wRuVGPs.js.br +0 -0
  117. package/focus-app/client/_app/immutable/chunks/_wRuVGPs.js.gz +0 -0
  118. package/focus-app/client/_app/immutable/chunks/wbPk3Yxo.js +81 -0
  119. package/focus-app/client/_app/immutable/chunks/wbPk3Yxo.js.br +0 -0
  120. package/focus-app/client/_app/immutable/chunks/wbPk3Yxo.js.gz +0 -0
  121. package/focus-app/client/_app/immutable/entry/app.6DKouWRt.js +2 -0
  122. package/focus-app/client/_app/immutable/entry/app.6DKouWRt.js.br +0 -0
  123. package/focus-app/client/_app/immutable/entry/app.6DKouWRt.js.gz +0 -0
  124. package/focus-app/client/_app/immutable/entry/start.DlLmkUb7.js +1 -0
  125. package/focus-app/client/_app/immutable/entry/start.DlLmkUb7.js.br +2 -0
  126. package/focus-app/client/_app/immutable/entry/start.DlLmkUb7.js.gz +0 -0
  127. package/focus-app/client/_app/immutable/nodes/0.CuSOF0Of.js +5 -0
  128. package/focus-app/client/_app/immutable/nodes/0.CuSOF0Of.js.br +0 -0
  129. package/focus-app/client/_app/immutable/nodes/0.CuSOF0Of.js.gz +0 -0
  130. package/focus-app/client/_app/immutable/nodes/1.D39jdnqm.js +1 -0
  131. package/focus-app/client/_app/immutable/nodes/1.D39jdnqm.js.br +0 -0
  132. package/focus-app/client/_app/immutable/nodes/1.D39jdnqm.js.gz +0 -0
  133. package/focus-app/client/_app/immutable/nodes/2.CnU8ifRl.js +1 -0
  134. package/focus-app/client/_app/immutable/nodes/2.CnU8ifRl.js.br +0 -0
  135. package/focus-app/client/_app/immutable/nodes/2.CnU8ifRl.js.gz +0 -0
  136. package/focus-app/client/_app/version.json +1 -0
  137. package/focus-app/client/_app/version.json.br +0 -0
  138. package/focus-app/client/_app/version.json.gz +0 -0
  139. package/focus-app/env.js +70 -0
  140. package/focus-app/env.js.map +1 -0
  141. package/focus-app/h2a-focus.json +114 -0
  142. package/focus-app/handler.js +24 -0
  143. package/focus-app/handler.js.map +1 -0
  144. package/focus-app/index.js +147 -0
  145. package/focus-app/index.js.map +1 -0
  146. package/focus-app/server/chunks/chunks/exports.js-DUTkELZq.js +217 -0
  147. package/focus-app/server/chunks/chunks/exports.js-DUTkELZq.js.map +1 -0
  148. package/focus-app/server/chunks/chunks/false.js-B2gHlHjM.js +4 -0
  149. package/focus-app/server/chunks/chunks/false.js-B2gHlHjM.js.map +1 -0
  150. package/focus-app/server/chunks/chunks/friendly.js-D4fjovnZ.js +246 -0
  151. package/focus-app/server/chunks/chunks/friendly.js-D4fjovnZ.js.map +1 -0
  152. package/focus-app/server/chunks/chunks/index.js-Di21TltP.js +1315 -0
  153. package/focus-app/server/chunks/chunks/index.js-Di21TltP.js.map +1 -0
  154. package/focus-app/server/chunks/chunks/internal.js-33vbd70h.js +126 -0
  155. package/focus-app/server/chunks/chunks/internal.js-33vbd70h.js.map +1 -0
  156. package/focus-app/server/chunks/chunks/root.js-DO1m-gJA.js +2967 -0
  157. package/focus-app/server/chunks/chunks/root.js-DO1m-gJA.js.map +1 -0
  158. package/focus-app/server/chunks/chunks/server.js-Bf8x1V_n.js +16 -0
  159. package/focus-app/server/chunks/chunks/server.js-Bf8x1V_n.js.map +1 -0
  160. package/focus-app/server/chunks/chunks/utils.js-C_3_iViC.js +2545 -0
  161. package/focus-app/server/chunks/chunks/utils.js-C_3_iViC.js.map +1 -0
  162. package/focus-app/server/chunks/chunks/utils2.js-BQzn9ikS.js +38 -0
  163. package/focus-app/server/chunks/chunks/utils2.js-BQzn9ikS.js.map +1 -0
  164. package/focus-app/server/chunks/entries/endpoints/api/actions/launch/_server.ts.js-DUQcf9xd.js +63 -0
  165. package/focus-app/server/chunks/entries/endpoints/api/actions/launch/_server.ts.js-DUQcf9xd.js.map +1 -0
  166. package/focus-app/server/chunks/entries/endpoints/api/decisions/inject/_server.ts.js-j0NNcOSZ.js +100 -0
  167. package/focus-app/server/chunks/entries/endpoints/api/decisions/inject/_server.ts.js-j0NNcOSZ.js.map +1 -0
  168. package/focus-app/server/chunks/entries/fallbacks/error.svelte.js-Dj3sETSX.js +50 -0
  169. package/focus-app/server/chunks/entries/fallbacks/error.svelte.js-Dj3sETSX.js.map +1 -0
  170. package/focus-app/server/chunks/entries/pages/_layout.svelte.js-BoLsbuC2.js +1420 -0
  171. package/focus-app/server/chunks/entries/pages/_layout.svelte.js-BoLsbuC2.js.map +1 -0
  172. package/focus-app/server/chunks/entries/pages/_page.server.ts.js-ChRBj_xK.js +246 -0
  173. package/focus-app/server/chunks/entries/pages/_page.server.ts.js-ChRBj_xK.js.map +1 -0
  174. package/focus-app/server/chunks/entries/pages/_page.svelte.js-QDldMYhk.js +2725 -0
  175. package/focus-app/server/chunks/entries/pages/_page.svelte.js-QDldMYhk.js.map +1 -0
  176. package/focus-app/server/chunks/handler-Cp_5hLyY.js +1474 -0
  177. package/focus-app/server/chunks/handler-Cp_5hLyY.js.map +1 -0
  178. package/focus-app/server/chunks/index.js-CBh7Wjqp.js +4242 -0
  179. package/focus-app/server/chunks/index.js-CBh7Wjqp.js.map +1 -0
  180. package/focus-app/server/chunks/manifest.js-Cm6cC7mC.js +56 -0
  181. package/focus-app/server/chunks/manifest.js-Cm6cC7mC.js.map +1 -0
  182. package/focus-app/server/chunks/nodes/0.js-4wlmdsk8.js +9 -0
  183. package/focus-app/server/chunks/nodes/0.js-4wlmdsk8.js.map +1 -0
  184. package/focus-app/server/chunks/nodes/1.js-B-LpY-lC.js +9 -0
  185. package/focus-app/server/chunks/nodes/1.js-B-LpY-lC.js.map +1 -0
  186. package/focus-app/server/chunks/nodes/2.js-F6jp5eD9.js +19 -0
  187. package/focus-app/server/chunks/nodes/2.js-F6jp5eD9.js.map +1 -0
  188. package/focus-app/shims.js +33 -0
  189. package/focus-app/shims.js.map +1 -0
  190. package/package.json +8 -4
  191. package/skills/h2a/SKILL.md +7 -5
  192. package/skills/harness/SKILL.md +17 -0
  193. package/skills/harness/using-harness/SKILL.md +26 -0
@@ -0,0 +1,1315 @@
1
+ import { u as uneval } from './utils.js-C_3_iViC.js';
2
+
3
+ function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx$1(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
4
+
5
+ const DERIVED = 1 << 1;
6
+ const EFFECT = 1 << 2;
7
+ const RENDER_EFFECT = 1 << 3;
8
+ const MANAGED_EFFECT = 1 << 24;
9
+ const BLOCK_EFFECT = 1 << 4;
10
+ const BRANCH_EFFECT = 1 << 5;
11
+ const ROOT_EFFECT = 1 << 6;
12
+ const BOUNDARY_EFFECT = 1 << 7;
13
+ const CONNECTED = 1 << 9;
14
+ const CLEAN = 1 << 10;
15
+ const DIRTY = 1 << 11;
16
+ const MAYBE_DIRTY = 1 << 12;
17
+ const INERT = 1 << 13;
18
+ const DESTROYED = 1 << 14;
19
+ const REACTION_RAN = 1 << 15;
20
+ const DESTROYING = 1 << 25;
21
+ const EFFECT_TRANSPARENT = 1 << 16;
22
+ const EAGER_EFFECT = 1 << 17;
23
+ const HEAD_EFFECT = 1 << 18;
24
+ const EFFECT_PRESERVED = 1 << 19;
25
+ const USER_EFFECT = 1 << 20;
26
+ const WAS_MARKED = 1 << 16;
27
+ const REACTION_IS_UPDATING = 1 << 21;
28
+ const ASYNC = 1 << 22;
29
+ const ERROR_VALUE = 1 << 23;
30
+ const STATE_SYMBOL = /* @__PURE__ */ Symbol("$state");
31
+ const LEGACY_PROPS = /* @__PURE__ */ Symbol("legacy props");
32
+ const ATTRIBUTES_CACHE = /* @__PURE__ */ Symbol("attributes");
33
+ const CLASS_CACHE = /* @__PURE__ */ Symbol("class");
34
+ const STYLE_CACHE = /* @__PURE__ */ Symbol("style");
35
+ const TEXT_CACHE = /* @__PURE__ */ Symbol("text");
36
+ const STALE_REACTION = new class StaleReactionError extends Error {
37
+ name = "StaleReactionError";
38
+ message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
39
+ }();
40
+ const COMMENT_NODE = 8;
41
+ var is_array = Array.isArray;
42
+ var index_of = Array.prototype.indexOf;
43
+ var includes = Array.prototype.includes;
44
+ var array_from = Array.from;
45
+ var define_property = Object.defineProperty;
46
+ var get_descriptor = Object.getOwnPropertyDescriptor;
47
+ var object_prototype = Object.prototype;
48
+ var array_prototype = Array.prototype;
49
+ var get_prototype_of = Object.getPrototypeOf;
50
+ var is_extensible = Object.isExtensible;
51
+ var has_own_property = Object.prototype.hasOwnProperty;
52
+ const noop = () => {
53
+ };
54
+ function run(fn) {
55
+ return fn();
56
+ }
57
+ function run_all(arr) {
58
+ for (var i = 0; i < arr.length; i++) {
59
+ arr[i]();
60
+ }
61
+ }
62
+ function deferred() {
63
+ var resolve;
64
+ var reject;
65
+ var promise = new Promise((res, rej) => {
66
+ resolve = res;
67
+ reject = rej;
68
+ });
69
+ return { promise, resolve, reject };
70
+ }
71
+ function lifecycle_outside_component(name) {
72
+ {
73
+ throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
74
+ }
75
+ }
76
+ const HYDRATION_START = "[";
77
+ const HYDRATION_START_ELSE = "[!";
78
+ const HYDRATION_START_FAILED = "[?";
79
+ const HYDRATION_END = "]";
80
+ const HYDRATION_ERROR = {};
81
+ const ELEMENT_IS_NAMESPACED = 1;
82
+ const ELEMENT_PRESERVE_ATTRIBUTE_CASE = 1 << 1;
83
+ const ELEMENT_IS_INPUT = 1 << 2;
84
+ const UNINITIALIZED = /* @__PURE__ */ Symbol("uninitialized");
85
+ const VOID_ELEMENT_NAMES = [
86
+ "area",
87
+ "base",
88
+ "br",
89
+ "col",
90
+ "command",
91
+ "embed",
92
+ "hr",
93
+ "img",
94
+ "input",
95
+ "keygen",
96
+ "link",
97
+ "meta",
98
+ "param",
99
+ "source",
100
+ "track",
101
+ "wbr"
102
+ ];
103
+ function is_void(name) {
104
+ return VOID_ELEMENT_NAMES.includes(name) || name.toLowerCase() === "!doctype";
105
+ }
106
+ const DOM_BOOLEAN_ATTRIBUTES = [
107
+ "allowfullscreen",
108
+ "async",
109
+ "autofocus",
110
+ "autoplay",
111
+ "checked",
112
+ "controls",
113
+ "default",
114
+ "disabled",
115
+ "formnovalidate",
116
+ "indeterminate",
117
+ "inert",
118
+ "ismap",
119
+ "loop",
120
+ "multiple",
121
+ "muted",
122
+ "nomodule",
123
+ "novalidate",
124
+ "open",
125
+ "playsinline",
126
+ "readonly",
127
+ "required",
128
+ "reversed",
129
+ "seamless",
130
+ "selected",
131
+ "webkitdirectory",
132
+ "defer",
133
+ "disablepictureinpicture",
134
+ "disableremoteplayback"
135
+ ];
136
+ function is_boolean_attribute(name) {
137
+ return DOM_BOOLEAN_ATTRIBUTES.includes(name);
138
+ }
139
+ const PASSIVE_EVENTS = ["touchstart", "touchmove"];
140
+ function is_passive_event(name) {
141
+ return PASSIVE_EVENTS.includes(name);
142
+ }
143
+ const RAW_TEXT_ELEMENTS = (
144
+ /** @type {const} */
145
+ ["textarea", "script", "style", "title"]
146
+ );
147
+ function is_raw_text_element(name) {
148
+ return RAW_TEXT_ELEMENTS.includes(
149
+ /** @type {typeof RAW_TEXT_ELEMENTS[number]} */
150
+ name
151
+ );
152
+ }
153
+ const 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;
154
+ const ATTR_REGEX = /[&"<]/g;
155
+ const CONTENT_REGEX = /[&<]/g;
156
+ function escape_html(value, is_attr) {
157
+ const str = String(value ?? "");
158
+ const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
159
+ pattern.lastIndex = 0;
160
+ let escaped = "";
161
+ let last = 0;
162
+ while (pattern.test(str)) {
163
+ const i = pattern.lastIndex - 1;
164
+ const ch = str[i];
165
+ escaped += str.substring(last, i) + (ch === "&" ? "&amp;" : ch === '"' ? "&quot;" : "&lt;");
166
+ last = i + 1;
167
+ }
168
+ return escaped + str.substring(last);
169
+ }
170
+ const replacements = {
171
+ translate: /* @__PURE__ */ new Map([
172
+ [true, "yes"],
173
+ [false, "no"]
174
+ ])
175
+ };
176
+ function attr(name, value, is_boolean = false) {
177
+ if (name === "hidden" && value !== "until-found") {
178
+ is_boolean = true;
179
+ }
180
+ if (value == null || !value && is_boolean) return "";
181
+ const normalized = has_own_property.call(replacements, name) && replacements[name].get(value) || value;
182
+ const assignment = is_boolean ? `=""` : `="${escape_html(normalized, true)}"`;
183
+ return ` ${name}${assignment}`;
184
+ }
185
+ function clsx(value) {
186
+ if (typeof value === "object") {
187
+ return clsx$1(value);
188
+ } else {
189
+ return value ?? "";
190
+ }
191
+ }
192
+ const whitespace = [..." \n\r\f \v\uFEFF"];
193
+ function to_class(value, hash, directives) {
194
+ var classname = value == null ? "" : "" + value;
195
+ if (hash) {
196
+ classname = classname ? classname + " " + hash : hash;
197
+ }
198
+ if (directives) {
199
+ for (var key of Object.keys(directives)) {
200
+ if (directives[key]) {
201
+ classname = classname ? classname + " " + key : key;
202
+ } else if (classname.length) {
203
+ var len = key.length;
204
+ var a = 0;
205
+ while ((a = classname.indexOf(key, a)) >= 0) {
206
+ var b = a + len;
207
+ if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) {
208
+ classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1);
209
+ } else {
210
+ a = b;
211
+ }
212
+ }
213
+ }
214
+ }
215
+ }
216
+ return classname === "" ? null : classname;
217
+ }
218
+ function append_styles(styles, important = false) {
219
+ var separator = important ? " !important;" : ";";
220
+ var css = "";
221
+ for (var key of Object.keys(styles)) {
222
+ var value = styles[key];
223
+ if (value != null && value !== "") {
224
+ css += " " + key + ": " + value + separator;
225
+ }
226
+ }
227
+ return css;
228
+ }
229
+ function to_css_name(name) {
230
+ if (name[0] !== "-" || name[1] !== "-") {
231
+ return name.toLowerCase();
232
+ }
233
+ return name;
234
+ }
235
+ function to_style(value, styles) {
236
+ if (styles) {
237
+ var new_style = "";
238
+ var normal_styles;
239
+ var important_styles;
240
+ if (Array.isArray(styles)) {
241
+ normal_styles = styles[0];
242
+ important_styles = styles[1];
243
+ } else {
244
+ normal_styles = styles;
245
+ }
246
+ if (value) {
247
+ value = String(value).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
248
+ var in_str = false;
249
+ var in_apo = 0;
250
+ var in_comment = false;
251
+ var reserved_names = [];
252
+ if (normal_styles) {
253
+ reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
254
+ }
255
+ if (important_styles) {
256
+ reserved_names.push(...Object.keys(important_styles).map(to_css_name));
257
+ }
258
+ var start_index = 0;
259
+ var name_index = -1;
260
+ const len = value.length;
261
+ for (var i = 0; i < len; i++) {
262
+ var c = value[i];
263
+ if (in_comment) {
264
+ if (c === "/" && value[i - 1] === "*") {
265
+ in_comment = false;
266
+ }
267
+ } else if (in_str) {
268
+ if (in_str === c) {
269
+ in_str = false;
270
+ }
271
+ } else if (c === "/" && value[i + 1] === "*") {
272
+ in_comment = true;
273
+ } else if (c === '"' || c === "'") {
274
+ in_str = c;
275
+ } else if (c === "(") {
276
+ in_apo++;
277
+ } else if (c === ")") {
278
+ in_apo--;
279
+ }
280
+ if (!in_comment && in_str === false && in_apo === 0) {
281
+ if (c === ":" && name_index === -1) {
282
+ name_index = i;
283
+ } else if (c === ";" || i === len - 1) {
284
+ if (name_index !== -1) {
285
+ var name = to_css_name(value.substring(start_index, name_index).trim());
286
+ if (!reserved_names.includes(name)) {
287
+ if (c !== ";") {
288
+ i++;
289
+ }
290
+ var property = value.substring(start_index, i).trim();
291
+ new_style += " " + property + ";";
292
+ }
293
+ }
294
+ start_index = i + 1;
295
+ name_index = -1;
296
+ }
297
+ }
298
+ }
299
+ }
300
+ if (normal_styles) {
301
+ new_style += append_styles(normal_styles);
302
+ }
303
+ if (important_styles) {
304
+ new_style += append_styles(important_styles, true);
305
+ }
306
+ new_style = new_style.trim();
307
+ return new_style === "" ? null : new_style;
308
+ }
309
+ return value == null ? null : String(value);
310
+ }
311
+ const BLOCK_OPEN = `<!--${HYDRATION_START}-->`;
312
+ const BLOCK_CLOSE = `<!--${HYDRATION_END}-->`;
313
+ const EMPTY_COMMENT = `<!---->`;
314
+ let controller = null;
315
+ function abort() {
316
+ controller?.abort(STALE_REACTION);
317
+ controller = null;
318
+ }
319
+ function await_invalid() {
320
+ const error = new Error(`await_invalid
321
+ Encountered asynchronous work while rendering synchronously.
322
+ https://svelte.dev/e/await_invalid`);
323
+ error.name = "Svelte error";
324
+ throw error;
325
+ }
326
+ function dynamic_element_invalid_tag(tag) {
327
+ const error = new Error(`dynamic_element_invalid_tag
328
+ \`<svelte:element this="${tag}">\` is not a valid element name — the element will not be rendered
329
+ https://svelte.dev/e/dynamic_element_invalid_tag`);
330
+ error.name = "Svelte error";
331
+ throw error;
332
+ }
333
+ function invalid_csp() {
334
+ const error = new Error(`invalid_csp
335
+ \`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously.
336
+ https://svelte.dev/e/invalid_csp`);
337
+ error.name = "Svelte error";
338
+ throw error;
339
+ }
340
+ function invalid_id_prefix() {
341
+ const error = new Error(`invalid_id_prefix
342
+ The \`idPrefix\` option cannot include \`--\`.
343
+ https://svelte.dev/e/invalid_id_prefix`);
344
+ error.name = "Svelte error";
345
+ throw error;
346
+ }
347
+ function server_context_required() {
348
+ const error = new Error(`server_context_required
349
+ Could not resolve \`render\` context.
350
+ https://svelte.dev/e/server_context_required`);
351
+ error.name = "Svelte error";
352
+ throw error;
353
+ }
354
+ var ssr_context = null;
355
+ function set_ssr_context(v) {
356
+ ssr_context = v;
357
+ }
358
+ function getContext(key) {
359
+ const context_map = get_or_init_context_map();
360
+ const result = (
361
+ /** @type {T} */
362
+ context_map.get(key)
363
+ );
364
+ return result;
365
+ }
366
+ function setContext(key, context) {
367
+ get_or_init_context_map().set(key, context);
368
+ return context;
369
+ }
370
+ function get_or_init_context_map(name) {
371
+ if (ssr_context === null) {
372
+ lifecycle_outside_component();
373
+ }
374
+ return ssr_context.c ??= new Map(get_parent_context(ssr_context) || void 0);
375
+ }
376
+ function push(fn) {
377
+ ssr_context = { p: ssr_context, c: null, r: null };
378
+ }
379
+ function pop() {
380
+ ssr_context = /** @type {SSRContext} */
381
+ ssr_context.p;
382
+ }
383
+ function get_parent_context(ssr_context2) {
384
+ let parent = ssr_context2.p;
385
+ while (parent !== null) {
386
+ const context_map = parent.c;
387
+ if (context_map !== null) {
388
+ return context_map;
389
+ }
390
+ parent = parent.p;
391
+ }
392
+ return null;
393
+ }
394
+ function unresolved_hydratable(key, stack) {
395
+ {
396
+ console.warn(`https://svelte.dev/e/unresolved_hydratable`);
397
+ }
398
+ }
399
+ function get_render_context() {
400
+ const store = als?.getStore();
401
+ {
402
+ server_context_required();
403
+ }
404
+ return store;
405
+ }
406
+ let als = null;
407
+ let text_encoder;
408
+ let crypto;
409
+ const obfuscated_import = (module_name) => import(
410
+ /* @vite-ignore */
411
+ module_name
412
+ );
413
+ async function sha256(data) {
414
+ text_encoder ??= new TextEncoder();
415
+ crypto ??= globalThis.crypto?.subtle?.digest ? globalThis.crypto : (
416
+ // @ts-ignore - we don't install node types in the prod build
417
+ // don't use import('node:crypto') directly because static analysers will think we rely on node when we don't
418
+ (await obfuscated_import("node:crypto")).webcrypto
419
+ );
420
+ const hash_buffer = await crypto.subtle.digest("SHA-256", text_encoder.encode(data));
421
+ return base64_encode(hash_buffer);
422
+ }
423
+ function base64_encode(bytes) {
424
+ if (globalThis.Buffer) {
425
+ return globalThis.Buffer.from(bytes).toString("base64");
426
+ }
427
+ let binary = "";
428
+ for (let i = 0; i < bytes.length; i++) {
429
+ binary += String.fromCharCode(bytes[i]);
430
+ }
431
+ return btoa(binary);
432
+ }
433
+ class Renderer {
434
+ /**
435
+ * The contents of the renderer.
436
+ * @type {RendererItem[]}
437
+ */
438
+ #out = [];
439
+ /**
440
+ * Any `onDestroy` callbacks registered during execution of this renderer.
441
+ * @type {(() => void)[] | undefined}
442
+ */
443
+ #on_destroy = void 0;
444
+ /**
445
+ * Whether this renderer is a component body.
446
+ * @type {boolean}
447
+ */
448
+ #is_component_body = false;
449
+ /**
450
+ * If set, this renderer is an error boundary. When async collection
451
+ * of the children fails, the failed snippet is rendered instead.
452
+ * @type {{
453
+ * failed: (renderer: Renderer, error: unknown, reset: () => void) => void;
454
+ * transformError: (error: unknown) => unknown;
455
+ * context: SSRContext | null;
456
+ * } | null}
457
+ */
458
+ #boundary = null;
459
+ /**
460
+ * The type of string content that this renderer is accumulating.
461
+ * @type {RendererType}
462
+ */
463
+ type;
464
+ /** @type {Renderer | undefined} */
465
+ #parent;
466
+ /**
467
+ * Asynchronous work associated with this renderer
468
+ * @type {Promise<void> | undefined}
469
+ */
470
+ promise = void 0;
471
+ /**
472
+ * State which is associated with the content tree as a whole.
473
+ * It will be re-exposed, uncopied, on all children.
474
+ * @type {SSRState}
475
+ * @readonly
476
+ */
477
+ global;
478
+ /**
479
+ * State that is local to the branch it is declared in.
480
+ * It will be shallow-copied to all children.
481
+ *
482
+ * @type {{ select_value: string | undefined }}
483
+ */
484
+ local;
485
+ /**
486
+ * @param {SSRState} global
487
+ * @param {Renderer | undefined} [parent]
488
+ */
489
+ constructor(global, parent) {
490
+ this.#parent = parent;
491
+ this.global = global;
492
+ this.local = parent ? { ...parent.local } : { select_value: void 0 };
493
+ this.type = parent ? parent.type : "body";
494
+ }
495
+ /**
496
+ * @param {(renderer: Renderer) => void} fn
497
+ */
498
+ head(fn) {
499
+ const head2 = new Renderer(this.global, this);
500
+ head2.type = "head";
501
+ this.#out.push(head2);
502
+ head2.child(fn);
503
+ }
504
+ /**
505
+ * @param {Array<Promise<void>>} blockers
506
+ * @param {(renderer: Renderer) => void} fn
507
+ */
508
+ async_block(blockers, fn) {
509
+ this.#out.push(BLOCK_OPEN);
510
+ this.async(blockers, fn);
511
+ this.#out.push(BLOCK_CLOSE);
512
+ }
513
+ /**
514
+ * @param {Array<Promise<void>>} blockers
515
+ * @param {(renderer: Renderer) => void} fn
516
+ */
517
+ async(blockers, fn) {
518
+ let callback = fn;
519
+ if (blockers.length > 0) {
520
+ const context = ssr_context;
521
+ callback = (renderer) => {
522
+ return Promise.all(blockers).then(() => {
523
+ const previous_context = ssr_context;
524
+ try {
525
+ set_ssr_context(context);
526
+ return fn(renderer);
527
+ } finally {
528
+ set_ssr_context(previous_context);
529
+ }
530
+ });
531
+ };
532
+ }
533
+ this.child(callback);
534
+ }
535
+ /**
536
+ * @param {Array<() => void>} thunks
537
+ */
538
+ run(thunks) {
539
+ const context = ssr_context;
540
+ let promise = Promise.resolve(thunks[0]());
541
+ const promises = [promise];
542
+ for (const fn of thunks.slice(1)) {
543
+ promise = promise.then(() => {
544
+ const previous_context = ssr_context;
545
+ set_ssr_context(context);
546
+ try {
547
+ return fn();
548
+ } finally {
549
+ set_ssr_context(previous_context);
550
+ }
551
+ });
552
+ promises.push(promise);
553
+ }
554
+ promise.catch(noop);
555
+ this.promise = promise;
556
+ return promises;
557
+ }
558
+ /**
559
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
560
+ */
561
+ child_block(fn) {
562
+ this.#out.push(BLOCK_OPEN);
563
+ this.child(fn);
564
+ this.#out.push(BLOCK_CLOSE);
565
+ }
566
+ /**
567
+ * Create a child renderer. The child renderer inherits the state from the parent,
568
+ * but has its own content.
569
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
570
+ */
571
+ child(fn) {
572
+ const child = new Renderer(this.global, this);
573
+ this.#out.push(child);
574
+ const parent = ssr_context;
575
+ set_ssr_context({
576
+ ...ssr_context,
577
+ p: parent,
578
+ c: null,
579
+ r: child
580
+ });
581
+ const result = fn(child);
582
+ set_ssr_context(parent);
583
+ if (result instanceof Promise) {
584
+ result.catch(noop);
585
+ result.finally(() => set_ssr_context(null)).catch(noop);
586
+ if (child.global.mode === "sync") {
587
+ await_invalid();
588
+ }
589
+ child.promise = result;
590
+ }
591
+ return child;
592
+ }
593
+ /**
594
+ * Render children inside an error boundary. If the children throw and the API-level
595
+ * `transformError` transform handles the error (doesn't re-throw), the `failed` snippet is
596
+ * rendered instead. Otherwise the error propagates.
597
+ *
598
+ * @param {{ failed?: (renderer: Renderer, error: unknown, reset: () => void) => void }} props
599
+ * @param {(renderer: Renderer) => MaybePromise<void>} children_fn
600
+ */
601
+ boundary(props, children_fn) {
602
+ const child = new Renderer(this.global, this);
603
+ this.#out.push(child);
604
+ const parent_context = ssr_context;
605
+ if (props.failed) {
606
+ child.#boundary = {
607
+ failed: props.failed,
608
+ transformError: this.global.transformError,
609
+ context: parent_context
610
+ };
611
+ }
612
+ set_ssr_context({
613
+ ...ssr_context,
614
+ p: parent_context,
615
+ c: null,
616
+ r: child
617
+ });
618
+ try {
619
+ const result = children_fn(child);
620
+ set_ssr_context(parent_context);
621
+ if (result instanceof Promise) {
622
+ if (child.global.mode === "sync") {
623
+ await_invalid();
624
+ }
625
+ result.catch(noop);
626
+ child.promise = result;
627
+ }
628
+ } catch (error) {
629
+ set_ssr_context(parent_context);
630
+ const failed_snippet = props.failed;
631
+ if (!failed_snippet) throw error;
632
+ const result = this.global.transformError(error);
633
+ child.#out.length = 0;
634
+ child.#boundary = null;
635
+ if (result instanceof Promise) {
636
+ if (this.global.mode === "sync") {
637
+ await_invalid();
638
+ }
639
+ child.promise = /** @type {Promise<unknown>} */
640
+ result.then((transformed) => {
641
+ set_ssr_context(parent_context);
642
+ child.#out.push(Renderer.#serialize_failed_boundary(transformed));
643
+ failed_snippet(child, transformed, noop);
644
+ child.#out.push(BLOCK_CLOSE);
645
+ });
646
+ child.promise.catch(noop);
647
+ } else {
648
+ child.#out.push(Renderer.#serialize_failed_boundary(result));
649
+ failed_snippet(child, result, noop);
650
+ child.#out.push(BLOCK_CLOSE);
651
+ }
652
+ }
653
+ }
654
+ /**
655
+ * Create a component renderer. The component renderer inherits the state from the parent,
656
+ * but has its own content. It is treated as an ordering boundary for ondestroy callbacks.
657
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
658
+ * @param {Function} [component_fn]
659
+ * @returns {void}
660
+ */
661
+ component(fn, component_fn) {
662
+ push();
663
+ const child = this.child(fn);
664
+ child.#is_component_body = true;
665
+ pop();
666
+ }
667
+ /**
668
+ * @param {Record<string, any>} attrs
669
+ * @param {(renderer: Renderer) => void} fn
670
+ * @param {string | undefined} [css_hash]
671
+ * @param {Record<string, boolean> | undefined} [classes]
672
+ * @param {Record<string, string> | undefined} [styles]
673
+ * @param {number | undefined} [flags]
674
+ * @param {boolean | undefined} [is_rich]
675
+ * @returns {void}
676
+ */
677
+ select(attrs, fn, css_hash, classes, styles, flags, is_rich) {
678
+ const { value, ...select_attrs } = attrs;
679
+ this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags)}>`);
680
+ this.child((renderer) => {
681
+ renderer.local.select_value = value;
682
+ fn(renderer);
683
+ });
684
+ this.push(`${is_rich ? "<!>" : ""}</select>`);
685
+ }
686
+ /**
687
+ * @param {Record<string, any>} attrs
688
+ * @param {string | number | boolean | ((renderer: Renderer) => void)} body
689
+ * @param {string | undefined} [css_hash]
690
+ * @param {Record<string, boolean> | undefined} [classes]
691
+ * @param {Record<string, string> | undefined} [styles]
692
+ * @param {number | undefined} [flags]
693
+ * @param {boolean | undefined} [is_rich]
694
+ */
695
+ option(attrs, body, css_hash, classes, styles, flags, is_rich) {
696
+ this.#out.push(`<option${attributes(attrs, css_hash, classes, styles, flags)}`);
697
+ const close = (renderer, value, { head: head2, body: body2 }) => {
698
+ if (has_own_property.call(attrs, "value")) {
699
+ value = attrs.value;
700
+ }
701
+ if (value === this.local.select_value) {
702
+ renderer.#out.push(' selected=""');
703
+ }
704
+ renderer.#out.push(`>${body2}${is_rich ? "<!>" : ""}</option>`);
705
+ if (head2) {
706
+ renderer.head((child) => child.push(head2));
707
+ }
708
+ };
709
+ if (typeof body === "function") {
710
+ this.child((renderer) => {
711
+ const r = new Renderer(this.global, this);
712
+ body(r);
713
+ if (this.global.mode === "async") {
714
+ return r.#collect_content_async().then((content) => {
715
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
716
+ });
717
+ } else {
718
+ const content = r.#collect_content();
719
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
720
+ }
721
+ });
722
+ } else {
723
+ close(this, body, { body: escape_html(body) });
724
+ }
725
+ }
726
+ /**
727
+ * @param {(renderer: Renderer) => void} fn
728
+ */
729
+ title(fn) {
730
+ const path = this.get_path();
731
+ const close = (head2) => {
732
+ this.global.set_title(head2, path);
733
+ };
734
+ this.child((renderer) => {
735
+ const r = new Renderer(renderer.global, renderer);
736
+ fn(r);
737
+ if (renderer.global.mode === "async") {
738
+ return r.#collect_content_async().then((content) => {
739
+ close(content.head);
740
+ });
741
+ } else {
742
+ const content = r.#collect_content();
743
+ close(content.head);
744
+ }
745
+ });
746
+ }
747
+ /**
748
+ * @param {string | (() => Promise<string>)} content
749
+ */
750
+ push(content) {
751
+ if (typeof content === "function") {
752
+ this.child(async (renderer) => renderer.push(await content()));
753
+ } else {
754
+ this.#out.push(content);
755
+ }
756
+ }
757
+ /**
758
+ * @param {() => void} fn
759
+ */
760
+ on_destroy(fn) {
761
+ (this.#on_destroy ??= []).push(fn);
762
+ }
763
+ /**
764
+ * @returns {number[]}
765
+ */
766
+ get_path() {
767
+ return this.#parent ? [...this.#parent.get_path(), this.#parent.#out.indexOf(this)] : [];
768
+ }
769
+ /**
770
+ * @deprecated this is needed for legacy component bindings
771
+ */
772
+ copy() {
773
+ const copy = new Renderer(this.global, this.#parent);
774
+ copy.#out = this.#out.map((item) => item instanceof Renderer ? item.copy() : item);
775
+ copy.promise = this.promise;
776
+ return copy;
777
+ }
778
+ /**
779
+ * @param {Renderer} other
780
+ * @deprecated this is needed for legacy component bindings
781
+ */
782
+ subsume(other) {
783
+ if (this.global.mode !== other.global.mode) {
784
+ throw new Error(
785
+ "invariant: A renderer cannot switch modes. If you're seeing this, there's a compiler bug. File an issue!"
786
+ );
787
+ }
788
+ this.local = other.local;
789
+ this.#out = other.#out.map((item, i) => {
790
+ const current = this.#out[i];
791
+ if (current instanceof Renderer && item instanceof Renderer) {
792
+ current.subsume(item);
793
+ return current;
794
+ }
795
+ return item;
796
+ });
797
+ this.promise = other.promise;
798
+ this.type = other.type;
799
+ }
800
+ get length() {
801
+ return this.#out.length;
802
+ }
803
+ /**
804
+ * Creates the hydration comment that marks the start of a failed boundary.
805
+ * The error is JSON-serialized and embedded inside an HTML comment for the client
806
+ * to parse during hydration. The JSON is escaped to prevent `-->` or `<!--` sequences
807
+ * from breaking out of the comment (XSS). Uses unicode escapes which `JSON.parse()`
808
+ * handles transparently.
809
+ * @param {unknown} error
810
+ * @returns {string}
811
+ */
812
+ static #serialize_failed_boundary(error) {
813
+ var json = JSON.stringify(error);
814
+ var escaped = json.replace(/>/g, "\\u003e").replace(/</g, "\\u003c");
815
+ return `<!--${HYDRATION_START_FAILED}${escaped}-->`;
816
+ }
817
+ /**
818
+ * Only available on the server and when compiling with the `server` option.
819
+ * 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.
820
+ * @template {Record<string, any>} Props
821
+ * @param {Component<Props>} component
822
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} [options]
823
+ * @returns {RenderOutput}
824
+ */
825
+ static render(component, options = {}) {
826
+ let sync;
827
+ const result = (
828
+ /** @type {RenderOutput} */
829
+ {}
830
+ );
831
+ Object.defineProperties(result, {
832
+ html: {
833
+ get: () => {
834
+ return (sync ??= Renderer.#render(component, options)).body;
835
+ }
836
+ },
837
+ head: {
838
+ get: () => {
839
+ return (sync ??= Renderer.#render(component, options)).head;
840
+ }
841
+ },
842
+ body: {
843
+ get: () => {
844
+ return (sync ??= Renderer.#render(component, options)).body;
845
+ }
846
+ },
847
+ hashes: {
848
+ value: {
849
+ script: ""
850
+ }
851
+ },
852
+ then: {
853
+ value: (
854
+ /**
855
+ * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
856
+ *
857
+ * @template TResult1
858
+ * @template [TResult2=never]
859
+ * @param { (value: SyncRenderOutput) => TResult1 } onfulfilled
860
+ * @param { (reason: unknown) => TResult2 } onrejected
861
+ */
862
+ (onfulfilled, onrejected) => {
863
+ {
864
+ const result2 = sync ??= Renderer.#render(component, options);
865
+ const user_result = onfulfilled({
866
+ head: result2.head,
867
+ body: result2.body,
868
+ html: result2.body,
869
+ hashes: { script: [] }
870
+ });
871
+ return Promise.resolve(user_result);
872
+ }
873
+ }
874
+ )
875
+ }
876
+ });
877
+ return result;
878
+ }
879
+ /**
880
+ * Collect all of the `onDestroy` callbacks registered during rendering. In an async context, this is only safe to call
881
+ * after awaiting `collect_async`.
882
+ *
883
+ * Child renderers are "porous" and don't affect execution order, but component body renderers
884
+ * create ordering boundaries. Within a renderer, callbacks run in order until hitting a component boundary.
885
+ * @returns {Iterable<() => void>}
886
+ */
887
+ *#collect_on_destroy() {
888
+ for (const component of this.#traverse_components()) {
889
+ yield* component.#collect_ondestroy();
890
+ }
891
+ }
892
+ /**
893
+ * Performs a depth-first search of renderers, yielding the deepest components first, then additional components as we backtrack up the tree.
894
+ * @returns {Iterable<Renderer>}
895
+ */
896
+ *#traverse_components() {
897
+ for (const child of this.#out) {
898
+ if (typeof child !== "string") {
899
+ yield* child.#traverse_components();
900
+ }
901
+ }
902
+ if (this.#is_component_body) {
903
+ yield this;
904
+ }
905
+ }
906
+ /**
907
+ * @returns {Iterable<() => void>}
908
+ */
909
+ *#collect_ondestroy() {
910
+ if (this.#on_destroy) {
911
+ for (const fn of this.#on_destroy) {
912
+ yield fn;
913
+ }
914
+ }
915
+ for (const child of this.#out) {
916
+ if (child instanceof Renderer && !child.#is_component_body) {
917
+ yield* child.#collect_ondestroy();
918
+ }
919
+ }
920
+ }
921
+ /**
922
+ * Render a component. Throws if any of the children are performing asynchronous work.
923
+ *
924
+ * @template {Record<string, any>} Props
925
+ * @param {Component<Props>} component
926
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string }} options
927
+ * @returns {AccumulatedContent}
928
+ */
929
+ static #render(component, options) {
930
+ var previous_context = ssr_context;
931
+ try {
932
+ const renderer = Renderer.#open_render("sync", component, options);
933
+ const content = renderer.#collect_content();
934
+ return Renderer.#close_render(content, renderer);
935
+ } finally {
936
+ abort();
937
+ set_ssr_context(previous_context);
938
+ }
939
+ }
940
+ /**
941
+ * Render a component.
942
+ *
943
+ * @template {Record<string, any>} Props
944
+ * @param {Component<Props>} component
945
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
946
+ * @returns {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>}
947
+ */
948
+ static async #render_async(component, options) {
949
+ const previous_context = ssr_context;
950
+ try {
951
+ const renderer = Renderer.#open_render("async", component, options);
952
+ const content = await renderer.#collect_content_async();
953
+ const hydratables = await renderer.#collect_hydratables();
954
+ if (hydratables !== null) {
955
+ content.head = hydratables + content.head;
956
+ }
957
+ return Renderer.#close_render(content, renderer);
958
+ } finally {
959
+ set_ssr_context(previous_context);
960
+ abort();
961
+ }
962
+ }
963
+ /**
964
+ * Collect all of the code from the `out` array and return it as a string, or a promise resolving to a string.
965
+ * @param {AccumulatedContent} content
966
+ * @returns {AccumulatedContent}
967
+ */
968
+ #collect_content(content = { head: "", body: "" }) {
969
+ for (const item of this.#out) {
970
+ if (typeof item === "string") {
971
+ content[this.type] += item;
972
+ } else if (item instanceof Renderer) {
973
+ item.#collect_content(content);
974
+ }
975
+ }
976
+ return content;
977
+ }
978
+ /**
979
+ * Collect all of the code from the `out` array and return it as a string.
980
+ * @param {AccumulatedContent} content
981
+ * @returns {Promise<AccumulatedContent>}
982
+ */
983
+ async #collect_content_async(content = { head: "", body: "" }) {
984
+ await this.promise;
985
+ for (const item of this.#out) {
986
+ if (typeof item === "string") {
987
+ content[this.type] += item;
988
+ } else if (item instanceof Renderer) {
989
+ if (item.#boundary) {
990
+ const boundary_content = { head: "", body: "" };
991
+ try {
992
+ await item.#collect_content_async(boundary_content);
993
+ content.head += boundary_content.head;
994
+ content.body += boundary_content.body;
995
+ } catch (error) {
996
+ const { context, failed, transformError } = item.#boundary;
997
+ set_ssr_context(context);
998
+ let promise = transformError(error);
999
+ set_ssr_context(null);
1000
+ let transformed = await promise;
1001
+ set_ssr_context(context);
1002
+ const failed_renderer = new Renderer(item.global, item);
1003
+ failed_renderer.type = item.type;
1004
+ failed_renderer.#out.push(Renderer.#serialize_failed_boundary(transformed));
1005
+ failed(failed_renderer, transformed, noop);
1006
+ failed_renderer.#out.push(BLOCK_CLOSE);
1007
+ await failed_renderer.#collect_content_async(content);
1008
+ }
1009
+ } else {
1010
+ await item.#collect_content_async(content);
1011
+ }
1012
+ }
1013
+ }
1014
+ return content;
1015
+ }
1016
+ async #collect_hydratables() {
1017
+ const ctx = get_render_context().hydratable;
1018
+ for (const [_, key] of ctx.unresolved_promises) {
1019
+ unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? "<missing stack trace>");
1020
+ }
1021
+ for (const comparison of ctx.comparisons) {
1022
+ await comparison;
1023
+ }
1024
+ return await this.#hydratable_block(ctx);
1025
+ }
1026
+ /**
1027
+ * @template {Record<string, any>} Props
1028
+ * @param {'sync' | 'async'} mode
1029
+ * @param {import('svelte').Component<Props>} component
1030
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp; transformError?: (error: unknown) => unknown }} options
1031
+ * @returns {Renderer}
1032
+ */
1033
+ static #open_render(mode, component, options) {
1034
+ if (options.idPrefix?.includes("--")) {
1035
+ invalid_id_prefix();
1036
+ }
1037
+ var previous_context = ssr_context;
1038
+ try {
1039
+ const renderer = new Renderer(
1040
+ new SSRState(
1041
+ mode,
1042
+ options.idPrefix ? options.idPrefix + "-" : "",
1043
+ options.csp,
1044
+ options.transformError
1045
+ )
1046
+ );
1047
+ const context = { p: null, c: options.context ?? null, r: renderer };
1048
+ set_ssr_context(context);
1049
+ renderer.push(BLOCK_OPEN);
1050
+ component(renderer, options.props ?? {});
1051
+ renderer.push(BLOCK_CLOSE);
1052
+ return renderer;
1053
+ } finally {
1054
+ set_ssr_context(previous_context);
1055
+ }
1056
+ }
1057
+ /**
1058
+ * @param {AccumulatedContent} content
1059
+ * @param {Renderer} renderer
1060
+ * @returns {AccumulatedContent & { hashes: { script: Sha256Source[] } }}
1061
+ */
1062
+ static #close_render(content, renderer) {
1063
+ for (const cleanup of renderer.#collect_on_destroy()) {
1064
+ cleanup();
1065
+ }
1066
+ let head2 = content.head + renderer.global.get_title();
1067
+ let body = content.body;
1068
+ for (const { hash, code } of renderer.global.css) {
1069
+ head2 += `<style id="${hash}">${code}</style>`;
1070
+ }
1071
+ return {
1072
+ head: head2,
1073
+ body,
1074
+ hashes: {
1075
+ script: renderer.global.csp.script_hashes
1076
+ }
1077
+ };
1078
+ }
1079
+ /**
1080
+ * @param {HydratableContext} ctx
1081
+ */
1082
+ async #hydratable_block(ctx) {
1083
+ if (ctx.lookup.size === 0) {
1084
+ return null;
1085
+ }
1086
+ let entries = [];
1087
+ let has_promises = false;
1088
+ for (const [k, v] of ctx.lookup) {
1089
+ if (v.promises) {
1090
+ has_promises = true;
1091
+ for (const p of v.promises) await p;
1092
+ }
1093
+ entries.push(`[${uneval(k)},${v.serialized}]`);
1094
+ }
1095
+ let prelude = `const h = (window.__svelte ??= {}).h ??= new Map();`;
1096
+ if (has_promises) {
1097
+ prelude = `const r = (v) => Promise.resolve(v);
1098
+ ${prelude}`;
1099
+ }
1100
+ const body = `
1101
+ {
1102
+ ${prelude}
1103
+
1104
+ for (const [k, v] of [
1105
+ ${entries.join(",\n ")}
1106
+ ]) {
1107
+ h.set(k, v);
1108
+ }
1109
+ }
1110
+ `;
1111
+ let csp_attr = "";
1112
+ if (this.global.csp.nonce) {
1113
+ csp_attr = ` nonce="${this.global.csp.nonce}"`;
1114
+ } else if (this.global.csp.hash) {
1115
+ const hash = await sha256(body);
1116
+ this.global.csp.script_hashes.push(`sha256-${hash}`);
1117
+ }
1118
+ return `
1119
+ <script${csp_attr}>${body}<\/script>`;
1120
+ }
1121
+ }
1122
+ class SSRState {
1123
+ /** @readonly @type {Csp & { script_hashes: Sha256Source[] }} */
1124
+ csp;
1125
+ /** @readonly @type {'sync' | 'async'} */
1126
+ mode;
1127
+ /** @readonly @type {() => string} */
1128
+ uid;
1129
+ /** @readonly @type {Set<{ hash: string; code: string }>} */
1130
+ css = /* @__PURE__ */ new Set();
1131
+ /**
1132
+ * `transformError` passed to `render`. Called when an error boundary catches an error.
1133
+ * Throws by default if unset in `render`.
1134
+ * @type {(error: unknown) => unknown}
1135
+ */
1136
+ transformError;
1137
+ /** @type {{ path: number[], value: string }} */
1138
+ #title = { path: [], value: "" };
1139
+ /**
1140
+ * @param {'sync' | 'async'} mode
1141
+ * @param {string} id_prefix
1142
+ * @param {Csp} csp
1143
+ * @param {((error: unknown) => unknown) | undefined} [transformError]
1144
+ */
1145
+ constructor(mode, id_prefix = "", csp = { hash: false }, transformError) {
1146
+ this.mode = mode;
1147
+ this.csp = { ...csp, script_hashes: [] };
1148
+ this.transformError = transformError ?? ((error) => {
1149
+ throw error;
1150
+ });
1151
+ let uid = 1;
1152
+ this.uid = () => `${id_prefix}s${uid++}`;
1153
+ }
1154
+ get_title() {
1155
+ return this.#title.value;
1156
+ }
1157
+ /**
1158
+ * Performs a depth-first (lexicographic) comparison using the path. Rejects sets
1159
+ * from earlier than or equal to the current value.
1160
+ * @param {string} value
1161
+ * @param {number[]} path
1162
+ */
1163
+ set_title(value, path) {
1164
+ const current = this.#title.path;
1165
+ let i = 0;
1166
+ let l = Math.min(path.length, current.length);
1167
+ while (i < l && path[i] === current[i]) i += 1;
1168
+ if (path[i] === void 0) return;
1169
+ if (current[i] === void 0 || path[i] > current[i]) {
1170
+ this.#title.path = path;
1171
+ this.#title.value = value;
1172
+ }
1173
+ }
1174
+ }
1175
+ const 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;
1176
+ function element(renderer, tag, attributes_fn = noop, children_fn = noop) {
1177
+ renderer.push("<!---->");
1178
+ if (tag) {
1179
+ if (!REGEX_VALID_TAG_NAME.test(tag)) {
1180
+ dynamic_element_invalid_tag(tag);
1181
+ }
1182
+ renderer.push(`<${tag}`);
1183
+ attributes_fn();
1184
+ renderer.push(`>`);
1185
+ if (!is_void(tag)) {
1186
+ children_fn();
1187
+ if (!is_raw_text_element(tag)) {
1188
+ renderer.push(EMPTY_COMMENT);
1189
+ }
1190
+ renderer.push(`</${tag}>`);
1191
+ }
1192
+ }
1193
+ renderer.push("<!---->");
1194
+ }
1195
+ function render(component, options = {}) {
1196
+ if (options.csp?.hash && options.csp.nonce) {
1197
+ invalid_csp();
1198
+ }
1199
+ return Renderer.render(
1200
+ /** @type {Component<Props>} */
1201
+ component,
1202
+ options
1203
+ );
1204
+ }
1205
+ function head(hash, renderer, fn) {
1206
+ renderer.head((renderer2) => {
1207
+ renderer2.push(`<!--${hash}-->`);
1208
+ renderer2.child(fn);
1209
+ renderer2.push(EMPTY_COMMENT);
1210
+ });
1211
+ }
1212
+ function attributes(attrs, css_hash, classes, styles, flags = 0) {
1213
+ if (styles) {
1214
+ attrs.style = to_style(attrs.style, styles);
1215
+ }
1216
+ if (attrs.class) {
1217
+ attrs.class = clsx(attrs.class);
1218
+ }
1219
+ if (css_hash || classes) {
1220
+ attrs.class = to_class(attrs.class, css_hash, classes);
1221
+ }
1222
+ let attr_str = "";
1223
+ let name;
1224
+ const is_html = (flags & ELEMENT_IS_NAMESPACED) === 0;
1225
+ const lowercase = (flags & ELEMENT_PRESERVE_ATTRIBUTE_CASE) === 0;
1226
+ const is_input = (flags & ELEMENT_IS_INPUT) !== 0;
1227
+ for (name of Object.keys(attrs)) {
1228
+ if (typeof attrs[name] === "function") continue;
1229
+ if (name[0] === "$" && name[1] === "$") continue;
1230
+ if (name === "" || INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
1231
+ var value = attrs[name];
1232
+ var lower = name.toLowerCase();
1233
+ if (lowercase) name = lower;
1234
+ if (lower.length > 2 && lower.startsWith("on")) continue;
1235
+ if (is_input) {
1236
+ if (name === "defaultvalue" || name === "defaultchecked") {
1237
+ name = name === "defaultvalue" ? "value" : "checked";
1238
+ if (attrs[name]) continue;
1239
+ }
1240
+ }
1241
+ attr_str += attr(name, value, is_html && is_boolean_attribute(name));
1242
+ }
1243
+ return attr_str;
1244
+ }
1245
+ function spread_props(props) {
1246
+ const merged_props = {};
1247
+ let key;
1248
+ for (let i = 0; i < props.length; i++) {
1249
+ const obj = props[i];
1250
+ if (obj == null) continue;
1251
+ for (key of Object.keys(obj)) {
1252
+ const desc = Object.getOwnPropertyDescriptor(obj, key);
1253
+ if (desc) {
1254
+ Object.defineProperty(merged_props, key, desc);
1255
+ } else {
1256
+ merged_props[key] = obj[key];
1257
+ }
1258
+ }
1259
+ }
1260
+ return merged_props;
1261
+ }
1262
+ function attr_class(value, hash, directives) {
1263
+ var result = to_class(value, hash, directives);
1264
+ return result ? ` class="${escape_html(result, true)}"` : "";
1265
+ }
1266
+ function attr_style(value, directives) {
1267
+ var result = to_style(value, directives);
1268
+ return result ? ` style="${escape_html(result, true)}"` : "";
1269
+ }
1270
+ function bind_props(props_parent, props_now) {
1271
+ for (const key of Object.keys(props_now)) {
1272
+ const initial_value = props_parent[key];
1273
+ const value = props_now[key];
1274
+ if (initial_value === void 0 && value !== void 0 && Object.getOwnPropertyDescriptor(props_parent, key)?.set) {
1275
+ props_parent[key] = value;
1276
+ }
1277
+ }
1278
+ }
1279
+ function ensure_array_like(array_like_or_iterator) {
1280
+ if (array_like_or_iterator) {
1281
+ return array_like_or_iterator.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
1282
+ }
1283
+ return [];
1284
+ }
1285
+ function once(get_value) {
1286
+ let value = (
1287
+ /** @type {V} */
1288
+ UNINITIALIZED
1289
+ );
1290
+ return () => {
1291
+ if (value === UNINITIALIZED) {
1292
+ value = get_value();
1293
+ }
1294
+ return value;
1295
+ };
1296
+ }
1297
+ function props_id(renderer) {
1298
+ const uid = renderer.global.uid();
1299
+ renderer.push("<!--$" + uid + "-->");
1300
+ return uid;
1301
+ }
1302
+ function derived(fn) {
1303
+ const get_value = ssr_context === null ? fn : once(fn);
1304
+ let updated_value;
1305
+ return function(new_value) {
1306
+ if (arguments.length === 0) {
1307
+ return updated_value ?? get_value();
1308
+ }
1309
+ updated_value = new_value;
1310
+ return updated_value;
1311
+ };
1312
+ }
1313
+
1314
+ export { HYDRATION_START_ELSE as $, ATTRIBUTES_CACHE as A, BLOCK_EFFECT as B, CONNECTED as C, DERIVED as D, ERROR_VALUE as E, EFFECT_PRESERVED as F, EFFECT_TRANSPARENT as G, HYDRATION_START as H, INERT as I, HEAD_EFFECT as J, DESTROYING as K, LEGACY_PROPS as L, MAYBE_DIRTY as M, BOUNDARY_EFFECT as N, index_of as O, STALE_REACTION as P, noop as Q, REACTION_RAN as R, STATE_SYMBOL as S, TEXT_CACHE as T, UNINITIALIZED as U, array_from as V, WAS_MARKED as W, is_passive_event as X, setContext as Y, derived as Z, HYDRATION_END as _, COMMENT_NODE as a, HYDRATION_START_FAILED as a0, USER_EFFECT as a1, head as a2, attr as a3, escape_html as a4, getContext as a5, attr_class as a6, clsx as a7, attributes as a8, ensure_array_like as a9, bind_props as aa, element as ab, run as ac, spread_props as ad, attr_style as ae, props_id as af, HYDRATION_ERROR as b, array_prototype as c, define_property as d, DIRTY as e, CLASS_CACHE as f, get_descriptor as g, STYLE_CACHE as h, is_extensible as i, get_prototype_of as j, is_array as k, CLEAN as l, EFFECT as m, ASYNC as n, object_prototype as o, DESTROYED as p, EAGER_EFFECT as q, render as r, deferred as s, RENDER_EFFECT as t, MANAGED_EFFECT as u, ROOT_EFFECT as v, BRANCH_EFFECT as w, REACTION_IS_UPDATING as x, run_all as y, includes as z };
1315
+ //# sourceMappingURL=index.js-Di21TltP.js.map