@demiurgejs/core 0.2.0-beta.1 → 0.2.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +2 -0
  2. package/dist/adapter/testing.d.ts +33 -0
  3. package/dist/adapter/testing.d.ts.map +1 -0
  4. package/dist/adapter/testing.js +251 -0
  5. package/dist/adapter/testing.js.map +1 -0
  6. package/dist/browser/file-router.d.ts.map +1 -1
  7. package/dist/chunks/document-shell-WoM8yZlR.js +35 -0
  8. package/dist/chunks/document-shell-WoM8yZlR.js.map +1 -0
  9. package/dist/chunks/image-codec-Di53WpcH.js +141 -0
  10. package/dist/chunks/image-codec-Di53WpcH.js.map +1 -0
  11. package/dist/chunks/images-Edar3eU1.js +339 -0
  12. package/dist/chunks/images-Edar3eU1.js.map +1 -0
  13. package/dist/chunks/request-metadata-DaIYq4Ea.js +677 -0
  14. package/dist/chunks/request-metadata-DaIYq4Ea.js.map +1 -0
  15. package/dist/chunks/streaming-D0fGAuiO.js +469 -0
  16. package/dist/chunks/streaming-D0fGAuiO.js.map +1 -0
  17. package/dist/chunks/{testing-DBjVCN5v.js → testing-CRflAw4X.js} +1300 -1139
  18. package/dist/chunks/testing-CRflAw4X.js.map +1 -0
  19. package/dist/cli.d.ts.map +1 -1
  20. package/dist/cli.js +63 -54
  21. package/dist/cli.js.map +1 -1
  22. package/dist/data/cache.d.ts +8 -0
  23. package/dist/data/cache.d.ts.map +1 -1
  24. package/dist/data/idempotency.d.ts.map +1 -1
  25. package/dist/data/index.d.ts +3 -1
  26. package/dist/data/index.d.ts.map +1 -1
  27. package/dist/data/testing.d.ts.map +1 -1
  28. package/dist/data/testing.js +94 -72
  29. package/dist/data/testing.js.map +1 -1
  30. package/dist/data/tiered.d.ts +7 -0
  31. package/dist/data/tiered.d.ts.map +1 -0
  32. package/dist/document/deferred-scripts.d.ts +11 -0
  33. package/dist/document/deferred-scripts.d.ts.map +1 -0
  34. package/dist/document/hydration.d.ts.map +1 -1
  35. package/dist/document/index.d.ts +4 -1
  36. package/dist/document/index.d.ts.map +1 -1
  37. package/dist/document/render.d.ts.map +1 -1
  38. package/dist/document/scripts.d.ts +12 -1
  39. package/dist/document/scripts.d.ts.map +1 -1
  40. package/dist/document/trusted-types.d.ts +10 -0
  41. package/dist/document/trusted-types.d.ts.map +1 -0
  42. package/dist/edge/assets.d.ts +14 -0
  43. package/dist/edge/assets.d.ts.map +1 -0
  44. package/dist/edge/index.d.ts +19 -0
  45. package/dist/edge/index.d.ts.map +1 -0
  46. package/dist/edge/index.js +286 -0
  47. package/dist/edge/index.js.map +1 -0
  48. package/dist/edge/stores.d.ts +8 -0
  49. package/dist/edge/stores.d.ts.map +1 -0
  50. package/dist/edge/streaming.d.ts +7 -0
  51. package/dist/edge/streaming.d.ts.map +1 -0
  52. package/dist/index.d.ts +7 -7
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +895 -556
  55. package/dist/index.js.map +1 -1
  56. package/dist/internal/testing.js +6 -6
  57. package/dist/kv/index.d.ts +5 -0
  58. package/dist/kv/index.d.ts.map +1 -0
  59. package/dist/kv/index.js +126 -0
  60. package/dist/kv/index.js.map +1 -0
  61. package/dist/kv/rate-limit-store.d.ts +8 -0
  62. package/dist/kv/rate-limit-store.d.ts.map +1 -0
  63. package/dist/kv/store.d.ts +28 -0
  64. package/dist/kv/store.d.ts.map +1 -0
  65. package/dist/node/font.d.ts +5 -0
  66. package/dist/node/font.d.ts.map +1 -0
  67. package/dist/node/http.d.ts.map +1 -1
  68. package/dist/node/image.d.ts +15 -0
  69. package/dist/node/image.d.ts.map +1 -0
  70. package/dist/node/index.d.ts +4 -0
  71. package/dist/node/index.d.ts.map +1 -1
  72. package/dist/node/index.js +25 -23
  73. package/dist/node/index.js.map +1 -1
  74. package/dist/node/static.d.ts.map +1 -1
  75. package/dist/node/streaming.d.ts.map +1 -1
  76. package/dist/platform/analytics.d.ts +58 -5
  77. package/dist/platform/analytics.d.ts.map +1 -1
  78. package/dist/platform/font-assets.d.ts +19 -0
  79. package/dist/platform/font-assets.d.ts.map +1 -0
  80. package/dist/platform/fonts.d.ts +14 -4
  81. package/dist/platform/fonts.d.ts.map +1 -1
  82. package/dist/platform/image-codec.d.ts +15 -0
  83. package/dist/platform/image-codec.d.ts.map +1 -0
  84. package/dist/platform/image-url.d.ts +17 -0
  85. package/dist/platform/image-url.d.ts.map +1 -0
  86. package/dist/platform/image.d.ts +8 -0
  87. package/dist/platform/image.d.ts.map +1 -0
  88. package/dist/platform/images.d.ts +15 -0
  89. package/dist/platform/images.d.ts.map +1 -1
  90. package/dist/platform/index.d.ts +13 -6
  91. package/dist/platform/index.d.ts.map +1 -1
  92. package/dist/platform/observability.d.ts +2 -1
  93. package/dist/platform/observability.d.ts.map +1 -1
  94. package/dist/platform/web-vitals-client.d.ts +32 -0
  95. package/dist/platform/web-vitals-client.d.ts.map +1 -0
  96. package/dist/platform/web-vitals.d.ts +78 -0
  97. package/dist/platform/web-vitals.d.ts.map +1 -0
  98. package/dist/redis/index.d.ts +5 -0
  99. package/dist/redis/index.d.ts.map +1 -0
  100. package/dist/redis/index.js +209 -0
  101. package/dist/redis/index.js.map +1 -0
  102. package/dist/redis/rate-limit-store.d.ts +8 -0
  103. package/dist/redis/rate-limit-store.d.ts.map +1 -0
  104. package/dist/redis/store.d.ts +8 -0
  105. package/dist/redis/store.d.ts.map +1 -0
  106. package/dist/route/action.d.ts.map +1 -1
  107. package/dist/route/middleware.d.ts.map +1 -1
  108. package/dist/route/response.d.ts.map +1 -1
  109. package/dist/router/index.d.ts +1 -1
  110. package/dist/router/index.d.ts.map +1 -1
  111. package/dist/router/manifest.d.ts +1 -0
  112. package/dist/router/manifest.d.ts.map +1 -1
  113. package/dist/security/cookies.d.ts +26 -0
  114. package/dist/security/cookies.d.ts.map +1 -0
  115. package/dist/security/env.d.ts.map +1 -1
  116. package/dist/security/fetch-metadata.d.ts +29 -0
  117. package/dist/security/fetch-metadata.d.ts.map +1 -0
  118. package/dist/security/index.d.ts +5 -1
  119. package/dist/security/index.d.ts.map +1 -1
  120. package/dist/security/policy.d.ts +2 -27
  121. package/dist/security/policy.d.ts.map +1 -1
  122. package/dist/security/rate-limit.d.ts +6 -3
  123. package/dist/security/rate-limit.d.ts.map +1 -1
  124. package/dist/security/request.d.ts.map +1 -1
  125. package/dist/security/types.d.ts +82 -6
  126. package/dist/security/types.d.ts.map +1 -1
  127. package/dist/security/verification.d.ts.map +1 -1
  128. package/dist/server/document-shell.d.ts +12 -0
  129. package/dist/server/document-shell.d.ts.map +1 -0
  130. package/dist/server/index.d.ts +1 -1
  131. package/dist/server/index.d.ts.map +1 -1
  132. package/dist/server/request-handler.d.ts +6 -2
  133. package/dist/server/request-handler.d.ts.map +1 -1
  134. package/dist/static/images.d.ts +13 -0
  135. package/dist/static/images.d.ts.map +1 -0
  136. package/dist/static/index.d.ts +8 -0
  137. package/dist/static/index.d.ts.map +1 -1
  138. package/dist/static/index.js +421 -313
  139. package/dist/static/index.js.map +1 -1
  140. package/dist/static/vercel.d.ts +3 -0
  141. package/dist/static/vercel.d.ts.map +1 -1
  142. package/dist/vite/index.d.ts +3 -0
  143. package/dist/vite/index.d.ts.map +1 -1
  144. package/dist/vite/index.js +1041 -652
  145. package/dist/vite/index.js.map +1 -1
  146. package/dist/vite/plugin.d.ts +9 -0
  147. package/dist/vite/plugin.d.ts.map +1 -1
  148. package/dist/vite/policy-verification.d.ts.map +1 -1
  149. package/dist/vite/route-audit.d.ts +50 -0
  150. package/dist/vite/route-audit.d.ts.map +1 -0
  151. package/package.json +34 -3
  152. package/dist/chunks/request-metadata-DwEO1EAS.js +0 -477
  153. package/dist/chunks/request-metadata-DwEO1EAS.js.map +0 -1
  154. package/dist/chunks/streaming-Ci6vf3BB.js +0 -353
  155. package/dist/chunks/streaming-Ci6vf3BB.js.map +0 -1
  156. package/dist/chunks/testing-DBjVCN5v.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,184 +1,186 @@
1
- import { jsx as H } from "react/jsx-runtime";
2
- import { createContext as _, useState as I, useRef as T, useEffect as C, useMemo as V, createElement as f, useContext as W, Component as G } from "react";
3
- import { g as K, H as Y, h as Z, i as Q } from "./chunks/request-metadata-DwEO1EAS.js";
4
- import { j as Qt, k as Xt, l as Jt, d as er, m as tr, r as rr, n as nr } from "./chunks/request-metadata-DwEO1EAS.js";
5
- import { p as z, k as X, l as J, t as ee, n as te, R as re, o as x, q as ne, j as O, u as ae, w as L, x as ie, N as D, y as oe, z as se, A as ce, B as ue, H as le, C as fe, D as de, E as me } from "./chunks/testing-DBjVCN5v.js";
6
- import { F as ir, G as or, I as sr, J as cr, K as ur, L as lr, M as fr, O as dr, P as mr, a as hr, Q as gr, S as pr, d as wr, b as yr, T as vr, U as br, V as Er, W as Sr, X as Rr, Y as Ar, Z as $r, _ as xr, $ as kr, a0 as Ir, h as Tr, a1 as Cr, a2 as zr, a3 as Dr, a4 as Nr, a5 as Or, a6 as Lr, a7 as Mr, m as Pr, a8 as Ur, a9 as Fr, aa as jr, ab as Br, ac as qr, ad as Hr, ae as _r, af as Vr, ag as Wr, ah as Gr, ai as Kr, s as Yr, aj as Zr, ak as Qr, al as Xr, am as Jr, an as en, ao as tn, ap as rn, aq as nn, e as an, f as on, v as sn } from "./chunks/testing-DBjVCN5v.js";
1
+ import { jsx as V } from "react/jsx-runtime";
2
+ import { createContext as re, useState as F, useRef as z, useEffect as P, useMemo as ne, createElement as w, useContext as oe, Component as ae } from "react";
3
+ import { g as ie, H as se, h as U, i as ce, j as I } from "./chunks/request-metadata-DaIYq4Ea.js";
4
+ import { F as xr, k as Cr, l as Ir, m as Nr, n as Lr, d as Pr, o as Dr, q as Or, t as Mr, u as Fr, v as zr, p as Ur, a as Br, w as _r, x as jr } from "./chunks/request-metadata-DaIYq4Ea.js";
5
+ import { z as B, x as ue, A as le, B as fe, C as de, D as he, R as me, E as D, F as pe, y as W, G as ge, i as q, H as we, N as _, I as ye, J as ve, K as be, L as Se, O as Ee, P as Re, Q as Te, S as ke } from "./chunks/testing-CRflAw4X.js";
6
+ import { T as Vr, U as Wr, V as qr, W as Gr, X as Kr, Y as Jr, Z as Yr, _ as Zr, $ as Xr, a0 as Qr, a1 as en, u as tn, a2 as rn, d as nn, c as on, q as an, f as sn, e as cn, a3 as un, a4 as ln, a5 as fn, a6 as dn, a7 as hn, a8 as mn, a9 as pn, aa as gn, ab as wn, ac as yn, h as vn, ad as bn, ae as Sn, af as En, ag as Rn, ah as Tn, ai as kn, aj as An, ak as $n, m as xn, al as Cn, am as In, an as Nn, ao as Ln, ap as Pn, aq as Dn, s as On, ar as Mn, w as Fn, as as zn, at as Un, au as Bn, av as _n, aw as jn, ax as Hn, v as Vn, g as Wn, a as qn } from "./chunks/testing-CRflAw4X.js";
7
+ import { k as Ae } from "./chunks/images-Edar3eU1.js";
8
+ import { d as Kn, l as Jn, m as Yn, n as Zn, f as Xn, o as Qn, q as eo, a as to, s as ro, t as no, b as oo, h as ao, j as io, r as so } from "./chunks/images-Edar3eU1.js";
7
9
  import "react-dom/server";
8
- const he = "24h", ge = 1e4;
9
- function vt(e = {}) {
10
- const t = e.now ?? Date.now, r = e.defaultTtl ?? he, n = e.maximumEntries ?? ge;
10
+ const $e = "24h", xe = 1e4;
11
+ function Yt(e = {}) {
12
+ const t = e.now ?? Date.now, r = e.defaultTtl ?? $e, n = e.maximumEntries ?? xe;
11
13
  if (!Number.isSafeInteger(n) || n <= 0)
12
14
  throw new Error(
13
15
  "Demiurge idempotency maximumEntries must be a positive integer."
14
16
  );
15
- const a = z(r);
16
- if (!Number.isFinite(a))
17
+ const o = B(r);
18
+ if (!Number.isFinite(o))
17
19
  throw new Error("Demiurge idempotency defaultTtl must be finite.");
18
- const i = /* @__PURE__ */ new Map();
20
+ const a = /* @__PURE__ */ new Map();
19
21
  return {
20
- async run(s) {
21
- const o = X(s.key), u = t();
22
- pe(i, u);
23
- const d = i.get(o);
24
- if (d && (d.pending || d.expiresAt > u))
22
+ async run(i) {
23
+ const s = ue(i.key), l = t();
24
+ Ce(a, l);
25
+ const d = a.get(s);
26
+ if (d && (d.pending || d.expiresAt > l))
25
27
  return {
26
- key: o,
28
+ key: s,
27
29
  replayed: !0,
28
30
  value: await d.value
29
31
  };
30
- if (i.size >= n && we(i), i.size >= n)
32
+ if (a.size >= n && Ie(a), a.size >= n)
31
33
  throw new Error(
32
34
  "Demiurge idempotency store is at capacity with in-flight mutations."
33
35
  );
34
- const p = Promise.resolve().then(s.fn), c = {
36
+ const p = Promise.resolve().then(i.fn), c = {
35
37
  expiresAt: Number.POSITIVE_INFINITY,
36
38
  pending: !0,
37
39
  value: p
38
40
  };
39
- i.set(o, c);
41
+ a.set(s, c);
40
42
  try {
41
- const l = await p;
42
- return c.pending = !1, c.expiresAt = t() + z(s.ttl ?? r), {
43
- key: o,
43
+ const f = await p;
44
+ return c.pending = !1, c.expiresAt = t() + B(i.ttl ?? r), {
45
+ key: s,
44
46
  replayed: !1,
45
- value: l
47
+ value: f
46
48
  };
47
- } catch (l) {
48
- throw i.get(o) === c && i.delete(o), l;
49
+ } catch (f) {
50
+ throw a.get(s) === c && a.delete(s), f;
49
51
  }
50
52
  }
51
53
  };
52
54
  }
53
- function pe(e, t) {
55
+ function Ce(e, t) {
54
56
  for (const [r, n] of e)
55
57
  !n.pending && n.expiresAt <= t && e.delete(r);
56
58
  }
57
- function we(e) {
59
+ function Ie(e) {
58
60
  for (const [t, r] of e)
59
61
  if (!r.pending) {
60
62
  e.delete(t);
61
63
  return;
62
64
  }
63
65
  }
64
- function bt(e, t) {
66
+ function Zt(e, t) {
65
67
  return e.run(t);
66
68
  }
67
- function Et(e) {
69
+ function Xt(e) {
68
70
  return {
69
71
  entries: e
70
72
  };
71
73
  }
72
- function St(e) {
74
+ function Qt(e) {
73
75
  return [
74
76
  '<?xml version="1.0" encoding="UTF-8"?>',
75
77
  `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"${e.entries.some((r) => r.alternates?.length) ? ' xmlns:xhtml="http://www.w3.org/1999/xhtml"' : ""}>`,
76
- ...e.entries.map(ve),
78
+ ...e.entries.map(Le),
77
79
  "</urlset>",
78
80
  ""
79
81
  ].join(`
80
82
  `);
81
83
  }
82
- function Rt(e) {
84
+ function er(e) {
83
85
  return e;
84
86
  }
85
- function At(e) {
87
+ function tr(e) {
86
88
  return e;
87
89
  }
88
- function $t(e) {
90
+ function rr(e) {
89
91
  const t = [];
90
92
  for (const r of e.rules ?? []) {
91
- for (const n of b(r.userAgent))
93
+ for (const n of A(r.userAgent))
92
94
  t.push(`User-agent: ${n}`);
93
- for (const n of b(r.allow))
95
+ for (const n of A(r.allow))
94
96
  t.push(`Allow: ${n}`);
95
- for (const n of b(r.disallow))
97
+ for (const n of A(r.disallow))
96
98
  t.push(`Disallow: ${n}`);
97
99
  t.push("");
98
100
  }
99
101
  e.host && t.push(`Host: ${e.host}`);
100
- for (const r of b(e.sitemap))
102
+ for (const r of A(e.sitemap))
101
103
  t.push(`Sitemap: ${r}`);
102
104
  return `${t.join(`
103
105
  `).replace(/\n+$/, "")}
104
106
  `;
105
107
  }
106
- function ye(e) {
107
- const t = e.width ?? 1200, r = e.height ?? 630, n = e.background ?? "#101820", a = e.foreground ?? "#ffffff", i = A(e.title, 120), s = e.subtitle ? A(e.subtitle, 160) : void 0, o = e.brand ? A(e.brand, 80) : void 0;
108
- return Se(t, r), [
109
- `<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${r}" viewBox="0 0 ${t} ${r}" role="img" aria-label="${g(i)}">`,
110
- ` <rect width="100%" height="100%" fill="${g(n)}" />`,
111
- o ? ` <text x="72" y="96" fill="${g(a)}" font-family="Inter, ui-sans-serif, system-ui, sans-serif" font-size="32" font-weight="700">${w(o)}</text>` : null,
112
- ` <text x="72" y="${s ? 300 : 340}" fill="${g(a)}" font-family="Inter, ui-sans-serif, system-ui, sans-serif" font-size="76" font-weight="800">${w(i)}</text>`,
113
- s ? ` <text x="72" y="392" fill="${g(a)}" fill-opacity="0.78" font-family="Inter, ui-sans-serif, system-ui, sans-serif" font-size="38" font-weight="500">${w(s)}</text>` : null,
108
+ function Ne(e) {
109
+ const t = e.width ?? 1200, r = e.height ?? 630, n = e.background ?? "#101820", o = e.foreground ?? "#ffffff", a = N(e.title, 120), i = e.subtitle ? N(e.subtitle, 160) : void 0, s = e.brand ? N(e.brand, 80) : void 0;
110
+ return Oe(t, r), [
111
+ `<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${r}" viewBox="0 0 ${t} ${r}" role="img" aria-label="${E(a)}">`,
112
+ ` <rect width="100%" height="100%" fill="${E(n)}" />`,
113
+ s ? ` <text x="72" y="96" fill="${E(o)}" font-family="Inter, ui-sans-serif, system-ui, sans-serif" font-size="32" font-weight="700">${R(s)}</text>` : null,
114
+ ` <text x="72" y="${i ? 300 : 340}" fill="${E(o)}" font-family="Inter, ui-sans-serif, system-ui, sans-serif" font-size="76" font-weight="800">${R(a)}</text>`,
115
+ i ? ` <text x="72" y="392" fill="${E(o)}" fill-opacity="0.78" font-family="Inter, ui-sans-serif, system-ui, sans-serif" font-size="38" font-weight="500">${R(i)}</text>` : null,
114
116
  "</svg>"
115
- ].filter((u) => !!u).join(`
117
+ ].filter((l) => !!l).join(`
116
118
  `);
117
119
  }
118
- function xt(e) {
119
- return new Response(ye(e), {
120
+ function nr(e) {
121
+ return new Response(Ne(e), {
120
122
  headers: {
121
123
  "cache-control": "public, max-age=31536000, immutable",
122
124
  "content-type": "image/svg+xml; charset=utf-8"
123
125
  }
124
126
  });
125
127
  }
126
- function ve(e) {
128
+ function Le(e) {
127
129
  return [
128
130
  " <url>",
129
- ` <loc>${w(e.url)}</loc>`,
130
- e.lastModified ? ` <lastmod>${w(be(e.lastModified))}</lastmod>` : null,
131
+ ` <loc>${R(e.url)}</loc>`,
132
+ e.lastModified ? ` <lastmod>${R(Pe(e.lastModified))}</lastmod>` : null,
131
133
  e.changeFrequency ? ` <changefreq>${e.changeFrequency}</changefreq>` : null,
132
- e.priority !== void 0 ? ` <priority>${Ee(e.priority)}</priority>` : null,
134
+ e.priority !== void 0 ? ` <priority>${De(e.priority)}</priority>` : null,
133
135
  ...(e.alternates ?? []).map(
134
- (t) => ` <xhtml:link rel="alternate" hreflang="${g(t.hrefLang)}" href="${g(t.href)}" />`
136
+ (t) => ` <xhtml:link rel="alternate" hreflang="${E(t.hrefLang)}" href="${E(t.href)}" />`
135
137
  ),
136
138
  " </url>"
137
139
  ].filter((t) => !!t).join(`
138
140
  `);
139
141
  }
140
- function be(e) {
142
+ function Pe(e) {
141
143
  return e instanceof Date ? e.toISOString() : e;
142
144
  }
143
- function Ee(e) {
145
+ function De(e) {
144
146
  if (e < 0 || e > 1)
145
147
  throw new Error("Sitemap entry priority must be between 0 and 1.");
146
148
  return String(e);
147
149
  }
148
- function b(e) {
150
+ function A(e) {
149
151
  return e === void 0 ? [] : Array.isArray(e) ? e : [e];
150
152
  }
151
- function w(e) {
153
+ function R(e) {
152
154
  return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
153
155
  }
154
- function g(e) {
155
- return w(e).replaceAll('"', "&quot;").replaceAll("'", "&apos;");
156
+ function E(e) {
157
+ return R(e).replaceAll('"', "&quot;").replaceAll("'", "&apos;");
156
158
  }
157
- function A(e, t) {
159
+ function N(e, t) {
158
160
  return e.length > t ? `${e.slice(0, t - 3)}...` : e;
159
161
  }
160
- function Se(e, t) {
162
+ function Oe(e, t) {
161
163
  if (!Number.isSafeInteger(e) || e <= 0)
162
164
  throw new Error("OG image width must be a positive integer.");
163
165
  if (!Number.isSafeInteger(t) || t <= 0)
164
166
  throw new Error("OG image height must be a positive integer.");
165
167
  }
166
- function kt(e) {
167
- return J(
168
+ function or(e) {
169
+ return le(
168
170
  async (t) => {
169
171
  const r = e.input ? await e.input(t) : void 0, n = {
170
172
  ...t,
171
173
  input: r
172
- }, a = async () => await Re(
174
+ }, o = async () => await Me(
173
175
  await e.handler(n),
174
176
  t
175
177
  );
176
178
  if (!e.idempotency)
177
- return await a();
178
- const i = typeof e.idempotency.key == "function" ? e.idempotency.key(n) : e.idempotency.key;
179
+ return await o();
180
+ const a = typeof e.idempotency.key == "function" ? e.idempotency.key(n) : e.idempotency.key;
179
181
  return (await e.idempotency.store.run({
180
- fn: a,
181
- key: i,
182
+ fn: o,
183
+ key: a,
182
184
  ttl: e.idempotency.ttl
183
185
  })).value;
184
186
  },
@@ -189,7 +191,7 @@ function kt(e) {
189
191
  }
190
192
  );
191
193
  }
192
- const It = {
194
+ const ar = {
193
195
  async formData({ request: e }) {
194
196
  return await e.formData();
195
197
  },
@@ -200,10 +202,10 @@ const It = {
200
202
  return await e.text();
201
203
  }
202
204
  };
203
- async function Re(e, t) {
204
- return e instanceof Response ? e : await ee(e, t);
205
+ async function Me(e, t) {
206
+ return e instanceof Response ? e : await fe(e, t);
205
207
  }
206
- function Tt(e) {
208
+ function ir(e) {
207
209
  return typeof e == "function" ? {
208
210
  kind: "page",
209
211
  render: { mode: "ssr" },
@@ -216,10 +218,10 @@ function Tt(e) {
216
218
  view: e.view
217
219
  };
218
220
  }
219
- function Ct(e) {
221
+ function sr(e) {
220
222
  return e;
221
223
  }
222
- const zt = {
224
+ const cr = {
223
225
  hmac(e) {
224
226
  return {
225
227
  kind: "response",
@@ -227,7 +229,7 @@ const zt = {
227
229
  const r = new Uint8Array(await t.request.arrayBuffer()), n = t.request.headers.get(
228
230
  e.header ?? "x-webhook-signature"
229
231
  );
230
- return n ? await Ae(r, n, e) ? await e.handler({
232
+ return n ? await Fe(r, n, e) ? await e.handler({
231
233
  ...t,
232
234
  rawBody: r,
233
235
  text: () => new TextDecoder().decode(r)
@@ -243,15 +245,15 @@ const zt = {
243
245
  };
244
246
  }
245
247
  };
246
- async function Ae(e, t, r) {
247
- const n = r.algorithm ?? "SHA-256", a = r.encoding ?? "hex", i = $e(
248
+ async function Fe(e, t, r) {
249
+ const n = r.algorithm ?? "SHA-256", o = r.encoding ?? "hex", a = ze(
248
250
  t,
249
251
  n,
250
252
  r.prefix
251
- ), s = xe(i, a);
252
- if (!s)
253
+ ), i = Ue(a, o);
254
+ if (!i)
253
255
  return !1;
254
- const o = await globalThis.crypto.subtle.importKey(
256
+ const s = await globalThis.crypto.subtle.importKey(
255
257
  "raw",
256
258
  new TextEncoder().encode(r.secret),
257
259
  {
@@ -263,16 +265,16 @@ async function Ae(e, t, r) {
263
265
  );
264
266
  return await globalThis.crypto.subtle.verify(
265
267
  "HMAC",
266
- o,
267
268
  s,
269
+ i,
268
270
  Uint8Array.from(e).buffer
269
271
  );
270
272
  }
271
- function $e(e, t, r) {
272
- const n = e.trim(), a = r === void 0 ? `${t.toLowerCase().replace("-", "")}=` : r;
273
- return a !== !1 && n.startsWith(a) ? n.slice(a.length).trim() : n;
273
+ function ze(e, t, r) {
274
+ const n = e.trim(), o = r === void 0 ? `${t.toLowerCase().replace("-", "")}=` : r;
275
+ return o !== !1 && n.startsWith(o) ? n.slice(o.length).trim() : n;
274
276
  }
275
- function xe(e, t) {
277
+ function Ue(e, t) {
276
278
  if (t === "hex")
277
279
  return /^(?:[0-9a-f]{2})+$/i.test(e) ? Uint8Array.from(
278
280
  e.match(/.{2}/g) ?? [],
@@ -289,47 +291,110 @@ function xe(e, t) {
289
291
  return null;
290
292
  }
291
293
  }
292
- class ke extends Error {
294
+ const Be = /^[!#$%&'*+\-.^_`|~A-Za-z0-9]+$/, _e = {
295
+ host: "__Host-",
296
+ none: "",
297
+ secure: "__Secure-"
298
+ }, j = 4096;
299
+ function O(e, t = "host") {
300
+ return `${_e[t]}${e}`;
301
+ }
302
+ function je(e) {
303
+ const t = e.scope ?? "host", r = O(e.name, t), n = [], o = (a, i) => {
304
+ n.push({ code: a, message: i, name: r });
305
+ };
306
+ if (Be.test(e.name) || o(
307
+ "cookie-name-invalid",
308
+ `Cookie name ${JSON.stringify(e.name)} contains a character that a cookie name cannot hold. Use letters, digits, or the token characters that RFC 6265 allows.`
309
+ ), (e.name.startsWith("__Host-") || e.name.startsWith("__Secure-")) && o(
310
+ "cookie-name-carries-prefix",
311
+ `Cookie name ${JSON.stringify(e.name)} already carries a prefix. Remove the prefix from name and declare scope ${JSON.stringify(t === "none" ? "host" : t)} instead.`
312
+ ), t !== "none" && e.secure === !1 && o(
313
+ "cookie-scope-requires-secure",
314
+ `Cookie ${r} uses scope ${JSON.stringify(t)}, so it requires Secure. Remove secure: false, or declare scope "none" for a cookie that a browser must accept over plain HTTP.`
315
+ ), t === "host" && e.domain !== void 0 && o(
316
+ "cookie-domain-not-allowed",
317
+ `Cookie ${r} uses scope "host", so it cannot carry a Domain attribute. Remove domain, or declare scope "secure" to share the cookie with subdomains.`
318
+ ), t === "host" && e.path !== void 0 && e.path !== "/" && o(
319
+ "cookie-path-not-allowed",
320
+ `Cookie ${r} uses scope "host", so it requires Path=/. Remove path, or declare scope "secure" for a cookie that a path must limit.`
321
+ ), e.sameSite === "None" && e.secure === !1 && o(
322
+ "cookie-same-site-none-requires-secure",
323
+ `Cookie ${r} declares SameSite=None, so it requires Secure. Remove secure: false, or declare a SameSite policy of "Lax" or "Strict".`
324
+ ), e.maxAge !== void 0 && (!Number.isInteger(e.maxAge) || e.maxAge < 0) && o(
325
+ "cookie-max-age-invalid",
326
+ `Cookie ${r} declares maxAge ${JSON.stringify(e.maxAge)}. Use a whole number of seconds that is zero or greater.`
327
+ ), n.length === 0) {
328
+ const a = new TextEncoder().encode(G(e, t, r)).length;
329
+ a > j && o(
330
+ "cookie-too-large",
331
+ `Cookie ${r} serializes to ${a} bytes, and a browser drops a cookie above ${j} bytes. Store the payload on the server and keep an identifier in the cookie.`
332
+ );
333
+ }
334
+ return n;
335
+ }
336
+ function ur(e, t = "host") {
337
+ if (typeof document > "u")
338
+ return;
339
+ const r = typeof e == "string" ? { name: e, scope: t } : e;
340
+ return de(document.cookie).get(
341
+ O(r.name, r.scope ?? "host")
342
+ );
343
+ }
344
+ function lr(e) {
345
+ const t = je(e);
346
+ if (t.length > 0)
347
+ throw new Error(
348
+ `Demiurge rejected a cookie declaration. ${t.map((n) => n.message).join(" ")}`
349
+ );
350
+ const r = e.scope ?? "host";
351
+ return G(e, r, O(e.name, r));
352
+ }
353
+ function G(e, t, r) {
354
+ const n = [`${r}=${encodeURIComponent(e.value)}`], o = t === "host" ? "/" : e.path ?? "/";
355
+ return n.push(`Path=${o}`), t !== "host" && e.domain !== void 0 && n.push(`Domain=${e.domain}`), e.expires && n.push(`Expires=${e.expires.toUTCString()}`), e.maxAge !== void 0 && n.push(`Max-Age=${e.maxAge}`), n.push(`SameSite=${e.sameSite ?? "Lax"}`), (e.httpOnly ?? !0) && n.push("HttpOnly"), (t !== "none" || (e.secure ?? !0)) && n.push("Secure"), n.join("; ");
356
+ }
357
+ class He extends Error {
293
358
  issues;
294
359
  constructor(t) {
295
- super(Oe(t)), this.name = "EnvValidationError", this.issues = t;
360
+ super(Ye(t)), this.name = "EnvValidationError", this.issues = t;
296
361
  }
297
362
  }
298
- function Dt(e) {
363
+ function fr(e) {
299
364
  return e;
300
365
  }
301
- function Nt(e, t) {
366
+ function dr(e, t) {
302
367
  const r = [], n = {};
303
- for (const a of Object.keys(e)) {
304
- const i = e[a], s = t[String(a)];
305
- if (s === void 0 || s === "") {
306
- if (i.optional) {
307
- n[a] = void 0;
368
+ for (const o of Object.keys(e)) {
369
+ const a = e[o], i = t[String(o)];
370
+ if (i === void 0 || i === "") {
371
+ if (a.optional) {
372
+ n[o] = void 0;
308
373
  continue;
309
374
  }
310
375
  r.push({
311
376
  code: "missing",
312
- key: String(a),
313
- message: `Environment variable ${String(a)} is required.`
377
+ key: String(o),
378
+ message: `Environment variable ${String(o)} is required.`
314
379
  });
315
380
  continue;
316
381
  }
317
382
  try {
318
- n[a] = i.parse(String(a), s);
319
- } catch (o) {
383
+ n[o] = a.parse(String(o), i);
384
+ } catch (s) {
320
385
  r.push({
321
386
  code: "invalid",
322
- key: String(a),
323
- message: o instanceof Error ? o.message : `Environment variable ${String(a)} is invalid.`
387
+ key: String(o),
388
+ message: s instanceof Error ? s.message : `Environment variable ${String(o)} is invalid.`
324
389
  });
325
390
  }
326
391
  }
327
392
  if (r.length)
328
- throw new ke(r);
393
+ throw new He(r);
329
394
  return n;
330
395
  }
331
- function Ie(e = {}) {
332
- return y(e, !1, (t, r) => {
396
+ function Ve(e = {}) {
397
+ return T(e, !1, (t, r) => {
333
398
  if (r === "true" || r === "1")
334
399
  return !0;
335
400
  if (r === "false" || r === "0")
@@ -337,8 +402,8 @@ function Ie(e = {}) {
337
402
  throw new Error(`Environment variable ${t} must be true, false, 1, or 0.`);
338
403
  });
339
404
  }
340
- function Te(e, t = {}) {
341
- return y(t, !1, (r, n) => {
405
+ function We(e, t = {}) {
406
+ return T(t, !1, (r, n) => {
342
407
  if (e.includes(n))
343
408
  return n;
344
409
  throw new Error(
@@ -346,8 +411,8 @@ function Te(e, t = {}) {
346
411
  );
347
412
  });
348
413
  }
349
- function Ce(e = {}) {
350
- return y(e, !1, (t, r) => {
414
+ function qe(e = {}) {
415
+ return T(e, !1, (t, r) => {
351
416
  if (!/^-?\d+$/.test(r))
352
417
  throw new Error(`Environment variable ${t} must be an integer.`);
353
418
  const n = Number(r);
@@ -364,22 +429,22 @@ function Ce(e = {}) {
364
429
  return n;
365
430
  });
366
431
  }
367
- function ze(e = {}) {
368
- return y(
432
+ function Ge(e = {}) {
433
+ return T(
369
434
  e,
370
435
  !0,
371
- (t, r) => M(t, r, e)
436
+ (t, r) => K(t, r, e)
372
437
  );
373
438
  }
374
- function De(e = {}) {
375
- return y(
439
+ function Ke(e = {}) {
440
+ return T(
376
441
  e,
377
442
  !1,
378
- (t, r) => M(t, r, e)
443
+ (t, r) => K(t, r, e)
379
444
  );
380
445
  }
381
- function Ne(e = {}) {
382
- return y(e, !1, (t, r) => {
446
+ function Je(e = {}) {
447
+ return T(e, !1, (t, r) => {
383
448
  let n;
384
449
  try {
385
450
  n = new URL(r);
@@ -393,32 +458,32 @@ function Ne(e = {}) {
393
458
  return n;
394
459
  });
395
460
  }
396
- const Ot = {
397
- boolean: Ie,
398
- enum: Te,
399
- integer: Ce,
400
- secret: ze,
401
- string: De,
402
- url: Ne
461
+ const hr = {
462
+ boolean: Ve,
463
+ enum: We,
464
+ integer: qe,
465
+ secret: Ge,
466
+ string: Ke,
467
+ url: Je
403
468
  };
404
- function y(e, t, r) {
469
+ function T(e, t, r) {
405
470
  return {
406
471
  optional: e.optional ?? !1,
407
472
  parse: r,
408
473
  sensitive: t
409
474
  };
410
475
  }
411
- function M(e, t, r) {
476
+ function K(e, t, r) {
412
477
  if (r.minLength !== void 0 && t.length < r.minLength)
413
478
  throw new Error(
414
479
  `Environment variable ${e} must be at least ${r.minLength} characters.`
415
480
  );
416
481
  return t;
417
482
  }
418
- function Oe(e) {
483
+ function Ye(e) {
419
484
  return e.length === 1 ? e[0].message : `Environment validation failed with ${e.length} issues.`;
420
485
  }
421
- function Lt(e = {}) {
486
+ function mr(e = {}) {
422
487
  return async function(r) {
423
488
  if (r.method.toUpperCase() !== "POST")
424
489
  return new Response(null, {
@@ -427,25 +492,25 @@ function Lt(e = {}) {
427
492
  },
428
493
  status: 405
429
494
  });
430
- const n = Me(r);
495
+ const n = Xe(r);
431
496
  if (n)
432
497
  return n;
433
- const a = Pe(e, r);
434
- if (a)
435
- return a;
436
- e.maxBodySize !== void 0 && (r = te({ maxBodySize: e.maxBodySize }, r));
437
- let i;
498
+ const o = Qe(e, r);
499
+ if (o)
500
+ return o;
501
+ e.maxBodySize !== void 0 && (r = he({ maxBodySize: e.maxBodySize }, r));
502
+ let a;
438
503
  try {
439
- i = await r.json();
440
- } catch (o) {
441
- return o instanceof re ? new Response("Security report body too large.", { status: 413 }) : new Response("Invalid security report JSON.", {
504
+ a = await r.json();
505
+ } catch (s) {
506
+ return s instanceof me ? new Response("Security report body too large.", { status: 413 }) : new Response("Invalid security report JSON.", {
442
507
  status: 400
443
508
  });
444
509
  }
445
- const s = Ue(i);
446
- for (let o = 0; o < s.length; o += 1)
447
- await e.onReport?.(s[o], {
448
- index: o,
510
+ const i = et(a);
511
+ for (let s = 0; s < i.length; s += 1)
512
+ await e.onReport?.(i[s], {
513
+ index: s,
449
514
  request: r
450
515
  });
451
516
  return new Response(null, {
@@ -453,20 +518,20 @@ function Lt(e = {}) {
453
518
  });
454
519
  };
455
520
  }
456
- const Le = /* @__PURE__ */ new Set([
521
+ const Ze = /* @__PURE__ */ new Set([
457
522
  "application/csp-report",
458
523
  "application/reports+json"
459
524
  ]);
460
- function Me(e) {
525
+ function Xe(e) {
461
526
  const t = e.headers.get("content-type");
462
527
  if (!t)
463
528
  return null;
464
529
  const r = t.split(";", 1)[0]?.trim().toLowerCase();
465
- return r && Le.has(r) ? null : new Response("Unsupported security report Content-Type.", {
530
+ return r && Ze.has(r) ? null : new Response("Unsupported security report Content-Type.", {
466
531
  status: 415
467
532
  });
468
533
  }
469
- function Pe(e, t) {
534
+ function Qe(e, t) {
470
535
  if (e.maxBodySize === void 0)
471
536
  return null;
472
537
  const r = t.headers.get("content-length");
@@ -477,32 +542,32 @@ function Pe(e, t) {
477
542
  status: 400
478
543
  });
479
544
  const n = Number(r);
480
- return Number.isSafeInteger(n) ? n > x(e.maxBodySize) ? new Response("Security report body too large.", {
545
+ return Number.isSafeInteger(n) ? n > D(e.maxBodySize) ? new Response("Security report body too large.", {
481
546
  status: 413
482
547
  }) : null : new Response("Invalid Content-Length.", {
483
548
  status: 400
484
549
  });
485
550
  }
486
- function Ue(e) {
487
- return Array.isArray(e) ? e : Fe(e) && "csp-report" in e ? [e["csp-report"]] : [e];
551
+ function et(e) {
552
+ return Array.isArray(e) ? e : tt(e) && "csp-report" in e ? [e["csp-report"]] : [e];
488
553
  }
489
- function Fe(e) {
554
+ function tt(e) {
490
555
  return typeof e == "object" && e !== null;
491
556
  }
492
- function Mt(e, t) {
557
+ function pr(e, t) {
493
558
  const r = {}, n = [];
494
- let a = 0;
495
- for (const [i, s] of Object.entries(t.files)) {
496
- const o = e.getAll(i).filter(qe);
497
- r[i] = o, s.required && o.length === 0 && n.push({
559
+ let o = 0;
560
+ for (const [a, i] of Object.entries(t.files)) {
561
+ const s = e.getAll(a).filter(ot);
562
+ r[a] = s, i.required && s.length === 0 && n.push({
498
563
  code: "file-missing",
499
- field: i,
500
- message: `Upload field ${i} requires at least one file.`
564
+ field: a,
565
+ message: `Upload field ${a} requires at least one file.`
501
566
  });
502
- for (const u of o)
503
- a += u.size, je(i, u, s, n);
567
+ for (const l of s)
568
+ o += l.size, rt(a, l, i, n);
504
569
  }
505
- return t.maxTotalSize !== void 0 && a > x(t.maxTotalSize) && n.push({
570
+ return t.maxTotalSize !== void 0 && o > D(t.maxTotalSize) && n.push({
506
571
  code: "total-upload-too-large",
507
572
  field: "*",
508
573
  message: `Uploaded files exceed the maximum total size of ${t.maxTotalSize}.`
@@ -510,27 +575,27 @@ function Mt(e, t) {
510
575
  files: r,
511
576
  issues: n,
512
577
  ok: n.length === 0,
513
- totalSize: a
578
+ totalSize: o
514
579
  };
515
580
  }
516
- function je(e, t, r, n) {
517
- r.maxSize !== void 0 && t.size > x(r.maxSize) && n.push({
581
+ function rt(e, t, r, n) {
582
+ r.maxSize !== void 0 && t.size > D(r.maxSize) && n.push({
518
583
  code: "file-too-large",
519
584
  field: e,
520
585
  message: `Upload field ${e} contains ${t.name || "a file"} larger than ${r.maxSize}.`
521
- }), r.types?.length && !Be(t.type, r.types) && n.push({
586
+ }), r.types?.length && !nt(t.type, r.types) && n.push({
522
587
  code: "file-type-not-allowed",
523
588
  field: e,
524
589
  message: `Upload field ${e} contains ${t.name || "a file"} with disallowed type ${t.type || "unknown"}.`
525
590
  });
526
591
  }
527
- function Be(e, t) {
592
+ function nt(e, t) {
528
593
  return t.some((r) => r.endsWith("/*") ? e.startsWith(r.slice(0, -1)) : e === r);
529
594
  }
530
- function qe(e) {
595
+ function ot(e) {
531
596
  return e instanceof File;
532
597
  }
533
- function He(e, t) {
598
+ function at(e, t) {
534
599
  const r = t.headers.get("origin");
535
600
  if (!r)
536
601
  return {
@@ -539,7 +604,7 @@ function He(e, t) {
539
604
  origin: r,
540
605
  reason: e.allowMissingOrigin ? void 0 : "missing-origin"
541
606
  };
542
- const n = P(r);
607
+ const n = J(r);
543
608
  if (!n)
544
609
  return {
545
610
  allowed: !1,
@@ -547,28 +612,28 @@ function He(e, t) {
547
612
  origin: r,
548
613
  reason: "invalid-origin"
549
614
  };
550
- const a = _e(e, n, t);
615
+ const o = it(e, n, t);
551
616
  return {
552
- allowed: a,
617
+ allowed: o,
553
618
  expected: e.origins,
554
619
  origin: n,
555
- reason: a ? void 0 : "origin-not-allowed"
620
+ reason: o ? void 0 : "origin-not-allowed"
556
621
  };
557
622
  }
558
- function Pt(e, t) {
559
- return !e || He(e, t).allowed ? null : new Response("WebSocket origin not allowed.", {
623
+ function gr(e, t) {
624
+ return !e || at(e, t).allowed ? null : new Response("WebSocket origin not allowed.", {
560
625
  status: 403
561
626
  });
562
627
  }
563
- function _e(e, t, r) {
628
+ function it(e, t, r) {
564
629
  return e.origins === "same-origin" ? t === new URL(r.url).origin : e.origins.some(
565
- (n) => Ve(n, t)
630
+ (n) => st(n, t)
566
631
  );
567
632
  }
568
- function Ve(e, t) {
569
- return e === "null" ? t === "null" : P(e) === t;
633
+ function st(e, t) {
634
+ return e === "null" ? t === "null" : J(e) === t;
570
635
  }
571
- function P(e) {
636
+ function J(e) {
572
637
  if (e === "null")
573
638
  return e;
574
639
  try {
@@ -586,122 +651,122 @@ function P(e) {
586
651
  return null;
587
652
  }
588
653
  }
589
- function We(e) {
590
- const t = O(e.routes), r = e.loadNavigationData ?? F;
654
+ function ct(e) {
655
+ const t = W(e.routes), r = e.loadNavigationData ?? Z;
591
656
  return function() {
592
- const [a, i] = I(() => E()), [s, o] = I(
657
+ const [o, a] = F(() => $()), [i, s] = F(
593
658
  () => e.initialMatch ?? { status: "loading" }
594
- ), u = T(!!e.initialMatch), d = T(0);
595
- C(() => {
659
+ ), l = z(!!e.initialMatch), d = z(0);
660
+ P(() => {
596
661
  function c() {
597
- i(E());
662
+ a($());
598
663
  }
599
664
  return window.addEventListener("popstate", c), () => window.removeEventListener("popstate", c);
600
- }, []), C(() => {
601
- let c = !1, l = !1;
602
- const m = ++d.current, R = new AbortController(), v = () => !c && m === d.current;
603
- if (u.current && Ke(e.initialMatch) === a.pathname)
604
- return u.current = !1, () => {
665
+ }, []), P(() => {
666
+ let c = !1, f = !1;
667
+ const h = ++d.current, v = new AbortController(), S = () => !c && h === d.current;
668
+ if (l.current && lt(e.initialMatch) === o.pathname)
669
+ return l.current = !1, () => {
605
670
  c = !0;
606
671
  };
607
- o({ status: "loading" }), ae(t, a.pathname).then((h) => {
608
- v() && !l && h && o({ loading: h, status: "loading" });
672
+ s({ status: "loading" }), ge(t, o.pathname).then((m) => {
673
+ S() && !f && m && s({ loading: m, status: "loading" });
609
674
  }).catch(() => {
610
675
  });
611
- const k = new Request(a.href, { signal: R.signal });
612
- return Promise.resolve(r(k)).then(
613
- (h) => L(
676
+ const b = new Request(o.href, { signal: v.signal });
677
+ return Promise.resolve(r(b)).then(
678
+ (m) => q(
614
679
  t,
615
- a.pathname,
616
- k,
617
- h,
680
+ o.pathname,
681
+ b,
682
+ m,
618
683
  void 0,
619
684
  { documentContributions: !1 }
620
685
  )
621
- ).then((h) => {
622
- l = !0, v() && o(h);
623
- }).catch(async (h) => {
624
- if (l = !0, !v() || R.signal.aborted)
686
+ ).then((m) => {
687
+ f = !0, S() && s(m);
688
+ }).catch(async (m) => {
689
+ if (f = !0, !S() || v.signal.aborted)
625
690
  return;
626
- const q = await ie(
691
+ const k = await we(
627
692
  t,
628
- a.pathname
693
+ o.pathname
629
694
  );
630
- v() && o({
631
- Error: q,
632
- error: h,
633
- pathname: a.pathname,
695
+ S() && s({
696
+ Error: k,
697
+ error: m,
698
+ pathname: o.pathname,
634
699
  status: "error"
635
700
  });
636
701
  }), () => {
637
- c = !0, R.abort();
702
+ c = !0, v.abort();
638
703
  };
639
- }, [a.pathname, a.search]);
640
- const p = V(
704
+ }, [o.pathname, o.search]);
705
+ const p = ne(
641
706
  () => ({
642
707
  navigation: e.navigation ?? "server",
643
708
  push(c) {
644
- const l = E();
709
+ const f = $();
645
710
  window.history.pushState(null, "", c);
646
- const m = E();
647
- i(m), l.pathname === m.pathname && l.search === m.search && l.hash !== m.hash && Je(m.hash);
711
+ const h = $();
712
+ a(h), f.pathname === h.pathname && f.search === h.search && f.hash !== h.hash && pt(h.hash);
648
713
  }
649
714
  }),
650
715
  []
651
716
  );
652
- return f(j.Provider, {
717
+ return w(X.Provider, {
653
718
  value: p,
654
- children: f(Ze, {
655
- key: `${a.pathname}${a.search}`,
719
+ children: w(dt, {
720
+ key: `${o.pathname}${o.search}`,
656
721
  Loading: e.loading,
657
722
  NotFound: e.notFound,
658
- match: s
723
+ match: i
659
724
  })
660
725
  });
661
726
  };
662
727
  }
663
- function Ge(e, t) {
664
- const r = t.getAttribute(Z);
728
+ function ut(e, t) {
729
+ const r = t.getAttribute(ce);
665
730
  return e.status === "not-found" ? r === "not-found" : e.status === "ready" && r === null;
666
731
  }
667
- function Ke(e) {
732
+ function lt(e) {
668
733
  if (e)
669
734
  return e.status === "ready" ? e.match.pathname : e.status === "loading" ? void 0 : e.pathname;
670
735
  }
671
- async function Ut(e) {
736
+ async function wr(e) {
672
737
  const t = e.root ?? document.getElementById("root");
673
738
  if (!t)
674
739
  throw new Error(
675
740
  "Demiurge expected a #root element in the framework document."
676
741
  );
677
- const r = O(e.routes), n = e.loadNavigationData ?? F, a = e.initialData ?? K(document), i = await L(
742
+ const r = W(e.routes), n = e.loadNavigationData ?? Z, o = e.initialData ?? ie(document), a = await q(
678
743
  r,
679
744
  window.location.pathname,
680
745
  new Request(window.location.href),
681
- a ?? await n(new Request(window.location.href)),
746
+ o ?? await n(new Request(window.location.href)),
682
747
  void 0,
683
748
  { documentContributions: !1 }
684
- ), s = Ge(i, t), o = We(
685
- s ? {
749
+ ), i = ut(a, t), s = ct(
750
+ i ? {
686
751
  ...e,
687
- initialMatch: i,
752
+ initialMatch: a,
688
753
  loadNavigationData: n,
689
- navigation: a?.navigation ?? e.navigation
754
+ navigation: o?.navigation ?? e.navigation
690
755
  } : {
691
756
  ...e,
692
757
  loadNavigationData: n,
693
- navigation: a?.navigation ?? e.navigation
758
+ navigation: o?.navigation ?? e.navigation
694
759
  }
695
- ), { createRoot: u, hydrateRoot: d } = Ye(
760
+ ), { createRoot: l, hydrateRoot: d } = ft(
696
761
  await import("react-dom/client")
697
762
  );
698
- if (s && t.hasAttribute(Y)) {
699
- d(t, f(o));
763
+ if (i && t.hasAttribute(se)) {
764
+ d(t, w(s)), U();
700
765
  return;
701
766
  }
702
- t.replaceChildren(), u(t).render(f(o));
767
+ t.replaceChildren(), l(t).render(w(s)), U();
703
768
  }
704
- function Ye(e) {
769
+ function ft(e) {
705
770
  const t = typeof e.createRoot == "function" && typeof e.hydrateRoot == "function" ? e : e.default;
706
771
  if (!t || typeof t.createRoot != "function" || typeof t.hydrateRoot != "function")
707
772
  throw new Error(
@@ -709,57 +774,57 @@ function Ye(e) {
709
774
  );
710
775
  return t;
711
776
  }
712
- function Ft(e) {
713
- const t = tt(), r = ne(e);
714
- return /* @__PURE__ */ H(
777
+ function yr(e) {
778
+ const t = wt(), r = pe(e);
779
+ return /* @__PURE__ */ V(
715
780
  "a",
716
781
  {
717
782
  className: e.className,
718
783
  href: r,
719
784
  onClick: (n) => {
720
- t.navigation === "server" && et(n) && (n.preventDefault(), t.push(r));
785
+ t.navigation === "server" && gt(n) && (n.preventDefault(), t.push(r));
721
786
  },
722
787
  children: e.children
723
788
  }
724
789
  );
725
790
  }
726
- function Ze({
791
+ function dt({
727
792
  Loading: e,
728
793
  NotFound: t,
729
794
  match: r
730
795
  }) {
731
796
  if (r.status === "loading") {
732
797
  const c = r.loading ?? e;
733
- return c ? f(c) : null;
798
+ return c ? w(c) : null;
734
799
  }
735
800
  if (r.status === "not-found") {
736
- const c = r.notFound ?? t ?? de;
801
+ const c = r.notFound ?? t ?? Te;
737
802
  return r.layouts.reduceRight(
738
- (l, m) => f(m, {
739
- children: l,
803
+ (f, h) => w(h, {
804
+ children: f,
740
805
  path: {},
741
806
  pathname: r.pathname
742
807
  }),
743
- f(c, { pathname: r.pathname })
808
+ w(c, { pathname: r.pathname })
744
809
  );
745
810
  }
746
811
  if (r.status === "error")
747
- return r.Error ? f(r.Error, {
812
+ return r.Error ? w(r.Error, {
748
813
  error: r.error,
749
814
  pathname: r.pathname,
750
- status: U(r.error)
815
+ status: Y(r.error)
751
816
  }) : null;
752
- const { data: n, error: a, page: i, layouts: s, path: o, pathname: u } = r.match, d = f(i, { data: n, path: o, pathname: u }), p = s.reduceRight(
753
- (c, l) => f(l, { path: o, pathname: u, children: c }),
817
+ const { data: n, error: o, page: a, layouts: i, path: s, pathname: l } = r.match, d = w(a, { data: n, path: s, pathname: l }), p = i.reduceRight(
818
+ (c, f) => w(f, { path: s, pathname: l, children: c }),
754
819
  d
755
820
  );
756
- return f(Qe, {
757
- Error: a,
821
+ return w(ht, {
822
+ Error: o,
758
823
  children: p,
759
- pathname: u
824
+ pathname: l
760
825
  });
761
826
  }
762
- class Qe extends G {
827
+ class ht extends ae {
763
828
  static getDerivedStateFromError(t) {
764
829
  return { error: t };
765
830
  }
@@ -768,17 +833,17 @@ class Qe extends G {
768
833
  this.state.error !== void 0 && t.pathname !== this.props.pathname && this.setState({ error: void 0 });
769
834
  }
770
835
  render() {
771
- return this.state.error !== void 0 ? this.props.Error ? f(this.props.Error, {
836
+ return this.state.error !== void 0 ? this.props.Error ? w(this.props.Error, {
772
837
  error: this.state.error,
773
838
  pathname: this.props.pathname,
774
- status: U(this.state.error)
839
+ status: Y(this.state.error)
775
840
  }) : null : this.props.children;
776
841
  }
777
842
  }
778
- function U(e) {
779
- return me(e) ? e.status : 500;
843
+ function Y(e) {
844
+ return ke(e) ? e.status : 500;
780
845
  }
781
- function E() {
846
+ function $() {
782
847
  return {
783
848
  hash: window.location.hash,
784
849
  href: window.location.href,
@@ -786,42 +851,42 @@ function E() {
786
851
  search: window.location.search
787
852
  };
788
853
  }
789
- async function F(e) {
854
+ async function Z(e) {
790
855
  const t = new Headers(e.headers);
791
- t.set("accept", "application/json"), t.set(D, oe);
856
+ t.set("accept", "application/json"), t.set(_, ye);
792
857
  const r = await fetch(new Request(e, {
793
858
  credentials: "same-origin",
794
859
  headers: t
795
- })), n = r.headers.get(D);
796
- if (n === se) {
797
- const a = await r.json();
798
- if (a.hasData !== !0)
860
+ })), n = r.headers.get(_);
861
+ if (n === ve) {
862
+ const o = await r.json();
863
+ if (o.hasData !== !0)
799
864
  throw new Error("Demiurge received malformed navigation route data.");
800
- return { data: a.data, hasData: !0 };
865
+ return { data: o.data, hasData: !0 };
801
866
  }
802
- if (n === ce)
867
+ if (n === be)
803
868
  return { hasData: !0 };
804
- if (n === ue || !r.ok) {
805
- const a = await Xe(r), i = le.includes(
869
+ if (n === Se || !r.ok) {
870
+ const o = await mt(r), a = Ee.includes(
806
871
  r.status
807
872
  ) ? r.status : 500;
808
- throw fe(i, {
809
- detail: typeof a?.detail == "string" ? a.detail : void 0,
810
- title: typeof a?.title == "string" ? a.title : void 0
873
+ throw Re(a, {
874
+ detail: typeof o?.detail == "string" ? o.detail : void 0,
875
+ title: typeof o?.title == "string" ? o.title : void 0
811
876
  });
812
877
  }
813
878
  throw new Error(
814
879
  "Demiurge expected a navigation data response from the application server."
815
880
  );
816
881
  }
817
- async function Xe(e) {
882
+ async function mt(e) {
818
883
  try {
819
884
  return await e.json();
820
885
  } catch {
821
886
  return;
822
887
  }
823
888
  }
824
- function Je(e) {
889
+ function pt(e) {
825
890
  queueMicrotask(() => {
826
891
  if (!e) {
827
892
  window.scrollTo?.(0, 0);
@@ -836,205 +901,162 @@ function Je(e) {
836
901
  document.getElementById(t)?.scrollIntoView?.();
837
902
  });
838
903
  }
839
- function et(e) {
904
+ function gt(e) {
840
905
  return e.button === 0 && !e.metaKey && !e.altKey && !e.ctrlKey && !e.shiftKey;
841
906
  }
842
- const j = _({
907
+ const X = re({
843
908
  navigation: "document",
844
909
  push(e) {
845
910
  window.location.href = e;
846
911
  }
847
912
  });
848
- function tt() {
849
- return W(j);
850
- }
851
- const rt = "/_demiurge/image";
852
- function jt(e) {
853
- return e;
854
- }
855
- function Bt(e, t = {}) {
856
- return B(e, t) !== null;
913
+ function wt() {
914
+ return oe(X);
857
915
  }
858
- function qt(e, t = {}) {
859
- const r = B(e.src, t);
860
- if (!r)
861
- throw new Error(`Image source "${e.src}" is not allowed by the image policy.`);
862
- $("width", e.width), $("height", e.height), st(e.quality);
863
- const n = e.format ?? "auto", i = ct(e.width, e.widths).map((o) => {
864
- const u = Math.round(e.height / e.width * o);
865
- return {
866
- format: n,
867
- height: u,
868
- src: ut({
869
- format: n,
870
- optimizerPath: t.optimizerPath ?? rt,
871
- quality: e.quality,
872
- src: e.src,
873
- width: o
874
- }),
875
- width: o
876
- };
877
- }), s = i[0];
878
- return {
879
- alt: e.alt,
880
- decoding: "async",
881
- fetchPriority: e.priority ? "high" : void 0,
882
- height: e.height,
883
- loading: e.priority ? "eager" : "lazy",
884
- sizes: e.sizes,
885
- source: r,
886
- src: s.src,
887
- srcSet: i.map((o) => `${o.src} ${o.width}w`).join(", "),
888
- variants: i,
889
- width: e.width
890
- };
891
- }
892
- function B(e, t) {
893
- if (e.startsWith("/") && !e.startsWith("//"))
894
- return t.local === !1 ? null : { kind: "local", src: e };
895
- let r;
896
- try {
897
- r = new URL(e);
898
- } catch {
899
- return null;
900
- }
901
- return r.protocol !== "https:" && r.protocol !== "http:" ? null : nt(r, t.remote ?? []) ? { kind: "remote", src: r.toString() } : null;
902
- }
903
- function nt(e, t) {
904
- return t.some(
905
- (r) => typeof r == "string" ? at(e, r) : it(e, r)
916
+ function vr({ className: e, id: t, policy: r, ...n }) {
917
+ const o = Ae(n, r);
918
+ return /* @__PURE__ */ V(
919
+ "img",
920
+ {
921
+ alt: o.alt,
922
+ className: e,
923
+ decoding: o.decoding,
924
+ fetchPriority: o.fetchPriority,
925
+ height: o.height,
926
+ id: t,
927
+ loading: o.loading,
928
+ sizes: o.sizes,
929
+ src: o.src,
930
+ srcSet: o.srcSet,
931
+ width: o.width
932
+ }
906
933
  );
907
934
  }
908
- function at(e, t) {
909
- try {
910
- return e.origin === new URL(t).origin;
911
- } catch {
912
- return !1;
913
- }
914
- }
915
- function it(e, t) {
916
- return t.protocol && e.protocol !== t.protocol || e.hostname !== t.hostname || t.port !== void 0 && e.port !== t.port ? !1 : t.pathname ? ot(e.pathname, t.pathname) : !0;
917
- }
918
- function ot(e, t) {
919
- return t.endsWith("*") ? e.startsWith(t.slice(0, -1)) : e === t;
920
- }
921
- function $(e, t) {
922
- if (!Number.isInteger(t) || t <= 0)
923
- throw new Error(`Image ${e} must be a positive integer.`);
924
- }
925
- function st(e) {
926
- if (e !== void 0 && (!Number.isInteger(e) || e < 1 || e > 100))
927
- throw new Error("Image quality must be an integer between 1 and 100.");
928
- }
929
- function ct(e, t) {
930
- const r = t ?? [e, e * 2], n = [...new Set(r)];
931
- for (const a of n)
932
- $("width", a);
933
- return n.sort((a, i) => a - i);
934
- }
935
- function ut({
936
- format: e,
937
- optimizerPath: t,
938
- quality: r,
939
- src: n,
940
- width: a
941
- }) {
942
- const i = new URLSearchParams({
943
- src: n,
944
- w: String(a)
945
- });
946
- return r !== void 0 && i.set("q", String(r)), e !== "auto" && i.set("f", e), `${t}?${i.toString()}`;
947
- }
948
- const Ht = {
949
- google(e) {
935
+ const yt = "https://js.sentry-cdn.com", br = {
936
+ /**
937
+ * Plausible loads one script and posts events to its own API. The snippet
938
+ * carries configuration in `data-domain`, so no inline code is involved.
939
+ * `endpoint` accepts a same-origin path prefix for a proxied deployment.
940
+ */
941
+ plausible(e) {
942
+ const t = vt(e.domain), r = H(e.endpoint ?? "https://plausible.io");
950
943
  return {
951
- display: e.display ?? "swap",
952
- family: e.family,
953
- kind: "font",
954
- source: "google",
955
- src: e.src,
956
- style: e.style ?? "normal",
957
- weight: e.weight ?? 400
944
+ consent: e.consent ?? !1,
945
+ domain: t,
946
+ kind: "analytics",
947
+ needs: {
948
+ connect: [r.source],
949
+ script: [r.source]
950
+ },
951
+ provider: "plausible",
952
+ scripts: [
953
+ I({
954
+ dataApi: `${r.base}/api/event`,
955
+ dataDomain: t,
956
+ defer: !0,
957
+ needs: { connect: [r.source] },
958
+ purpose: "analytics",
959
+ src: `${r.base}/js/script.js`,
960
+ strategy: e.strategy ?? "afterInteractive"
961
+ })
962
+ ]
958
963
  };
959
964
  },
960
- local(e) {
961
- if (!e.src.trim())
962
- throw new Error("Local font source must not be empty.");
965
+ /**
966
+ * The Sentry loader script carries the DSN in its own filename, so a page
967
+ * needs no inline configuration call. Events go to the DSN host, which is
968
+ * why the integration also declares a `connect-src` need.
969
+ */
970
+ sentry(e) {
971
+ const t = Et(e.dsn), r = St(
972
+ e.loaderHost ?? yt,
973
+ "Sentry loader host"
974
+ );
963
975
  return {
964
- display: e.display ?? "swap",
965
- family: e.name,
966
- kind: "font",
967
- source: "local",
968
- src: e.src,
969
- style: e.style ?? "normal",
970
- weight: e.weight ?? 400
976
+ consent: e.consent ?? !1,
977
+ ingestOrigin: t.origin,
978
+ kind: "analytics",
979
+ needs: {
980
+ connect: [t.origin],
981
+ script: [r]
982
+ },
983
+ projectId: t.projectId,
984
+ provider: "sentry",
985
+ scripts: [
986
+ I({
987
+ crossOrigin: "anonymous",
988
+ needs: { connect: [t.origin] },
989
+ purpose: "error-monitoring",
990
+ src: `${r}/${t.publicKey}.min.js`,
991
+ // Errors thrown before the app is interactive are the ones an
992
+ // application can least afford to lose.
993
+ strategy: e.strategy ?? "beforeInteractive"
994
+ })
995
+ ]
971
996
  };
972
- }
973
- };
974
- function _t(e) {
975
- return [...e];
976
- }
977
- function Vt(e) {
978
- return e.filter((t) => t.src).map((t) => ({
979
- as: "font",
980
- crossOrigin: "anonymous",
981
- href: t.src,
982
- kind: "link",
983
- rel: "preload",
984
- type: lt(t.src)
985
- }));
986
- }
987
- function Wt(e) {
988
- return e.filter((t) => t.source === "local" && t.src).map((t) => {
989
- const r = t.src;
990
- return [
991
- "@font-face {",
992
- ` font-family: "${N(t.family)}";`,
993
- ` src: url("${N(r)}") format("${ft(r)}");`,
994
- ` font-style: ${t.style};`,
995
- ` font-weight: ${t.weight};`,
996
- ` font-display: ${t.display};`,
997
- "}"
998
- ].join(`
999
- `);
1000
- }).join(`
1001
- `);
1002
- }
1003
- function lt(e) {
1004
- return e.split("?")[0].split("#")[0].split(".").pop()?.toLowerCase() === "woff" ? "font/woff" : "font/woff2";
1005
- }
1006
- function ft(e) {
1007
- return e.split("?")[0].split("#")[0].split(".").pop()?.toLowerCase() === "woff" ? "woff" : "woff2";
1008
- }
1009
- function N(e) {
1010
- return e.replace(/[\\"]/g, "\\$&");
1011
- }
1012
- const Gt = {
1013
- plausible(e) {
1014
- const t = dt(e.domain), r = mt(e.endpoint ?? "https://plausible.io");
997
+ },
998
+ /**
999
+ * OpenTelemetry publishes no hosted browser loader. Browser instrumentation
1000
+ * is application code bundled from npm packages, so this helper describes
1001
+ * the part a policy has to know about: the OTLP endpoint the exporter posts
1002
+ * to, and an optional same-origin entry script that starts the SDK.
1003
+ */
1004
+ openTelemetry(e) {
1005
+ const t = H(e.endpoint), r = e.script;
1006
+ if (r !== void 0 && !r.startsWith("/"))
1007
+ throw new Error(
1008
+ "OpenTelemetry browser instrumentation must be a same-origin script path."
1009
+ );
1015
1010
  return {
1016
- connectSrc: r.origin,
1017
1011
  consent: e.consent ?? !1,
1018
- domain: t,
1012
+ endpoint: t.base || "/",
1019
1013
  kind: "analytics",
1020
- provider: "plausible",
1021
- script: Q({
1022
- dataApi: `${r.origin}/api/event`,
1023
- dataDomain: t,
1024
- purpose: "analytics",
1025
- src: `${r.origin}/js/script.js`,
1026
- strategy: e.strategy ?? "afterInteractive"
1027
- })
1014
+ needs: r ? { connect: [t.source], script: ["'self'"] } : { connect: [t.source] },
1015
+ provider: "opentelemetry",
1016
+ scripts: r ? [
1017
+ I({
1018
+ needs: { connect: [t.source] },
1019
+ purpose: "observability",
1020
+ src: r,
1021
+ strategy: e.strategy ?? "module"
1022
+ })
1023
+ ] : []
1028
1024
  };
1025
+ },
1026
+ /** Merges the CSP needs of every integration into one route policy. */
1027
+ policy(...e) {
1028
+ const t = {};
1029
+ for (const r of e)
1030
+ for (const n of ["connect", "img", "script"]) {
1031
+ const o = r.needs[n];
1032
+ !o || o.length === 0 || (t[n] = [.../* @__PURE__ */ new Set([...t[n] ?? [], ...o])]);
1033
+ }
1034
+ return { security: { needs: t } };
1035
+ },
1036
+ /** Collects the script contributions of every integration. */
1037
+ scripts(...e) {
1038
+ return e.flatMap((t) => [...t.scripts]);
1029
1039
  }
1030
1040
  };
1031
- function dt(e) {
1041
+ function vt(e) {
1032
1042
  const t = e.trim();
1033
1043
  if (!t || t.includes("/") || t.includes(" "))
1034
1044
  throw new Error("Analytics domain must be a hostname without a path.");
1035
1045
  return t;
1036
1046
  }
1037
- function mt(e) {
1047
+ function H(e) {
1048
+ if (e.startsWith("/")) {
1049
+ if (e.startsWith("//"))
1050
+ throw new Error("Analytics endpoint must not be a scheme-relative URL.");
1051
+ return {
1052
+ base: e === "/" ? "" : e.replace(/\/+$/, ""),
1053
+ source: "'self'"
1054
+ };
1055
+ }
1056
+ const t = bt(e);
1057
+ return { base: t.origin, source: t.origin };
1058
+ }
1059
+ function bt(e) {
1038
1060
  let t;
1039
1061
  try {
1040
1062
  t = new URL(e);
@@ -1045,132 +1067,449 @@ function mt(e) {
1045
1067
  throw new Error("Analytics endpoint must use HTTPS.");
1046
1068
  return t;
1047
1069
  }
1048
- function Kt(e = {}) {
1070
+ function St(e, t) {
1071
+ let r;
1072
+ try {
1073
+ r = new URL(e);
1074
+ } catch {
1075
+ throw new Error(`${t} must be an absolute URL.`);
1076
+ }
1077
+ if (r.protocol !== "https:")
1078
+ throw new Error(`${t} must use HTTPS.`);
1079
+ return r.origin;
1080
+ }
1081
+ function Et(e) {
1082
+ let t;
1083
+ try {
1084
+ t = new URL(e);
1085
+ } catch {
1086
+ throw new Error("Sentry DSN must be an absolute URL.");
1087
+ }
1088
+ if (t.protocol !== "https:")
1089
+ throw new Error("Sentry DSN must use HTTPS.");
1090
+ const r = t.pathname.replace(/^\//, "");
1091
+ if (!t.username || t.password)
1092
+ throw new Error(
1093
+ "Sentry DSN must carry a public key and no secret key."
1094
+ );
1095
+ if (!/^[A-Za-z0-9_-]+$/.test(r))
1096
+ throw new Error("Sentry DSN must end with a project identifier.");
1097
+ return {
1098
+ origin: t.origin,
1099
+ projectId: r,
1100
+ publicKey: t.username
1101
+ };
1102
+ }
1103
+ function Sr(e = {}) {
1049
1104
  return {
1050
1105
  async request(t) {
1051
- await S({ kind: "request", signal: t }, e);
1106
+ await x({ kind: "request", signal: t }, e);
1052
1107
  },
1053
1108
  async serverStart(t = {}) {
1054
- await S({ kind: "server-start", signal: t }, e);
1109
+ await x({ kind: "server-start", signal: t }, e);
1055
1110
  },
1056
1111
  async trace(t) {
1057
- await S({ kind: "trace", signal: t }, e);
1112
+ await x({ kind: "trace", signal: t }, e);
1058
1113
  },
1059
1114
  async reportWebVitals(t) {
1060
- await S({ kind: "web-vital", signal: t }, e);
1115
+ await x({ kind: "web-vital", signal: t }, e);
1061
1116
  }
1062
1117
  };
1063
1118
  }
1064
- async function S(e, t) {
1119
+ async function x(e, t) {
1065
1120
  await t.onEvent?.(e), e.kind === "request" ? await t.request?.(e.signal) : e.kind === "server-start" ? await t.serverStart?.(e.signal) : e.kind === "trace" ? await t.trace?.(e.signal) : await t.webVitals?.(e.signal);
1066
1121
  }
1122
+ const Rt = [
1123
+ "CLS",
1124
+ "FCP",
1125
+ "FID",
1126
+ "INP",
1127
+ "LCP",
1128
+ "TTFB"
1129
+ ], L = [
1130
+ "CLS",
1131
+ "FCP",
1132
+ "INP",
1133
+ "LCP",
1134
+ "TTFB"
1135
+ ], Tt = new Set(Rt), kt = /* @__PURE__ */ new Set([
1136
+ "back-forward",
1137
+ "back-forward-cache",
1138
+ "navigate",
1139
+ "prerender",
1140
+ "reload",
1141
+ "restore"
1142
+ ]), At = /* @__PURE__ */ new Set([
1143
+ "good",
1144
+ "needs-improvement",
1145
+ "poor"
1146
+ ]);
1147
+ function $t(e) {
1148
+ return typeof e == "string" && Tt.has(e);
1149
+ }
1150
+ function xt(e) {
1151
+ return typeof e == "string" && kt.has(e);
1152
+ }
1153
+ function Ct(e) {
1154
+ return typeof e == "string" && At.has(e);
1155
+ }
1156
+ const It = {
1157
+ CLS: { good: 0.1, poor: 0.25 },
1158
+ FCP: { good: 1800, poor: 3e3 },
1159
+ FID: { good: 100, poor: 300 },
1160
+ INP: { good: 200, poor: 500 },
1161
+ LCP: { good: 2500, poor: 4e3 },
1162
+ TTFB: { good: 800, poor: 1800 }
1163
+ };
1164
+ function Nt(e, t) {
1165
+ const r = It[e];
1166
+ return t <= r.good ? "good" : t > r.poor ? "poor" : "needs-improvement";
1167
+ }
1168
+ const Q = 32;
1169
+ function Er(e) {
1170
+ const t = Dt(e.endpoint), r = Ot(e.metrics), n = Mt(e.sampleRate);
1171
+ return {
1172
+ endpoint: t.url,
1173
+ kind: "web-vitals",
1174
+ metrics: r,
1175
+ needs: { connect: [t.source] },
1176
+ sampleRate: n
1177
+ };
1178
+ }
1179
+ function Rr(...e) {
1180
+ const t = /* @__PURE__ */ new Set();
1181
+ for (const r of e)
1182
+ for (const n of r.needs.connect ?? [])
1183
+ t.add(n);
1184
+ return t.size === 0 ? { security: { needs: {} } } : { security: { needs: { connect: [...t] } } };
1185
+ }
1186
+ async function Tr(e, t = {}) {
1187
+ const r = t.maxMetrics ?? Q;
1188
+ let n;
1189
+ try {
1190
+ n = await e.json();
1191
+ } catch {
1192
+ return { ok: !1, reason: "unreadable-body" };
1193
+ }
1194
+ return Lt(n, r);
1195
+ }
1196
+ function Lt(e, t = Q) {
1197
+ if (!ee(e) || !Array.isArray(e.metrics))
1198
+ return { ok: !1, reason: "invalid-payload" };
1199
+ if (e.metrics.length > t)
1200
+ return { ok: !1, reason: "too-many-metrics" };
1201
+ const r = [];
1202
+ for (const n of e.metrics) {
1203
+ const o = Pt(n);
1204
+ if (!o)
1205
+ return { ok: !1, reason: "invalid-payload" };
1206
+ r.push(o);
1207
+ }
1208
+ return { metrics: r, ok: !0 };
1209
+ }
1210
+ function Pt(e) {
1211
+ if (!ee(e))
1212
+ return;
1213
+ const { id: t, name: r, navigationType: n, rating: o, url: a, value: i } = e;
1214
+ if (!(typeof t != "string" || t.length === 0 || t.length > 128) && !(!$t(r) || !xt(n)) && Ct(o) && !(typeof a != "string" || a.length === 0 || a.length > 2048) && !(typeof i != "number" || !Number.isFinite(i) || i < 0))
1215
+ return { id: t, name: r, navigationType: n, rating: o, url: a, value: i };
1216
+ }
1217
+ function ee(e) {
1218
+ return typeof e == "object" && e !== null;
1219
+ }
1220
+ function Dt(e) {
1221
+ if (e.startsWith("/")) {
1222
+ if (e.startsWith("//"))
1223
+ throw new Error(
1224
+ "The web vitals endpoint must not be a scheme-relative URL."
1225
+ );
1226
+ return { source: "'self'", url: e };
1227
+ }
1228
+ let t;
1229
+ try {
1230
+ t = new URL(e);
1231
+ } catch {
1232
+ throw new Error(
1233
+ "The web vitals endpoint must be a same-origin path or an absolute URL."
1234
+ );
1235
+ }
1236
+ if (t.protocol !== "https:")
1237
+ throw new Error("The web vitals endpoint must use HTTPS.");
1238
+ return { source: t.origin, url: t.href };
1239
+ }
1240
+ function Ot(e) {
1241
+ if (!e)
1242
+ return L;
1243
+ const t = [];
1244
+ for (const r of e) {
1245
+ if (!L.includes(r))
1246
+ throw new Error(
1247
+ `The browser collector does not measure ${JSON.stringify(r)}. Demiurge collects ${L.join(", ")}.`
1248
+ );
1249
+ t.includes(r) || t.push(r);
1250
+ }
1251
+ if (t.length === 0)
1252
+ throw new Error("A web vitals integration must collect one metric or more.");
1253
+ return t;
1254
+ }
1255
+ function Mt(e) {
1256
+ if (e === void 0)
1257
+ return 1;
1258
+ if (!Number.isFinite(e) || e < 0 || e > 1)
1259
+ throw new Error("The web vitals sample rate must be between 0 and 1.");
1260
+ return e;
1261
+ }
1262
+ const Ft = 1e3, zt = 5e3, Ut = 40;
1263
+ function Bt(e, t = {}) {
1264
+ if (typeof window > "u" || typeof PerformanceObserver > "u")
1265
+ return () => {
1266
+ };
1267
+ const r = t.random ?? Math.random;
1268
+ if (e.sampleRate < 1 && r() >= e.sampleRate)
1269
+ return () => {
1270
+ };
1271
+ const n = t.transport ?? _t, o = new Set(e.metrics), a = [], i = [], s = /* @__PURE__ */ new Set();
1272
+ let l = jt(), d = 0, p = 0, c = 0, f = 0, h, v, S = !1;
1273
+ const b = (u, g) => {
1274
+ if (S || s.has(u))
1275
+ return;
1276
+ s.add(u);
1277
+ const y = {
1278
+ id: `${u}-${Date.now()}-${Math.floor(r() * 1e9)}`,
1279
+ name: u,
1280
+ navigationType: l,
1281
+ rating: Nt(u, g),
1282
+ url: window.location.href,
1283
+ value: Math.round(g * 1e3) / 1e3
1284
+ };
1285
+ i.push(y), t.onReport?.(y);
1286
+ }, m = () => {
1287
+ if (S || (h !== void 0 && b("LCP", h), v !== void 0 && b("INP", v), o.has("CLS") && b("CLS", d), i.length === 0))
1288
+ return;
1289
+ const u = i.splice(0, i.length);
1290
+ n(e.endpoint, { metrics: u });
1291
+ }, k = () => {
1292
+ document.visibilityState === "hidden" && m();
1293
+ }, M = (u) => {
1294
+ u.persisted && (l = "back-forward-cache", s.clear(), d = 0, p = 0, c = 0, f = 0, h = void 0, v = void 0, o.has("FCP") && b("FCP", performance.now() - u.timeStamp));
1295
+ };
1296
+ if (o.has("TTFB")) {
1297
+ const u = te();
1298
+ u && u.responseStart > 0 && b("TTFB", u.responseStart);
1299
+ }
1300
+ return o.has("FCP") && C(a, { buffered: !0, type: "paint" }, (u) => {
1301
+ for (const g of u)
1302
+ g.name === "first-contentful-paint" && b("FCP", g.startTime);
1303
+ }), o.has("LCP") && C(
1304
+ a,
1305
+ { buffered: !0, type: "largest-contentful-paint" },
1306
+ (u) => {
1307
+ const g = u.at(-1);
1308
+ g && (h = g.startTime);
1309
+ }
1310
+ ), o.has("CLS") && C(a, { buffered: !0, type: "layout-shift" }, (u) => {
1311
+ for (const g of u) {
1312
+ const y = g;
1313
+ if (y.hadRecentInput)
1314
+ continue;
1315
+ p > 0 && y.startTime - f < Ft && y.startTime - c < zt ? p += y.value : (p = y.value, c = y.startTime), f = y.startTime, d = Math.max(d, p);
1316
+ }
1317
+ }), o.has("INP") && C(
1318
+ a,
1319
+ {
1320
+ buffered: !0,
1321
+ durationThreshold: Ut,
1322
+ type: "event"
1323
+ },
1324
+ (u) => {
1325
+ for (const g of u)
1326
+ v = Math.max(v ?? 0, g.duration);
1327
+ }
1328
+ ), document.addEventListener("visibilitychange", k), window.addEventListener("pagehide", m), window.addEventListener("pageshow", M), () => {
1329
+ m(), S = !0;
1330
+ for (const u of a)
1331
+ u.disconnect();
1332
+ document.removeEventListener("visibilitychange", k), window.removeEventListener("pagehide", m), window.removeEventListener("pageshow", M);
1333
+ };
1334
+ }
1335
+ function kr({ integration: e, onReport: t, transport: r }) {
1336
+ return P(
1337
+ () => Bt(e, { onReport: t, transport: r }),
1338
+ [e, t, r]
1339
+ ), null;
1340
+ }
1341
+ function _t(e, t) {
1342
+ const r = JSON.stringify(t);
1343
+ if (typeof navigator < "u" && typeof navigator.sendBeacon == "function") {
1344
+ const n = new Blob([r], { type: "application/json" });
1345
+ if (navigator.sendBeacon(e, n))
1346
+ return;
1347
+ }
1348
+ fetch(e, {
1349
+ body: r,
1350
+ headers: { "content-type": "application/json" },
1351
+ keepalive: !0,
1352
+ method: "POST"
1353
+ }).catch(() => {
1354
+ });
1355
+ }
1356
+ function C(e, t, r) {
1357
+ try {
1358
+ const n = new PerformanceObserver((o) => r(o.getEntries()));
1359
+ n.observe(t), e.push(n);
1360
+ } catch {
1361
+ return;
1362
+ }
1363
+ }
1364
+ function te() {
1365
+ if (!(typeof performance > "u"))
1366
+ return performance.getEntriesByType("navigation")[0];
1367
+ }
1368
+ function jt() {
1369
+ const e = te();
1370
+ return e?.type === "back_forward" ? "back-forward" : e?.type === "reload" || e?.type === "prerender" ? e.type : "navigate";
1371
+ }
1067
1372
  export {
1068
- ke as EnvValidationError,
1069
- le as HTTP_ERROR_STATUSES,
1070
- ir as HttpError,
1071
- Ft as Link,
1072
- Qt as Script,
1073
- kt as action,
1074
- It as actionInput,
1075
- Gt as analytics,
1076
- Xt as assertAdapterCapabilities,
1077
- or as auditScriptDependencies,
1078
- Jt as checkAdapterCapabilities,
1079
- He as checkWebSocketOrigin,
1080
- sr as createCache,
1081
- cr as createCorsHeaders,
1082
- ur as createCsrfCookie,
1083
- lr as createCsrfToken,
1084
- We as createFileRouter,
1085
- fr as createInvalidation,
1086
- dr as createMemoryCache,
1087
- mr as createMemoryCacheStore,
1088
- vt as createMemoryIdempotencyStore,
1089
- hr as createMemoryRateLimitStore,
1090
- gr as createRequestHandler,
1091
- pr as createSecurityAudit,
1092
- wr as createSecurityHeaders,
1093
- Lt as createSecurityReportHandler,
1094
- yr as cspHash,
1095
- vr as cspNonce,
1096
- er as defineAdapter,
1097
- Dt as defineEnvSchema,
1098
- _t as defineFonts,
1099
- jt as defineImages,
1100
- Kt as defineInstrumentation,
1101
- br as defineLinks,
1102
- Er as defineMetadata,
1103
- Ct as defineMiddleware,
1104
- At as defineOgImage,
1105
- Rt as defineRobots,
1106
- Sr as defineRoutePolicy,
1107
- tr as defineScripts,
1108
- Rr as defineSecurityPolicy,
1109
- Et as defineSitemap,
1110
- Ar as defineTags,
1111
- $r as enforceAllowedMethods,
1112
- xr as enforceCsrfProtection,
1113
- kr as enforceRateLimit,
1114
- Ir as enforceRequestSecurity,
1115
- Pt as enforceWebSocketOrigin,
1116
- Ot as env,
1117
- Ht as font,
1118
- Vt as fontPreloadLinks,
1119
- Tr as handleRequestWithManifest,
1120
- ne as href,
1121
- Cr as html,
1122
- fe as httpError,
1123
- Ut as hydrateFileRouter,
1124
- Bt as isAllowedImageSource,
1125
- me as isHttpError,
1126
- zr as issueCsrfToken,
1127
- Dr as json,
1128
- Nr as jsonl,
1129
- Or as link,
1130
- Lr as mergeRoutePolicies,
1131
- Mr as mergeRouteSecurityPolicies,
1132
- Pr as mergeSecurityPolicies,
1133
- Ur as meta,
1373
+ L as COLLECTED_WEB_VITAL_NAMES,
1374
+ Vr as CacheNotFoundError,
1375
+ He as EnvValidationError,
1376
+ xr as FRAMEWORK_TRUSTED_TYPES_POLICY,
1377
+ Ee as HTTP_ERROR_STATUSES,
1378
+ Wr as HttpError,
1379
+ vr as Image,
1380
+ yr as Link,
1381
+ Cr as Script,
1382
+ Rt as WEB_VITAL_NAMES,
1383
+ It as WEB_VITAL_THRESHOLDS,
1384
+ kr as WebVitals,
1385
+ or as action,
1386
+ ar as actionInput,
1387
+ br as analytics,
1388
+ qr as applyFetchMetadataVary,
1389
+ Ir as assertAdapterCapabilities,
1390
+ Gr as auditScriptDependencies,
1391
+ Kr as cacheNotFound,
1392
+ Nr as checkAdapterCapabilities,
1393
+ Jr as checkFetchMetadata,
1394
+ at as checkWebSocketOrigin,
1395
+ Bt as collectWebVitals,
1396
+ Yr as createCache,
1397
+ Zr as createCorsHeaders,
1398
+ Xr as createCsrfCookie,
1399
+ Qr as createCsrfToken,
1400
+ ct as createFileRouter,
1401
+ Lr as createFrameworkScriptUrl,
1402
+ en as createInvalidation,
1403
+ tn as createMemoryCache,
1404
+ rn as createMemoryCacheStore,
1405
+ Yt as createMemoryIdempotencyStore,
1406
+ nn as createMemoryRateLimitStore,
1407
+ on as createRequestHandler,
1408
+ lr as createSecureCookie,
1409
+ an as createSecurityAudit,
1410
+ sn as createSecurityHeaders,
1411
+ mr as createSecurityReportHandler,
1412
+ cn as cspHash,
1413
+ un as cspNonce,
1414
+ Kn as defaultFontPath,
1415
+ Pr as defineAdapter,
1416
+ fr as defineEnvSchema,
1417
+ Jn as defineFonts,
1418
+ Yn as defineImages,
1419
+ Sr as defineInstrumentation,
1420
+ Dr as defineLinks,
1421
+ ln as defineMetadata,
1422
+ sr as defineMiddleware,
1423
+ tr as defineOgImage,
1424
+ er as defineRobots,
1425
+ fn as defineRoutePolicy,
1426
+ Or as defineScripts,
1427
+ dn as defineSecurityPolicy,
1428
+ Xt as defineSitemap,
1429
+ hn as defineTags,
1430
+ Er as defineWebVitals,
1431
+ mn as enforceAllowedMethods,
1432
+ pn as enforceCsrfProtection,
1433
+ gn as enforceFetchMetadataPolicy,
1434
+ wn as enforceRateLimit,
1435
+ yn as enforceRequestSecurity,
1436
+ gr as enforceWebSocketOrigin,
1437
+ hr as env,
1438
+ Zn as font,
1439
+ Xn as fontAssetFileName,
1440
+ Qn as fontAssetUrl,
1441
+ eo as fontLinks,
1442
+ to as fontMediaType,
1443
+ ro as fontPreloadLinks,
1444
+ no as fontSources,
1445
+ oo as fontStylesheetUrl,
1446
+ Mr as getScriptWorker,
1447
+ vn as handleRequestWithManifest,
1448
+ pe as href,
1449
+ bn as html,
1450
+ Re as httpError,
1451
+ wr as hydrateFileRouter,
1452
+ ao as isAllowedImageSource,
1453
+ Sn as isCacheNotFoundError,
1454
+ ke as isHttpError,
1455
+ En as issueCsrfToken,
1456
+ Rn as json,
1457
+ Tn as jsonl,
1458
+ kn as link,
1459
+ An as mergeRoutePolicies,
1460
+ $n as mergeRouteSecurityPolicies,
1461
+ xn as mergeSecurityPolicies,
1462
+ Cn as meta,
1134
1463
  Fr as modulePreload,
1135
- jr as notFound,
1136
- Tt as page,
1137
- x as parseBodySize,
1138
- z as parseCacheDuration,
1139
- Br as parseCookieHeader,
1140
- qr as parseRateLimitWindow,
1141
- qt as planImageTransform,
1142
- Hr as preconnect,
1143
- _r as preload,
1144
- Vr as query,
1145
- Wr as redirect,
1146
- Wt as renderFontFaceCss,
1147
- xt as renderOgImageResponse,
1148
- ye as renderOgImageSvg,
1149
- rr as renderPageResponse,
1150
- $t as renderRobots,
1151
- St as renderSitemap,
1152
- Gr as resolveLinks,
1153
- Kr as resolveMetadata,
1154
- nr as resolveScripts,
1155
- J as response,
1156
- bt as runIdempotentMutation,
1157
- Q as script,
1158
- Yr as security,
1159
- X as serializeCacheKey,
1160
- Zr as serializeCacheNamespace,
1161
- Qr as serializeCacheTag,
1162
- Xr as serverTiming,
1163
- Jr as sse,
1164
- en as stream,
1165
- tn as structuredData,
1166
- rn as tag,
1167
- nn as text,
1168
- ee as toResponse,
1169
- an as validateCorsPolicy,
1170
- Nt as validateEnv,
1171
- on as validateRateLimitPolicy,
1172
- sn as validateRouteModules,
1173
- Mt as validateUploads,
1174
- zt as webhook
1464
+ In as notFound,
1465
+ ir as page,
1466
+ D as parseBodySize,
1467
+ B as parseCacheDuration,
1468
+ de as parseCookieHeader,
1469
+ io as parseImageOptimizerRequest,
1470
+ Nn as parseRateLimitWindow,
1471
+ Lt as parseWebVitalsBeacon,
1472
+ Ae as planImageTransform,
1473
+ zr as preconnect,
1474
+ Ur as preload,
1475
+ Ln as query,
1476
+ ur as readSecureCookie,
1477
+ Tr as readWebVitalsBeacon,
1478
+ Pn as redirect,
1479
+ so as renderFontFaceCss,
1480
+ nr as renderOgImageResponse,
1481
+ Ne as renderOgImageSvg,
1482
+ Br as renderPageResponse,
1483
+ rr as renderRobots,
1484
+ Qt as renderSitemap,
1485
+ _r as resolveLinks,
1486
+ Dn as resolveMetadata,
1487
+ jr as resolveScripts,
1488
+ le as response,
1489
+ Zt as runIdempotentMutation,
1490
+ I as script,
1491
+ O as secureCookieName,
1492
+ On as security,
1493
+ _t as sendWebVitalsBeacon,
1494
+ ue as serializeCacheKey,
1495
+ Mn as serializeCacheNamespace,
1496
+ Fn as serializeCacheTag,
1497
+ zn as serverTiming,
1498
+ Un as sse,
1499
+ U as startDeferredScripts,
1500
+ Bn as stream,
1501
+ _n as structuredData,
1502
+ jn as tag,
1503
+ Hn as text,
1504
+ fe as toResponse,
1505
+ Vn as validateCorsPolicy,
1506
+ dr as validateEnv,
1507
+ Wn as validateRateLimitPolicy,
1508
+ qn as validateRouteModules,
1509
+ je as validateSecureCookie,
1510
+ pr as validateUploads,
1511
+ Nt as webVitalRating,
1512
+ Rr as webVitalsPolicy,
1513
+ cr as webhook
1175
1514
  };
1176
1515
  //# sourceMappingURL=index.js.map